filter.admin.js 1.5 KB

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