我有一个客户端,该客户端提供了具有下拉功能的自定义标头,它显然需要链接jquery-2.2.3.min.js才能正常工作,因为没有它,单击时它不会扩展。当我确实加载jquery-2.2.3.min.js时,它破坏了站点中大量的其他功能,而这些功能我无法允许发生。当我用jQuery替换$时,我仍然没有运气。我对解决这样的问题太缺乏经验了。任何帮助将不胜感激。下面是他们提供的脚本。该站点的链接为http://hdefirstresponder.com,由于存在许多问题,该链接目前未链接jquery-2.2.3.min.js。
var brandsHeaderLink = $(".emerson-brands-header > a");
var utilNav = $(".utility-navigation");
var footerNav = $(".emerson-brands > .brands-menu");
var expandedClass = 'expanded';
var firstLoadClass = 'first-load';
var fullCollapseClass = 'full-collapse';
var cookieName = "EmersonBrandsBannerCookie";
var cookies = document.cookie.split(';');
var cookieFound = false;
//Banner is to be displayed for 5 seconds before dropping a cookie
//banner will be hidden if the cookie is present
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i];
if (cookie.indexOf(cookieName) >= 0) {
cookieFound = true;
break;
}
}
if (!cookieFound) {
brandsHeaderLink.addClass(expandedClass);
utilNav.addClass(firstLoadClass);
utilNav.addClass(expandedClass);
setTimeout(function() {
utilNav.removeClass(firstLoadClass);
brandsHeaderLink.removeClass(expandedClass);
utilNav.removeClass(expandedClass);
var date = new Date((Math.pow(2, 31) - 1) * 1000);
var expires = "expires=" + date.toGMTString();
var domain = "domain=" + location.hostname + ";path=/";
document.cookie = cookieName + "=" + true + "; " + domain + "; " + expires;
}, 5000);
}
(function () {
$(function () {
var updatePushpin = function () {
$("#layout-jump").pushpin('remove');
if ($(".hide-on-large-only").css("display") === "none") {
$("#layout-jump").pushpin({
top: 5
});
}
};
updatePushpin();
$(window).bind("orientationchange resize", updatePushpin);
brandsHeaderLink.on("click", function (e) {
e.preventDefault();
brandsHeaderLink.toggleClass(expandedClass);
utilNav.toggleClass(expandedClass);
utilNav.removeClass(firstLoadClass);
footerNav.toggleClass("hidden"); //hidden is a css class with display: none
});
var previousPosistion;
$(document).on("scroll", function () {
var currentPosistion = $(window).pageYOffset || $(document).scrollTop();
if (currentPosistion > previousPosistion) {
utilNav.addClass(fullCollapseClass);
}
else if (currentPosistion < previousPosistion) {
utilNav.removeClass(fullCollapseClass);
}
previousPosistion = currentPosistion;
});
});
})();