1(function ($) { 2 3$(document).ready(function() { 4 5 // Expression to check for absolute internal links. 6 var isInternal = new RegExp("^(https?):\/\/" + window.location.host, "i"); 7 8 // Attach onclick event to document only and catch clicks on all elements. 9 $(document.body).click(function(event) { 10 // Catch the closest surrounding link of a clicked element. 11 $(event.target).closest("a,area").each(function() { 12 13 var ga = Drupal.settings.googleanalytics; 14 // Expression to check for special links like gotwo.module /go/* links. 15 var isInternalSpecial = new RegExp("(\/go\/.*)$", "i"); 16 // Expression to check for download links. 17 var isDownload = new RegExp("\\.(" + ga.trackDownloadExtensions + ")$", "i"); 18 19 // Is the clicked URL internal? 20 if (isInternal.test(this.href)) { 21 // Skip 'click' tracking, if custom tracking events are bound. 22 if ($(this).is('.colorbox')) { 23 // Do nothing here. The custom event will handle all tracking. 24 } 25 // Is download tracking activated and the file extension configured for download tracking? 26 else if (ga.trackDownload && isDownload.test(this.href)) { 27 // Download link clicked. 28 var extension = isDownload.exec(this.href); 29 _gaq.push(["_trackEvent", "Downloads", extension[1].toUpperCase(), this.href.replace(isInternal, '')]); 30 } 31 else if (isInternalSpecial.test(this.href)) { 32 // Keep the internal URL for Google Analytics website overlay intact. 33 _gaq.push(["_trackPageview", this.href.replace(isInternal, '')]); 34 } 35 } 36 else { 37 if (ga.trackMailto && $(this).is("a[href^='mailto:'],area[href^='mailto:']")) { 38 // Mailto link clicked. 39 _gaq.push(["_trackEvent", "Mails", "Click", this.href.substring(7)]); 40 } 41 else if (ga.trackOutbound && this.href.match(/^\w+:\/\//i)) { 42 if (ga.trackDomainMode == 2 && isCrossDomain(this.hostname, ga.trackCrossDomains)) { 43 // Top-level cross domain clicked. document.location is handled by _link internally. 44 event.preventDefault(); 45 _gaq.push(["_link", this.href]); 46 } 47 else { 48 // External link clicked. 49 _gaq.push(["_trackEvent", "Outbound links", "Click", this.href]); 50 } 51 } 52 } 53 }); 54 }); 55 56 // Colorbox: This event triggers when the transition has completed and the 57 // newly loaded content has been revealed. 58 $(document).bind("cbox_complete", function() { 59 var href = $.colorbox.element().attr("href"); 60 if (href) { 61 _gaq.push(["_trackPageview", href.replace(isInternal, '')]); 62 } 63 }); 64 65}); 66 67/** 68 * Check whether the hostname is part of the cross domains or not. 69 * 70 * @param string hostname 71 * The hostname of the clicked URL. 72 * @param array crossDomains 73 * All cross domain hostnames as JS array. 74 * 75 * @return boolean 76 */
77function isCrossDomain(hostname, crossDomains) { 78 /** 79 * jQuery < 1.6.3 bug: $.inArray crushes IE6 and Chrome if second argument is 80 * `null` or `undefined`, http://bugs.jquery.com/ticket/10076, 81 * https://github.com/jquery/jquery/commit/a839af034db2bd934e4d4fa6758a3fed8de74174 82 * 83 * @todo: Remove/Refactor in D8 84 */ 85 if (!crossDomains) { 86 return false; 87 } 88 else { 89 return $.inArray(hostname, crossDomains) > -1 ? true : false; 90 } 91} 92 93})(jQuery);
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.