Issue #822128 by roborn, JamesK, nod_: Fixed 'Textarea + summary' widget broken when field allows multiple values.

8.0.x
catch 2012-05-01 12:43:16 +09:00
parent 3278b19d19
commit 9111e803b1
1 changed files with 31 additions and 31 deletions

View File

@ -6,41 +6,41 @@
Drupal.behaviors.textSummary = {
attach: function (context, settings) {
$(context).find('.text-summary').once('text-summary', function () {
var $widget = $(this).closest('div.field-type-text-with-summary');
var $summaries = $widget.find('div.text-summary-wrapper');
var $widget = $(this).closest('.text-format-wrapper');
$summaries.once('text-summary-wrapper').each(function(index) {
var $summary = $(this);
var $summary = $widget.find('.text-summary-wrapper');
var $summaryLabel = $summary.find('label');
var $full = $widget.find('.text-full').eq(index).closest('.form-item');
var $full = $widget.find('.text-full').closest('.form-item');
var $fullLabel = $full.find('label');
// Create a placeholder label when the field cardinality is
// unlimited or greater than 1.
if ($fullLabel.length == 0) {
// Create a placeholder label when the field cardinality is greater
// than 1.
if ($fullLabel.length === 0) {
$fullLabel = $('<label></label>').prependTo($full);
}
// Setup the edit/hide summary link.
var $link = $('<span class="field-edit-link">(<a class="link-edit-summary" href="#">' + Drupal.t('Hide summary') + '</a>)</span>').toggle(
function () {
// Set up the edit/hide summary link.
var $link = $('<span class="field-edit-link">(<a class="link-edit-summary" href="#nogo">' + Drupal.t('Hide summary') + '</a>)</span>');
var $a = $link.find('a');
$link.toggle(
function (e) {
e.preventDefault();
$summary.hide();
$(this).find('a').html(Drupal.t('Edit summary')).end().appendTo($fullLabel);
return false;
$a.html(Drupal.t('Edit summary'));
$link.appendTo($fullLabel);
},
function () {
function (e) {
e.preventDefault();
$summary.show();
$(this).find('a').html(Drupal.t('Hide summary')).end().appendTo($summaryLabel);
return false;
$a.html(Drupal.t('Hide summary'));
$link.appendTo($summaryLabel);
}
).appendTo($summaryLabel);
// If no summary is set, hide the summary field.
if ($(this).find('.text-summary').val() == '') {
if ($widget.find('.text-summary').val() === '') {
$link.click();
}
return;
});
});
}
};