(function ($) { Drupal.advanced_forum = Drupal.advanced_forum || {}; Drupal.behaviors.advanced_forum = { attach: function(context) { // Retrieve the collapsed status from a stored cookie. // cookie format is: page1=1,2,3/page2=1,4,5/page3=5,6,1... var cookie = $.cookie('Drupal.advanced_forum.collapsed'); var pages = cookie ? cookie.split('/') : []; // Create associative array where key=page path and value=comma-separated list of collapsed forum ids Drupal.advanced_forum.collapsed_page = []; if (pages) { for (var i = 0; i < pages.length; i++) { var tmp = pages[i].split('='); Drupal.advanced_forum.collapsed_page[tmp[0]] = tmp[1].split(','); } } // Get data for current page Drupal.advanced_forum.collapsed_current = Drupal.advanced_forum.collapsed_page[encodeURIComponent(window.location.pathname)]; if (!Drupal.advanced_forum.collapsed_current) { Drupal.advanced_forum.collapsed_current = []; // For intial load default collapsed state settings needs to checked in init function. Drupal.advanced_forum.initial_load = 1; } else { Drupal.advanced_forum.initial_load = 0; } var handleElement = $('.forum-collapsible', context); // Set initial collapsed state handleElement.once('forum-collapsible', Drupal.advanced_forum.init); handleElement.addClass('clickable').click(function(event) { event.preventDefault(); // Get forum id var id = $(this).attr('id').split('-')[2]; if ( $(this).hasClass('container-collapsed')) { Drupal.advanced_forum.expand(id, Drupal.settings.advanced_forum.effect); // Reset collapsed status Drupal.advanced_forum.collapsed_current.splice($.inArray(id, Drupal.advanced_forum.collapsed_current),1); } else { Drupal.advanced_forum.collapse(id, Drupal.settings.advanced_forum.effect); // Set collapsed status Drupal.advanced_forum.collapsed_current.push(id); } // Put status back Drupal.advanced_forum.collapsed_page[encodeURIComponent(window.location.pathname)] = Drupal.advanced_forum.collapsed_current; // Build cookie string cookie = ''; for (var x in Drupal.advanced_forum.collapsed_page) { cookie += '/' + x + '=' + Drupal.advanced_forum.collapsed_page[x]; } // Save new cookie $.cookie( 'Drupal.advanced_forum.collapsed', cookie.substr(1), { path: '/', // The cookie should "never" expire. expires: 36500 } ); }); } }; /** * Initialize and set collapsible status. * Initial collapsing/expanding effect is set to 'toggle' to avoid flickers. */ Drupal.advanced_forum.init = function() { // get forum id var id = $(this).attr('id').split('-')[2]; // On initial load, deal with default collapsed state of containers. if(Drupal.advanced_forum.initial_load) { var list = 0; for(list in Drupal.settings.advanced_forum.default_collapsed_list) { if (id == list) { Drupal.advanced_forum.collapse(id, 'toggle'); break; } } } else { // Check if item is collapsed if ($.inArray(id, Drupal.advanced_forum.collapsed_current) > -1) { $(this) .addClass('container-collapsed') .parent().addClass('container-collapsed'); Drupal.advanced_forum.collapse(id, 'toggle'); } else { $(this) .removeClass('container-collapsed') .parent().removeClass('container-collapsed'); Drupal.advanced_forum.expand(id, 'toggle'); } } }; Drupal.advanced_forum.collapse = function(id, effect) { switch(effect) { case 'fade': $('#forum-table-' + id).fadeOut('fast'); break; case 'slide': $('#forum-table-' + id).slideUp('fast'); break; default: $('#forum-table-' + id).hide(); } $('#forum-collapsible-' + id) .addClass('container-collapsed') .parent().addClass('container-collapsed'); }; Drupal.advanced_forum.expand = function(id, effect) { switch(effect) { case 'fade': $('#forum-table-' + id).fadeIn('fast'); break; case 'slide': $('#forum-table-' + id).slideDown('fast'); break; default: $('#forum-table-' + id).show(); } $('#forum-collapsible-' + id) .removeClass('container-collapsed') .parent().removeClass('container-collapsed'); }; })(jQuery); ; (function($) { Drupal.behaviors.CToolsJumpMenu = { attach: function(context) { $('.ctools-jump-menu-hide') .once('ctools-jump-menu') .hide(); $('.ctools-jump-menu-change') .once('ctools-jump-menu') .change(function() { var loc = $(this).val(); var urlArray = loc.split('::'); if (urlArray[1]) { location.href = urlArray[1]; } else { location.href = loc; } return false; }); $('.ctools-jump-menu-button') .once('ctools-jump-menu') .click(function() { // Instead of submitting the form, just perform the redirect. // Find our sibling value. var $select = $(this).parents('form').find('.ctools-jump-menu-select'); var loc = $select.val(); var urlArray = loc.split('::'); if (urlArray[1]) { location.href = urlArray[1]; } else { location.href = loc; } return false; }); } } })(jQuery); ; (function ($) { Drupal.googleanalytics = {}; $(document).ready(function() { // Attach mousedown, keyup, touchstart events to document only and catch // clicks on all elements. $(document.body).bind("mousedown keyup touchstart", function(event) { // Catch the closest surrounding link of a clicked element. $(event.target).closest("a,area").each(function() { // Is the clicked URL internal? if (Drupal.googleanalytics.isInternal(this.href)) { // Skip 'click' tracking, if custom tracking events are bound. if ($(this).is('.colorbox') && (Drupal.settings.googleanalytics.trackColorbox)) { // Do nothing here. The custom event will handle all tracking. //console.info("Click on .colorbox item has been detected."); } // Is download tracking activated and the file extension configured for download tracking? else if (Drupal.settings.googleanalytics.trackDownload && Drupal.googleanalytics.isDownload(this.href)) { // Download link clicked. ga("send", { "hitType": "event", "eventCategory": "Downloads", "eventAction": Drupal.googleanalytics.getDownloadExtension(this.href).toUpperCase(), "eventLabel": Drupal.googleanalytics.getPageUrl(this.href), "transport": "beacon" }); } else if (Drupal.googleanalytics.isInternalSpecial(this.href)) { // Keep the internal URL for Google Analytics website overlay intact. ga("send", { "hitType": "pageview", "page": Drupal.googleanalytics.getPageUrl(this.href), "transport": "beacon" }); } } else { if (Drupal.settings.googleanalytics.trackMailto && $(this).is("a[href^='mailto:'],area[href^='mailto:']")) { // Mailto link clicked. ga("send", { "hitType": "event", "eventCategory": "Mails", "eventAction": "Click", "eventLabel": this.href.substring(7), "transport": "beacon" }); } else if (Drupal.settings.googleanalytics.trackOutbound && this.href.match(/^\w+:\/\//i)) { if (Drupal.settings.googleanalytics.trackDomainMode !== 2 || (Drupal.settings.googleanalytics.trackDomainMode === 2 && !Drupal.googleanalytics.isCrossDomain(this.hostname, Drupal.settings.googleanalytics.trackCrossDomains))) { // External link clicked / No top-level cross domain clicked. ga("send", { "hitType": "event", "eventCategory": "Outbound links", "eventAction": "Click", "eventLabel": this.href, "transport": "beacon" }); } } } }); }); // Track hash changes as unique pageviews, if this option has been enabled. if (Drupal.settings.googleanalytics.trackUrlFragments) { window.onhashchange = function() { ga("send", { "hitType": "pageview", "page": location.pathname + location.search + location.hash }); }; } // Colorbox: This event triggers when the transition has completed and the // newly loaded content has been revealed. if (Drupal.settings.googleanalytics.trackColorbox) { $(document).bind("cbox_complete", function () { var href = $.colorbox.element().attr("href"); if (href) { ga("send", { "hitType": "pageview", "page": Drupal.googleanalytics.getPageUrl(href) }); } }); } }); /** * Check whether the hostname is part of the cross domains or not. * * @param string hostname * The hostname of the clicked URL. * @param array crossDomains * All cross domain hostnames as JS array. * * @return boolean */ Drupal.googleanalytics.isCrossDomain = function (hostname, crossDomains) { /** * jQuery < 1.6.3 bug: $.inArray crushes IE6 and Chrome if second argument is * `null` or `undefined`, http://bugs.jquery.com/ticket/10076, * https://github.com/jquery/jquery/commit/a839af034db2bd934e4d4fa6758a3fed8de74174 * * @todo: Remove/Refactor in D8 */ if (!crossDomains) { return false; } else { return $.inArray(hostname, crossDomains) > -1 ? true : false; } }; /** * Check whether this is a download URL or not. * * @param string url * The web url to check. * * @return boolean */ Drupal.googleanalytics.isDownload = function (url) { var isDownload = new RegExp("\\.(" + Drupal.settings.googleanalytics.trackDownloadExtensions + ")([\?#].*)?$", "i"); return isDownload.test(url); }; /** * Check whether this is an absolute internal URL or not. * * @param string url * The web url to check. * * @return boolean */ Drupal.googleanalytics.isInternal = function (url) { var isInternal = new RegExp("^(https?):\/\/" + window.location.host, "i"); return isInternal.test(url); }; /** * Check whether this is a special URL or not. * * URL types: * - gotwo.module /go/* links. * * @param string url * The web url to check. * * @return boolean */ Drupal.googleanalytics.isInternalSpecial = function (url) { var isInternalSpecial = new RegExp("(\/go\/.*)$", "i"); return isInternalSpecial.test(url); }; /** * Extract the relative internal URL from an absolute internal URL. * * Examples: * - http://mydomain.com/node/1 -> /node/1 * - http://example.com/foo/bar -> http://example.com/foo/bar * * @param string url * The web url to check. * * @return string * Internal website URL */ Drupal.googleanalytics.getPageUrl = function (url) { var extractInternalUrl = new RegExp("^(https?):\/\/" + window.location.host, "i"); return url.replace(extractInternalUrl, ''); }; /** * Extract the download file extension from the URL. * * @param string url * The web url to check. * * @return string * The file extension of the passed url. e.g. "zip", "txt" */ Drupal.googleanalytics.getDownloadExtension = function (url) { var extractDownloadextension = new RegExp("\\.(" + Drupal.settings.googleanalytics.trackDownloadExtensions + ")([\?#].*)?$", "i"); var extension = extractDownloadextension.exec(url); return (extension === null) ? '' : extension[1]; }; })(jQuery); ;