(function ($) { Drupal.settings.views = Drupal.settings.views || {'ajax_path': '/views/ajax'}; Drupal.quicktabs = Drupal.quicktabs || {}; Drupal.quicktabs.getQTName = function (el) { return el.id.substring(el.id.indexOf('-') +1); } Drupal.behaviors.quicktabs = { attach: function (context, settings) { $.extend(true, Drupal.settings, settings); $('.quicktabs-wrapper', context).once(function(){ Drupal.quicktabs.prepare(this); }); } } // Setting up the inital behaviours Drupal.quicktabs.prepare = function(el) { // el.id format: "quicktabs-$name" var qt_name = Drupal.quicktabs.getQTName(el); var $ul = $(el).find('ul.quicktabs-tabs:first'); $("ul.quicktabs-tabs li a span#active-quicktabs-tab").remove(); $ul.find('li a').each(function(i, element){ element.myTabIndex = i; element.qt_name = qt_name; var tab = new Drupal.quicktabs.tab(element); var parent_li = $(element).parents('li').get(0); if ($(parent_li).hasClass('active')) { $(element).addClass('quicktabs-loaded'); $(element).append('' + Drupal.t('(active tab)') + ''); } $(element).once(function() {$(this).bind('click', {tab: tab}, Drupal.quicktabs.clickHandler);}); }); } Drupal.quicktabs.clickHandler = function(event) { var tab = event.data.tab; var element = this; // Set clicked tab to active. $(this).parents('li').siblings().removeClass('active'); $(this).parents('li').addClass('active'); $("ul.quicktabs-tabs li a span#active-quicktabs-tab").remove(); $(this).append('' + Drupal.t('(active tab)') + ''); // Hide all tabpages. tab.container.children().addClass('quicktabs-hide'); if (!tab.tabpage.hasClass("quicktabs-tabpage")) { tab = new Drupal.quicktabs.tab(element); } tab.tabpage.removeClass('quicktabs-hide'); $(element).trigger('switchtab'); return false; } // Constructor for an individual tab Drupal.quicktabs.tab = function (el) { this.element = el; this.tabIndex = el.myTabIndex; var qtKey = 'qt_' + el.qt_name; var i = 0; for (var key in Drupal.settings.quicktabs[qtKey].tabs) { if (i == this.tabIndex) { this.tabObj = Drupal.settings.quicktabs[qtKey].tabs[key]; this.tabKey = key; } i++; } this.tabpage_id = 'quicktabs-tabpage-' + el.qt_name + '-' + this.tabKey; this.container = $('#quicktabs-container-' + el.qt_name); this.tabpage = this.container.find('#' + this.tabpage_id); } if (Drupal.ajax) { /** * Handle an event that triggers an AJAX response. * * We unfortunately need to override this function, which originally comes from * misc/ajax.js, in order to be able to cache loaded tabs, i.e. once a tab * content has loaded it should not need to be loaded again. * * I have removed all comments that were in the original core function, so that * the only comments inside this function relate to the Quicktabs modification * of it. */ Drupal.ajax.prototype.eventResponse = function (element, event) { var ajax = this; if (ajax.ajaxing) { return false; } try { if (ajax.form) { if (ajax.setClick) { element.form.clk = element; } ajax.form.ajaxSubmit(ajax.options); } else { // Do not perform an ajax request for already loaded Quicktabs content. if (!$(element).hasClass('quicktabs-loaded')) { ajax.beforeSerialize(ajax.element, ajax.options); $.ajax(ajax.options); if ($(element).parents('ul').hasClass('quicktabs-tabs')) { $(element).addClass('quicktabs-loaded'); } } } } catch (e) { ajax.ajaxing = false; alert("An error occurred while attempting to process " + ajax.options.url + ": " + e.message); } return false; }; } })(jQuery); ; Drupal.TBMegaMenu = Drupal.TBMegaMenu || {}; (function ($) { Drupal.TBMegaMenu.oldWindowWidth = 0; Drupal.TBMegaMenu.displayedMenuMobile = false; Drupal.TBMegaMenu.supportedScreens = [980]; Drupal.TBMegaMenu.menuResponsive = function () { var windowWidth = window.innerWidth ? window.innerWidth : $(window).width(); var navCollapse = $('.tb-megamenu').children('.nav-collapse'); if (windowWidth < Drupal.TBMegaMenu.supportedScreens[0]) { navCollapse.addClass('collapse'); if (Drupal.TBMegaMenu.displayedMenuMobile) { navCollapse.css({height: 'auto', overflow: 'visible'}); } else { navCollapse.css({height: 0, overflow: 'hidden'}); } } else { // If width of window is greater than 980 (supported screen). navCollapse.removeClass('collapse'); if (navCollapse.height() <= 0) { navCollapse.css({height: 'auto', overflow: 'visible'}); } } }; Drupal.behaviors.tbMegaMenuAction = { attach: function(context) { $('.tb-megamenu-button', context).once('menuIstance', function () { var This = this; $(This).click(function() { if(parseInt($(this).parent().children('.nav-collapse').height())) { $(this).parent().children('.nav-collapse').css({height: 0, overflow: 'hidden'}); Drupal.TBMegaMenu.displayedMenuMobile = false; } else { $(this).parent().children('.nav-collapse').css({height: 'auto', overflow: 'visible'}); Drupal.TBMegaMenu.displayedMenuMobile = true; } }); }); var isTouch = 'ontouchstart' in window && !(/hp-tablet/gi).test(navigator.appVersion); if(!isTouch){ $(document).ready(function($){ var mm_duration = 0; $('.tb-megamenu').each (function(){ if ($(this).data('duration')) { mm_duration = $(this).data('duration'); } }); var mm_timeout = mm_duration ? 100 + mm_duration : 500; $('.nav > li, li.mega').hover(function(event) { var $this = $(this); if ($this.hasClass ('mega')) { $this.addClass ('animating'); clearTimeout ($this.data('animatingTimeout')); $this.data('animatingTimeout', setTimeout(function(){$this.removeClass ('animating')}, mm_timeout)); clearTimeout ($this.data('hoverTimeout')); $this.data('hoverTimeout', setTimeout(function(){$this.addClass ('open')}, 100)); } else { clearTimeout ($this.data('hoverTimeout')); $this.data('hoverTimeout', setTimeout(function(){$this.addClass ('open')}, 100)); } }, function(event) { var $this = $(this); if ($this.hasClass ('mega')) { $this.addClass ('animating'); clearTimeout ($this.data('animatingTimeout')); $this.data('animatingTimeout', setTimeout(function(){$this.removeClass ('animating')}, mm_timeout)); clearTimeout ($this.data('hoverTimeout')); $this.data('hoverTimeout', setTimeout(function(){$this.removeClass ('open')}, 100)); } else { clearTimeout ($this.data('hoverTimeout')); $this.data('hoverTimeout', setTimeout(function(){$this.removeClass ('open')}, 100)); } }); }); } $(window).resize(function() { var windowWidth = window.innerWidth ? window.innerWidth : $(window).width(); if(windowWidth != Drupal.TBMegaMenu.oldWindowWidth){ Drupal.TBMegaMenu.oldWindowWidth = windowWidth; Drupal.TBMegaMenu.menuResponsive(); } }); }, } })(jQuery); ; Drupal.TBMegaMenu = Drupal.TBMegaMenu || {}; (function ($) { Drupal.TBMegaMenu.createTouchMenu = function(items) { items.children('a').each( function() { var $item = $(this); var tbitem = $(this).parent(); $item.click( function(event){ if ($item.hasClass('tb-megamenu-clicked')) { var $uri = $item.attr('href'); window.location.href = $uri; } else { event.preventDefault(); $item.addClass('tb-megamenu-clicked'); if(!tbitem.hasClass('open')){ tbitem.addClass('open'); } } }).closest('li').mouseleave( function(){ $item.removeClass('tb-megamenu-clicked'); tbitem.removeClass('open'); }); }); /* items.children('a').children('span.caret').each( function() { var $item = $(this).parent(); $item.click(function(event){ tbitem = $item.parent(); if ($item.hasClass('tb-megamenu-clicked')) { Drupal.TBMegaMenu.eventStopPropagation(event); if(tbitem.hasClass('open')){ tbitem.removeClass('open'); $item.removeClass('tb-megamenu-clicked'); } } else { Drupal.TBMegaMenu.eventStopPropagation(event); $item.addClass('tb-megamenu-clicked'); if(!tbitem.hasClass('open')){ tbitem.addClass('open'); $item.removeClass('tb-megamenu-clicked'); } } }); }); */ } Drupal.TBMegaMenu.eventStopPropagation = function(event) { if (event.stopPropagation) { event.stopPropagation(); } else if (window.event) { window.event.cancelBubble = true; } } Drupal.behaviors.tbMegaMenuTouchAction = { attach: function(context) { var isTouch = 'ontouchstart' in window && !(/hp-tablet/gi).test(navigator.appVersion); if(isTouch){ $('html').addClass('touch'); Drupal.TBMegaMenu.createTouchMenu($('.tb-megamenu ul.nav li.mega').has('.dropdown-menu')); } } } })(jQuery); ;