Projet

Général

Profil

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

root / drupal7 / sites / all / modules / matomo / matomo.admin.js @ 60283730

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="matomo_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="matomo_visibility_pages"]:checked', context);
25
      if ($radio.val() == 0) {
26
        if (!$('textarea[name="matomo_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="matomo_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="matomo_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-matomo-trackmailto', context).is(':checked')) {
70
        vals.push(Drupal.t('Mailto links'));
71
      }
72
      if ($('input#edit-matomo-track', context).is(':checked')) {
73
        vals.push(Drupal.t('Outbound links'));
74
        vals.push(Drupal.t('Downloads'));
75
      }
76
      if ($('input#edit-matomo-trackcolorbox', context).is(':checked')) {
77
        vals.push(Drupal.t('Colorbox'));
78
      }
79
      if (!vals.length) {
80
        return Drupal.t('Not tracked');
81
      }
82
      return Drupal.t('@items enabled', {'@items' : vals.join(', ')});
83
    });
84

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

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

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

    
120
})(jQuery);