| 1 |
; |
| 2 |
(function (b, c) { |
| 3 |
var $ = b.jQuery || b.Cowboy || (b.Cowboy = {}), a; |
| 4 |
$.throttle = a = function (e, f, j, i) { |
| 5 |
var h, d = 0; |
| 6 |
if (typeof f !== "boolean") { |
| 7 |
i = j; |
| 8 |
j = f; |
| 9 |
f = c |
| 10 |
} |
| 11 |
function g() { |
| 12 |
var o = this, m = +new Date() - d, n = arguments; |
| 13 |
function l() { |
| 14 |
d = +new Date(); |
| 15 |
j.apply(o, n) |
| 16 |
} |
| 17 |
function k() { |
| 18 |
h = c |
| 19 |
} |
| 20 |
if (i && !h) { |
| 21 |
l() |
| 22 |
} |
| 23 |
h && clearTimeout(h); |
| 24 |
if (i === c && m > e) { |
| 25 |
l() |
| 26 |
} else { |
| 27 |
if (f !== true) { |
| 28 |
h = setTimeout(i ? k : l, i === c ? e - m : e) |
| 29 |
} |
| 30 |
} |
| 31 |
} |
| 32 |
if ($.guid) { |
| 33 |
g.guid = j.guid = j.guid || $.guid++ |
| 34 |
} |
| 35 |
return g |
| 36 |
}; |
| 37 |
$.debounce = function (d, e, f) { |
| 38 |
return f === c ? a(d, e, false) : a(d, f, e !== false) |
| 39 |
} |
| 40 |
})(this); |
| 41 |
(function ($) { |
| 42 |
'use strict'; |
| 43 |
function transitionEnd() { |
| 44 |
var el = document.createElement('quadmenu') |
| 45 |
|
| 46 |
var transEndEventNames = { |
| 47 |
WebkitTransition: 'webkitTransitionEnd', |
| 48 |
MozTransition: 'transitionend', |
| 49 |
OTransition: 'oTransitionEnd otransitionend', |
| 50 |
transition: 'transitionend' |
| 51 |
} |
| 52 |
|
| 53 |
for (var name in transEndEventNames) { |
| 54 |
if (el.style[name] !== undefined) { |
| 55 |
return {end: transEndEventNames[name]} |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
return false // explicit for ie8 ( ._.) |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
$.fn.emulateTransitionEnd = function (duration) { |
| 64 |
var called = false |
| 65 |
var $el = this |
| 66 |
$(this).one('quadmenuTransitionEnd', function () { |
| 67 |
called = true |
| 68 |
}) |
| 69 |
var callback = function () { |
| 70 |
if (!called) |
| 71 |
$($el).trigger($.support.transition.end) |
| 72 |
} |
| 73 |
setTimeout(callback, duration) |
| 74 |
return this |
| 75 |
} |
| 76 |
|
| 77 |
$(function () { |
| 78 |
$.support.transition = transitionEnd() |
| 79 |
|
| 80 |
if (!$.support.transition) |
| 81 |
return |
| 82 |
|
| 83 |
$.event.special.quadmenuTransitionEnd = { |
| 84 |
bindType: $.support.transition.end, |
| 85 |
delegateType: $.support.transition.end, |
| 86 |
handle: function (e) { |
| 87 |
if ($(e.target).is(this)) |
| 88 |
return e.handleObj.handler.apply(this, arguments) |
| 89 |
} |
| 90 |
} |
| 91 |
}) |
| 92 |
|
| 93 |
var QuadMenuCollapse = function (element, options) { |
| 94 |
this.$element = $(element) |
| 95 |
this.options = $.extend({}, QuadMenuCollapse.DEFAULTS, options) |
| 96 |
this.$trigger = $('[data-quadmenu="collapse"][href="#' + element.id + '"],' + |
| 97 |
'[data-quadmenu="collapse"][data-target="#' + element.id + '"]') |
| 98 |
this.transitioning = null |
| 99 |
|
| 100 |
if (this.options.parent) { |
| 101 |
this.$parent = this.getParent() |
| 102 |
} else { |
| 103 |
this.addAriaAndQuadMenuCollapsedClass(this.$element, this.$trigger) |
| 104 |
} |
| 105 |
|
| 106 |
if (this.options.toggle) |
| 107 |
this.toggle() |
| 108 |
} |
| 109 |
|
| 110 |
QuadMenuCollapse.TRANSITION_DURATION = 350 |
| 111 |
|
| 112 |
QuadMenuCollapse.DEFAULTS = { |
| 113 |
toggle: true |
| 114 |
} |
| 115 |
|
| 116 |
QuadMenuCollapse.prototype.dimension = function () { |
| 117 |
var hasWidth = this.$element.hasClass('width') |
| 118 |
return hasWidth ? 'width' : 'height' |
| 119 |
} |
| 120 |
|
| 121 |
QuadMenuCollapse.prototype.show = function () { |
| 122 |
if (this.transitioning || this.$element.hasClass('in')) |
| 123 |
return |
| 124 |
|
| 125 |
var activesData |
| 126 |
var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing') |
| 127 |
|
| 128 |
if (actives && actives.length) { |
| 129 |
activesData = actives.data('quadmenu.collapse') |
| 130 |
if (activesData && activesData.transitioning) |
| 131 |
return |
| 132 |
} |
| 133 |
|
| 134 |
var startEvent = $.Event('show.quadmenu.collapse') |
| 135 |
this.$element.trigger(startEvent) |
| 136 |
if (startEvent.isDefaultPrevented()) |
| 137 |
return |
| 138 |
|
| 139 |
if (actives && actives.length) { |
| 140 |
Plugin.call(actives, 'hide') |
| 141 |
activesData || actives.data('quadmenu.collapse', null) |
| 142 |
} |
| 143 |
|
| 144 |
var dimension = this.dimension() |
| 145 |
|
| 146 |
this.$element |
| 147 |
.removeClass('collapse') |
| 148 |
.addClass('collapsing')[dimension](0) |
| 149 |
.attr('aria-expanded', true) |
| 150 |
|
| 151 |
this.$trigger |
| 152 |
.removeClass('collapsed') |
| 153 |
.attr('aria-expanded', true) |
| 154 |
|
| 155 |
this.transitioning = 1 |
| 156 |
|
| 157 |
var complete = function () { |
| 158 |
this.$element |
| 159 |
.removeClass('collapsing') |
| 160 |
.addClass('collapse in')[dimension]('') |
| 161 |
this.transitioning = 0 |
| 162 |
this.$element |
| 163 |
.trigger('shown.quadmenu.collapse') |
| 164 |
} |
| 165 |
|
| 166 |
if (!$.support.transition) |
| 167 |
return complete.call(this) |
| 168 |
|
| 169 |
var scrollSize = $.camelCase(['scroll', dimension].join('-')) |
| 170 |
|
| 171 |
this.$element |
| 172 |
.one('quadmenuTransitionEnd', $.proxy(complete, this)) |
| 173 |
.emulateTransitionEnd(QuadMenuCollapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize]) |
| 174 |
} |
| 175 |
|
| 176 |
QuadMenuCollapse.prototype.hide = function () { |
| 177 |
if (this.transitioning || !this.$element.hasClass('in')) |
| 178 |
return |
| 179 |
|
| 180 |
var startEvent = $.Event('hide.quadmenu.collapse') |
| 181 |
this.$element.trigger(startEvent) |
| 182 |
if (startEvent.isDefaultPrevented()) |
| 183 |
return |
| 184 |
|
| 185 |
var dimension = this.dimension() |
| 186 |
|
| 187 |
this.$element[dimension](this.$element[dimension]())[0].offsetHeight |
| 188 |
|
| 189 |
this.$element |
| 190 |
.addClass('collapsing') |
| 191 |
.removeClass('collapse in') |
| 192 |
.attr('aria-expanded', false) |
| 193 |
|
| 194 |
this.$trigger |
| 195 |
.addClass('collapsed') |
| 196 |
.attr('aria-expanded', false) |
| 197 |
|
| 198 |
this.transitioning = 1 |
| 199 |
|
| 200 |
var complete = function () { |
| 201 |
this.transitioning = 0 |
| 202 |
this.$element |
| 203 |
.removeClass('collapsing') |
| 204 |
.addClass('collapse') |
| 205 |
.trigger('hidden.quadmenu.collapse') |
| 206 |
} |
| 207 |
|
| 208 |
if (!$.support.transition) |
| 209 |
return complete.call(this) |
| 210 |
|
| 211 |
this.$element |
| 212 |
[dimension](0) |
| 213 |
.one('quadmenuTransitionEnd', $.proxy(complete, this)) |
| 214 |
.emulateTransitionEnd(QuadMenuCollapse.TRANSITION_DURATION) |
| 215 |
} |
| 216 |
|
| 217 |
QuadMenuCollapse.prototype.toggle = function () { |
| 218 |
this[this.$element.hasClass('in') ? 'hide' : 'show']() |
| 219 |
} |
| 220 |
|
| 221 |
QuadMenuCollapse.prototype.getParent = function () { |
| 222 |
return $(this.options.parent) |
| 223 |
.find('[data-quadmenu="collapse"][data-parent="' + this.options.parent + '"]') |
| 224 |
.each($.proxy(function (i, element) { |
| 225 |
var $element = $(element) |
| 226 |
this.addAriaAndQuadMenuCollapsedClass(getTargetFromTrigger($element), $element) |
| 227 |
}, this)) |
| 228 |
.end() |
| 229 |
} |
| 230 |
|
| 231 |
QuadMenuCollapse.prototype.addAriaAndQuadMenuCollapsedClass = function ($element, $trigger) { |
| 232 |
var isOpen = $element.hasClass('in') |
| 233 |
|
| 234 |
$element.attr('aria-expanded', isOpen) |
| 235 |
$trigger |
| 236 |
.toggleClass('collapsed', !isOpen) |
| 237 |
.attr('aria-expanded', isOpen) |
| 238 |
} |
| 239 |
|
| 240 |
function getTargetFromTrigger($trigger) { |
| 241 |
var href |
| 242 |
var target = $trigger.attr('data-target') |
| 243 |
|| (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7 |
| 244 |
|
| 245 |
return $(target) |
| 246 |
} |
| 247 |
|
| 248 |
|
| 249 |
// COLLAPSE PLUGIN DEFINITION |
| 250 |
// ========================== |
| 251 |
|
| 252 |
function Plugin(option) { |
| 253 |
return this.each(function () { |
| 254 |
var $this = $(this) |
| 255 |
var data = $this.data('quadmenu.collapse') |
| 256 |
var options = $.extend({}, QuadMenuCollapse.DEFAULTS, $this.data(), typeof option == 'object' && option) |
| 257 |
|
| 258 |
if (!data && options.toggle && /show|hide/.test(option)) |
| 259 |
options.toggle = false |
| 260 |
if (!data) |
| 261 |
$this.data('quadmenu.collapse', (data = new QuadMenuCollapse(this, options))) |
| 262 |
if (typeof option == 'string') |
| 263 |
data[option]() |
| 264 |
}) |
| 265 |
} |
| 266 |
|
| 267 |
var old = $.fn.collapse |
| 268 |
|
| 269 |
$.fn.collapse = Plugin |
| 270 |
$.fn.collapse.Constructor = QuadMenuCollapse |
| 271 |
|
| 272 |
|
| 273 |
// COLLAPSE NO CONFLICT |
| 274 |
// ==================== |
| 275 |
|
| 276 |
$.fn.collapse.noConflict = function () { |
| 277 |
$.fn.collapse = old |
| 278 |
return this |
| 279 |
} |
| 280 |
|
| 281 |
|
| 282 |
// COLLAPSE DATA-API |
| 283 |
// ================= |
| 284 |
|
| 285 |
$(document).on('click.quadmenu.collapse.data-api', '[data-quadmenu="collapse"]', function (e) { |
| 286 |
var $this = $(this) |
| 287 |
|
| 288 |
if (!$this.attr('data-target')) |
| 289 |
e.preventDefault() |
| 290 |
|
| 291 |
var $target = getTargetFromTrigger($this) |
| 292 |
var data = $target.data('quadmenu.collapse') |
| 293 |
var option = data ? 'toggle' : $this.data() |
| 294 |
|
| 295 |
Plugin.call($target, option) |
| 296 |
}) |
| 297 |
|
| 298 |
}(jQuery)); |
| 299 |
(function ($, window, document, undefined) { |
| 300 |
'use strict'; |
| 301 |
var defaults = { |
| 302 |
responsive: true, |
| 303 |
containerGutter: parseInt(quadmenu.gutter), |
| 304 |
touchEvents: true, |
| 305 |
mouseEvents: true, |
| 306 |
moveThreshold: 50, |
| 307 |
//intent_sensitivity: 15, |
| 308 |
intent_timeout: 300, |
| 309 |
intent_interval: 30, |
| 310 |
}; |
| 311 |
function Plugin(element, options) { |
| 312 |
var plugin = this; |
| 313 |
this.element = element; |
| 314 |
this.$quadmenu = $(this.element); |
| 315 |
this.$ul = this.$quadmenu.find('ul.quadmenu-navbar-nav'); |
| 316 |
this.settings = $.extend({}, defaults, options); |
| 317 |
this.touchenabled = ('ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0); |
| 318 |
this.mobiledevice = (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)); |
| 319 |
this.perfectScrollbar = (typeof $.fn.perfectScrollbar !== 'undefined' && !this.mobiledevice) ? true : false; |
| 320 |
if (this.touchenabled) { |
| 321 |
this.$quadmenu.addClass('quadmenu-touch'); |
| 322 |
} else { |
| 323 |
this.$quadmenu.addClass('quadmenu-notouch'); |
| 324 |
} |
| 325 |
|
| 326 |
if (window.navigator.pointerEnabled) { |
| 327 |
this.touchStart = 'pointerdown'; |
| 328 |
this.touchEnd = 'pointerup'; |
| 329 |
this.touchMove = 'pointermove'; |
| 330 |
} else if (window.navigator.msPointerEnabled) { |
| 331 |
this.touchStart = 'MSPointerDown'; |
| 332 |
this.touchEnd = 'MSPointerUp'; |
| 333 |
this.touchMove = 'MSPointerMove'; |
| 334 |
} else { |
| 335 |
this.touchStart = 'touchstart'; |
| 336 |
this.touchEnd = 'touchend'; |
| 337 |
this.touchMove = 'touchmove'; |
| 338 |
} |
| 339 |
|
| 340 |
this.init(); |
| 341 |
} |
| 342 |
|
| 343 |
Plugin.prototype = { |
| 344 |
init: function () { |
| 345 |
this.quadmenuResolveConflics(); |
| 346 |
this.quadmenuInitClasses(); |
| 347 |
this.quadmenuInitWidth(); |
| 348 |
this.quadmenuInitContainerWidth(); |
| 349 |
this.quadmenuInitLazyLoad(); |
| 350 |
//this.quadmenuInitNavbarVertical(); |
| 351 |
this.quadmenuInitNavbarSticky(); // horizontal |
| 352 |
this.quadmenuInitNavbarOffcanvas(); |
| 353 |
this.quadmenuInitNavbarSlideBar(); // horizontal |
| 354 |
this.quadmenuInitItemTabs(); // horizontal |
| 355 |
this.quadmenuInitItemCarousel(); |
| 356 |
this.quadmenuInitItemLogIn(); |
| 357 |
this.quadmenuInitItemSocial(); |
| 358 |
this.quadmenuInitItemCart(); |
| 359 |
this.quadmenuInitItemWidgets(); |
| 360 |
this.quadmenuInitDropdownFloat(); // horizontal |
| 361 |
this.quadmenuInitDropdownMaxHeight(); // horizontal |
| 362 |
this.quadmenuInitDropdownTouchEvents(); |
| 363 |
this.quadmenuInitDropdownMouseEvents(); |
| 364 |
this.quadmenuInitDropdownRetractors(); |
| 365 |
this.quadmenuInitDropdownCloseAll(); // horizontal |
| 366 |
this.quadmenuInitScrollBar(); // horizontal |
| 367 |
this.quadmenuInit(); |
| 368 |
}, |
| 369 |
quadmenuInit: function () { |
| 370 |
|
| 371 |
this.$quadmenu.trigger('init.quadmenu'); |
| 372 |
|
| 373 |
}, |
| 374 |
quadmenuResolveConflics: function () { |
| 375 |
|
| 376 |
if (this.$quadmenu.data('unwrap')) { |
| 377 |
|
| 378 |
this.$quadmenu.unwrap('nav').find('.quadmenu-item, .quadmenu-dropdown-toggle, .quadmenu-dropdown-menu, .quadmenu-dropdown-submenu').add(this.$quadmenu).removeAttr('style').unbind().off(); |
| 379 |
} |
| 380 |
|
| 381 |
}, |
| 382 |
quadmenuInitClasses: function (plugin) { |
| 383 |
|
| 384 |
plugin = plugin || this; |
| 385 |
plugin.handleClasses(); |
| 386 |
$(window).resize($.debounce(300, function () { |
| 387 |
plugin.handleClasses(); |
| 388 |
})); |
| 389 |
}, |
| 390 |
handleClasses: function () { |
| 391 |
|
| 392 |
var template = this.$quadmenu.data('template'), |
| 393 |
mobile = this.settings.responsive && (window.innerWidth <= this.$quadmenu.data('breakpoint')) ? true : false; |
| 394 |
|
| 395 |
if (!mobile && template == 'collapse') { |
| 396 |
this.$quadmenu.addClass('quadmenu-is-horizontal'); |
| 397 |
} |
| 398 |
|
| 399 |
if (!mobile && template == 'embed') { |
| 400 |
this.$quadmenu.addClass('quadmenu-is-horizontal'); |
| 401 |
} |
| 402 |
|
| 403 |
if (!mobile && template == 'offcanvas') { |
| 404 |
this.$quadmenu.addClass('quadmenu-is-horizontal'); |
| 405 |
} |
| 406 |
|
| 407 |
if (mobile) { |
| 408 |
this.$quadmenu.removeClass('quadmenu-is-horizontal'); |
| 409 |
} |
| 410 |
|
| 411 |
this.$quadmenu.removeClass('no-js').addClass('js'); |
| 412 |
|
| 413 |
}, |
| 414 |
quadmenuInitDropdownTouchEvents: function (plugin) { |
| 415 |
|
| 416 |
plugin = plugin || this; |
| 417 |
if (!this.settings.touchEvents) |
| 418 |
return; |
| 419 |
this.$ul.on(this.touchStart + '.quadmenu.toggle', '.quadmenu-dropdown > .quadmenu-dropdown-toggle', function (e) { |
| 420 |
plugin.handleTouchEvents(e, this, plugin); |
| 421 |
}); |
| 422 |
this.$ul.on('click', '.quadmenu-dropdown > .quadmenu-dropdown-toggle', function (e) { |
| 423 |
plugin.handleClicks(e, this); |
| 424 |
}); |
| 425 |
}, |
| 426 |
quadmenuInitDropdownMouseEvents: function (plugin) { |
| 427 |
|
| 428 |
plugin = plugin || this; |
| 429 |
plugin.handleDropdownMouseEvents(); |
| 430 |
$(window).resize($.debounce(600, function () { |
| 431 |
plugin.handleDropdownMouseEvents(); |
| 432 |
})); |
| 433 |
}, |
| 434 |
handleDropdownMouseEvents: function (plugin) { |
| 435 |
|
| 436 |
plugin = plugin || this; |
| 437 |
this.$ul.find('.quadmenu-item').off('mouseleave.hoverIntent mouseenter.hoverIntent mousemove.hoverIntent'); |
| 438 |
this.$ul.find('.quadmenu-item').removeProp('hoverIntent_t'); |
| 439 |
this.$ul.find('.quadmenu-item').removeProp('hoverIntent_s'); |
| 440 |
if (!this.settings.mouseEvents) |
| 441 |
return; |
| 442 |
this.$ul.on('click', '.quadmenu-item > .quadmenu-dropdown-toggle', function (e) { |
| 443 |
plugin.handleLink(e, this); |
| 444 |
}); |
| 445 |
this.$ul.on('click.quadmenu.toggle', '.quadmenu-item > .quadmenu-dropdown-toggle', function (e) { |
| 446 |
plugin.handleMouseClick(e, this, plugin); |
| 447 |
}); |
| 448 |
if (!this.$quadmenu.hasClass('quadmenu-is-horizontal') || typeof $.fn.hoverIntent === 'undefined') |
| 449 |
return; |
| 450 |
plugin.handleMouseHover(this.$ul.find('.quadmenu-item > .quadmenu-dropdown-toggle.hoverintent'), plugin); |
| 451 |
}, |
| 452 |
handleMouseHover: function (target, plugin) { |
| 453 |
var $target = $(target), |
| 454 |
$li = $target.parent('.quadmenu-item'); |
| 455 |
$target.off('click.quadmenu.toggle'); |
| 456 |
$target.off(this.touchStart + '.quadmenu.toggle'); |
| 457 |
if (!$li.length) |
| 458 |
return; |
| 459 |
$li.hoverIntent({ |
| 460 |
over: function () { |
| 461 |
|
| 462 |
var $li = $(this), |
| 463 |
$target = $li.find('> .quadmenu-dropdown-menu'); |
| 464 |
if ($target.data('quadmenu-killHover')) |
| 465 |
return; |
| 466 |
plugin.triggerSubmenu($li, plugin); |
| 467 |
}, |
| 468 |
out: function () { |
| 469 |
|
| 470 |
var $li = $(this), |
| 471 |
$target = $li.find('> .quadmenu-dropdown-menu'); |
| 472 |
if ($target.data('quadmenu-killHover')) |
| 473 |
return; |
| 474 |
if ($li.hasClass('quadmenu-item-type-tab')) |
| 475 |
return; |
| 476 |
plugin.closeSubmenu($li); |
| 477 |
}, |
| 478 |
//sensitivity: plugin.settings.intent_sensitivity, |
| 479 |
timeout: plugin.settings.intent_timeout, |
| 480 |
interval: plugin.settings.intent_interval |
| 481 |
}); |
| 482 |
}, |
| 483 |
quadmenuInitDropdownRetractors: function (plugin) { |
| 484 |
|
| 485 |
plugin = plugin || this; |
| 486 |
this.$ul.on('click.retractor', '.quadmenu-item.quadmenu-dropdown.open > .quadmenu-dropdown-toggle > .quadmenu-item-content > .quadmenu-caret', function (e) { |
| 487 |
plugin.handleDropdownCloseEnd(e, this, plugin); |
| 488 |
}); |
| 489 |
// we dont need to off this evet on window resize because touch events hare handled by the browser |
| 490 |
if (!this.settings.touchEvents) |
| 491 |
return; |
| 492 |
this.$ul.on(this.touchStart + '.retractor', '.quadmenu-item.quadmenu-dropdown.open > .quadmenu-dropdown-toggle > .quadmenu-item-content > .quadmenu-caret', function (e) { |
| 493 |
plugin.handleDropdownCloseStart(e, this, plugin); |
| 494 |
}); |
| 495 |
}, |
| 496 |
handleTouchEvents: function (e, target, plugin) { |
| 497 |
|
| 498 |
var $target = $(target); |
| 499 |
//disable hoverintent on touch devices |
| 500 |
//$li.off('mouseleave.hoverIntent'); |
| 501 |
$target.on(plugin.touchEnd, function (e) { |
| 502 |
plugin.handleTouchTap(e, this, plugin); |
| 503 |
}); |
| 504 |
$target.on(plugin.touchMove, function (e) { |
| 505 |
plugin.preventTapOnScroll(e, this, plugin); |
| 506 |
}); |
| 507 |
if (e.originalEvent !== undefined) { |
| 508 |
|
| 509 |
if (e.originalEvent.touches) { |
| 510 |
$target.data('quadmenu-startX', e.originalEvent.touches[0].clientX); |
| 511 |
$target.data('quadmenu-startY', e.originalEvent.touches[0].clientY); |
| 512 |
} |
| 513 |
//microsoft |
| 514 |
else if (e.originalEvent.clientY) { |
| 515 |
var pos = $target.offset(); |
| 516 |
$target.data('quadmenu-startX', e.originalEvent.clientX); |
| 517 |
$target.data('quadmenu-startY', e.originalEvent.clientY); |
| 518 |
} |
| 519 |
|
| 520 |
} |
| 521 |
|
| 522 |
}, |
| 523 |
preventTapOnScroll: function (e, target, plugin) { |
| 524 |
|
| 525 |
var $target = $(target); |
| 526 |
if (e.originalEvent !== undefined) { |
| 527 |
|
| 528 |
//make sure the touch points aren't too close, if so, then remove the event handlers |
| 529 |
if (e.originalEvent.touches) { |
| 530 |
if (Math.abs(e.originalEvent.touches[0].clientX - $target.data('quadmenu-startX')) > plugin.settings.moveThreshold || |
| 531 |
Math.abs(e.originalEvent.touches[0].clientY - $target.data('quadmenu-startY')) > plugin.settings.moveThreshold) { |
| 532 |
|
| 533 |
plugin.resetHandlers($target); |
| 534 |
} |
| 535 |
} else if (e.originalEvent.clientY) { |
| 536 |
var pos = $target.data(pos); |
| 537 |
if (Math.abs(e.originalEvent.clientX - $target.data('quadmenu-startX')) > plugin.settings.moveThreshold || |
| 538 |
Math.abs(e.originalEvent.clientY - $target.data('quadmenu-startY')) > plugin.settings.moveThreshold) { |
| 539 |
|
| 540 |
plugin.resetHandlers($target); |
| 541 |
} |
| 542 |
} |
| 543 |
|
| 544 |
} |
| 545 |
|
| 546 |
}, |
| 547 |
handleTouchTap: function (e, target, plugin) { |
| 548 |
e.preventDefault(); |
| 549 |
|
| 550 |
var $target = $(target), |
| 551 |
$li = $target.parent(); |
| 552 |
//prevent clicks |
| 553 |
$target.data('quadmenu-killClick', true); |
| 554 |
//prevent hover |
| 555 |
$target.data('quadmenu-killHover', true); |
| 556 |
setTimeout(function () { |
| 557 |
$target.data('quadmenu-killClick', false).data('quadmenu-killHover', false); |
| 558 |
}, 1000); |
| 559 |
//close other submenus |
| 560 |
if (this.$quadmenu.hasClass('quadmenu-is-horizontal')) { |
| 561 |
plugin.closeSubmenu($li.siblings('.open')); |
| 562 |
} |
| 563 |
|
| 564 |
if ($li.hasClass('quadmenu-dropdown')) { |
| 565 |
//if submenu is already open then close it |
| 566 |
if ($li.hasClass('open')) { |
| 567 |
//please don't close tabs |
| 568 |
if (!$li.hasClass('quadmenu-item-type-tab') || !this.$quadmenu.hasClass('quadmenu-is-horizontal')) { |
| 569 |
plugin.closeSubmenu($li); |
| 570 |
} |
| 571 |
//allow link to be followed |
| 572 |
plugin.handleLink(e, target, true); |
| 573 |
} |
| 574 |
//if submenu is closed then open the submenu and prevent link from being followed |
| 575 |
else { |
| 576 |
plugin.openSubmenu($li); |
| 577 |
} |
| 578 |
} |
| 579 |
//allow links whitout submenus to be followed |
| 580 |
else { |
| 581 |
plugin.handleLink(e, target, true); |
| 582 |
} |
| 583 |
|
| 584 |
plugin.resetHandlers($target); |
| 585 |
}, |
| 586 |
handleLink: function (e, link, follow) { |
| 587 |
|
| 588 |
follow = follow || false; |
| 589 |
var $link = $(link), |
| 590 |
href = $link.attr('href'); |
| 591 |
if (!$link.is('a')) |
| 592 |
return; |
| 593 |
if (!href) { |
| 594 |
e.preventDefault(); |
| 595 |
return; |
| 596 |
} |
| 597 |
|
| 598 |
if (!follow || !e.isDefaultPrevented()) |
| 599 |
return; |
| 600 |
//handle links after preventDefault |
| 601 |
if ($link.attr('target') === '_blank') { |
| 602 |
window.open(href, '_blank'); |
| 603 |
} else { |
| 604 |
window.location = href; |
| 605 |
} |
| 606 |
|
| 607 |
}, |
| 608 |
handleMouseClick: function (e, target, plugin) { |
| 609 |
|
| 610 |
var $target = $(target), |
| 611 |
$li = $target.parent('.quadmenu-item'); |
| 612 |
if ($target.data('quadmenu-killClick') || !$li.length) |
| 613 |
return; |
| 614 |
//disable hoverintent on click, just in case |
| 615 |
//$li.off('mousemove.hoverIntent'); |
| 616 |
//$li.off('mouseenter.hoverIntent'); |
| 617 |
//$li.off('mouseleave.hoverIntent'); |
| 618 |
if ($li.hasClass('open')) { |
| 619 |
|
| 620 |
if ($target.is('a')) { |
| 621 |
plugin.handleLink(e, target); |
| 622 |
} |
| 623 |
|
| 624 |
} else if ($li.hasClass('quadmenu-dropdown')) { |
| 625 |
e.preventDefault(); |
| 626 |
//close other submenus |
| 627 |
if (this.$quadmenu.hasClass('quadmenu-is-horizontal')) { |
| 628 |
plugin.closeSubmenu($li.siblings('.open')); |
| 629 |
} |
| 630 |
plugin.openSubmenu($li); |
| 631 |
} |
| 632 |
|
| 633 |
}, |
| 634 |
handleDropdownCloseStart: function (e, caret, plugin) { |
| 635 |
e.preventDefault(); |
| 636 |
//e.stopPropagation(); // prevent envent on url |
| 637 |
$(caret).on(plugin.touchEnd, function (e) { |
| 638 |
plugin.handleDropdownCloseEnd(e, this, plugin); |
| 639 |
}); |
| 640 |
}, |
| 641 |
handleDropdownCloseEnd: function (e, caret, plugin) { |
| 642 |
e.preventDefault(); |
| 643 |
e.stopPropagation(); // prevent envent on url |
| 644 |
var $li = $(caret).closest('.quadmenu-dropdown.open'); |
| 645 |
plugin.closeSubmenu($li); |
| 646 |
$(caret).off(plugin.touchEnd); |
| 647 |
return false; |
| 648 |
}, |
| 649 |
resetHandlers: function ($target) { |
| 650 |
|
| 651 |
$target.off(this.touchEnd); |
| 652 |
$target.off(this.touchMove); |
| 653 |
var $li = $target.parent(); |
| 654 |
//1326 error en touch se desactiva hoverintent definitvamente |
| 655 |
$li.off('mousemove.hoverIntent'); |
| 656 |
$li.off('mouseenter.hoverIntent'); |
| 657 |
$li.off('mouseleave.hoverIntent'); |
| 658 |
$li.removeProp('hoverIntent_t'); |
| 659 |
$li.removeProp('hoverIntent_s'); |
| 660 |
}, |
| 661 |
triggerSubmenu: function ($li, plugin) { |
| 662 |
plugin.closeSubmenu($li.siblings('.open')); |
| 663 |
plugin.openSubmenu($li); |
| 664 |
}, |
| 665 |
openSubmenu: function ($li, timeout) { |
| 666 |
|
| 667 |
if ($li.hasClass('open')) |
| 668 |
return; |
| 669 |
timeout = timeout || 100; |
| 670 |
$li.trigger('show.quadmenu.dropdown'); |
| 671 |
$li.addClass('opening'); |
| 672 |
setTimeout(function () { |
| 673 |
$li.addClass('open'); |
| 674 |
$li.removeClass('opening'); |
| 675 |
$li.trigger('shown.quadmenu.dropdown'); |
| 676 |
}, timeout); |
| 677 |
}, |
| 678 |
closeSubmenu: function ($li, timeout) { |
| 679 |
|
| 680 |
if (!$li.hasClass('open')) |
| 681 |
return; |
| 682 |
timeout = timeout || 200; |
| 683 |
$li.trigger('hide.quadmenu.dropdown'); |
| 684 |
$li.addClass('closing'); |
| 685 |
setTimeout(function () { |
| 686 |
$li.find('.quadmenu-item').removeClass('open'); |
| 687 |
$li.removeClass('open').removeClass('closing'); |
| 688 |
$li.trigger('hidden.quadmenu.dropdown'); |
| 689 |
}, timeout); |
| 690 |
}, |
| 691 |
handleClicks: function (e, target) { |
| 692 |
|
| 693 |
var $target = $(target); |
| 694 |
if ($target.data('quadmenu-killClick')) { |
| 695 |
e.preventDefault(); |
| 696 |
} |
| 697 |
}, |
| 698 |
quadmenuInitDropdownCloseAll: function (plugin) { |
| 699 |
|
| 700 |
plugin = plugin || this; |
| 701 |
/* |
| 702 |
* resize is calling in mobile touch taps and closing all menus |
| 703 |
* $(window).resize($.debounce(300, function () { |
| 704 |
plugin.closeAllSubmenus(); |
| 705 |
}));*/ |
| 706 |
|
| 707 |
if (!this.$quadmenu.hasClass('quadmenu-is-horizontal')) |
| 708 |
return; |
| 709 |
$(document).on(this.touchEnd + '.hidden.quadmenu.dropdown.all click.hidden.quadmenu.dropdown.all', function (e) { |
| 710 |
|
| 711 |
if ($(e.target).closest('#quadmenu').length) |
| 712 |
return; |
| 713 |
plugin.closeAllSubmenus(); |
| 714 |
}); |
| 715 |
}, |
| 716 |
closeAllSubmenus: function () { |
| 717 |
|
| 718 |
var $li = this.$ul.find('.quadmenu-item.open'); |
| 719 |
if (!$li.length) |
| 720 |
return; |
| 721 |
this.closeSubmenu($li, 100); |
| 722 |
//this.trigger('hidden.quadmenu.dropdown.all'); |
| 723 |
|
| 724 |
return; |
| 725 |
}, |
| 726 |
quadmenuInitDropdownMaxHeight: function (plugin) { |
| 727 |
|
| 728 |
plugin = plugin || this; |
| 729 |
this.$ul.off('shown.quadmenu.dropdown.height'); |
| 730 |
if (!this.$quadmenu.hasClass('quadmenu-is-horizontal')) |
| 731 |
return; |
| 732 |
this.$ul.on('shown.quadmenu.dropdown.height', '.dropdown-maxheight', function (e) { |
| 733 |
plugin.handleDropdownMaxHeight($(this)); |
| 734 |
}); |
| 735 |
this.$ul.on('shown.quadmenu.dropdown.tabheight', '.dropdown-maxheight.quadmenu-item-type-tab', function (e) { |
| 736 |
plugin.handleTabsHeight($(this)); |
| 737 |
}); |
| 738 |
$(window).resize($.debounce(300, function () { |
| 739 |
plugin.$ul.find('.dropdown-maxheight > .quadmenu-dropdown-menu > ul').css({'height': '', 'overflow-y': ''}).removeData('quadmenu-dropdownHeight').removeData('quadmenu-maxHeight'); |
| 740 |
})); |
| 741 |
}, |
| 742 |
handleDropdownMaxHeight: function (li, minHeight) { |
| 743 |
|
| 744 |
if (typeof $.fn.scrollTop === 'undefined') |
| 745 |
return; |
| 746 |
minHeight = minHeight || 200; |
| 747 |
var $li = $(li), |
| 748 |
$dropdown = $li.find('> .quadmenu-dropdown-menu > ul'); |
| 749 |
if (!$dropdown.length) |
| 750 |
return; |
| 751 |
|
| 752 |
var dropdownHeight = $dropdown.removeAttr('style').outerHeight(), |
| 753 |
offsetTop = this.getElementOffset($dropdown), |
| 754 |
scrollTop = $(window).scrollTop(), |
| 755 |
currentTop = Math.max(0, offsetTop - scrollTop), |
| 756 |
currentBottom = $(window).height() - currentTop - 15, |
| 757 |
maxHeight = Math.min(dropdownHeight, currentBottom), |
| 758 |
Height = parseInt(Math.max(maxHeight, minHeight)); |
| 759 |
$dropdown.css({'height': Height + 'px', 'overflow-y': 'auto'}).data('quadmenu-maxHeight', Height); |
| 760 |
|
| 761 |
return Height; |
| 762 |
}, |
| 763 |
//quadmenuInitItemActive: function () { |
| 764 |
// this.$ul.find('.current-menu-item:not(.quadmenu-item-type-tab)').addClass('active').first().parents('.quadmenu-item:not(.quadmenu-item-type-tab)').addClass('active'); |
| 765 |
//}, |
| 766 |
quadmenuInitNavbarSticky: function () { |
| 767 |
|
| 768 |
var plugin = this; |
| 769 |
|
| 770 |
if (typeof $.fn.scrollTop === 'undefined') |
| 771 |
return; |
| 772 |
|
| 773 |
if (!this.$quadmenu.hasClass('quadmenu-is-horizontal')) |
| 774 |
return; |
| 775 |
|
| 776 |
plugin.$sticky = this.$quadmenu.filter('[data-sticky="1"]').first(); |
| 777 |
|
| 778 |
if (!plugin.$sticky.length) |
| 779 |
return; |
| 780 |
|
| 781 |
plugin.is_sticky = false; |
| 782 |
|
| 783 |
$(window).on('load', function () { |
| 784 |
|
| 785 |
var topLast = 0; |
| 786 |
|
| 787 |
plugin.sticky_height = plugin.$sticky.height(); |
| 788 |
|
| 789 |
plugin.adminbar_height = $('#wpadminbar').height() || 0; |
| 790 |
|
| 791 |
plugin.sticky_offset = plugin.$sticky.offset().top; |
| 792 |
|
| 793 |
plugin.topYSticky = Math.max(plugin.$sticky.offset().top - plugin.adminbar_height, plugin.$sticky.data('sticky-offset'), plugin.sticky_height + plugin.adminbar_height); |
| 794 |
|
| 795 |
if (plugin.topYSticky > plugin.sticky_offset) { |
| 796 |
plugin.$sticky.addClass('quadmenu-sticky-animation'); |
| 797 |
} |
| 798 |
|
| 799 |
$(window).on('scroll', function () { |
| 800 |
|
| 801 |
var topY = $(this).scrollTop(); |
| 802 |
|
| 803 |
if (plugin.is_sticky && (topY < (plugin.topYSticky))) { |
| 804 |
plugin.handleUnSticky(); |
| 805 |
} |
| 806 |
|
| 807 |
if (!plugin.is_sticky && (topY > (plugin.topYSticky))) { |
| 808 |
plugin.handleSticky(); |
| 809 |
} |
| 810 |
|
| 811 |
topLast = topY; |
| 812 |
}); |
| 813 |
|
| 814 |
}); |
| 815 |
|
| 816 |
|
| 817 |
}, |
| 818 |
handleSticky: function () { |
| 819 |
|
| 820 |
var plugin = this; |
| 821 |
plugin.is_sticky = true; |
| 822 |
var placeholder = $('<div />').addClass('quadmenu-sticky-wrapper').css({ |
| 823 |
'height': plugin.sticky_height + 'px', |
| 824 |
'position': 'static' |
| 825 |
}); |
| 826 |
plugin.$sticky.find('.quadmenu-navbar-collapse.collapse.in').collapse('hide'); |
| 827 |
plugin.$sticky.toggleClass('quadmenu-sticky-top').wrap(placeholder); |
| 828 |
plugin.$sticky.trigger('sticking.quadmenu.navbar'); |
| 829 |
//setTimeout(function () { |
| 830 |
plugin.$sticky.trigger('sticky.quadmenu.navbar'); |
| 831 |
//}, 200); |
| 832 |
}, |
| 833 |
handleUnSticking: function () { |
| 834 |
|
| 835 |
var plugin = this; |
| 836 |
plugin.is_sticky = false; |
| 837 |
plugin.$sticky.addClass('quadmenu-unsticking-top'); |
| 838 |
}, |
| 839 |
handleUnSticky: function () { |
| 840 |
|
| 841 |
var plugin = this; |
| 842 |
plugin.is_sticky = false; |
| 843 |
plugin.$sticky.trigger('unsticking.quadmenu.navbar'); |
| 844 |
//plugin.$sticky.addClass('quadmenu-unsticking-top'); |
| 845 |
setTimeout(function () { |
| 846 |
//plugin.$sticky.removeClass('quadmenu-unsticking-top'); |
| 847 |
}, 200); |
| 848 |
plugin.$sticky.removeClass('quadmenu-sticky-top'); |
| 849 |
plugin.$sticky.unwrap(); |
| 850 |
plugin.$sticky.trigger('unsticky.quadmenu.navbar'); |
| 851 |
}, |
| 852 |
quadmenuInitDropdownFloat: function (plugin) { |
| 853 |
|
| 854 |
plugin = plugin || this; |
| 855 |
plugin.handleDropdownFloat(); |
| 856 |
$(window).resize($.debounce(600, function () { |
| 857 |
plugin.handleDropdownFloat(); |
| 858 |
})); |
| 859 |
}, |
| 860 |
handleDropdownFloat: function (plugin) { |
| 861 |
|
| 862 |
plugin = plugin || this; |
| 863 |
this.$ul.off('shown.quadmenu.dropdown.float'); |
| 864 |
if (!this.$quadmenu.hasClass('quadmenu-is-horizontal')) |
| 865 |
return; |
| 866 |
this.$ul.on('shown.quadmenu.dropdown.float', '.quadmenu-item.quadmenu-dropdown:not(.quadmenu-item-type-tab):not(.quadmenu-item-type-tabs)', function (e) { |
| 867 |
var $dropdown = $(this).find('> .quadmenu-dropdown-menu:not(.quadmenu-dropdown-stretch-content):not(.quadmenu-dropdown-stretch-dropdown)'); |
| 868 |
if (!$dropdown.length) |
| 869 |
return; |
| 870 |
var elH = $dropdown.outerWidth(), |
| 871 |
W = $(window).innerWidth(), |
| 872 |
p = $dropdown.offset(), |
| 873 |
l = p.left, |
| 874 |
r = parseInt(W - (l + elH)); |
| 875 |
|
| 876 |
if ($(this).hasClass('quadmenu-dropdown-left') && l < 0) { |
| 877 |
$dropdown.css({'margin-right': l - plugin.settings.containerGutter + 'px'}); |
| 878 |
} else if (r < 0) { |
| 879 |
$dropdown.css({'margin-left': r - plugin.settings.containerGutter + 'px'}); |
| 880 |
} |
| 881 |
|
| 882 |
}); |
| 883 |
}, |
| 884 |
quadmenuInitWidth: function (plugin) { |
| 885 |
|
| 886 |
plugin = plugin || this; |
| 887 |
if (!plugin.$quadmenu.data('width')) |
| 888 |
return; |
| 889 |
plugin.handleFullWidth(plugin.$quadmenu); |
| 890 |
$(window).resize($.debounce(600, function () { |
| 891 |
plugin.handleFullWidth(plugin.$quadmenu); |
| 892 |
})); |
| 893 |
}, |
| 894 |
handleFullWidth: function (navbar) { |
| 895 |
|
| 896 |
var $navbar = $(navbar); |
| 897 |
$navbar.css({ |
| 898 |
position: '', |
| 899 |
'box-sizing': '', |
| 900 |
left: '', |
| 901 |
right: '', |
| 902 |
width: '' |
| 903 |
}); |
| 904 |
var margin_left = parseInt($navbar.css('margin-left'), 10), |
| 905 |
offset = 0 - $navbar.offset().left - margin_left, |
| 906 |
width = $(window).width(); |
| 907 |
$navbar.css({ |
| 908 |
position: 'relative', |
| 909 |
'box-sizing': 'border-box', |
| 910 |
left: offset, |
| 911 |
right: offset, |
| 912 |
width: width |
| 913 |
}); |
| 914 |
}, |
| 915 |
quadmenuInitContainerWidth: function (plugin) { |
| 916 |
|
| 917 |
plugin = plugin || this; |
| 918 |
plugin.handleContainerWidth(plugin.$quadmenu); |
| 919 |
this.$quadmenu.on('sticking.quadmenu.navbar unsticking.quadmenu.navbar', function () { |
| 920 |
plugin.handleContainerWidth($(this)); |
| 921 |
}); |
| 922 |
$(window).resize($.debounce(600, function () { |
| 923 |
plugin.handleContainerWidth(plugin.$quadmenu); |
| 924 |
})); |
| 925 |
}, |
| 926 |
handleContainerWidth: function (navbar) { |
| 927 |
|
| 928 |
var $navbar = $(navbar), |
| 929 |
$container = $navbar.find('.quadmenu-container'); |
| 930 |
if (!$navbar.data('selector')) |
| 931 |
return; |
| 932 |
$container.css({'width': $(this.$quadmenu.data('selector')).innerWidth() + 'px'}); |
| 933 |
}, |
| 934 |
quadmenuInitLazyLoad: function (plugin) { |
| 935 |
|
| 936 |
plugin = plugin || this; |
| 937 |
|
| 938 |
/*this.$quadmenu.on('show.quadmenu.collapse show.quadmenu.dropdown', function (e) { |
| 939 |
|
| 940 |
$(this).find('img[data-src]').each(function (e) { |
| 941 |
|
| 942 |
var $img = $(this), |
| 943 |
width = $img.innerWidth(), |
| 944 |
height = $img.attr('height') || width, |
| 945 |
ratio = width / height, |
| 946 |
loaded = $img.data('lazyload'); |
| 947 |
|
| 948 |
if (!loaded && ratio != 1) { |
| 949 |
$img.css({'width': width + 'px', 'height': (width / ratio) + 'px'}); |
| 950 |
} |
| 951 |
|
| 952 |
}); |
| 953 |
|
| 954 |
});*/ |
| 955 |
|
| 956 |
this.$quadmenu.on('init.quadmenu shown.quadmenu.collapse shown.quadmenu.dropdown', function (e) { |
| 957 |
|
| 958 |
$(this).find('img[data-src]:visible').each(function (e) { |
| 959 |
|
| 960 |
var $img = $(this), |
| 961 |
src = $img.data('src'), |
| 962 |
srcset = $img.data('srcset'), |
| 963 |
loaded = $img.data('lazyload'); |
| 964 |
|
| 965 |
if (!loaded) { |
| 966 |
|
| 967 |
$img.addClass('quadmenu-lazyload'); |
| 968 |
|
| 969 |
if (src) { |
| 970 |
$img.attr('src', src).removeAttr('data-src').data('lazyload', true); |
| 971 |
} |
| 972 |
|
| 973 |
if (srcset) { |
| 974 |
$img.attr('srcset', srcset).removeAttr('data-srcset').data('lazyload', true); |
| 975 |
} |
| 976 |
|
| 977 |
} |
| 978 |
|
| 979 |
}); |
| 980 |
|
| 981 |
}); |
| 982 |
}, |
| 983 |
/*quadmenuInitNavbarVertical: function (plugin) { |
| 984 |
|
| 985 |
plugin = plugin || this; |
| 986 |
if (!this.$quadmenu.hasClass('quadmenu-is-vertical')) |
| 987 |
return; |
| 988 |
plugin.handleNavbarVertical(); |
| 989 |
$(window).resize($.debounce(600, function () { |
| 990 |
plugin.handleNavbarVertical(); |
| 991 |
})); |
| 992 |
}, |
| 993 |
handleNavbarVertical: function (plugin) { |
| 994 |
|
| 995 |
plugin = plugin || this; |
| 996 |
if (this.$quadmenu.find('.navbar-offcanvas').hasClass('in')) |
| 997 |
return; |
| 998 |
setTimeout(function () { |
| 999 |
plugin.closeAllSubmenus(); |
| 1000 |
plugin.$quadmenu.find('[data-quadmenu=offcanvas]').trigger('click'); |
| 1001 |
}, 500); |
| 1002 |
},*/ |
| 1003 |
quadmenuInitNavbarOffcanvas: function (plugin) { |
| 1004 |
|
| 1005 |
plugin = plugin || this; |
| 1006 |
|
| 1007 |
this.$quadmenu.on('show.quadmenu.collapse shown.quadmenu.collapse hide.quadmenu.collapse hidden.quadmenu.collapse', '.navbar-offcanvas', function (e) { |
| 1008 |
|
| 1009 |
//var $offcanvas = $('.navbar-offcanvas', $(this)); |
| 1010 |
|
| 1011 |
//if ($offcanvas.length) { |
| 1012 |
|
| 1013 |
var width = $(this).width(), |
| 1014 |
translateX = plugin.$quadmenu.hasClass('quadmenu-offcanvas-left') ? width : width * -1; |
| 1015 |
|
| 1016 |
$(this).trigger(e.type + '.quadmenu.offcanvas', [translateX]); |
| 1017 |
|
| 1018 |
//} |
| 1019 |
|
| 1020 |
}); |
| 1021 |
|
| 1022 |
this.$quadmenu.on('show.quadmenu.offcanvas', '.navbar-offcanvas', function (e, translateX) { |
| 1023 |
|
| 1024 |
var $transform = $('> .quadmenu-navbar-toggle', plugin.$quadmenu).add($('.quadmenu-navbar-header', plugin.$quadmenu)); |
| 1025 |
|
| 1026 |
$transform.css({'transform': 'translateX(' + translateX + 'px)'}); |
| 1027 |
|
| 1028 |
$(this).css({'transform': 'translateX(0)'}); |
| 1029 |
|
| 1030 |
$('body').addClass('quadmenu-offcanvas-in'); |
| 1031 |
|
| 1032 |
plugin.$quadmenu.addClass('quadmenu-is-vertical'); |
| 1033 |
}); |
| 1034 |
|
| 1035 |
this.$quadmenu.on('hide.quadmenu.offcanvas', '.navbar-offcanvas', function (e) { |
| 1036 |
|
| 1037 |
var $transform = $('> .quadmenu-navbar-toggle', plugin.$quadmenu).add($('.quadmenu-navbar-header', plugin.$quadmenu)); |
| 1038 |
|
| 1039 |
$transform.css({'transform': ''}); |
| 1040 |
|
| 1041 |
$(this).removeAttr('style'); |
| 1042 |
|
| 1043 |
$('body').removeClass('quadmenu-offcanvas-in'); |
| 1044 |
|
| 1045 |
plugin.$quadmenu.removeClass('quadmenu-is-vertical'); |
| 1046 |
}); |
| 1047 |
|
| 1048 |
this.$quadmenu.on('shown.quadmenu.offcanvas hidden.quadmenu.offcanvas', '.navbar-offcanvas', function (e, translateX) { |
| 1049 |
|
| 1050 |
setTimeout(function () { |
| 1051 |
|
| 1052 |
var $transform = $(this).add($('> .quadmenu-navbar-toggle', plugin.$quadmenu)).add($('.quadmenu-navbar-header', plugin.$quadmenu)); |
| 1053 |
|
| 1054 |
$transform.toggleClass('canvas-sliding'); |
| 1055 |
|
| 1056 |
}, 1000); |
| 1057 |
}); |
| 1058 |
|
| 1059 |
$(document).on(this.touchStart + '.hide.quadmenu.offcanvas click.hide.quadmenu.offcanvas', function (e) { |
| 1060 |
|
| 1061 |
var $target = $(e.target), |
| 1062 |
responsive = plugin.settings.responsive && (window.innerWidth <= plugin.$quadmenu.data('breakpoint')) ? true : false; |
| 1063 |
if ($target.closest('#quadmenu').length) |
| 1064 |
return; |
| 1065 |
if (!responsive) |
| 1066 |
return; |
| 1067 |
$target.on(plugin.touchEnd, function (e) { |
| 1068 |
$('.navbar-offcanvas').collapse('hide'); |
| 1069 |
}); |
| 1070 |
$target.on(plugin.touchMove, function (e) { |
| 1071 |
plugin.preventTapOnScroll(e, this, plugin); |
| 1072 |
}); |
| 1073 |
if (e.originalEvent !== undefined) { |
| 1074 |
|
| 1075 |
if (e.originalEvent.touches) { |
| 1076 |
$target.data('quadmenu-startX', e.originalEvent.touches[0].clientX); |
| 1077 |
$target.data('quadmenu-startY', e.originalEvent.touches[0].clientY); |
| 1078 |
} |
| 1079 |
//microsoft |
| 1080 |
else if (e.originalEvent.clientY) { |
| 1081 |
var pos = $target.offset(); |
| 1082 |
$target.data('quadmenu-startX', e.originalEvent.clientX); |
| 1083 |
$target.data('quadmenu-startY', e.originalEvent.clientY); |
| 1084 |
} |
| 1085 |
} |
| 1086 |
|
| 1087 |
}); |
| 1088 |
}, |
| 1089 |
quadmenuInitScrollBar: function (plugin) { |
| 1090 |
|
| 1091 |
plugin = plugin || this; |
| 1092 |
if (!this.perfectScrollbar) |
| 1093 |
return; |
| 1094 |
plugin.handleDropdownScrollbar(); |
| 1095 |
plugin.handleVerticalScrollbar(); |
| 1096 |
$(window).resize($.debounce(300, function () { |
| 1097 |
plugin.handleDropdownScrollbar(); |
| 1098 |
plugin.handleVerticalScrollbar(); |
| 1099 |
})); |
| 1100 |
}, |
| 1101 |
handleDropdownScrollbar: function (plugin) { |
| 1102 |
|
| 1103 |
plugin = plugin || this; |
| 1104 |
this.$ul.off('shown.quadmenu.dropdown.pscrollbar'); |
| 1105 |
this.$ul.find('.ps-container').perfectScrollbar('destroy').data('ps-id', false); |
| 1106 |
if (!this.$quadmenu.hasClass('quadmenu-is-horizontal')) |
| 1107 |
return; |
| 1108 |
this.$ul.on('shown.quadmenu.dropdown.pscrollbar', '.dropdown-maxheight', function (e) { |
| 1109 |
plugin.$dropdown = $(this).find('> .quadmenu-dropdown-menu > ul'); |
| 1110 |
//fix for mousehover ---------------------- |
| 1111 |
plugin.$dropdown.scroll($.debounce(500, true, function () { |
| 1112 |
$(this).data('quadmenu-killHover', true); |
| 1113 |
})); |
| 1114 |
plugin.$dropdown.scroll($.debounce(500, function () { |
| 1115 |
$(this).removeData('quadmenu-killHover'); |
| 1116 |
})); |
| 1117 |
if (plugin.$dropdown.data('ps-id')) { |
| 1118 |
plugin.$dropdown.perfectScrollbar('update'); |
| 1119 |
return; |
| 1120 |
} |
| 1121 |
|
| 1122 |
plugin.$dropdown.perfectScrollbar({ |
| 1123 |
useKeyboard: true, |
| 1124 |
suppressScrollX: true, |
| 1125 |
includePadding: true, |
| 1126 |
scrollYMarginOffset: 1 |
| 1127 |
}); |
| 1128 |
}); |
| 1129 |
}, |
| 1130 |
handleVerticalScrollbar: function (plugin) { |
| 1131 |
|
| 1132 |
plugin = plugin || this; |
| 1133 |
plugin.$offcanvas = this.$quadmenu.find('.navbar-offcanvas'); |
| 1134 |
plugin.$offcanvas.perfectScrollbar('destroy').data('ps-id', false); |
| 1135 |
if (this.$quadmenu.hasClass('quadmenu-is-horizontal')) |
| 1136 |
return; |
| 1137 |
plugin.$offcanvas.on('shown.quadmenu.dropdown.pscrollbar hidden.quadmenu.dropdown.pscrollbar shown.quadmenu.offcanvas.pscrollbar hidden.quadmenu.offcanvas.pscrollbar', function (e) { |
| 1138 |
|
| 1139 |
var $psMenu = $(this); |
| 1140 |
$(this).on('mouseup mouseenter', '.ps-scrollbar-y-rail', function () { |
| 1141 |
$psMenu.find('.quadmenu-item > .quadmenu-dropdown-toggle').data('quadmenu-killHover', true); |
| 1142 |
}); |
| 1143 |
$(this).on('mouseleave', '.ps-scrollbar-y-rail', function () { |
| 1144 |
$psMenu.find('.quadmenu-item > .quadmenu-dropdown-toggle').removeData('quadmenu-killHover'); |
| 1145 |
}); |
| 1146 |
$psMenu.perfectScrollbar('update'); |
| 1147 |
}); |
| 1148 |
if (plugin.$offcanvas.data('ps-id')) { |
| 1149 |
plugin.$offcanvas.perfectScrollbar('update'); |
| 1150 |
return; |
| 1151 |
} |
| 1152 |
plugin.$offcanvas.perfectScrollbar({ |
| 1153 |
useKeyboard: true, |
| 1154 |
suppressScrollX: true, |
| 1155 |
includePadding: true, |
| 1156 |
scrollYMarginOffset: 1 |
| 1157 |
}); |
| 1158 |
}, |
| 1159 |
quadmenuInitNavbarSlideBar: function (plugin) { |
| 1160 |
|
| 1161 |
plugin = plugin || this; |
| 1162 |
|
| 1163 |
if (!this.$quadmenu.hasClass('quadmenu-is-horizontal') || !this.$quadmenu.hasClass('quadmenu-hover-slidebar')) |
| 1164 |
return; |
| 1165 |
|
| 1166 |
setTimeout(function () { |
| 1167 |
plugin.$ul.append('<li class="quadmenu-slidebar invisible"><span class="bar"></span></li>'); |
| 1168 |
plugin.handleSlideBar(plugin.$ul); |
| 1169 |
}, 1000); |
| 1170 |
}, |
| 1171 |
handleSlideBar: function (ul, plugin) { |
| 1172 |
|
| 1173 |
plugin = plugin || this; |
| 1174 |
|
| 1175 |
var $ul = $(ul), |
| 1176 |
slide_nav = $ul.find('> li.quadmenu-slidebar'), |
| 1177 |
$open = $ul.find('> li.open:visible'), |
| 1178 |
$item = $ul.find('> li.current-menu-item:visible'), |
| 1179 |
$ancestor = $ul.find('> li.current-menu-ancestor:visible'), |
| 1180 |
$current = $ul.find('> li:visible:first-child'); |
| 1181 |
|
| 1182 |
if ($ancestor.length) { |
| 1183 |
$current = $ancestor; |
| 1184 |
} |
| 1185 |
if ($item.length) { |
| 1186 |
$current = $item; |
| 1187 |
} |
| 1188 |
if ($open.length) { |
| 1189 |
$current = $open; |
| 1190 |
} |
| 1191 |
|
| 1192 |
function slide_nav_css($current) { |
| 1193 |
|
| 1194 |
if ($current.length) { |
| 1195 |
|
| 1196 |
var width = parseFloat($current.find('> a').outerWidth()), |
| 1197 |
pos_left = parseFloat($current.position().left), |
| 1198 |
pos_right = parseFloat($current.position().right); |
| 1199 |
slide_nav.css({'width': width + 'px', 'left': pos_left + 'px', 'right': pos_right + 'px'}).removeClass('invisible'); |
| 1200 |
} |
| 1201 |
|
| 1202 |
} |
| 1203 |
|
| 1204 |
slide_nav_css($current); |
| 1205 |
|
| 1206 |
slide_nav.data('slidebar-style', slide_nav.attr('style')); |
| 1207 |
|
| 1208 |
//handle sticky transforms |
| 1209 |
this.$ul.on('sticky.quadmenu.navbar.slidebar unsticky.quadmenu.navbar.slidebar', function () { |
| 1210 |
slide_nav.addClass('invisible'); |
| 1211 |
var $ul = $(this).find('.quadmenu-navbar-nav'), |
| 1212 |
$open = $ul.find('> ' + li + '.open'), |
| 1213 |
$active = $open.length ? $open : $ul.find('> li.quadmenu-item.quadmenu-item-level-0.active'), |
| 1214 |
$current = $active.length ? $active : $ul.find(li).not('.quadmenu-float-opposite').first(); |
| 1215 |
slide_nav_css($current); |
| 1216 |
slide_nav.data('slidebar-style', slide_nav.attr('style')); |
| 1217 |
}); |
| 1218 |
//handle mouse events |
| 1219 |
$ul.find('> li.quadmenu-item.quadmenu-has-link').on('hover.slidebar', function (e) { |
| 1220 |
slide_nav_css($(this)); |
| 1221 |
}); |
| 1222 |
|
| 1223 |
$ul.find('> li.quadmenu-item.quadmenu-has-link').on('mouseleave.slidebar', function (e) { |
| 1224 |
slide_nav.attr('style', slide_nav.data('slidebar-style')).show(); |
| 1225 |
}); |
| 1226 |
|
| 1227 |
$ul.on('shown.quadmenu.dropdown.slidebar', '> li.quadmenu-item.quadmenu-has-link', function (e) { |
| 1228 |
if ($(this).find('> a').hasClass('click')) { |
| 1229 |
slide_nav_css($(this)); |
| 1230 |
slide_nav.data('slidebar-style', slide_nav.attr('style')); |
| 1231 |
} |
| 1232 |
}); |
| 1233 |
|
| 1234 |
$ul.on('hide.quadmenu.dropdown.slidebar', '> li.quadmenu-item.quadmenu-has-link', function (e) { |
| 1235 |
|
| 1236 |
if ($(this).find('> a').hasClass('click')) { |
| 1237 |
slide_nav_css($current); |
| 1238 |
slide_nav.data('slidebar-style', slide_nav.attr('style')); |
| 1239 |
} |
| 1240 |
}); |
| 1241 |
}, |
| 1242 |
quadmenuInitItemTabs: function (plugin) { |
| 1243 |
|
| 1244 |
plugin = plugin || this; |
| 1245 |
plugin.handleTabs(); |
| 1246 |
$(window).resize($.debounce(600, function () { |
| 1247 |
plugin.handleTabs(); |
| 1248 |
})); |
| 1249 |
}, |
| 1250 |
handleTabs: function (plugin) { |
| 1251 |
|
| 1252 |
plugin = plugin || this; |
| 1253 |
this.$ul.off('shown.quadmenu.dropdown.tabs', '.quadmenu-item-type-tabs'); |
| 1254 |
this.$ul.off('shown.quadmenu.dropdown.tabheight', '.quadmenu-item-type-tab'); |
| 1255 |
this.$ul.find('.quadmenu-item-type-tab > .quadmenu-dropdown-menu > ul').data('quadmenu-maxHeight', false).data('quadmenu-killHover', false); |
| 1256 |
this.$ul.find('.quadmenu-item-type-tab > .quadmenu-dropdown-menu > ul').removeAttr('style'); |
| 1257 |
if (!this.$quadmenu.hasClass('quadmenu-is-horizontal')) |
| 1258 |
return; |
| 1259 |
this.$ul.on('shown.quadmenu.dropdown.tabs', '.quadmenu-item-type-tabs', function (e) { |
| 1260 |
|
| 1261 |
if (!$(e.target).hasClass('quadmenu-item-type-tabs')) |
| 1262 |
return; |
| 1263 |
|
| 1264 |
plugin.openSubmenu($(this).find('.quadmenu-item-type-tab:first')); |
| 1265 |
|
| 1266 |
|
| 1267 |
}); |
| 1268 |
}, |
| 1269 |
handleTabsHeight: function (open) { |
| 1270 |
|
| 1271 |
var $open = $(open), |
| 1272 |
$tabs = $open.closest('.quadmenu-dropdown-menu > ul'); |
| 1273 |
$tabs.css({'min-height': $open.find('> .quadmenu-dropdown-menu > ul').data('quadmenu-maxHeight') + 'px'}); |
| 1274 |
}, |
| 1275 |
getElementOffset: function (element) { |
| 1276 |
|
| 1277 |
var $element = $(element); |
| 1278 |
if (!$element.length) |
| 1279 |
return; |
| 1280 |
if (!$element.is(':visible')) { |
| 1281 |
$element.data('element-style', $element.attr('style')); |
| 1282 |
$element.css({'visibility': 'hidden', 'display': 'block', 'transform': 'none', 'animation': 'none'}); |
| 1283 |
$element.removeAttr('style').attr('style', $element.data('element-style')); |
| 1284 |
} |
| 1285 |
|
| 1286 |
return $element.offset().top; |
| 1287 |
}, |
| 1288 |
quadmenuInitItemCarousel: function (plugin) { |
| 1289 |
|
| 1290 |
plugin = plugin || this; |
| 1291 |
if (typeof $.fn.owlCarousel === 'undefined') |
| 1292 |
return; |
| 1293 |
this.$ul.on('mouseenter.hoverIntent', '.owl-carousel', function () { |
| 1294 |
|
| 1295 |
var $owl = $(this); |
| 1296 |
$owl.trigger('stop.owl.autoplay'); |
| 1297 |
}); |
| 1298 |
this.$ul.on('mouseleave.hoverIntent', '.owl-carousel', function () { |
| 1299 |
|
| 1300 |
var $owl = $(this); |
| 1301 |
if ($(this).data('autoplay') !== 'on') |
| 1302 |
return; |
| 1303 |
$owl.trigger('play.owl.autoplay'); |
| 1304 |
}); |
| 1305 |
this.$ul.on('hide.quadmenu.dropdown.carousel', '.quadmenu-item', function () { |
| 1306 |
|
| 1307 |
var $owl = $(this).find('.owl-carousel'); |
| 1308 |
|
| 1309 |
if (!$owl.length) |
| 1310 |
return; |
| 1311 |
|
| 1312 |
$owl.trigger('stop.owl.autoplay'); |
| 1313 |
$owl.trigger('stop.owl.video'); |
| 1314 |
|
| 1315 |
}); |
| 1316 |
this.$ul.on('shown.quadmenu.dropdown.carousel', '.quadmenu-item', function (e) { |
| 1317 |
// breakes the shown.quadmenu.dropdown event |
| 1318 |
//e.stopPropagation(); |
| 1319 |
|
| 1320 |
var $owl = $(this).find('.owl-carousel'); |
| 1321 |
|
| 1322 |
if ($owl.length) { |
| 1323 |
|
| 1324 |
plugin.handleCarousel($owl, plugin); |
| 1325 |
|
| 1326 |
} |
| 1327 |
|
| 1328 |
}); |
| 1329 |
|
| 1330 |
plugin.handleCarousel(this.$ul.find('.quadmenu-item-level-0 > .owl-carousel'), plugin); |
| 1331 |
|
| 1332 |
}, |
| 1333 |
handleCarousel: function (owl, plugin) { |
| 1334 |
|
| 1335 |
plugin = plugin || this; |
| 1336 |
|
| 1337 |
var $owl = $(owl); |
| 1338 |
|
| 1339 |
$owl.each(function () { |
| 1340 |
|
| 1341 |
var $owl = $(this), |
| 1342 |
speed = parseInt($owl.data('speed')), |
| 1343 |
autoplay = $owl.data('autoplay') === 'on' ? true : false, |
| 1344 |
pagination = $owl.data('pagination') === 'on' ? true : false, |
| 1345 |
dots = $owl.data('dots') === 'on' ? true : false, |
| 1346 |
items = $owl.data('items') || 1, |
| 1347 |
margin = parseInt(plugin.settings.containerGutter / 2), |
| 1348 |
dotsEach = items === 1, |
| 1349 |
autoplay_speed = parseInt($owl.data('autoplay_speed')) + speed; |
| 1350 |
|
| 1351 |
if ($owl.hasClass('owl-loaded')) { |
| 1352 |
$owl.trigger('refresh.owl.carousel'); |
| 1353 |
return; |
| 1354 |
} |
| 1355 |
|
| 1356 |
$owl.owlCarousel({ |
| 1357 |
itemClass: 'quadmenu-item-type-panel', |
| 1358 |
responsive: { |
| 1359 |
0: { |
| 1360 |
items: 1 |
| 1361 |
}, |
| 1362 |
600: { |
| 1363 |
items: Math.min(2, items) |
| 1364 |
}, |
| 1365 |
900: { |
| 1366 |
items: items |
| 1367 |
}, |
| 1368 |
}, |
| 1369 |
//autoWidth: true, |
| 1370 |
loop: true, |
| 1371 |
navText: false, |
| 1372 |
autoplayHoverPause: true, |
| 1373 |
dotsEach: dotsEach, |
| 1374 |
items: items, |
| 1375 |
margin: margin, |
| 1376 |
dots: dots, |
| 1377 |
nav: pagination, |
| 1378 |
smartSpeed: speed, |
| 1379 |
autoplay: autoplay, |
| 1380 |
autoplayTimeout: autoplay_speed, |
| 1381 |
}); |
| 1382 |
}); |
| 1383 |
}, |
| 1384 |
quadmenuInitItemLogIn: function (plugin) { |
| 1385 |
|
| 1386 |
plugin = plugin || this; |
| 1387 |
|
| 1388 |
this.$ul.on('hide.quadmenu.dropdown.login', '.quadmenu-item-type-login', function (e) { |
| 1389 |
|
| 1390 |
var $li = $(this); |
| 1391 |
|
| 1392 |
plugin.handleMouseHover($li.find('> .quadmenu-dropdown-toggle.hoverintent'), plugin); |
| 1393 |
}); |
| 1394 |
|
| 1395 |
this.$ul.on('shown.quadmenu.dropdown.login', '.quadmenu-item-type-login', function (e) { |
| 1396 |
|
| 1397 |
var $li = $(this); |
| 1398 |
|
| 1399 |
$li.find('input').on('click', function () { |
| 1400 |
$li.off('mousemove.hoverIntent'); |
| 1401 |
$li.off('mouseenter.hoverIntent'); |
| 1402 |
$li.off('mouseleave.hoverIntent'); |
| 1403 |
$li.removeProp('hoverIntent_t'); |
| 1404 |
$li.removeProp('hoverIntent_s'); |
| 1405 |
}); |
| 1406 |
|
| 1407 |
$li.find('[data-toggle=form]').on('click', function () { |
| 1408 |
e.preventDefault(); |
| 1409 |
$li.find($(this).data('target')).fadeIn().removeClass('hidden'); |
| 1410 |
$li.find($(this).data('current')).fadeOut().addClass('hidden'); |
| 1411 |
$li.find('> .quadmenu-dropdown-menu > ul').removeData('quadmenu-dropdownHeight'); |
| 1412 |
$li.find('> .quadmenu-dropdown-menu > ul').removeAttr('style'); |
| 1413 |
$li.trigger('shown.quadmenu.dropdown.height'); |
| 1414 |
$li.trigger('shown.quadmenu.dropdown.pscrollbar'); |
| 1415 |
}); |
| 1416 |
plugin.handleForm(e, $li); |
| 1417 |
}); |
| 1418 |
}, |
| 1419 |
handleForm: function (e, li) { |
| 1420 |
|
| 1421 |
var $li = $(li); |
| 1422 |
|
| 1423 |
$li.find('form').on('submit', function (e) { |
| 1424 |
|
| 1425 |
//Prevent default action, so when user clicks button he doesn't navigate away from page |
| 1426 |
if (e.preventDefault) { |
| 1427 |
e.preventDefault(); |
| 1428 |
} else { |
| 1429 |
e.returnValue = false; |
| 1430 |
} |
| 1431 |
|
| 1432 |
var $form = $(this); |
| 1433 |
|
| 1434 |
var $dropdown = $form.closest('.quadmenu-dropdown-menu'), |
| 1435 |
$message = $form.find('.quadmenu-result-message'); |
| 1436 |
// Collect data from inputs |
| 1437 |
$.ajax({ |
| 1438 |
type: 'POST', |
| 1439 |
url: ajaxurl, |
| 1440 |
data: { |
| 1441 |
action: $form.find('input[name=action]').val(), |
| 1442 |
user: $form.find('input[name=quadmenu_username]').val(), |
| 1443 |
pass: $form.find('input[name=quadmenu_pass]').val(), |
| 1444 |
mail: $form.find('input[name=quadmenu_email]').val(), |
| 1445 |
name: $form.find('input[name=quadmenu_name]').val(), |
| 1446 |
nick: $form.find('input[name=quadmenu_nick]').val(), |
| 1447 |
nonce: $form.find('input[name=' + $form.find('input[name=action]').val() + ']').val(), |
| 1448 |
}, |
| 1449 |
beforeSend: function () { |
| 1450 |
$dropdown.addClass('quadmenu-dropdown-mask'); |
| 1451 |
}, |
| 1452 |
complete: function () { |
| 1453 |
setTimeout(function () { |
| 1454 |
$dropdown.removeClass('quadmenu-dropdown-mask'); |
| 1455 |
}, 600); |
| 1456 |
}, |
| 1457 |
success: function (response) { |
| 1458 |
|
| 1459 |
$message.empty().append(response.data); |
| 1460 |
if (response.success === true) { |
| 1461 |
setTimeout(function () { |
| 1462 |
window.location.reload(); |
| 1463 |
}, 200); |
| 1464 |
} |
| 1465 |
}, |
| 1466 |
}); |
| 1467 |
}); |
| 1468 |
}, |
| 1469 |
quadmenuInitItemSocial: function (plugin) { |
| 1470 |
|
| 1471 |
plugin = plugin || this; |
| 1472 |
plugin.handleSocial(); |
| 1473 |
$(window).resize($.debounce(600, function () { |
| 1474 |
plugin.handleSocial(); |
| 1475 |
})); |
| 1476 |
}, |
| 1477 |
handleSocial: function (plugin) { |
| 1478 |
|
| 1479 |
plugin = plugin || this; |
| 1480 |
this.$ul.off('shown.quadmenu.dropdown.social hidden.quadmenu.dropdown.social'); |
| 1481 |
if (!this.$quadmenu.hasClass('quadmenu-is-horizontal')) |
| 1482 |
return; |
| 1483 |
this.$ul.on('shown.quadmenu.dropdown.social', '.quadmenu-item-type-social', function () { |
| 1484 |
plugin.$ul.find('> li.quadmenu-item.quadmenu-item-level-0:not(.quadmenu-item-type-social)').addClass('invisible'); |
| 1485 |
plugin.$ul.find('> li.quadmenu-slidebar').addClass('invisible'); |
| 1486 |
}); |
| 1487 |
this.$ul.on('hidden.quadmenu.dropdown.social', '.quadmenu-item-type-social', function () { |
| 1488 |
plugin.$ul.find('> li.quadmenu-item.quadmenu-item-level-0:not(.quadmenu-item-type-social)').removeClass('invisible'); |
| 1489 |
plugin.$ul.find('> li.quadmenu-slidebar').removeClass('invisible'); |
| 1490 |
}); |
| 1491 |
}, |
| 1492 |
quadmenuInitItemCart: function (plugin) { |
| 1493 |
|
| 1494 |
plugin = plugin || this; |
| 1495 |
|
| 1496 |
var $cart = plugin.$quadmenu.find('li.quadmenu-item-type-cart'); |
| 1497 |
|
| 1498 |
$cart.each(function () { |
| 1499 |
|
| 1500 |
var $li = $(this), |
| 1501 |
url = $li.find('> a').data('cart-url'), |
| 1502 |
animation = $li.find('> a').data('cart-animation'); |
| 1503 |
|
| 1504 |
if (window.location.href === url) { |
| 1505 |
$cart.removeClass('quadmenu-dropdown'); |
| 1506 |
$cart.find('> a').attr('href', 'javascript:void(0)'); |
| 1507 |
} |
| 1508 |
|
| 1509 |
$(document).bind('added_to_cart removed_from_cart edd_quantity_updated', function (e, cart) { |
| 1510 |
|
| 1511 |
$cart.find('.quadmenu-cart-qty', $li).addClass(animation); |
| 1512 |
|
| 1513 |
if (cart !== undefined && $(cart['span.quadmenu-cart-qty']).html() == 0) { |
| 1514 |
$li.addClass('quadmenu-cart-empty'); |
| 1515 |
} else { |
| 1516 |
$li.removeClass('quadmenu-cart-empty'); |
| 1517 |
} |
| 1518 |
|
| 1519 |
setTimeout(function () { |
| 1520 |
$cart.find('.quadmenu-cart-qty', $li).removeClass(animation); |
| 1521 |
}, 500); |
| 1522 |
|
| 1523 |
}); |
| 1524 |
|
| 1525 |
//$(document).bind('added_to_cart removed_from_cart', function (e, cart) { |
| 1526 |
|
| 1527 |
//if (cart !== undefined) { |
| 1528 |
//plugin.handleWooCart(plugin, $li, $(cart['div.widget_shopping_cart_content']), url); |
| 1529 |
//} |
| 1530 |
//}); |
| 1531 |
|
| 1532 |
$(document).bind('edd_quantity_updated', function () { |
| 1533 |
plugin.handleEddCart(plugin, $li, $cart, url); |
| 1534 |
}); |
| 1535 |
|
| 1536 |
}); |
| 1537 |
|
| 1538 |
}, |
| 1539 |
/*handleWooCart: function (plugin, $li, $cart, url) { |
| 1540 |
|
| 1541 |
plugin = plugin || this; |
| 1542 |
|
| 1543 |
var total = $cart.find('.total > .amount').html() || $('.quadmenu-dropdown-toggle', $li).data('cart-price'), |
| 1544 |
the_quantities = $cart.find('.quantity') || 0, |
| 1545 |
qty = 0, |
| 1546 |
numberPattern = /\d+/g; |
| 1547 |
|
| 1548 |
the_quantities.each(function (idx, el) { |
| 1549 |
var qtytext = $(el).html().match(numberPattern); |
| 1550 |
var qtyint = parseInt(qtytext[0]); |
| 1551 |
qty = qty + qtyint; |
| 1552 |
}); |
| 1553 |
|
| 1554 |
plugin.updateCart($li, total, qty, url); |
| 1555 |
|
| 1556 |
},*/ |
| 1557 |
handleEddCart: function (plugin, $li, $cart, url) { |
| 1558 |
|
| 1559 |
plugin = plugin || this; |
| 1560 |
|
| 1561 |
var $edd_cart = $cart.find('.widget_edd_cart_widget'); |
| 1562 |
|
| 1563 |
if (!$edd_cart.length) |
| 1564 |
return; |
| 1565 |
|
| 1566 |
var total = $edd_cart.find('.edd_subtotal .subtotal').html(), |
| 1567 |
qty = $edd_cart.find('.edd-cart-quantity').html(); |
| 1568 |
|
| 1569 |
plugin.updateCart($li, total, qty, url); |
| 1570 |
|
| 1571 |
}, |
| 1572 |
updateCart: function (li, total, qty, url) { |
| 1573 |
|
| 1574 |
var $li = $(li), |
| 1575 |
$total = $li.find('.quadmenu-cart-total'), |
| 1576 |
$qty = $li.find('.quadmenu-cart-qty'); |
| 1577 |
|
| 1578 |
$total.html(total); |
| 1579 |
|
| 1580 |
$qty.html(qty); |
| 1581 |
|
| 1582 |
if (qty > 0) { |
| 1583 |
$li.removeClass('quadmenu-cart-empty'); |
| 1584 |
} else { |
| 1585 |
$li.addClass('quadmenu-cart-empty'); |
| 1586 |
} |
| 1587 |
|
| 1588 |
if (url) { |
| 1589 |
$li.find('> a').attr('href', url); |
| 1590 |
} |
| 1591 |
|
| 1592 |
setTimeout(function () { |
| 1593 |
$qty.removeClass('animate'); |
| 1594 |
}, 1500); |
| 1595 |
}, |
| 1596 |
quadmenuInitItemWidgets: function (plugin) { |
| 1597 |
|
| 1598 |
$(document).on('show.quadmenu.dropdown', function (e) { |
| 1599 |
$(this).find('.widget_media_audio > video, .widget_media_audio > audio').each(function () { |
| 1600 |
this.player.resize(); |
| 1601 |
}); |
| 1602 |
}); |
| 1603 |
|
| 1604 |
$(document).on('hidden.quadmenu.dropdown', function (e) { |
| 1605 |
$(this).find('.widget_media_video video, .widget_media_video audio').each(function () { |
| 1606 |
this.player.pause(); |
| 1607 |
}); |
| 1608 |
}); |
| 1609 |
}, |
| 1610 |
}; |
| 1611 |
$.fn.quadmenu = function (options) { |
| 1612 |
|
| 1613 |
var args = arguments; |
| 1614 |
if (options === undefined || typeof options === 'object') { |
| 1615 |
|
| 1616 |
return this.each(function () { |
| 1617 |
if (!$.data(this, 'plugin_quadmenu')) { |
| 1618 |
$.data(this, 'plugin_quadmenu', new Plugin(this, options)); |
| 1619 |
} |
| 1620 |
}); |
| 1621 |
} else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') { |
| 1622 |
// Cache the method call to make it possible to return a value |
| 1623 |
var returns; |
| 1624 |
this.each(function () { |
| 1625 |
var instance = $.data(this, 'plugin_quadmenu'); |
| 1626 |
// Tests that there's already a plugin-instance and checks that the requested public method exists |
| 1627 |
if (instance instanceof Plugin && typeof instance[options] === 'function') { |
| 1628 |
|
| 1629 |
// Call the method of our plugin instance, and pass it the supplied arguments. |
| 1630 |
returns = instance[options].apply(instance, Array.prototype.slice.call(args, 1)); |
| 1631 |
} |
| 1632 |
|
| 1633 |
// Allow instances to be destroyed via the 'destroy' method |
| 1634 |
if (options === 'destroy') { |
| 1635 |
$.data(this, 'plugin_quadmenu', null); |
| 1636 |
} |
| 1637 |
}); |
| 1638 |
// If the earlier cached method gives a value back return the value, otherwise return this to preserve chainability. |
| 1639 |
return returns !== undefined ? returns : this; |
| 1640 |
} |
| 1641 |
}; |
| 1642 |
})(jQuery, window, document); |
| 1643 |
//console.time('Time'); |
| 1644 |
(function ($) { |
| 1645 |
|
| 1646 |
function quadmenu_init() { |
| 1647 |
$('nav#quadmenu').quadmenu(); |
| 1648 |
} |
| 1649 |
|
| 1650 |
quadmenu_init(); |
| 1651 |
|
| 1652 |
$(window).on('load', function () { |
| 1653 |
quadmenu_init(); |
| 1654 |
}); |
| 1655 |
|
| 1656 |
})(jQuery); |
| 1657 |
//console.timeEnd('Time'); |