1
|
|
2
|
(function ($) {
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
Drupal.behaviors.textSummary = {
|
8
|
attach: function (context, settings) {
|
9
|
$('.text-summary', context).once('text-summary', function () {
|
10
|
var $widget = $(this).closest('div.field-type-text-with-summary');
|
11
|
var $summaries = $widget.find('div.text-summary-wrapper');
|
12
|
|
13
|
$summaries.once('text-summary-wrapper').each(function(index) {
|
14
|
var $summary = $(this);
|
15
|
var $summaryLabel = $summary.find('label');
|
16
|
var $full = $widget.find('.text-full').eq(index).closest('.form-item');
|
17
|
var $fullLabel = $full.find('label');
|
18
|
|
19
|
|
20
|
|
21
|
if ($fullLabel.length == 0) {
|
22
|
$fullLabel = $('<label></label>').prependTo($full);
|
23
|
}
|
24
|
|
25
|
|
26
|
var $link = $('<span class="field-edit-link">(<a class="link-edit-summary" href="#">' + Drupal.t('Hide summary') + '</a>)</span>').toggle(
|
27
|
function () {
|
28
|
$summary.hide();
|
29
|
$(this).find('a').html(Drupal.t('Edit summary')).end().appendTo($fullLabel);
|
30
|
return false;
|
31
|
},
|
32
|
function () {
|
33
|
$summary.show();
|
34
|
$(this).find('a').html(Drupal.t('Hide summary')).end().appendTo($summaryLabel);
|
35
|
return false;
|
36
|
}
|
37
|
).appendTo($summaryLabel);
|
38
|
|
39
|
|
40
|
if ($(this).find('.text-summary').val() == '') {
|
41
|
$link.click();
|
42
|
}
|
43
|
return;
|
44
|
});
|
45
|
});
|
46
|
}
|
47
|
};
|
48
|
|
49
|
})(jQuery);
|