Projet

Général

Profil

Paste
Télécharger (3,82 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / piwik / piwik.admin.js @ e9f59589

1
(function ($) {
2

    
3
/**
4
 * Provide the summary information for the tracking settings vertical tabs.
5
 */
6
Drupal.behaviors.trackingSettingsSummary = {
7
  attach: function (context) {
8
    // Make sure this behavior is processed only if drupalSetSummary is defined.
9
    if (typeof jQuery.fn.drupalSetSummary == 'undefined') {
10
      return;
11
    }
12

    
13
    $('fieldset#edit-domain-tracking', context).drupalSetSummary(function (context) {
14
      var $radio = $('input[name="piwik_domain_mode"]:checked', context);
15
      if ($radio.val() == 0) {
16
        return Drupal.t('A single domain');
17
      }
18
      else if ($radio.val() == 1) {
19
        return Drupal.t('One domain with multiple subdomains');
20
      }
21
    });
22

    
23
    $('fieldset#edit-page-vis-settings', context).drupalSetSummary(function (context) {
24
      var $radio = $('input[name="piwik_visibility_pages"]:checked', context);
25
      if ($radio.val() == 0) {
26
        if (!$('textarea[name="piwik_pages"]', context).val()) {
27
          return Drupal.t('Not restricted');
28
        }
29
        else {
30
          return Drupal.t('All pages with exceptions');
31
        }
32
      }
33
      else {
34
        return Drupal.t('Restricted to certain pages');
35
      }
36
    });
37

    
38
    $('fieldset#edit-role-vis-settings', context).drupalSetSummary(function (context) {
39
      var vals = [];
40
      $('input[type="checkbox"]:checked', context).each(function () {
41
        vals.push($.trim($(this).next('label').text()));
42
      });
43
      if (!vals.length) {
44
        return Drupal.t('Not restricted');
45
      }
46
      else if ($('input[name="piwik_visibility_roles"]:checked', context).val() == 1) {
47
        return Drupal.t('Excepted: @roles', {'@roles' : vals.join(', ')});
48
      }
49
      else {
50
        return vals.join(', ');
51
      }
52
    });
53

    
54
    $('fieldset#edit-user-vis-settings', context).drupalSetSummary(function (context) {
55
      var $radio = $('input[name="piwik_custom"]:checked', context);
56
      if ($radio.val() == 0) {
57
        return Drupal.t('Not customizable');
58
      }
59
      else if ($radio.val() == 1) {
60
        return Drupal.t('On by default with opt out');
61
      }
62
      else {
63
        return Drupal.t('Off by default with opt in');
64
      }
65
    });
66

    
67
    $('fieldset#edit-linktracking', context).drupalSetSummary(function (context) {
68
      var vals = [];
69
      if ($('input#edit-piwik-trackmailto', context).is(':checked')) {
70
        vals.push(Drupal.t('Mailto links'));
71
      }
72
      if ($('input#edit-piwik-track', context).is(':checked')) {
73
        vals.push(Drupal.t('Outbound links'));
74
        vals.push(Drupal.t('Downloads'));
75
      }
76
      if (!vals.length) {
77
        return Drupal.t('Not tracked');
78
      }
79
      return Drupal.t('@items enabled', {'@items' : vals.join(', ')});
80
    });
81

    
82
    $('fieldset#edit-messagetracking', context).drupalSetSummary(function (context) {
83
      var vals = [];
84
      $('input[type="checkbox"]:checked', context).each(function () {
85
        vals.push($.trim($(this).next('label').text()));
86
      });
87
      if (!vals.length) {
88
        return Drupal.t('Not tracked');
89
      }
90
      return Drupal.t('@items enabled', {'@items' : vals.join(', ')});
91
    });
92

    
93
    $('fieldset#edit-search', context).drupalSetSummary(function (context) {
94
      var vals = [];
95
      if ($('input#edit-piwik-site-search', context).is(':checked')) {
96
        vals.push(Drupal.t('Site search'));
97
      }
98
      if (!vals.length) {
99
        return Drupal.t('Not tracked');
100
      }
101
      return Drupal.t('@items enabled', {'@items' : vals.join(', ')});
102
    });
103

    
104
    $('fieldset#edit-privacy', context).drupalSetSummary(function (context) {
105
      var vals = [];
106
      if ($('input#edit-piwik-privacy-donottrack', context).is(':checked')) {
107
        vals.push(Drupal.t('Universal web tracking opt-out'));
108
      }
109
      if (!vals.length) {
110
        return Drupal.t('No privacy');
111
      }
112
      return Drupal.t('@items enabled', {'@items' : vals.join(', ')});
113
    });
114
  }
115
};
116

    
117
})(jQuery);