views_send.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. (function ($) {
  2. Drupal.behaviors.viewsSend = {
  3. attach: function(context) {
  4. $('.views-send-selection-form', context).each(function() {
  5. Drupal.viewsSend.initTableBehaviors(this);
  6. Drupal.viewsSend.initGenericBehaviors(this);
  7. });
  8. }
  9. }
  10. Drupal.viewsSend = Drupal.viewsSend || {};
  11. Drupal.viewsSend.initTableBehaviors = function(form) {
  12. $('.views-send-table-select-all', form).show();
  13. // This is the "select all" checkbox in (each) table header.
  14. $('.views-send-table-select-all', form).click(function() {
  15. var table = $(this).closest('table')[0];
  16. $('input[id^="edit-views-send"]:not(:disabled)', table).attr('checked', this.checked);
  17. });
  18. }
  19. Drupal.viewsSend.initGenericBehaviors = function(form) {
  20. // Show the "select all" fieldset.
  21. $('.views-send-select-all-markup', form).show();
  22. $('.views-send-select-this-page', form).click(function() {
  23. $('input[id^="edit-views-send"]', form).attr('checked', this.checked);
  24. // Toggle the "select all" checkbox in grouped tables (if any).
  25. $('.views-send-table-select-all', form).attr('checked', this.checked);
  26. });
  27. $('.views-send-select', form).click(function() {
  28. // If a checkbox was deselected, uncheck any "select all" checkboxes.
  29. if (!this.checked) {
  30. $('.views-send-select-this-page', form).attr('checked', false);
  31. var table = $(this).closest('table')[0];
  32. if (table) {
  33. // Uncheck the "select all" checkbox in the table header.
  34. $('.views-send-table-select-all', table).attr('checked', false);
  35. }
  36. }
  37. });
  38. }
  39. })(jQuery);