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