root / drupal7 / sites / all / modules / file_entity / file_entity.admin.js @ 1f142f4f
1 |
(function ($) { |
---|---|
2 |
|
3 |
Drupal.behaviors.fileDisplayStatus = { |
4 |
attach: function (context, settings) { |
5 |
$('#file-displays-status-wrapper input.form-checkbox', context).once('display-status', function () { |
6 |
var $checkbox = $(this); |
7 |
// Retrieve the tabledrag row belonging to this display.
|
8 |
var $row = $('#' + $checkbox.attr('id').replace(/-status$/, '-weight'), context).closest('tr'); |
9 |
// Retrieve the vertical tab belonging to this display.
|
10 |
var tab = $('#' + $checkbox.attr('id').replace(/-status$/, '-settings'), context).data('verticalTab'); |
11 |
|
12 |
// Bind click handler to this checkbox to conditionally show and hide the
|
13 |
// display's tableDrag row and vertical tab pane.
|
14 |
$checkbox.bind('click.displayStatusUpdate', function () { |
15 |
if ($checkbox.is(':checked')) { |
16 |
$row.show();
|
17 |
if (tab) {
|
18 |
tab.tabShow().updateSummary(); |
19 |
} |
20 |
} |
21 |
else {
|
22 |
$row.hide();
|
23 |
if (tab) {
|
24 |
tab.tabHide().updateSummary(); |
25 |
} |
26 |
} |
27 |
// Restripe table after toggling visibility of table row.
|
28 |
Drupal.tableDrag['file-displays-order'].restripeTable();
|
29 |
}); |
30 |
|
31 |
// Attach summary for configurable displays (only for screen-readers).
|
32 |
if (tab) {
|
33 |
tab.fieldset.drupalSetSummary(function (tabContext) {
|
34 |
return $checkbox.is(':checked') ? Drupal.t('Enabled') : Drupal.t('Disabled'); |
35 |
}); |
36 |
} |
37 |
|
38 |
// Trigger our bound click handler to update elements to initial state.
|
39 |
$checkbox.triggerHandler('click.displayStatusUpdate'); |
40 |
}); |
41 |
} |
42 |
}; |
43 |
|
44 |
})(jQuery); |