; (function (b, c) { var $ = b.jQuery || b.Cowboy || (b.Cowboy = {}), a; $.throttle = a = function (e, f, j, i) { var h, d = 0; if (typeof f !== "boolean") { i = j; j = f; f = c } function g() { var o = this, m = +new Date() - d, n = arguments; function l() { d = +new Date(); j.apply(o, n) } function k() { h = c } if (i && !h) { l() } h && clearTimeout(h); if (i === c && m > e) { l() } else { if (f !== true) { h = setTimeout(i ? k : l, i === c ? e - m : e) } } } if ($.guid) { g.guid = j.guid = j.guid || $.guid++ } return g }; $.debounce = function (d, e, f) { return f === c ? a(d, e, false) : a(d, f, e !== false) } })(this); (function ($) { 'use strict'; function transitionEnd() { var el = document.createElement('quadmenu') var transEndEventNames = { WebkitTransition: 'webkitTransitionEnd', MozTransition: 'transitionend', OTransition: 'oTransitionEnd otransitionend', transition: 'transitionend' } for (var name in transEndEventNames) { if (el.style[name] !== undefined) { return {end: transEndEventNames[name]} } } return false // explicit for ie8 ( ._.) } $.fn.emulateTransitionEnd = function (duration) { var called = false var $el = this $(this).one('quadmenuTransitionEnd', function () { called = true }) var callback = function () { if (!called) $($el).trigger($.support.transition.end) } setTimeout(callback, duration) return this } $(function () { $.support.transition = transitionEnd() if (!$.support.transition) return $.event.special.quadmenuTransitionEnd = { bindType: $.support.transition.end, delegateType: $.support.transition.end, handle: function (e) { if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments) } } }) var QuadMenuCollapse = function (element, options) { this.$element = $(element) this.options = $.extend({}, QuadMenuCollapse.DEFAULTS, options) this.$trigger = $('[data-quadmenu="collapse"][href="#' + element.id + '"],' + '[data-quadmenu="collapse"][data-target="#' + element.id + '"]') this.transitioning = null if (this.options.parent) { this.$parent = this.getParent() } else { this.addAriaAndQuadMenuCollapsedClass(this.$element, this.$trigger) } if (this.options.toggle) this.toggle() } QuadMenuCollapse.TRANSITION_DURATION = 350 QuadMenuCollapse.DEFAULTS = { toggle: true } QuadMenuCollapse.prototype.dimension = function () { var hasWidth = this.$element.hasClass('width') return hasWidth ? 'width' : 'height' } QuadMenuCollapse.prototype.show = function () { if (this.transitioning || this.$element.hasClass('in')) return var activesData var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing') if (actives && actives.length) { activesData = actives.data('quadmenu.collapse') if (activesData && activesData.transitioning) return } var startEvent = $.Event('show.quadmenu.collapse') this.$element.trigger(startEvent) if (startEvent.isDefaultPrevented()) return if (actives && actives.length) { Plugin.call(actives, 'hide') activesData || actives.data('quadmenu.collapse', null) } var dimension = this.dimension() this.$element .removeClass('collapse') .addClass('collapsing')[dimension](0) .attr('aria-expanded', true) this.$trigger .removeClass('collapsed') .attr('aria-expanded', true) this.transitioning = 1 var complete = function () { this.$element .removeClass('collapsing') .addClass('collapse in')[dimension]('') this.transitioning = 0 this.$element .trigger('shown.quadmenu.collapse') } if (!$.support.transition) return complete.call(this) var scrollSize = $.camelCase(['scroll', dimension].join('-')) this.$element .one('quadmenuTransitionEnd', $.proxy(complete, this)) .emulateTransitionEnd(QuadMenuCollapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize]) } QuadMenuCollapse.prototype.hide = function () { if (this.transitioning || !this.$element.hasClass('in')) return var startEvent = $.Event('hide.quadmenu.collapse') this.$element.trigger(startEvent) if (startEvent.isDefaultPrevented()) return var dimension = this.dimension() this.$element[dimension](this.$element[dimension]())[0].offsetHeight this.$element .addClass('collapsing') .removeClass('collapse in') .attr('aria-expanded', false) this.$trigger .addClass('collapsed') .attr('aria-expanded', false) this.transitioning = 1 var complete = function () { this.transitioning = 0 this.$element .removeClass('collapsing') .addClass('collapse') .trigger('hidden.quadmenu.collapse') } if (!$.support.transition) return complete.call(this) this.$element [dimension](0) .one('quadmenuTransitionEnd', $.proxy(complete, this)) .emulateTransitionEnd(QuadMenuCollapse.TRANSITION_DURATION) } QuadMenuCollapse.prototype.toggle = function () { this[this.$element.hasClass('in') ? 'hide' : 'show']() } QuadMenuCollapse.prototype.getParent = function () { return $(this.options.parent) .find('[data-quadmenu="collapse"][data-parent="' + this.options.parent + '"]') .each($.proxy(function (i, element) { var $element = $(element) this.addAriaAndQuadMenuCollapsedClass(getTargetFromTrigger($element), $element) }, this)) .end() } QuadMenuCollapse.prototype.addAriaAndQuadMenuCollapsedClass = function ($element, $trigger) { var isOpen = $element.hasClass('in') $element.attr('aria-expanded', isOpen) $trigger .toggleClass('collapsed', !isOpen) .attr('aria-expanded', isOpen) } function getTargetFromTrigger($trigger) { var href var target = $trigger.attr('data-target') || (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7 return $(target) } // COLLAPSE PLUGIN DEFINITION // ========================== function Plugin(option) { return this.each(function () { var $this = $(this) var data = $this.data('quadmenu.collapse') var options = $.extend({}, QuadMenuCollapse.DEFAULTS, $this.data(), typeof option == 'object' && option) if (!data && options.toggle && /show|hide/.test(option)) options.toggle = false if (!data) $this.data('quadmenu.collapse', (data = new QuadMenuCollapse(this, options))) if (typeof option == 'string') data[option]() }) } var old = $.fn.collapse $.fn.collapse = Plugin $.fn.collapse.Constructor = QuadMenuCollapse // COLLAPSE NO CONFLICT // ==================== $.fn.collapse.noConflict = function () { $.fn.collapse = old return this } // COLLAPSE DATA-API // ================= $(document).on('click.quadmenu.collapse.data-api', '[data-quadmenu="collapse"]', function (e) { var $this = $(this) if (!$this.attr('data-target')) e.preventDefault() var $target = getTargetFromTrigger($this) var data = $target.data('quadmenu.collapse') var option = data ? 'toggle' : $this.data() Plugin.call($target, option) }) }(jQuery)); (function ($, window, document, undefined) { 'use strict'; var defaults = { responsive: true, containerGutter: parseInt(quadmenu.gutter), touchEvents: true, mouseEvents: true, moveThreshold: 50, //intent_sensitivity: 15, intent_timeout: 300, intent_interval: 30, }; function Plugin(element, options) { var plugin = this; this.element = element; this.$quadmenu = $(this.element); this.$ul = this.$quadmenu.find('ul.quadmenu-navbar-nav'); this.settings = $.extend({}, defaults, options); this.touchenabled = ('ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0); this.mobiledevice = (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)); this.perfectScrollbar = (typeof $.fn.perfectScrollbar !== 'undefined' && !this.mobiledevice) ? true : false; if (this.touchenabled) { this.$quadmenu.addClass('quadmenu-touch'); } else { this.$quadmenu.addClass('quadmenu-notouch'); } if (window.navigator.pointerEnabled) { this.touchStart = 'pointerdown'; this.touchEnd = 'pointerup'; this.touchMove = 'pointermove'; } else if (window.navigator.msPointerEnabled) { this.touchStart = 'MSPointerDown'; this.touchEnd = 'MSPointerUp'; this.touchMove = 'MSPointerMove'; } else { this.touchStart = 'touchstart'; this.touchEnd = 'touchend'; this.touchMove = 'touchmove'; } this.init(); } Plugin.prototype = { init: function () { this.quadmenuResolveConflics(); this.quadmenuInitClasses(); this.quadmenuInitWidth(); this.quadmenuInitContainerWidth(); this.quadmenuInitLazyLoad(); //this.quadmenuInitNavbarVertical(); this.quadmenuInitNavbarSticky(); // horizontal this.quadmenuInitNavbarOffcanvas(); this.quadmenuInitNavbarSlideBar(); // horizontal this.quadmenuInitItemTabs(); // horizontal this.quadmenuInitItemCarousel(); this.quadmenuInitItemLogIn(); this.quadmenuInitItemSocial(); this.quadmenuInitItemCart(); this.quadmenuInitItemWidgets(); this.quadmenuInitDropdownFloat(); // horizontal this.quadmenuInitDropdownMaxHeight(); // horizontal this.quadmenuInitDropdownTouchEvents(); this.quadmenuInitDropdownMouseEvents(); this.quadmenuInitDropdownRetractors(); this.quadmenuInitDropdownCloseAll(); // horizontal this.quadmenuInitScrollBar(); // horizontal this.quadmenuInit(); }, quadmenuInit: function () { this.$quadmenu.trigger('init.quadmenu'); }, quadmenuResolveConflics: function () { if (this.$quadmenu.data('unwrap')) { this.$quadmenu.unwrap('nav').find('.quadmenu-item, .quadmenu-dropdown-toggle, .quadmenu-dropdown-menu, .quadmenu-dropdown-submenu').add(this.$quadmenu).removeAttr('style').unbind().off(); } }, quadmenuInitClasses: function (plugin) { plugin = plugin || this; plugin.handleClasses(); $(window).resize($.debounce(300, function () { plugin.handleClasses(); })); }, handleClasses: function () { var template = this.$quadmenu.data('template'), mobile = this.settings.responsive && (window.innerWidth <= this.$quadmenu.data('breakpoint')) ? true : false; if (!mobile && template == 'collapse') { this.$quadmenu.addClass('quadmenu-is-horizontal'); } if (!mobile && template == 'embed') { this.$quadmenu.addClass('quadmenu-is-horizontal'); } if (!mobile && template == 'offcanvas') { this.$quadmenu.addClass('quadmenu-is-horizontal'); } if (mobile) { this.$quadmenu.removeClass('quadmenu-is-horizontal'); } this.$quadmenu.removeClass('no-js').addClass('js'); }, quadmenuInitDropdownTouchEvents: function (plugin) { plugin = plugin || this; if (!this.settings.touchEvents) return; this.$ul.on(this.touchStart + '.quadmenu.toggle', '.quadmenu-dropdown > .quadmenu-dropdown-toggle', function (e) { plugin.handleTouchEvents(e, this, plugin); }); this.$ul.on('click', '.quadmenu-dropdown > .quadmenu-dropdown-toggle', function (e) { plugin.handleClicks(e, this); }); }, quadmenuInitDropdownMouseEvents: function (plugin) { plugin = plugin || this; plugin.handleDropdownMouseEvents(); $(window).resize($.debounce(600, function () { plugin.handleDropdownMouseEvents(); })); }, handleDropdownMouseEvents: function (plugin) { plugin = plugin || this; this.$ul.find('.quadmenu-item').off('mouseleave.hoverIntent mouseenter.hoverIntent mousemove.hoverIntent'); this.$ul.find('.quadmenu-item').removeProp('hoverIntent_t'); this.$ul.find('.quadmenu-item').removeProp('hoverIntent_s'); if (!this.settings.mouseEvents) return; this.$ul.on('click', '.quadmenu-item > .quadmenu-dropdown-toggle', function (e) { plugin.handleLink(e, this); }); this.$ul.on('click.quadmenu.toggle', '.quadmenu-item > .quadmenu-dropdown-toggle', function (e) { plugin.handleMouseClick(e, this, plugin); }); if (!this.$quadmenu.hasClass('quadmenu-is-horizontal') || typeof $.fn.hoverIntent === 'undefined') return; plugin.handleMouseHover(this.$ul.find('.quadmenu-item > .quadmenu-dropdown-toggle.hoverintent'), plugin); }, handleMouseHover: function (target, plugin) { var $target = $(target), $li = $target.parent('.quadmenu-item'); $target.off('click.quadmenu.toggle'); $target.off(this.touchStart + '.quadmenu.toggle'); if (!$li.length) return; $li.hoverIntent({ over: function () { var $li = $(this), $target = $li.find('> .quadmenu-dropdown-menu'); if ($target.data('quadmenu-killHover')) return; plugin.triggerSubmenu($li, plugin); }, out: function () { var $li = $(this), $target = $li.find('> .quadmenu-dropdown-menu'); if ($target.data('quadmenu-killHover')) return; if ($li.hasClass('quadmenu-item-type-tab')) return; plugin.closeSubmenu($li); }, //sensitivity: plugin.settings.intent_sensitivity, timeout: plugin.settings.intent_timeout, interval: plugin.settings.intent_interval }); }, quadmenuInitDropdownRetractors: function (plugin) { plugin = plugin || this; this.$ul.on('click.retractor', '.quadmenu-item.quadmenu-dropdown.open > .quadmenu-dropdown-toggle > .quadmenu-item-content > .quadmenu-caret', function (e) { plugin.handleDropdownCloseEnd(e, this, plugin); }); // we dont need to off this evet on window resize because touch events hare handled by the browser if (!this.settings.touchEvents) return; this.$ul.on(this.touchStart + '.retractor', '.quadmenu-item.quadmenu-dropdown.open > .quadmenu-dropdown-toggle > .quadmenu-item-content > .quadmenu-caret', function (e) { plugin.handleDropdownCloseStart(e, this, plugin); }); }, handleTouchEvents: function (e, target, plugin) { var $target = $(target); //disable hoverintent on touch devices //$li.off('mouseleave.hoverIntent'); $target.on(plugin.touchEnd, function (e) { plugin.handleTouchTap(e, this, plugin); }); $target.on(plugin.touchMove, function (e) { plugin.preventTapOnScroll(e, this, plugin); }); if (e.originalEvent !== undefined) { if (e.originalEvent.touches) { $target.data('quadmenu-startX', e.originalEvent.touches[0].clientX); $target.data('quadmenu-startY', e.originalEvent.touches[0].clientY); } //microsoft else if (e.originalEvent.clientY) { var pos = $target.offset(); $target.data('quadmenu-startX', e.originalEvent.clientX); $target.data('quadmenu-startY', e.originalEvent.clientY); } } }, preventTapOnScroll: function (e, target, plugin) { var $target = $(target); if (e.originalEvent !== undefined) { //make sure the touch points aren't too close, if so, then remove the event handlers if (e.originalEvent.touches) { if (Math.abs(e.originalEvent.touches[0].clientX - $target.data('quadmenu-startX')) > plugin.settings.moveThreshold || Math.abs(e.originalEvent.touches[0].clientY - $target.data('quadmenu-startY')) > plugin.settings.moveThreshold) { plugin.resetHandlers($target); } } else if (e.originalEvent.clientY) { var pos = $target.data(pos); if (Math.abs(e.originalEvent.clientX - $target.data('quadmenu-startX')) > plugin.settings.moveThreshold || Math.abs(e.originalEvent.clientY - $target.data('quadmenu-startY')) > plugin.settings.moveThreshold) { plugin.resetHandlers($target); } } } }, handleTouchTap: function (e, target, plugin) { e.preventDefault(); var $target = $(target), $li = $target.parent(); //prevent clicks $target.data('quadmenu-killClick', true); //prevent hover $target.data('quadmenu-killHover', true); setTimeout(function () { $target.data('quadmenu-killClick', false).data('quadmenu-killHover', false); }, 1000); //close other submenus if (this.$quadmenu.hasClass('quadmenu-is-horizontal')) { plugin.closeSubmenu($li.siblings('.open')); } if ($li.hasClass('quadmenu-dropdown')) { //if submenu is already open then close it if ($li.hasClass('open')) { //please don't close tabs if (!$li.hasClass('quadmenu-item-type-tab') || !this.$quadmenu.hasClass('quadmenu-is-horizontal')) { plugin.closeSubmenu($li); } //allow link to be followed plugin.handleLink(e, target, true); } //if submenu is closed then open the submenu and prevent link from being followed else { plugin.openSubmenu($li); } } //allow links whitout submenus to be followed else { plugin.handleLink(e, target, true); } plugin.resetHandlers($target); }, handleLink: function (e, link, follow) { follow = follow || false; var $link = $(link), href = $link.attr('href'); if (!$link.is('a')) return; if (!href) { e.preventDefault(); return; } if (!follow || !e.isDefaultPrevented()) return; //handle links after preventDefault if ($link.attr('target') === '_blank') { window.open(href, '_blank'); } else { window.location = href; } }, handleMouseClick: function (e, target, plugin) { var $target = $(target), $li = $target.parent('.quadmenu-item'); if ($target.data('quadmenu-killClick') || !$li.length) return; //disable hoverintent on click, just in case //$li.off('mousemove.hoverIntent'); //$li.off('mouseenter.hoverIntent'); //$li.off('mouseleave.hoverIntent'); if ($li.hasClass('open')) { if ($target.is('a')) { plugin.handleLink(e, target); } } else if ($li.hasClass('quadmenu-dropdown')) { e.preventDefault(); //close other submenus if (this.$quadmenu.hasClass('quadmenu-is-horizontal')) { plugin.closeSubmenu($li.siblings('.open')); } plugin.openSubmenu($li); } }, handleDropdownCloseStart: function (e, caret, plugin) { e.preventDefault(); //e.stopPropagation(); // prevent envent on url $(caret).on(plugin.touchEnd, function (e) { plugin.handleDropdownCloseEnd(e, this, plugin); }); }, handleDropdownCloseEnd: function (e, caret, plugin) { e.preventDefault(); e.stopPropagation(); // prevent envent on url var $li = $(caret).closest('.quadmenu-dropdown.open'); plugin.closeSubmenu($li); $(caret).off(plugin.touchEnd); return false; }, resetHandlers: function ($target) { $target.off(this.touchEnd); $target.off(this.touchMove); var $li = $target.parent(); //1326 error en touch se desactiva hoverintent definitvamente $li.off('mousemove.hoverIntent'); $li.off('mouseenter.hoverIntent'); $li.off('mouseleave.hoverIntent'); $li.removeProp('hoverIntent_t'); $li.removeProp('hoverIntent_s'); }, triggerSubmenu: function ($li, plugin) { plugin.closeSubmenu($li.siblings('.open')); plugin.openSubmenu($li); }, openSubmenu: function ($li, timeout) { if ($li.hasClass('open')) return; timeout = timeout || 100; $li.trigger('show.quadmenu.dropdown'); $li.addClass('opening'); setTimeout(function () { $li.addClass('open'); $li.removeClass('opening'); $li.trigger('shown.quadmenu.dropdown'); }, timeout); }, closeSubmenu: function ($li, timeout) { if (!$li.hasClass('open')) return; timeout = timeout || 200; $li.trigger('hide.quadmenu.dropdown'); $li.addClass('closing'); setTimeout(function () { $li.find('.quadmenu-item').removeClass('open'); $li.removeClass('open').removeClass('closing'); $li.trigger('hidden.quadmenu.dropdown'); }, timeout); }, handleClicks: function (e, target) { var $target = $(target); if ($target.data('quadmenu-killClick')) { e.preventDefault(); } }, quadmenuInitDropdownCloseAll: function (plugin) { plugin = plugin || this; /* * resize is calling in mobile touch taps and closing all menus * $(window).resize($.debounce(300, function () { plugin.closeAllSubmenus(); }));*/ if (!this.$quadmenu.hasClass('quadmenu-is-horizontal')) return; $(document).on(this.touchEnd + '.hidden.quadmenu.dropdown.all click.hidden.quadmenu.dropdown.all', function (e) { if ($(e.target).closest('#quadmenu').length) return; plugin.closeAllSubmenus(); }); }, closeAllSubmenus: function () { var $li = this.$ul.find('.quadmenu-item.open'); if (!$li.length) return; this.closeSubmenu($li, 100); //this.trigger('hidden.quadmenu.dropdown.all'); return; }, quadmenuInitDropdownMaxHeight: function (plugin) { plugin = plugin || this; this.$ul.off('shown.quadmenu.dropdown.height'); if (!this.$quadmenu.hasClass('quadmenu-is-horizontal')) return; this.$ul.on('shown.quadmenu.dropdown.height', '.dropdown-maxheight', function (e) { plugin.handleDropdownMaxHeight($(this)); }); this.$ul.on('shown.quadmenu.dropdown.tabheight', '.dropdown-maxheight.quadmenu-item-type-tab', function (e) { plugin.handleTabsHeight($(this)); }); $(window).resize($.debounce(300, function () { plugin.$ul.find('.dropdown-maxheight > .quadmenu-dropdown-menu > ul').css({'height': '', 'overflow-y': ''}).removeData('quadmenu-dropdownHeight').removeData('quadmenu-maxHeight'); })); }, handleDropdownMaxHeight: function (li, minHeight) { if (typeof $.fn.scrollTop === 'undefined') return; minHeight = minHeight || 200; var $li = $(li), $dropdown = $li.find('> .quadmenu-dropdown-menu > ul'); if (!$dropdown.length) return; var dropdownHeight = $dropdown.removeAttr('style').outerHeight(), offsetTop = this.getElementOffset($dropdown), scrollTop = $(window).scrollTop(), currentTop = Math.max(0, offsetTop - scrollTop), currentBottom = $(window).height() - currentTop - 15, maxHeight = Math.min(dropdownHeight, currentBottom), Height = parseInt(Math.max(maxHeight, minHeight)); $dropdown.css({'height': Height + 'px', 'overflow-y': 'auto'}).data('quadmenu-maxHeight', Height); return Height; }, //quadmenuInitItemActive: function () { // this.$ul.find('.current-menu-item:not(.quadmenu-item-type-tab)').addClass('active').first().parents('.quadmenu-item:not(.quadmenu-item-type-tab)').addClass('active'); //}, quadmenuInitNavbarSticky: function () { var plugin = this; if (typeof $.fn.scrollTop === 'undefined') return; if (!this.$quadmenu.hasClass('quadmenu-is-horizontal')) return; plugin.$sticky = this.$quadmenu.filter('[data-sticky="1"]').first(); if (!plugin.$sticky.length) return; plugin.is_sticky = false; $(window).on('load', function () { var topLast = 0; plugin.sticky_height = plugin.$sticky.height(); plugin.adminbar_height = $('#wpadminbar').height() || 0; plugin.sticky_offset = plugin.$sticky.offset().top; plugin.topYSticky = Math.max(plugin.$sticky.offset().top - plugin.adminbar_height, plugin.$sticky.data('sticky-offset'), plugin.sticky_height + plugin.adminbar_height); if (plugin.topYSticky > plugin.sticky_offset) { plugin.$sticky.addClass('quadmenu-sticky-animation'); } $(window).on('scroll', function () { var topY = $(this).scrollTop(); if (plugin.is_sticky && (topY < (plugin.topYSticky))) { plugin.handleUnSticky(); } if (!plugin.is_sticky && (topY > (plugin.topYSticky))) { plugin.handleSticky(); } topLast = topY; }); }); }, handleSticky: function () { var plugin = this; plugin.is_sticky = true; var placeholder = $('
').addClass('quadmenu-sticky-wrapper').css({ 'height': plugin.sticky_height + 'px', 'position': 'static' }); plugin.$sticky.find('.quadmenu-navbar-collapse.collapse.in').collapse('hide'); plugin.$sticky.toggleClass('quadmenu-sticky-top').wrap(placeholder); plugin.$sticky.trigger('sticking.quadmenu.navbar'); //setTimeout(function () { plugin.$sticky.trigger('sticky.quadmenu.navbar'); //}, 200); }, handleUnSticking: function () { var plugin = this; plugin.is_sticky = false; plugin.$sticky.addClass('quadmenu-unsticking-top'); }, handleUnSticky: function () { var plugin = this; plugin.is_sticky = false; plugin.$sticky.trigger('unsticking.quadmenu.navbar'); //plugin.$sticky.addClass('quadmenu-unsticking-top'); setTimeout(function () { //plugin.$sticky.removeClass('quadmenu-unsticking-top'); }, 200); plugin.$sticky.removeClass('quadmenu-sticky-top'); plugin.$sticky.unwrap(); plugin.$sticky.trigger('unsticky.quadmenu.navbar'); }, quadmenuInitDropdownFloat: function (plugin) { plugin = plugin || this; plugin.handleDropdownFloat(); $(window).resize($.debounce(600, function () { plugin.handleDropdownFloat(); })); }, handleDropdownFloat: function (plugin) { plugin = plugin || this; this.$ul.off('shown.quadmenu.dropdown.float'); if (!this.$quadmenu.hasClass('quadmenu-is-horizontal')) return; this.$ul.on('shown.quadmenu.dropdown.float', '.quadmenu-item.quadmenu-dropdown:not(.quadmenu-item-type-tab):not(.quadmenu-item-type-tabs)', function (e) { var $dropdown = $(this).find('> .quadmenu-dropdown-menu:not(.quadmenu-dropdown-stretch-content):not(.quadmenu-dropdown-stretch-dropdown)'); if (!$dropdown.length) return; var elH = $dropdown.outerWidth(), W = $(window).innerWidth(), p = $dropdown.offset(), l = p.left, r = parseInt(W - (l + elH)); if ($(this).hasClass('quadmenu-dropdown-left') && l < 0) { $dropdown.css({'margin-right': l - plugin.settings.containerGutter + 'px'}); } else if (r < 0) { $dropdown.css({'margin-left': r - plugin.settings.containerGutter + 'px'}); } }); }, quadmenuInitWidth: function (plugin) { plugin = plugin || this; if (!plugin.$quadmenu.data('width')) return; plugin.handleFullWidth(plugin.$quadmenu); $(window).resize($.debounce(600, function () { plugin.handleFullWidth(plugin.$quadmenu); })); }, handleFullWidth: function (navbar) { var $navbar = $(navbar); $navbar.css({ position: '', 'box-sizing': '', left: '', right: '', width: '' }); var margin_left = parseInt($navbar.css('margin-left'), 10), offset = 0 - $navbar.offset().left - margin_left, width = $(window).width(); $navbar.css({ position: 'relative', 'box-sizing': 'border-box', left: offset, right: offset, width: width }); }, quadmenuInitContainerWidth: function (plugin) { plugin = plugin || this; plugin.handleContainerWidth(plugin.$quadmenu); this.$quadmenu.on('sticking.quadmenu.navbar unsticking.quadmenu.navbar', function () { plugin.handleContainerWidth($(this)); }); $(window).resize($.debounce(600, function () { plugin.handleContainerWidth(plugin.$quadmenu); })); }, handleContainerWidth: function (navbar) { var $navbar = $(navbar), $container = $navbar.find('.quadmenu-container'); if (!$navbar.data('selector')) return; $container.css({'width': $(this.$quadmenu.data('selector')).innerWidth() + 'px'}); }, quadmenuInitLazyLoad: function (plugin) { plugin = plugin || this; /*this.$quadmenu.on('show.quadmenu.collapse show.quadmenu.dropdown', function (e) { $(this).find('img[data-src]').each(function (e) { var $img = $(this), width = $img.innerWidth(), height = $img.attr('height') || width, ratio = width / height, loaded = $img.data('lazyload'); if (!loaded && ratio != 1) { $img.css({'width': width + 'px', 'height': (width / ratio) + 'px'}); } }); });*/ this.$quadmenu.on('init.quadmenu shown.quadmenu.collapse shown.quadmenu.dropdown', function (e) { $(this).find('img[data-src]:visible').each(function (e) { var $img = $(this), src = $img.data('src'), srcset = $img.data('srcset'), loaded = $img.data('lazyload'); if (!loaded) { $img.addClass('quadmenu-lazyload'); if (src) { $img.attr('src', src).removeAttr('data-src').data('lazyload', true); } if (srcset) { $img.attr('srcset', srcset).removeAttr('data-srcset').data('lazyload', true); } } }); }); }, /*quadmenuInitNavbarVertical: function (plugin) { plugin = plugin || this; if (!this.$quadmenu.hasClass('quadmenu-is-vertical')) return; plugin.handleNavbarVertical(); $(window).resize($.debounce(600, function () { plugin.handleNavbarVertical(); })); }, handleNavbarVertical: function (plugin) { plugin = plugin || this; if (this.$quadmenu.find('.navbar-offcanvas').hasClass('in')) return; setTimeout(function () { plugin.closeAllSubmenus(); plugin.$quadmenu.find('[data-quadmenu=offcanvas]').trigger('click'); }, 500); },*/ quadmenuInitNavbarOffcanvas: function (plugin) { plugin = plugin || this; this.$quadmenu.on('show.quadmenu.collapse shown.quadmenu.collapse hide.quadmenu.collapse hidden.quadmenu.collapse', '.navbar-offcanvas', function (e) { //var $offcanvas = $('.navbar-offcanvas', $(this)); //if ($offcanvas.length) { var width = $(this).width(), translateX = plugin.$quadmenu.hasClass('quadmenu-offcanvas-left') ? width : width * -1; $(this).trigger(e.type + '.quadmenu.offcanvas', [translateX]); //} }); this.$quadmenu.on('show.quadmenu.offcanvas', '.navbar-offcanvas', function (e, translateX) { var $transform = $('> .quadmenu-navbar-toggle', plugin.$quadmenu).add($('.quadmenu-navbar-header', plugin.$quadmenu)); $transform.css({'transform': 'translateX(' + translateX + 'px)'}); $(this).css({'transform': 'translateX(0)'}); $('body').addClass('quadmenu-offcanvas-in'); plugin.$quadmenu.addClass('quadmenu-is-vertical'); }); this.$quadmenu.on('hide.quadmenu.offcanvas', '.navbar-offcanvas', function (e) { var $transform = $('> .quadmenu-navbar-toggle', plugin.$quadmenu).add($('.quadmenu-navbar-header', plugin.$quadmenu)); $transform.css({'transform': ''}); $(this).removeAttr('style'); $('body').removeClass('quadmenu-offcanvas-in'); plugin.$quadmenu.removeClass('quadmenu-is-vertical'); }); this.$quadmenu.on('shown.quadmenu.offcanvas hidden.quadmenu.offcanvas', '.navbar-offcanvas', function (e, translateX) { setTimeout(function () { var $transform = $(this).add($('> .quadmenu-navbar-toggle', plugin.$quadmenu)).add($('.quadmenu-navbar-header', plugin.$quadmenu)); $transform.toggleClass('canvas-sliding'); }, 1000); }); $(document).on(this.touchStart + '.hide.quadmenu.offcanvas click.hide.quadmenu.offcanvas', function (e) { var $target = $(e.target), responsive = plugin.settings.responsive && (window.innerWidth <= plugin.$quadmenu.data('breakpoint')) ? true : false; if ($target.closest('#quadmenu').length) return; if (!responsive) return; $target.on(plugin.touchEnd, function (e) { $('.navbar-offcanvas').collapse('hide'); }); $target.on(plugin.touchMove, function (e) { plugin.preventTapOnScroll(e, this, plugin); }); if (e.originalEvent !== undefined) { if (e.originalEvent.touches) { $target.data('quadmenu-startX', e.originalEvent.touches[0].clientX); $target.data('quadmenu-startY', e.originalEvent.touches[0].clientY); } //microsoft else if (e.originalEvent.clientY) { var pos = $target.offset(); $target.data('quadmenu-startX', e.originalEvent.clientX); $target.data('quadmenu-startY', e.originalEvent.clientY); } } }); }, quadmenuInitScrollBar: function (plugin) { plugin = plugin || this; if (!this.perfectScrollbar) return; plugin.handleDropdownScrollbar(); plugin.handleVerticalScrollbar(); $(window).resize($.debounce(300, function () { plugin.handleDropdownScrollbar(); plugin.handleVerticalScrollbar(); })); }, handleDropdownScrollbar: function (plugin) { plugin = plugin || this; this.$ul.off('shown.quadmenu.dropdown.pscrollbar'); this.$ul.find('.ps-container').perfectScrollbar('destroy').data('ps-id', false); if (!this.$quadmenu.hasClass('quadmenu-is-horizontal')) return; this.$ul.on('shown.quadmenu.dropdown.pscrollbar', '.dropdown-maxheight', function (e) { plugin.$dropdown = $(this).find('> .quadmenu-dropdown-menu > ul'); //fix for mousehover ---------------------- plugin.$dropdown.scroll($.debounce(500, true, function () { $(this).data('quadmenu-killHover', true); })); plugin.$dropdown.scroll($.debounce(500, function () { $(this).removeData('quadmenu-killHover'); })); if (plugin.$dropdown.data('ps-id')) { plugin.$dropdown.perfectScrollbar('update'); return; } plugin.$dropdown.perfectScrollbar({ useKeyboard: true, suppressScrollX: true, includePadding: true, scrollYMarginOffset: 1 }); }); }, handleVerticalScrollbar: function (plugin) { plugin = plugin || this; plugin.$offcanvas = this.$quadmenu.find('.navbar-offcanvas'); plugin.$offcanvas.perfectScrollbar('destroy').data('ps-id', false); if (this.$quadmenu.hasClass('quadmenu-is-horizontal')) return; plugin.$offcanvas.on('shown.quadmenu.dropdown.pscrollbar hidden.quadmenu.dropdown.pscrollbar shown.quadmenu.offcanvas.pscrollbar hidden.quadmenu.offcanvas.pscrollbar', function (e) { var $psMenu = $(this); $(this).on('mouseup mouseenter', '.ps-scrollbar-y-rail', function () { $psMenu.find('.quadmenu-item > .quadmenu-dropdown-toggle').data('quadmenu-killHover', true); }); $(this).on('mouseleave', '.ps-scrollbar-y-rail', function () { $psMenu.find('.quadmenu-item > .quadmenu-dropdown-toggle').removeData('quadmenu-killHover'); }); $psMenu.perfectScrollbar('update'); }); if (plugin.$offcanvas.data('ps-id')) { plugin.$offcanvas.perfectScrollbar('update'); return; } plugin.$offcanvas.perfectScrollbar({ useKeyboard: true, suppressScrollX: true, includePadding: true, scrollYMarginOffset: 1 }); }, quadmenuInitNavbarSlideBar: function (plugin) { plugin = plugin || this; if (!this.$quadmenu.hasClass('quadmenu-is-horizontal') || !this.$quadmenu.hasClass('quadmenu-hover-slidebar')) return; setTimeout(function () { plugin.$ul.append('