summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-06-12 08:18:59 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-06-12 08:18:59 +0000
commitf0b5afb436e246fbd3830ddddcb559f1407a7e6f (patch)
tree55d3b43f18dc0aea8dfd1b6676f64e7261fb5b1d
parent7affd91ab6cbef068b56d050c20224382d922d7f (diff)
downloadbrdo-f0b5afb436e246fbd3830ddddcb559f1407a7e6f.tar.gz
brdo-f0b5afb436e246fbd3830ddddcb559f1407a7e6f.tar.bz2
#822128 by roborn: Fixed 'Textarea + summary' widget broken when field allows multiple values.
-rw-r--r--modules/field/modules/text/text.js52
1 files changed, 31 insertions, 21 deletions
diff --git a/modules/field/modules/text/text.js b/modules/field/modules/text/text.js
index 42f16c9e0..877132e40 100644
--- a/modules/field/modules/text/text.js
+++ b/modules/field/modules/text/text.js
@@ -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;
+ });
});
}
};