2015-06-05 20:17:55 +00:00
|
|
|
/**
|
2017-05-19 22:12:53 +00:00
|
|
|
* DO NOT EDIT THIS FILE.
|
|
|
|
* See the following change record for more information,
|
2017-05-23 14:30:14 +00:00
|
|
|
* https://www.drupal.org/node/2815083
|
2017-05-19 22:12:53 +00:00
|
|
|
* @preserve
|
|
|
|
**/
|
2015-06-05 20:17:55 +00:00
|
|
|
|
2016-02-29 03:25:57 +00:00
|
|
|
(function ($, Drupal) {
|
2014-01-27 21:41:32 +00:00
|
|
|
Drupal.behaviors.textSummary = {
|
2017-05-19 22:12:53 +00:00
|
|
|
attach: function attach(context, settings) {
|
2015-05-11 00:32:22 +00:00
|
|
|
$(context).find('.js-text-summary').once('text-summary').each(function () {
|
|
|
|
var $widget = $(this).closest('.js-text-format-wrapper');
|
|
|
|
var $summary = $widget.find('.js-text-summary-wrapper');
|
2015-04-15 07:59:36 +00:00
|
|
|
var $summaryLabel = $summary.find('label').eq(0);
|
Issue #2626716 by jacktonkin, MaskOta, tedbow, michielnugter, ozin, dawehner, swetashahi, una_maria, zviryatko, mohit_aghera, kryp71c, Jo Fitzgerald, Munavijayalakshmi, Truptti, droplet, andrewmacpherson: "Edit Summary" link not showing if "Help Text" is set
2018-04-07 23:37:20 +00:00
|
|
|
var $full = $widget.children('.js-form-type-textarea');
|
2015-04-15 07:59:36 +00:00
|
|
|
var $fullLabel = $full.find('label').eq(0);
|
2010-06-12 08:18:59 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if ($fullLabel.length === 0) {
|
|
|
|
$fullLabel = $('<label></label>').prependTo($full);
|
2010-06-12 08:18:59 +00:00
|
|
|
}
|
2012-05-01 03:43:16 +00:00
|
|
|
|
2020-01-30 09:08:38 +00:00
|
|
|
var $link = $("<span class=\"field-edit-link\"> (<button type=\"button\" class=\"link link-edit-summary\">".concat(Drupal.t('Hide summary'), "</button>)</span>"));
|
2014-01-27 21:41:32 +00:00
|
|
|
var $button = $link.find('button');
|
|
|
|
var toggleClick = true;
|
2015-01-10 01:36:01 +00:00
|
|
|
$link.on('click', function (e) {
|
2014-01-27 21:41:32 +00:00
|
|
|
if (toggleClick) {
|
|
|
|
$summary.hide();
|
|
|
|
$button.html(Drupal.t('Edit summary'));
|
|
|
|
$link.appendTo($fullLabel);
|
2017-05-19 22:12:53 +00:00
|
|
|
} else {
|
2014-01-27 21:41:32 +00:00
|
|
|
$summary.show();
|
|
|
|
$button.html(Drupal.t('Hide summary'));
|
|
|
|
$link.appendTo($summaryLabel);
|
|
|
|
}
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
e.preventDefault();
|
|
|
|
toggleClick = !toggleClick;
|
|
|
|
}).appendTo($summaryLabel);
|
|
|
|
|
2015-05-11 00:32:22 +00:00
|
|
|
if ($widget.find('.js-text-summary').val() === '') {
|
2014-01-27 21:41:32 +00:00
|
|
|
$link.trigger('click');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
2017-05-19 22:12:53 +00:00
|
|
|
})(jQuery, Drupal);
|