Chris@0: /** Chris@0: * DO NOT EDIT THIS FILE. Chris@0: * See the following change record for more information, Chris@0: * https://www.drupal.org/node/2815083 Chris@0: * @preserve Chris@0: **/ Chris@0: Chris@0: (function ($, Drupal) { Chris@0: Drupal.behaviors.textSummary = { Chris@0: attach: function attach(context, settings) { Chris@0: $(context).find('.js-text-summary').once('text-summary').each(function () { Chris@0: var $widget = $(this).closest('.js-text-format-wrapper'); Chris@0: Chris@0: var $summary = $widget.find('.js-text-summary-wrapper'); Chris@0: var $summaryLabel = $summary.find('label').eq(0); Chris@16: var $full = $widget.children('.js-form-type-textarea'); Chris@0: var $fullLabel = $full.find('label').eq(0); Chris@0: Chris@0: if ($fullLabel.length === 0) { Chris@0: $fullLabel = $('').prependTo($full); Chris@0: } Chris@0: Chris@0: var $link = $(' ()'); Chris@0: var $button = $link.find('button'); Chris@0: var toggleClick = true; Chris@0: $link.on('click', function (e) { Chris@0: if (toggleClick) { Chris@0: $summary.hide(); Chris@0: $button.html(Drupal.t('Edit summary')); Chris@0: $link.appendTo($fullLabel); Chris@0: } else { Chris@0: $summary.show(); Chris@0: $button.html(Drupal.t('Hide summary')); Chris@0: $link.appendTo($summaryLabel); Chris@0: } Chris@0: e.preventDefault(); Chris@0: toggleClick = !toggleClick; Chris@0: }).appendTo($summaryLabel); Chris@0: Chris@0: if ($widget.find('.js-text-summary').val() === '') { Chris@0: $link.trigger('click'); Chris@0: } Chris@0: }); Chris@0: } Chris@0: }; Chris@0: })(jQuery, Drupal);