Chris@0
|
1 /**
|
Chris@0
|
2 * DO NOT EDIT THIS FILE.
|
Chris@0
|
3 * See the following change record for more information,
|
Chris@0
|
4 * https://www.drupal.org/node/2815083
|
Chris@0
|
5 * @preserve
|
Chris@0
|
6 **/
|
Chris@0
|
7
|
Chris@0
|
8 (function ($, Drupal) {
|
Chris@0
|
9 Drupal.behaviors.textSummary = {
|
Chris@0
|
10 attach: function attach(context, settings) {
|
Chris@0
|
11 $(context).find('.js-text-summary').once('text-summary').each(function () {
|
Chris@0
|
12 var $widget = $(this).closest('.js-text-format-wrapper');
|
Chris@0
|
13
|
Chris@0
|
14 var $summary = $widget.find('.js-text-summary-wrapper');
|
Chris@0
|
15 var $summaryLabel = $summary.find('label').eq(0);
|
Chris@16
|
16 var $full = $widget.children('.js-form-type-textarea');
|
Chris@0
|
17 var $fullLabel = $full.find('label').eq(0);
|
Chris@0
|
18
|
Chris@0
|
19 if ($fullLabel.length === 0) {
|
Chris@0
|
20 $fullLabel = $('<label></label>').prependTo($full);
|
Chris@0
|
21 }
|
Chris@0
|
22
|
Chris@0
|
23 var $link = $('<span class="field-edit-link"> (<button type="button" class="link link-edit-summary">' + Drupal.t('Hide summary') + '</button>)</span>');
|
Chris@0
|
24 var $button = $link.find('button');
|
Chris@0
|
25 var toggleClick = true;
|
Chris@0
|
26 $link.on('click', function (e) {
|
Chris@0
|
27 if (toggleClick) {
|
Chris@0
|
28 $summary.hide();
|
Chris@0
|
29 $button.html(Drupal.t('Edit summary'));
|
Chris@0
|
30 $link.appendTo($fullLabel);
|
Chris@0
|
31 } else {
|
Chris@0
|
32 $summary.show();
|
Chris@0
|
33 $button.html(Drupal.t('Hide summary'));
|
Chris@0
|
34 $link.appendTo($summaryLabel);
|
Chris@0
|
35 }
|
Chris@0
|
36 e.preventDefault();
|
Chris@0
|
37 toggleClick = !toggleClick;
|
Chris@0
|
38 }).appendTo($summaryLabel);
|
Chris@0
|
39
|
Chris@0
|
40 if ($widget.find('.js-text-summary').val() === '') {
|
Chris@0
|
41 $link.trigger('click');
|
Chris@0
|
42 }
|
Chris@0
|
43 });
|
Chris@0
|
44 }
|
Chris@0
|
45 };
|
Chris@0
|
46 })(jQuery, Drupal); |