rules.debug.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * @file
  3. * Adds the collapsible functionality to the rules debug log.
  4. */
  5. // Registers the rules namespace.
  6. Drupal.rules = Drupal.rules || {};
  7. (function($) {
  8. Drupal.behaviors.rules_debug_log = {
  9. attach: function(context) {
  10. $('.rules-debug-open').click(function () {
  11. var icon = $(this).children('span.ui-icon');
  12. if ($(this).next().is(':hidden')) {
  13. Drupal.rules.changeDebugIcon(icon, true);
  14. }
  15. else {
  16. Drupal.rules.changeDebugIcon(icon, false);
  17. }
  18. $(this).next().toggle();
  19. }).next().hide();
  20. $('.rules-debug-open-main').click(function () {
  21. var icon = $(this).children('span.ui-icon');
  22. if ($(this).parent().next().is(':hidden')) {
  23. Drupal.rules.changeDebugIcon(icon, true);
  24. $(this).parent().children('.rules-debug-open-all').text(Drupal.t('-Close all-'));
  25. }
  26. else {
  27. Drupal.rules.changeDebugIcon(icon, false);
  28. $(this).parent().children('.rules-debug-open-all').text(Drupal.t('-Open all-'));
  29. }
  30. $(this).parent().next().toggle();
  31. }).parent().next().hide();
  32. $('.rules-debug-open-all').click(function() {
  33. if ($('.rules-debug-open-main').parent().next().is(':hidden')) {
  34. $('.rules-debug-open').next().show();
  35. Drupal.rules.changeDebugIcon($('.rules-debug-open').children('span.ui-icon'), true);
  36. $('.rules-debug-open-main').parent().next().show();
  37. Drupal.rules.changeDebugIcon($(this).prev().children('span.ui-icon'), true);
  38. $(this).text(Drupal.t('-Close all-'));
  39. }
  40. else {
  41. $('.rules-debug-open-main').parent().next().hide();
  42. Drupal.rules.changeDebugIcon($('.rules-debug-open-main').children('span.ui-icon'), false);
  43. $(this).text(Drupal.t('-Open all-'));
  44. $('.rules-debug-open').next().hide();
  45. Drupal.rules.changeDebugIcon($(this).prev().children('span.ui-icon'), false);
  46. }
  47. });
  48. }
  49. };
  50. /**
  51. * Changes the icon of a collapsible div.
  52. */
  53. Drupal.rules.changeDebugIcon = function(item, open) {
  54. if (open == true) {
  55. item.removeClass('ui-icon-triangle-1-e');
  56. item.addClass('ui-icon-triangle-1-s');
  57. }
  58. else {
  59. item.removeClass('ui-icon-triangle-1-s');
  60. item.addClass('ui-icon-triangle-1-e');
  61. }
  62. }
  63. })(jQuery);