Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
This commit is contained in:
commit
9921556621
13277 changed files with 1459781 additions and 0 deletions
58
core/modules/text/text.js
Normal file
58
core/modules/text/text.js
Normal file
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* @file
|
||||
* Text behaviors.
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Auto-hide summary textarea if empty and show hide and unhide links.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*/
|
||||
Drupal.behaviors.textSummary = {
|
||||
attach: function (context, settings) {
|
||||
$(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');
|
||||
var $summaryLabel = $summary.find('label').eq(0);
|
||||
var $full = $widget.find('.js-text-full').closest('.form-item');
|
||||
var $fullLabel = $full.find('label').eq(0);
|
||||
|
||||
// Create a placeholder label when the field cardinality is greater
|
||||
// than 1.
|
||||
if ($fullLabel.length === 0) {
|
||||
$fullLabel = $('<label></label>').prependTo($full);
|
||||
}
|
||||
|
||||
// Set up the edit/hide summary link.
|
||||
var $link = $('<span class="field-edit-link"> (<button type="button" class="link link-edit-summary">' + Drupal.t('Hide summary') + '</button>)</span>');
|
||||
var $button = $link.find('button');
|
||||
var toggleClick = true;
|
||||
$link.on('click', function (e) {
|
||||
if (toggleClick) {
|
||||
$summary.hide();
|
||||
$button.html(Drupal.t('Edit summary'));
|
||||
$link.appendTo($fullLabel);
|
||||
}
|
||||
else {
|
||||
$summary.show();
|
||||
$button.html(Drupal.t('Hide summary'));
|
||||
$link.appendTo($summaryLabel);
|
||||
}
|
||||
e.preventDefault();
|
||||
toggleClick = !toggleClick;
|
||||
}).appendTo($summaryLabel);
|
||||
|
||||
// If no summary is set, hide the summary field.
|
||||
if ($widget.find('.js-text-summary').val() === '') {
|
||||
$link.trigger('click');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
Reference in a new issue