1(function ($) { // JavaScript should be compatible with other libraries than jQuery 2 Drupal.behaviors.textResize = { // D7 "Changed Drupal.behaviors to objects having the methods "attach" and "detach"." 3 attach: function(context) { 4 // Which div or page element are we resizing? 5 if (text_resize_scope) { // Admin-specified scope takes precedence. 6 if ($('#'+text_resize_scope).length > 0) { 7 var element_to_resize = $('#'+text_resize_scope); // ID specified by admin 8 } 9 else if ($('.'+text_resize_scope).length > 0) { 10 var element_to_resize = $('.'+text_resize_scope); // CLASS specified by admin 11 } 12 else { 13 var element_to_resize = $(text_resize_scope); // It's just a tag specified by admin 14 } 15 } 16 else { // Look for some default scopes that might exist. 17 if ($('DIV.left-corner').length > 0) { 18 var element_to_resize = $('DIV.left-corner'); // Main body div for Garland 19 } 20 else if ($('#content-inner').length > 0) { 21 var element_to_resize = $('#content-inner'); // Main body div for Zen-based themes 22 } 23 else if ($('#squeeze > #content').length > 0) { 24 var element_to_resize = $('#squeeze > #content'); // Main body div for Zen Classic 25 } 26 } 27 // Set the initial font size if necessary 28 if ($.cookie('text_resize') != null) { 29 element_to_resize.css('font-size', parseFloat($.cookie('text_resize')) + 'px'); 30 } 31 if (text_resize_line_height_allow) { 32 // Set the initial line height if necessary 33 if ($.cookie('text_resize_line_height') != null) { 34 element_to_resize.css('line-height', parseFloat($.cookie('text_resize_line_height')) + 'px'); 35 } 36 } 37 // Changer links will change the text size when clicked 38 $('a.changer').click(function() { 39 // Set the current font size of the specified section as a variable 40 var currentFontSize = parseFloat(element_to_resize.css('font-size'), 10); 41 // Set the current line-height 42 var current_line_height = parseFloat(element_to_resize.css('line-height'), 10); 43 // javascript lets us choose which link was clicked, by ID 44 if (this.id == 'text_resize_increase') { 45 var new_font_size = currentFontSize * 1.2; 46 if (text_resize_line_height_allow) { var new_line_height = current_line_height * 1.2; } 47 // Allow resizing as long as font size doesn't go above text_resize_maximum. 48 if (new_font_size <= text_resize_maximum) { 49 $.cookie('text_resize', new_font_size, { path: '/' }); 50 if (text_resize_line_height_allow) { $.cookie('text_resize_line_height', new_line_height, { path: '/' }); } 51 var allow_change = true; 52 } 53 else { 54 $.cookie('text_resize', text_resize_maximum, { path: '/' }); 55 if (text_resize_line_height_allow) { $.cookie('text_resize_line_height', text_resize_line_height_max, { path: '/' }); } 56 var reset_size_max = true; 57 } 58 } 59 else if (this.id == 'text_resize_decrease') { 60 var new_font_size = currentFontSize / 1.2; 61 if (text_resize_line_height_allow) { var new_line_height = current_line_height / 1.2; } 62 if (new_font_size >= text_resize_minimum) { 63 // Allow resizing as long as font size doesn't go below text_resize_minimum. 64 $.cookie('text_resize', new_font_size, { path: '/' }); 65 if (text_resize_line_height_allow) { $.cookie('text_resize_line_height', new_line_height, { path: '/' }); } 66 var allow_change = true; 67 } 68 else { 69 // If it goes below text_resize_minimum, just leave it at text_resize_minimum. 70 $.cookie('text_resize', text_resize_minimum, { path: '/' }); 71 if (text_resize_line_height_allow) { $.cookie('text_resize_line_height', text_resize_line_height_min, { path: '/' }); } 72 var reset_size_min = true; 73 } 74 } 75 else if (this.id == 'text_resize_reset') { 76 $.cookie('text_resize', null, { path: '/' }); 77 if (text_resize_line_height_allow) { $.cookie('text_resize_line_height', null, { path: '/' }); } 78 var reset_size_original = true; 79 } 80 // jQuery lets us set the font size value of the main text div 81 if (allow_change == true) { 82 element_to_resize.css('font-size', new_font_size + 'px'); // Add 'px' onto the end, otherwise ems are used as units by default 83 if (text_resize_line_height_allow) { element_to_resize.css('line-height', new_line_height + 'px'); } 84 return false;
85 } 86 else if (reset_size_min == true) { 87 element_to_resize.css('font-size', text_resize_minimum + 'px'); 88 if (text_resize_line_height_allow) { element_to_resize.css('line-height', text_resize_line_height_min + 'px'); } 89 return false; 90 } 91 else if (reset_size_max == true) { 92 element_to_resize.css('font-size', text_resize_maximum + 'px'); 93 if (text_resize_line_height_allow) { element_to_resize.css('line-height', text_resize_line_height_max + 'px'); } 94 return false; 95 } 96 else if (reset_size_original == true) { 97 element_to_resize.css('font-size', ''); 98 if (text_resize_line_height_allow) { element_to_resize.css('line-height', ''); } 99 return false; 100 } 101 }); 102 } 103 }; 104})(jQuery);; 105(function ($) { 106 107Drupal.googleanalytics = {}; 108 109$(document).ready(function() { 110 111 // Attach mousedown, keyup, touchstart events to document only and catch 112 // clicks on all elements. 113 $(document.body).bind("mousedown keyup touchstart", function(event) { 114 115 // Catch the closest surrounding link of a clicked element. 116 $(event.target).closest("a,area").each(function() { 117 118 // Is the clicked URL internal? 119 if (Drupal.googleanalytics.isInternal(this.href)) { 120 // Skip 'click' tracking, if custom tracking events are bound. 121 if ($(this).is('.colorbox') && (Drupal.settings.googleanalytics.trackColorbox)) { 122 // Do nothing here. The custom event will handle all tracking. 123 //console.info("Click on .colorbox item has been detected."); 124 } 125 // Is download tracking activated and the file extension configured for download tracking? 126 else if (Drupal.settings.googleanalytics.trackDownload && Drupal.googleanalytics.isDownload(this.href)) { 127 // Download link clicked. 128 gtag('event', Drupal.googleanalytics.getDownloadExtension(this.href).toUpperCase(), { 129 event_category: 'Downloads', 130 event_label: Drupal.googleanalytics.getPageUrl(this.href), 131 transport_type: 'beacon' 132 }); 133 } 134 else if (Drupal.googleanalytics.isInternalSpecial(this.href)) { 135 // Keep the internal URL for Google Analytics website overlay intact. 136 // @todo: May require tracking ID 137 var target = this; 138 $.each(Drupal.settings.googleanalytics.account, function () { 139 gtag('config', this, { 140 page_path: Drupal.googleanalytics.getPageUrl(target.href), 141 transport_type: 'beacon' 142 }); 143 }); 144 } 145 } 146 else { 147 if (Drupal.settings.googleanalytics.trackMailto && $(this).is("a[href^='mailto:'],area[href^='mailto:']")) { 148 // Mailto link clicked. 149 gtag('event', 'Click', { 150 event_category: 'Mails', 151 event_label: this.href.substring(7), 152 transport_type: 'beacon' 153 }); 154 } 155 else if (Drupal.settings.googleanalytics.trackOutbound && this.href.match(/^\w+:\/\//i)) { 156 if (Drupal.settings.googleanalytics.trackDomainMode !== 2 || (Drupal.settings.googleanalytics.trackDomainMode === 2 && !Drupal.googleanalytics.isCrossDomain(this.hostname, Drupal.settings.googleanalytics.trackCrossDomains))) { 157 // External link clicked / No top-level cross domain clicked. 158 gtag('event', 'Click', { 159 event_category: 'Outbound links', 160 event_label: this.href, 161 transport_type: 'beacon' 162 }); 163 } 164 } 165 } 166 }); 167 }); 168 169 // Track hash changes as unique pageviews, if this option has been enabled. 170 if (Drupal.settings.googleanalytics.trackUrlFragments) { 171 window.onhashchange = function() { 172 $.each(Drupal.settings.googleanalytics.account, function () { 173 gtag('config', this, { 174 page_path: location.pathname + location.search + location.hash 175 }); 176 }); 177 }; 178 } 179 180 // Colorbox: This event triggers when the transition has completed and the 181 // newly loaded content has been revealed. 182 if (Drupal.settings.googleanalytics.trackColorbox) { 183 $(document).bind("cbox_complete", function () {
184 var href = $.colorbox.element().attr("href"); 185 if (href) { 186 $.each(Drupal.settings.googleanalytics.account, function () { 187 gtag('config', this, { 188 page_path: Drupal.googleanalytics.getPageUrl(href) 189 }); 190 }); 191 } 192 }); 193 } 194 195}); 196 197/** 198 * Check whether the hostname is part of the cross domains or not. 199 * 200 * @param string hostname 201 * The hostname of the clicked URL. 202 * @param array crossDomains 203 * All cross domain hostnames as JS array. 204 * 205 * @return boolean 206 */ 207Drupal.googleanalytics.isCrossDomain = function (hostname, crossDomains) { 208 /** 209 * jQuery < 1.6.3 bug: $.inArray crushes IE6 and Chrome if second argument is 210 * `null` or `undefined`, https://bugs.jquery.com/ticket/10076, 211 * https://github.com/jquery/jquery/commit/a839af034db2bd934e4d4fa6758a3fed8de74174 212 * 213 * @todo: Remove/Refactor in D8 214 */ 215 if (!crossDomains) { 216 return false; 217 } 218 else { 219 return $.inArray(hostname, crossDomains) > -1 ? true : false; 220 } 221}; 222 223/** 224 * Check whether this is a download URL or not. 225 * 226 * @param string url 227 * The web url to check. 228 * 229 * @return boolean 230 */ 231Drupal.googleanalytics.isDownload = function (url) { 232 var isDownload = new RegExp("\\.(" + Drupal.settings.googleanalytics.trackDownloadExtensions + ")([\?#].*)?$", "i"); 233 return isDownload.test(url); 234}; 235 236/** 237 * Check whether this is an absolute internal URL or not. 238 * 239 * @param string url 240 * The web url to check. 241 * 242 * @return boolean 243 */ 244Drupal.googleanalytics.isInternal = function (url) { 245 var isInternal = new RegExp("^(https?):\/\/" + window.location.host, "i"); 246 return isInternal.test(url); 247}; 248 249/** 250 * Check whether this is a special URL or not. 251 * 252 * URL types: 253 * - gotwo.module /go/* links. 254 * 255 * @param string url 256 * The web url to check. 257 * 258 * @return boolean 259 */ 260Drupal.googleanalytics.isInternalSpecial = function (url) { 261 var isInternalSpecial = new RegExp("(\/go\/.*)$", "i"); 262 return isInternalSpecial.test(url); 263}; 264 265/** 266 * Extract the relative internal URL from an absolute internal URL. 267 * 268 * Examples: 269 * - https://mydomain.com/node/1 -> /node/1 270 * - https://example.com/foo/bar -> https://example.com/foo/bar 271 * 272 * @param string url 273 * The web url to check. 274 * 275 * @return string 276 * Internal website URL 277 */ 278Drupal.googleanalytics.getPageUrl = function (url) { 279 var extractInternalUrl = new RegExp("^(https?):\/\/" + window.location.host, "i"); 280 return url.replace(extractInternalUrl, ''); 281}; 282 283/** 284 * Extract the download file extension from the URL. 285 * 286 * @param string url 287 * The web url to check. 288 * 289 * @return string 290 * The file extension of the passed url. e.g. "zip", "txt" 291 */ 292Drupal.googleanalytics.getDownloadExtension = function (url) { 293 var extractDownloadextension = new RegExp("\\.(" + Drupal.settings.googleanalytics.trackDownloadExtensions + ")([\?#].*)?$", "i"); 294 var extension = extractDownloadextension.exec(url); 295 return (extension === null) ? '' : extension[1]; 296}; 297 298})(jQuery); 299;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.