1
|
(function ($) {
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
Drupal.behaviors.flagRoles = {};
|
7
|
Drupal.behaviors.flagRoles.attach = function(context) {
|
8
|
$('#flag-roles input.flag-access', context).change(function() {
|
9
|
var unflagCheckbox = $(this).parents('tr:first').find('input.unflag-access').get(0);
|
10
|
if (this.checked) {
|
11
|
|
12
|
unflagCheckbox.disabled = false;
|
13
|
if (typeof(unflagCheckbox.previousFlagState) != 'undefined') {
|
14
|
unflagCheckbox.checked = unflagCheckbox.previousFlagState;
|
15
|
}
|
16
|
else {
|
17
|
unflagCheckbox.checked = true;
|
18
|
}
|
19
|
}
|
20
|
else {
|
21
|
|
22
|
unflagCheckbox.previousFlagState = unflagCheckbox.checked;
|
23
|
unflagCheckbox.disabled = true;
|
24
|
unflagCheckbox.checked = false;
|
25
|
}
|
26
|
});
|
27
|
|
28
|
$('#flag-roles input.unflag-access', context).change(function() {
|
29
|
if ($(this).parents('table:first').find('input.unflag-access:enabled:not(:checked)').size() == 0) {
|
30
|
$('div.form-item-unflag-denied-text').slideUp();
|
31
|
}
|
32
|
else {
|
33
|
$('div.form-item-unflag-denied-text').slideDown();
|
34
|
}
|
35
|
});
|
36
|
|
37
|
|
38
|
if ($('#flag-roles input.unflag-access:enabled:not(:checked)').size() == 0) {
|
39
|
$('div.form-item-unflag-denied-text').css('display', 'none');
|
40
|
}
|
41
|
};
|
42
|
|
43
|
|
44
|
|
45
|
|
46
|
Drupal.behaviors.flagSummary = {};
|
47
|
|
48
|
Drupal.behaviors.flagSummary.attach = function (context) {
|
49
|
$('fieldset.flag-fieldset', context).drupalSetSummary(function(context) {
|
50
|
var flags = [];
|
51
|
$('input:checkbox:checked', context).each(function() {
|
52
|
flags.push(this.title);
|
53
|
});
|
54
|
|
55
|
if (flags.length) {
|
56
|
return flags.join(', ');
|
57
|
}
|
58
|
else {
|
59
|
return Drupal.t('No flags');
|
60
|
}
|
61
|
});
|
62
|
};
|
63
|
|
64
|
})(jQuery);
|