Projet

Général

Profil

Paste
Télécharger (2,31 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / rules / ui / rules.debug.js @ d719f12f

1
/**
2
 * @file
3
 * Adds the collapsible functionality to the rules debug log.
4
 */
5

    
6
// Registers the rules namespace.
7
Drupal.rules = Drupal.rules || {};
8

    
9
(function($) {
10
  Drupal.behaviors.rules_debug_log = {
11
    attach: function(context) {
12
      $('.rules-debug-open').click(function () {
13
        var icon = $(this).children('span.ui-icon');
14
        if ($(this).next().is(':hidden')) {
15
          Drupal.rules.changeDebugIcon(icon, true);
16
        }
17
        else {
18
          Drupal.rules.changeDebugIcon(icon, false);
19
        }
20
        $(this).next().toggle();
21
      }).next().hide();
22

    
23
      $('.rules-debug-open-main').click(function () {
24
        var icon = $(this).children('span.ui-icon');
25
        if ($(this).parent().next().is(':hidden')) {
26
          Drupal.rules.changeDebugIcon(icon, true);
27
          $(this).parent().children('.rules-debug-open-all').text(Drupal.t('-Close all-'));
28
        }
29
        else {
30
          Drupal.rules.changeDebugIcon(icon, false);
31
          $(this).parent().children('.rules-debug-open-all').text(Drupal.t('-Open all-'));
32
        }
33
        $(this).parent().next().toggle();
34
      }).parent().next().hide();
35

    
36
      $('.rules-debug-open-all').click(function() {
37
        if ($('.rules-debug-open-main').parent().next().is(':hidden')) {
38
          $('.rules-debug-open').next().show();
39
          Drupal.rules.changeDebugIcon($('.rules-debug-open').children('span.ui-icon'), true);
40
          $('.rules-debug-open-main').parent().next().show();
41
          Drupal.rules.changeDebugIcon($(this).prev().children('span.ui-icon'), true);
42
          $(this).text(Drupal.t('-Close all-'));
43
        }
44
        else {
45
          $('.rules-debug-open-main').parent().next().hide();
46
          Drupal.rules.changeDebugIcon($('.rules-debug-open-main').children('span.ui-icon'), false);
47
          $(this).text(Drupal.t('-Open all-'));
48
          $('.rules-debug-open').next().hide();
49
          Drupal.rules.changeDebugIcon($(this).prev().children('span.ui-icon'), false);
50
        }
51
      });
52
    }
53
  };
54

    
55
  /**
56
   * Changes the icon of a collapsible div.
57
   */
58
  Drupal.rules.changeDebugIcon = function(item, open) {
59
    if (open == true) {
60
      item.removeClass('ui-icon-triangle-1-e');
61
      item.addClass('ui-icon-triangle-1-s');
62
    }
63
    else {
64
      item.removeClass('ui-icon-triangle-1-s');
65
      item.addClass('ui-icon-triangle-1-e');
66
    }
67
  }
68
})(jQuery);