matomo.admin.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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-domain-tracking', context).drupalSetSummary(function (context) {
  12. var $radio = $('input[name="matomo_domain_mode"]:checked', context);
  13. if ($radio.val() == 0) {
  14. return Drupal.t('A single domain');
  15. }
  16. else if ($radio.val() == 1) {
  17. return Drupal.t('One domain with multiple subdomains');
  18. }
  19. });
  20. $('fieldset#edit-page-vis-settings', context).drupalSetSummary(function (context) {
  21. var $radio = $('input[name="matomo_visibility_pages"]:checked', context);
  22. if ($radio.val() == 0) {
  23. if (!$('textarea[name="matomo_pages"]', context).val()) {
  24. return Drupal.t('Not restricted');
  25. }
  26. else {
  27. return Drupal.t('All pages with exceptions');
  28. }
  29. }
  30. else {
  31. return Drupal.t('Restricted to certain pages');
  32. }
  33. });
  34. $('fieldset#edit-role-vis-settings', context).drupalSetSummary(function (context) {
  35. var vals = [];
  36. $('input[type="checkbox"]:checked', context).each(function () {
  37. vals.push($.trim($(this).next('label').text()));
  38. });
  39. if (!vals.length) {
  40. return Drupal.t('Not restricted');
  41. }
  42. else if ($('input[name="matomo_visibility_roles"]:checked', context).val() == 1) {
  43. return Drupal.t('Excepted: @roles', {'@roles' : vals.join(', ')});
  44. }
  45. else {
  46. return vals.join(', ');
  47. }
  48. });
  49. $('fieldset#edit-user-vis-settings', context).drupalSetSummary(function (context) {
  50. var $radio = $('input[name="matomo_custom"]:checked', context);
  51. if ($radio.val() == 0) {
  52. return Drupal.t('Not customizable');
  53. }
  54. else if ($radio.val() == 1) {
  55. return Drupal.t('On by default with opt out');
  56. }
  57. else {
  58. return Drupal.t('Off by default with opt in');
  59. }
  60. });
  61. $('fieldset#edit-linktracking', context).drupalSetSummary(function (context) {
  62. var vals = [];
  63. if ($('input#edit-matomo-trackmailto', context).is(':checked')) {
  64. vals.push(Drupal.t('Mailto links'));
  65. }
  66. if ($('input#edit-matomo-track', context).is(':checked')) {
  67. vals.push(Drupal.t('Outbound links'));
  68. vals.push(Drupal.t('Downloads'));
  69. }
  70. if ($('input#edit-matomo-trackcolorbox', context).is(':checked')) {
  71. vals.push(Drupal.t('Colorbox'));
  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-messagetracking', context).drupalSetSummary(function (context) {
  79. var vals = [];
  80. $('input[type="checkbox"]:checked', context).each(function () {
  81. vals.push($.trim($(this).next('label').text()));
  82. });
  83. if (!vals.length) {
  84. return Drupal.t('Not tracked');
  85. }
  86. return Drupal.t('@items enabled', {'@items' : vals.join(', ')});
  87. });
  88. $('fieldset#edit-search', context).drupalSetSummary(function (context) {
  89. var vals = [];
  90. if ($('input#edit-matomo-site-search', context).is(':checked')) {
  91. vals.push(Drupal.t('Site search'));
  92. }
  93. if (!vals.length) {
  94. return Drupal.t('Not tracked');
  95. }
  96. return Drupal.t('@items enabled', {'@items' : vals.join(', ')});
  97. });
  98. $('fieldset#edit-privacy', context).drupalSetSummary(function (context) {
  99. var vals = [];
  100. if ($('input#edit-matomo-privacy-donottrack', context).is(':checked')) {
  101. vals.push(Drupal.t('Universal web tracking opt-out'));
  102. }
  103. if (!vals.length) {
  104. return Drupal.t('No privacy');
  105. }
  106. return Drupal.t('@items enabled', {'@items' : vals.join(', ')});
  107. });
  108. }
  109. };
  110. })(jQuery);