Issue #822128 by roborn, JamesK, nod_: Fixed 'Textarea + summary' widget broken when field allows multiple values.
parent
3278b19d19
commit
9111e803b1
|
@ -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;
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue