first commit 2
This commit is contained in:
+90
@@ -0,0 +1,90 @@
|
||||
var cbpHorizontalMenu = (function () {
|
||||
var b = $("#cbp-hrmenu > ul > li"),
|
||||
g = b.children("a"),
|
||||
c = $("body"),
|
||||
d = -1,
|
||||
closeTimer;
|
||||
|
||||
function f() {
|
||||
b.on("mouseenter", a);
|
||||
b.on("mouseleave", e);
|
||||
}
|
||||
|
||||
function a(event) {
|
||||
var currentLink = $(event.currentTarget).children("a");
|
||||
var i = $(event.currentTarget),
|
||||
h = i.index();
|
||||
|
||||
clearTimeout(closeTimer);
|
||||
|
||||
if (d !== -1 && d !== h) {
|
||||
b.eq(d).removeClass("cbp-hropen");
|
||||
}
|
||||
|
||||
i.addClass("cbp-hropen");
|
||||
d = h;
|
||||
}
|
||||
|
||||
function e(event) {
|
||||
var i = $(event.currentTarget);
|
||||
closeTimer = setTimeout(function() {
|
||||
i.removeClass("cbp-hropen");
|
||||
d = -1;
|
||||
}, 300); // 300ms delay to allow for mouse movement within sub-menu
|
||||
}
|
||||
|
||||
return {
|
||||
init: f
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
|
||||
var cbpHorizontalMenu_btm = (function () {
|
||||
var b = $("#cbp-hrmenu-btm > ul > li"),
|
||||
g = b.children("a, button"), // 'a'와 'button'을 모두 선택
|
||||
c = $("body"),
|
||||
d = -1;
|
||||
|
||||
function f() {
|
||||
g.on("click", a);
|
||||
b.on("click", function (h) {
|
||||
h.stopPropagation();
|
||||
});
|
||||
}
|
||||
|
||||
function a(j) {
|
||||
var currentElement = $(j.currentTarget);
|
||||
var i = currentElement.parent("li"),
|
||||
h = i.index();
|
||||
|
||||
var href = currentElement.attr("href");
|
||||
if (href && href !== "#") {
|
||||
// Allow the link to work if it's not "#" or if it's a valid URL
|
||||
return true;
|
||||
}
|
||||
|
||||
if (d !== -1) {
|
||||
b.eq(d).removeClass("cbp-hropen");
|
||||
}
|
||||
|
||||
if (d === h) {
|
||||
i.removeClass("cbp-hropen");
|
||||
d = -1;
|
||||
} else {
|
||||
i.addClass("cbp-hropen");
|
||||
d = h;
|
||||
c.off("click").on("click", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function e(h) {
|
||||
b.eq(d).removeClass("cbp-hropen");
|
||||
d = -1;
|
||||
}
|
||||
|
||||
return {
|
||||
init: f
|
||||
};
|
||||
})();
|
||||
Reference in New Issue
Block a user