Projet

Général

Profil

Paste
Télécharger (1,54 ko) Statistiques
| Branche: | Révision:

root / drupal7 / modules / filter / filter.admin.js @ 01dfd3b5

1
(function ($) {
2

    
3
Drupal.behaviors.filterStatus = {
4
  attach: function (context, settings) {
5
    $('#filters-status-wrapper input.form-checkbox', context).once('filter-status', function () {
6
      var $checkbox = $(this);
7
      // Retrieve the tabledrag row belonging to this filter.
8
      var $row = $('#' + $checkbox.attr('id').replace(/-status$/, '-weight'), context).closest('tr');
9
      // Retrieve the vertical tab belonging to this filter.
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
      // filter's tableDrag row and vertical tab pane.
14
      $checkbox.bind('click.filterUpdate', 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['filter-order'].restripeTable();
29
      });
30

    
31
      // Attach summary for configurable filters (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.filterUpdate');
40
    });
41
  }
42
};
43

    
44
})(jQuery);