Commit f0b5afb4 authored by webchick's avatar webchick
Browse files

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

parent 7affd91a
......@@ -9,30 +9,40 @@ Drupal.behaviors.textSummary = {
attach: function (context, settings) {
$('.text-summary', context).once('text-summary', function () {
var $widget = $(this).closest('div.field-type-text-with-summary');
var $summary = $widget.find('div.text-summary-wrapper');
var $summaryLabel = $summary.find('label');
var $full = $widget.find('.form-item:has(.text-full)');
var $fullLabel = $full.find('label');
var $summaries = $widget.find('div.text-summary-wrapper');
// 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 () {
$summary.hide();
$(this).find('a').html(Drupal.t('Edit summary')).end().appendTo($fullLabel);
return false;
},
function () {
$summary.show();
$(this).find('a').html(Drupal.t('Hide summary')).end().appendTo($summaryLabel);
return false;
$summaries.once('text-summary-wrapper').each(function(index) {
var $summary = $(this);
var $summaryLabel = $summary.find('label');
var $full = $widget.find('.text-full').eq(index).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) {
$fullLabel = $('<label></label>').prependTo($full);
}
).appendTo($summaryLabel);
// If no summary is set, hide the summary field.
if ($(this).val() == '') {
$link.click();
}
return;
// 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 () {
$summary.hide();
$(this).find('a').html(Drupal.t('Edit summary')).end().appendTo($fullLabel);
return false;
},
function () {
$summary.show();
$(this).find('a').html(Drupal.t('Hide summary')).end().appendTo($summaryLabel);
return false;
}
).appendTo($summaryLabel);
// If no summary is set, hide the summary field.
if ($(this).val() == '') {
$link.click();
}
return;
});
});
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment