googleanalytics.admin.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. (function ($) {
  2. /**
  3. * Provide the summary information for the tracking settings vertical tabs.
  4. */
  5. Drupal.behaviors.trackingSettingsSummary = {
  6. attach: function (context) {
  7. // Make sure this behavior is processed only if drupalSetSummary is defined.
  8. if (typeof jQuery.fn.drupalSetSummary == 'undefined') {
  9. return;
  10. }
  11. $('fieldset#edit-page-vis-settings', context).drupalSetSummary(function (context) {
  12. var $radio = $('input[name="googleanalytics_visibility_pages"]:checked', context);
  13. if ($radio.val() == 0) {
  14. if (!$('textarea[name="googleanalytics_pages"]', context).val()) {
  15. return Drupal.t('Not restricted');
  16. }
  17. else {
  18. return Drupal.t('All pages with exceptions');
  19. }
  20. }
  21. else {
  22. return Drupal.t('Restricted to certain pages');
  23. }
  24. });
  25. $('fieldset#edit-role-vis-settings', context).drupalSetSummary(function (context) {
  26. var vals = [];
  27. $('input[type="checkbox"]:checked', context).each(function () {
  28. vals.push($.trim($(this).next('label').text()));
  29. });
  30. if (!vals.length) {
  31. return Drupal.t('Not restricted');
  32. }
  33. else if ($('input[name="googleanalytics_visibility_roles"]:checked', context).val() == 1) {
  34. return Drupal.t('Excepted: @roles', {'@roles' : vals.join(', ')});
  35. }
  36. else {
  37. return vals.join(', ');
  38. }
  39. });
  40. $('fieldset#edit-user-vis-settings', context).drupalSetSummary(function (context) {
  41. var $radio = $('input[name="googleanalytics_custom"]:checked', context);
  42. if ($radio.val() == 0) {
  43. return Drupal.t('Not customizable');
  44. }
  45. else if ($radio.val() == 1) {
  46. return Drupal.t('On by default with opt out');
  47. }
  48. else {
  49. return Drupal.t('Off by default with opt in');
  50. }
  51. });
  52. $('fieldset#edit-linktracking', context).drupalSetSummary(function (context) {
  53. var vals = [];
  54. if ($('input#edit-googleanalytics-trackoutbound', context).is(':checked')) {
  55. vals.push(Drupal.t('Outbound links'));
  56. }
  57. if ($('input#edit-googleanalytics-trackmailto', context).is(':checked')) {
  58. vals.push(Drupal.t('Mailto links'));
  59. }
  60. if ($('input#edit-googleanalytics-trackfiles', context).is(':checked')) {
  61. vals.push(Drupal.t('Downloads'));
  62. }
  63. if ($('input#edit-googleanalytics-trackcolorbox', context).is(':checked')) {
  64. vals.push(Drupal.t('Colorbox'));
  65. }
  66. if ($('input#edit-googleanalytics-tracklinkid', context).is(':checked')) {
  67. vals.push(Drupal.t('Link attribution'));
  68. }
  69. if ($('input#edit-googleanalytics-trackurlfragments', context).is(':checked')) {
  70. vals.push(Drupal.t('URL fragments'));
  71. }
  72. if (!vals.length) {
  73. return Drupal.t('Not tracked');
  74. }
  75. return Drupal.t('@items enabled', {'@items' : vals.join(', ')});
  76. });
  77. $('fieldset#edit-messagetracking', context).drupalSetSummary(function (context) {
  78. var vals = [];
  79. $('input[type="checkbox"]:checked', context).each(function () {
  80. vals.push($.trim($(this).next('label').text()));
  81. });
  82. if (!vals.length) {
  83. return Drupal.t('Not tracked');
  84. }
  85. return Drupal.t('@items enabled', {'@items' : vals.join(', ')});
  86. });
  87. $('fieldset#edit-search-and-advertising', context).drupalSetSummary(function (context) {
  88. var vals = [];
  89. if ($('input#edit-googleanalytics-site-search', context).is(':checked')) {
  90. vals.push(Drupal.t('Site search'));
  91. }
  92. if ($('input#edit-googleanalytics-trackadsense', context).is(':checked')) {
  93. vals.push(Drupal.t('AdSense ads'));
  94. }
  95. if ($('input#edit-googleanalytics-trackdoubleclick', context).is(':checked')) {
  96. vals.push(Drupal.t('Display features'));
  97. }
  98. if (!vals.length) {
  99. return Drupal.t('Not tracked');
  100. }
  101. return Drupal.t('@items enabled', {'@items' : vals.join(', ')});
  102. });
  103. $('fieldset#edit-domain-tracking', context).drupalSetSummary(function (context) {
  104. var $radio = $('input[name="googleanalytics_domain_mode"]:checked', context);
  105. if ($radio.val() == 0) {
  106. return Drupal.t('A single domain');
  107. }
  108. else if ($radio.val() == 1) {
  109. return Drupal.t('One domain with multiple subdomains');
  110. }
  111. else {
  112. return Drupal.t('Multiple top-level domains');
  113. }
  114. });
  115. $('fieldset#edit-privacy', context).drupalSetSummary(function (context) {
  116. var vals = [];
  117. if ($('input#edit-googleanalytics-tracker-anonymizeip', context).is(':checked')) {
  118. vals.push(Drupal.t('Anonymize IP'));
  119. }
  120. if ($('input#edit-googleanalytics-privacy-donottrack', context).is(':checked')) {
  121. vals.push(Drupal.t('Universal web tracking opt-out'));
  122. }
  123. if (!vals.length) {
  124. return Drupal.t('No privacy');
  125. }
  126. return Drupal.t('@items enabled', {'@items' : vals.join(', ')});
  127. });
  128. }
  129. };
  130. })(jQuery);