3 * Attaches administration-specific behavior for the Filter module.
6 (function ($, Drupal) {
11 * Displays and updates the status of filters on the admin page.
13 * @type {Drupal~behavior}
15 * @prop {Drupal~behaviorAttach} attach
16 * Attaches behaviors to the filter admin view.
18 Drupal.behaviors.filterStatus = {
19 attach: function (context, settings) {
20 var $context = $(context);
21 $context.find('#filters-status-wrapper input.form-checkbox').once('filter-status').each(function () {
22 var $checkbox = $(this);
23 // Retrieve the tabledrag row belonging to this filter.
24 var $row = $context.find('#' + $checkbox.attr('id').replace(/-status$/, '-weight')).closest('tr');
25 // Retrieve the vertical tab belonging to this filter.
26 var $filterSettings = $context.find('#' + $checkbox.attr('id').replace(/-status$/, '-settings'));
27 var filterSettingsTab = $filterSettings.data('verticalTab');
29 // Bind click handler to this checkbox to conditionally show and hide
30 // the filter's tableDrag row and vertical tab pane.
31 $checkbox.on('click.filterUpdate', function () {
32 if ($checkbox.is(':checked')) {
34 if (filterSettingsTab) {
35 filterSettingsTab.tabShow().updateSummary();
38 // On very narrow viewports, Vertical Tabs are disabled.
39 $filterSettings.show();
44 if (filterSettingsTab) {
45 filterSettingsTab.tabHide().updateSummary();
48 // On very narrow viewports, Vertical Tabs are disabled.
49 $filterSettings.hide();
52 // Restripe table after toggling visibility of table row.
53 Drupal.tableDrag['filter-order'].restripeTable();
56 // Attach summary for configurable filters (only for screen readers).
57 if (filterSettingsTab) {
58 filterSettingsTab.details.drupalSetSummary(function (tabContext) {
59 return $checkbox.is(':checked') ? Drupal.t('Enabled') : Drupal.t('Disabled');
63 // Trigger our bound click handler to update elements to initial state.
64 $checkbox.triggerHandler('click.filterUpdate');