file_entity.admin.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. (function ($) {
  2. Drupal.behaviors.fileDisplayStatus = {
  3. attach: function (context, settings) {
  4. $('#file-displays-status-wrapper input.form-checkbox', context).once('display-status', function () {
  5. var $checkbox = $(this);
  6. // Retrieve the tabledrag row belonging to this display.
  7. var $row = $('#' + $checkbox.attr('id').replace(/-status$/, '-weight'), context).closest('tr');
  8. // Retrieve the vertical tab belonging to this display.
  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. // display's tableDrag row and vertical tab pane.
  12. $checkbox.bind('click.displayStatusUpdate', 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['file-displays-order'].restripeTable();
  27. });
  28. // Attach summary for configurable displays (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.displayStatusUpdate');
  36. });
  37. }
  38. };
  39. })(jQuery);