1 2$(document).ready(function() { 3 4 // Expression to check for absolute internal links. 5 var isInternal = new RegExp("^(https?):\/\/" + window.location.host, "i"); 6 7 // Attach onclick event to document only and catch clicks on all elements. 8 $(document.body).click(function(event) { 9 // Catch only the first parent link of a clicked element. 10 $(event.target).parents("a:first,area:first").andSelf().filter("a,area").each(function() { 11 12 var ga = Drupal.settings.googleanalytics; 13 // Expression to check for special links like gotwo.module /go/* links. 14 var isInternalSpecial = new RegExp("(\/go\/.*)$", "i"); 15 // Expression to check for download links. 16 var isDownload = new RegExp("\\.(" + ga.trackDownloadExtensions + ")$", "i"); 17 18 // Is the clicked URL internal? 19 if (isInternal.test(this.href)) { 20 // Skip 'click' tracking, if custom tracking events are bound. 21 if ($(this).is('.colorbox')) { 22 // Do nothing here. The custom event will handle all tracking. 23 } 24 // Is download tracking activated and the file extension configured for download tracking? 25 else if (ga.trackDownload && isDownload.test(this.href)) { 26 // Download link clicked. 27 var extension = isDownload.exec(this.href); 28 _gaq.push(["_trackEvent", "Downloads", extension[1].toUpperCase(), this.href.replace(isInternal, '')]); 29 } 30 else if (isInternalSpecial.test(this.href)) { 31 // Keep the internal URL for Google Analytics website overlay intact. 32 _gaq.push(["_trackPageview", this.href.replace(isInternal, '')]); 33 } 34 } 35 else { 36 if (ga.trackMailto && $(this).is("a[href^='mailto:'],area[href^='mailto:']")) { 37 // Mailto link clicked. 38 _gaq.push(["_trackEvent", "Mails", "Click", this.href.substring(7)]); 39 } 40 else if (ga.trackOutbound && this.href.match(/^\w+:\/\//i)) { 41 // External link clicked. 42 _gaq.push(["_trackEvent", "Outbound links", "Click", this.href]); 43 } 44 } 45 }); 46 }); 47 48 // Colorbox: This event triggers when the transition has completed and the 49 // newly loaded content has been revealed. 50 $(document).bind("cbox_complete", function() { 51 var href = $.colorbox.element().attr("href"); 52 if (href) { 53 _gaq.push(["_trackPageview", href.replace(isInternal, '')]); 54 } 55 }); 56 57});
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.