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