googleanalytics.admin.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 (!vals.length) {
  64. return Drupal.t('Not tracked');
  65. }
  66. return Drupal.t('@items enabled', {'@items' : vals.join(', ')});
  67. });
  68. $('fieldset#edit-messagetracking', context).drupalSetSummary(function (context) {
  69. var vals = [];
  70. $('input[type="checkbox"]:checked', context).each(function () {
  71. vals.push($.trim($(this).next('label').text()));
  72. });
  73. if (!vals.length) {
  74. return Drupal.t('Not tracked');
  75. }
  76. return Drupal.t('@items enabled', {'@items' : vals.join(', ')});
  77. });
  78. $('fieldset#edit-search-and-advertising', context).drupalSetSummary(function (context) {
  79. var vals = [];
  80. if ($('input#edit-googleanalytics-site-search', context).is(':checked')) {
  81. vals.push(Drupal.t('Site search'));
  82. }
  83. if ($('input#edit-googleanalytics-trackadsense', context).is(':checked')) {
  84. vals.push(Drupal.t('AdSense ads'));
  85. }
  86. if ($('input#edit-googleanalytics-trackdoubleclick', context).is(':checked')) {
  87. vals.push(Drupal.t('Display features'));
  88. }
  89. if (!vals.length) {
  90. return Drupal.t('Not tracked');
  91. }
  92. return Drupal.t('@items enabled', {'@items' : vals.join(', ')});
  93. });
  94. $('fieldset#edit-domain-tracking', context).drupalSetSummary(function (context) {
  95. var $radio = $('input[name="googleanalytics_domain_mode"]:checked', context);
  96. if ($radio.val() == 0) {
  97. return Drupal.t('A single domain');
  98. }
  99. else if ($radio.val() == 1) {
  100. return Drupal.t('One domain with multiple subdomains');
  101. }
  102. else {
  103. return Drupal.t('Multiple top-level domains');
  104. }
  105. });
  106. $('fieldset#edit-privacy', context).drupalSetSummary(function (context) {
  107. var vals = [];
  108. if ($('input#edit-googleanalytics-tracker-anonymizeip', context).is(':checked')) {
  109. vals.push(Drupal.t('Anonymize IP'));
  110. }
  111. if ($('input#edit-googleanalytics-privacy-donottrack', context).is(':checked')) {
  112. vals.push(Drupal.t('Universal web tracking opt-out'));
  113. }
  114. if (!vals.length) {
  115. return Drupal.t('No privacy');
  116. }
  117. return Drupal.t('@items enabled', {'@items' : vals.join(', ')});
  118. });
  119. }
  120. };
  121. })(jQuery);