(function ($) { $.fn.hoverIntent = function (f, g) { var cfg = { sensitivity: 7, interval: 100, timeout: 0 }; cfg = $.extend(cfg, g ? { over: f, out: g} : f); var cX, cY, pX, pY; var track = function (ev) { cX = ev.pageX; cY = ev.pageY; }; var compare = function (ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) { $(ob).unbind("mousemove", track); ob.hoverIntent_s = 1; return cfg.over.apply(ob, [ev]); } else { pX = cX; pY = cY; ob.hoverIntent_t = setTimeout(function () { compare(ev, ob); }, cfg.interval); } }; var delay = function (ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); ob.hoverIntent_s = 0; return cfg.out.apply(ob, [ev]); }; var handleHover = function (e) { var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget; while (p && p != this) { try { p = p.parentNode; } catch (e) { p = this; } } if (p == this) { return false; } var ev = jQuery.extend({}, e); var ob = this; if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); } if (e.type == "mouseover") { pX = ev.pageX; pY = ev.pageY; $(ob).bind("mousemove", track); if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout(function () { compare(ev, ob); }, cfg.interval); } } else { $(ob).unbind("mousemove", track); if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout(function () { delay(ev, ob); }, cfg.timeout); } } }; return this.mouseover(handleHover).mouseout(handleHover); }; })(jQuery);
(function (a) { a.fn.dcMegaMenu = function (b) { var c = { classParent: "dc-mega", classContainer: "sub-container", classSubParent: "mega-hdr", classSubLink: "mega-hdr", classWidget: "dc-extra", rowItems: 3, speed: "fast", effect: "fade", outEffect: "fade", event: "hover", fullWidth: false, onLoad: function () { }, beforeOpen: function () { }, beforeClose: function () { } }; var b = a.extend(c, b); var d = this; return d.each(function (b) { function j() { var b = a(".sub", this); a(this).addClass("mega-hover"); if (c.effect == "fade") { a(b).fadeIn(c.speed) } if (c.effect == "slide") { a(b).show(c.speed) } if (c.effect == "slideDown") { a(b).slideDown(c.speed) } c.beforeOpen.call(this) } function k(b) { var d = a(".sub", b); a(b).addClass("mega-hover"); if (c.effect == "fade") { a(d).fadeIn(c.speed) } if (c.effect == "slide") { a(d).show(c.speed) } if (c.effect == "slideDown") { a(d).slideDown(c.speed) } c.beforeOpen.call(this) } function l() { var b = a(".sub", this); a(this).removeClass("mega-hover"); if (c.outEffect == "fade") { a(b).fadeOut(c.speed) } if (c.outEffect == "slide") { a(b).hide(c.speed) } if (c.outEffect == "slideUp") { a(b).slideUp(c.speed) } c.beforeClose.call(this) } function m(b) { var d = a(".sub", b); a(b).removeClass("mega-hover"); if (c.outEffect == "fade") { a(d).fadeOut(c.speed) } if (c.outEffect == "slide") { a(d).hide(c.speed) } if (c.outEffect == "slideUp") { a(d).slideUp(c.speed) } c.beforeClose.call(this) } function n() { a("li", d).removeClass("mega-hover"); a(".sub", d).hide() } function o() { $arrow = '<span class="dc-mega-icon"></span>'; var b = g + "-li"; var o = d.outerWidth(); a("> li", d).each(function () { var j = a("> ul", this); var k = a("> a", this); if (j.length) { k.addClass(g).append($arrow); j.addClass("sub").wrap('<div class="' + h + '" />'); var l = a(this).position(); pl = l.left; if (a("ul", j).length) { a(this).addClass(b); a("." + h, this).addClass("mega"); a("> li", j).each(function () { if (!a(this).hasClass(i)) { a(this).addClass("mega-unit"); if (a("> ul", this).length) { a(this).addClass(e); a("> a", this).addClass(e + "-a") } else { a(this).addClass(f); a("> a", this).addClass(f + "-a") } } }); var m = a(".mega-unit", this); rowSize = parseInt(c.rowItems); for (var n = 0; n < m.length; n += rowSize) { m.slice(n, n + rowSize).wrapAll('<div class="row" />') } j.show(); var p = a(this).width(); var q = pl + p; var r = o - q; var s = j.outerWidth(); var t = j.parent("." + h).outerWidth(); var u = t - s; if (c.fullWidth == true) { var v = o - u; j.parent("." + h).css({ width: v + "px" }); d.addClass("full-width") } var w = a(".mega-unit", j).outerWidth(true); var x = a(".row:eq(0) .mega-unit", j).length; var y = w * x; var z = y + u; a(".row", this).each(function () { a(".mega-unit:last", this).addClass("last"); var b = undefined; a(".mega-unit > a", this).each(function () { var c = parseInt(a(this).height()); if (b === undefined || b < c) { b = c } }); a(".mega-unit > a", this).css("height", b + "px"); a(this).css("width", y + 15 + "px") }); if (c.fullWidth == true) { C = { left: 0 } } else { var A = r < A ? A + A - r : (z - p) / 2; var B = pl - A; var C = { left: pl + "px", marginLeft: -A + "px" }; if (B < 0) { C = { left: 0 } } else if (r < A) { C = { right: 0 } } } a("." + h, this).css(C); a(".row", j).each(function () { var b = a(this).height(); a(".mega-unit", this).css({ height: b + "px" }); a(this).parent(".row").css({ height: b + "px" }) }); j.hide() } else { a("." + h, this).addClass("non-mega").css("left", pl - 70 + "px") } } }); var p = a("> li > a", d).outerHeight(true); a("." + h, d).css({ top: p + "px" }).css("z-index", "1000"); if (c.event == "hover") { var q = { sensitivity: 2, interval: 100, over: j, timeout: 400, out: l }; a("li", d).hoverIntent(q) } if (c.event == "click") { a("body").mouseup(function (b) { if (!a(b.target).parents(".mega-hover").length) { n() } }); a("> li > a." + g, d).click(function (b) { var c = a(this).parent(); if (c.hasClass("mega-hover")) { m(c) } else { k(c) } b.preventDefault() }) } c.onLoad.call(this) } var e = c.classSubParent; var f = c.classSubLink; var g = c.classParent; var h = c.classContainer; var i = c.classWidget; o() }) } })(jQuery)
