我知道这个问题已经被问过很多次了,但是到目前为止,我无法使我的下拉菜单和大型菜单与hoverTimeout一起使用。没有hoverTimeout的菜单就可以了。有人可以看看并提出解决方案吗? 谢谢。
我使用// Taufik Nurrohman超时的JQuery悬停事件
这是我的代码:
// JQuery hover event with timeout by Taufik Nurrohman - https://plus.google.com/108949996304093815163/about
(function(c){c.fn.hoverTimeout=function(d,e,f,g){return this.each(function(){var a=null,b=c(this);b.hover(function(){clearTimeout(a);a=setTimeout(function(){e.call(b)},d)},function(){clearTimeout(a);a=setTimeout(function(){g.call(b)},f)})})}})(jQuery);
$("#bigmag-menu ul li").each(function() {
$(this).hoverTimeout(0, function() {
}, 0, function() {
})
});
$(document).ready(function (e) {
var t = -1,
a = "",
i = "";
e("#bigmag-menu").find("ul").find("li").each(function () {
for (var l = e(this).text(), s = e(this).find("a").attr("href"), n = 0, r = 0; r < l.length && -1 != (n = l.indexOf("_", n)); r++) n++;
if (level = r, level > t && (a += "<ul>", i += "<ul>"), level < t) {
offset = t - level;
for (r = 0; r < offset; r++) a += "</ul></li>", i += "</ul></li>"
}
l = l.replace(/_/gi, ""), a += "<li><a href='" + s + "'>" + l + "</a>", i += "<li><a href='" + s + "'>";
for (r = 0; r < level; r++) i += "";
i += l + "</a>", t = level
});
for (var l = 0; t >= l; l++) a += "</ul>", i += "</ul>", 0 != l && (a += "</li>", i += "</li>");
e("#bigmag-menu .LinkList").html(i), e("#bigmag-menu > .LinkList > ul").attr("id", "bigmag_menu"), e("#bigmag_menu a").map(function () {
var t = e(this).attr("href"); - 1 != (t = t.toLowerCase()).indexOf("[mega menu]") && (e(this).addClass("mega-link"), e(this).attr("href", "/search/label/" + e(this).text() + "?&max-results=" + perPage))
}), selectnav("bigmag_menu"), e("#bigmag-menu ul > li > ul").parent("li").addClass("hasSubmenu"), e("#bigmag-menu .widget").attr("style", "display:block!important;"), e("#bigmag_menu a.mega-link").map(function () {
var t = e(this),
a = t.attr("href");
if (a = a.toLowerCase(), t.hasClass("mega-link")) {
var i = t.text();
e.ajax({
url: "/feeds/posts/default/-/" + i + "?alt=json-in-script&max-results=4",
type: "get",
dataType: "jsonp",
success: function (a) {
t.closest("li").addClass("isMega hasSubmenu");
for (f = 0; f < a.feed.link.length; f++) {
var l = a.feed.link[f],
s = l.rel,
n = l.type;
if ("alternate" == s && "text/html" == n) {
var r = l.href + "?&max-results=" + perPage;
t.attr("href", r)
}
}
var d = a.feed.openSearch$totalResults.$t,
p = a.feed.openSearch$startIndex.$t,
c = a.feed.openSearch$itemsPerPage.$t;
if (d > 4);
else;
var o = Math.ceil(d / c);
if (a.feed.entry) {
var m = "<ul";
m = m + ' data-itemnums="' + c + '" data-label="' + i + '" data-start="' + p + '" data-stages="' + o + '" data-cstage="1" data-tpst="' + d + '"', m += '><div class="mega-nav"><a class="mega-prev disable" href="javascript:;"><i class="fa fa-arrow-left"></i></a><a class="mega-next" href="javascript:;"><i class="fa fa-arrow-right"></i></a></div><div class="bigmag-mega-loading" style="display:none">\t<div class="bigmag-loading-inner"> <div class="bigmag-thecube">\t<div class="bigmag-cube bigmag-c1"></div>\t<div class="bigmag-cube bigmag-c2"></div>\t<div class="bigmag-cube bigmag-c4"></div>\t<div class="bigmag-cube bigmag-c3"></div>\t\t</div></div> </div><div class="mega-inner row-megamenu">';
for (var f = 0; f < a.feed.entry.length; f++) {
var u = a.feed.entry[f];
if (u.media$thumbnail) - 1 !== (g = u.media$thumbnail.url).indexOf("/s72-c") && (g = g.replace("/s72-c", "/s1600")), -1 !== g.indexOf("img.youtube.com") && (g = g.replace("/default.jpg", "/maxresdefault.jpg"));
else var g = "https://3.bp.blogspot.com/-Auu9GFpjt54/W5FBINOr8CI/AAAAAAAAAyA/VF1LcviFSIA1-3SbfNfvmHxckazNcjaXQCLcBGAs/s1600/notfound.png";
for (var h = u.title.$t, x = 0; x < u.link.length; x++)
if ("alternate" == u.link[x].rel) var v = u.link[x].href;
m = m + '<div class="bigmag-mega-item col-megamenu"><div class="bigmag-m-thumb tlrp-thumb" style="background:url(\'' + g + '\')"><a class="linkcover" href="' + v + '"><span class="thumb-overlay"></span></a></div><div class="bigmag-text"><a href="' + v + '">' + h + "</a></div></div>"
}
m += "</div></ul>", t.after(function () {
e(this).after(m);
var t = e(this).closest(".isMega");
t.find(".mega-prev").click(function () {
var t = e(this).closest("ul");
t.find(".bigmag-mega-loading").fadeIn(0);
var a = t.attr("data-label"),
i = Number(t.attr("data-start")),
l = Number(t.attr("data-cstage")),
s = (Number(t.attr("data-stages")), Number(t.attr("data-itemnums")));
if (i -= s, l - 1 <= 1 ? e(this).addClass("disable") : e(this).removeClass("disable"), t.find(".mega-next").removeClass("disable"), l > 1) {
var n = "",
r = "/feeds/posts/default/-/" + a + "?alt=json-in-script&start-index=" + i + "&max-results=" + s;
e.ajax({
url: r,
type: "get",
dataType: "jsonp",
success: function (e) {
if (t.attr("data-start", i), t.attr("data-cstage", l - 1), e.feed.entry) {
for (var a = 0; a < e.feed.entry.length; a++) {
var s = e.feed.entry[a];
if (s.media$thumbnail) - 1 !== (r = s.media$thumbnail.url).indexOf("/s72-c") && (r = r.replace("/s72-c", "/s1600")), -1 !== r.indexOf("img.youtube.com") && (r = r.replace("/default.jpg", "/maxresdefault.jpg"));
else var r = "https://3.bp.blogspot.com/-Auu9GFpjt54/W5FBINOr8CI/AAAAAAAAAyA/VF1LcviFSIA1-3SbfNfvmHxckazNcjaXQCLcBGAs/s1600/notfound.png";
for (var d = s.title.$t, p = 0; p < s.link.length; p++)
if ("alternate" == s.link[p].rel) var c = s.link[p].href;
n = n + '<div class="bigmag-mega-item col-megamenu"><div class="bigmag-m-thumb tlrp-thumb" style="background:url(\'' + r + '\')"><a class="linkcover" href="' + c + '"><span class="thumb-overlay"></span></a></div><div class="bigmag-text"><a href="' + c + '">' + d + "</a></div></div>"
}
t.find(".mega-inner").html(n), setTimeout(function () {
t.find(".bigmag-mega-loading").fadeOut()
}, 1e3)
}
},
error: function (e) {
setTimeout(function () {
t.find(".bigmag-mega-loading").fadeOut()
}, 1e3)
}
})
}
}), t.find(".mega-next").click(function () {
var t = e(this).closest("ul");
t.find(".bigmag-mega-loading").fadeIn(0);
var a = t.attr("data-label"),
i = Number(t.attr("data-start")),
l = Number(t.attr("data-cstage")),
s = Number(t.attr("data-stages")),
n = Number(t.attr("data-itemnums"));
if (i += n, l + 1 == s ? e(this).addClass("disable") : e(this).removeClass("disable"), l >= 1 ? t.find(".mega-prev").removeClass("disable") : t.find(".mega-prev").addClass("disable"), s > l) {
var r = "",
d = "/feeds/posts/default/-/" + a + "?alt=json-in-script&start-index=" + i + "&max-results=" + n;
e.ajax({
url: d,
type: "get",
dataType: "jsonp",
success: function (e) {
if (t.attr("data-start", i), t.attr("data-cstage", l + 1), e.feed.entry) {
for (var a = 0; a < e.feed.entry.length; a++) {
var s = e.feed.entry[a];
if (s.media$thumbnail) - 1 !== (n = s.media$thumbnail.url).indexOf("/s72-c") && (n = n.replace("/s72-c", "/s1600")), -1 !== n.indexOf("img.youtube.com") && (n = n.replace("/default.jpg", "/maxresdefault.jpg"));
else var n = "https://3.bp.blogspot.com/-Auu9GFpjt54/W5FBINOr8CI/AAAAAAAAAyA/VF1LcviFSIA1-3SbfNfvmHxckazNcjaXQCLcBGAs/s1600/notfound.png";
for (var d = s.title.$t, p = 0; p < s.link.length; p++)
if ("alternate" == s.link[p].rel) var c = s.link[p].href;
r = r + '<div class="bigmag-mega-item col-megamenu"><div class="bigmag-m-thumb tlrp-thumb" style="background:url(\'' + n + '\')"><a class="linkcover" href="' + c + '"><span class="thumb-overlay"></span></a></div><div class="bigmag-text"><a href="' + c + '">' + d + "</a></div></div>"
}
t.find(".mega-inner").html(r), setTimeout(function () {
t.find(".bigmag-mega-loading").fadeOut()
}, 1e3)
}
},
error: function (e) {
setTimeout(function () {
t.find(".bigmag-mega-loading").fadeOut()
}, 1e3)
}
})
}
})
})
}
},
error: function (e) {}
})
}
}), e(".FeaturedPost .post-summary").map(function () {
if (e(this).find(".image")) {
var t = e(this).find(".image").attr("src");
e(this).attr("style", "background-image:url(" + t + ");")
}
e(this).append("<div class='overlay'></div>")
})
}),