;
(function ($) {
$.fn.extend({
"scrollBar": function (options) {
var settings = {
barWidth: 5,
position: "x,y",
wheelDis: 15
};
options = $.extend(settings, options);
var direction = $("html").hasClass("LANG-sa") ? "left" : "right";
if(direction == 'left'){
settings.direction = 0;
}
var horizontalDiv = '
';
var verticalDiv = '';
var T = this;
/**
* 将每个div的padding值保存到自定义属性中
*/
T.each(function () {
$(this).attr("paddingR", $(this).css("padding-right")).attr("paddingB", $(this).css("padding-bottom"));
});
/**
*
*创建滚动条的函数
*/
function creatScrollBar(obj) {
var This = $(obj).get(0); //转化为JS对象,增加运行效率
var paddingR = parseFloat($(obj).attr("paddingR"));
var paddingB = parseFloat($(obj).attr("paddingB"));
$(obj).css({
"padding-right": paddingR + "px",
"padding-bottom": paddingB + "px",
"overflow": "hidden"
});
//获取内容的总高度和总宽度
if (!($(obj).children().hasClass("scrollContentDiv"))) {
(baseLib.browserVersion() == "ios" || baseLib.browserVersion() == "android") ? $(obj).wrapInner(''): $(obj).wrapInner('');
};
if ($(obj).css("position") == "static") {
$(obj).css({
"position": "relative"
});
};
var scrollContentDiv = $(obj).find(".scrollContentDiv");
var scrollH = scrollContentDiv[0].scrollHeight;
var scrollW = scrollContentDiv[0].scrollWidth;
var innerH = scrollContentDiv.height();
var innerW = scrollContentDiv.width();
var outerH = $(obj).innerHeight();
var outerW = $(obj).innerWidth();
function addVerticalBar(a) {
if (baseLib.browserVersion() == 6) {
This.style.paddingRight = paddingR + settings.barWidth + "px";
} else {
//This.style.paddingRight = (paddingR + settings.barWidth == 5 ? 0 : paddingR + settings.barWidth) + "px";
}
innerH = $(a).height();
var barHeight = outerH * (innerH / scrollH);
$(a).find(".scrollBarBox").remove().end().append(verticalDiv).find(".verticalBar").height(barHeight);
};
function addHorizontalBar(a) {
This.style.paddingBottom = paddingB + settings.barWidth + 'px';
innerW = $(a).width();
var barWidth = outerW * (innerW / scrollW);
$(a).find(".scrollBarBox").remove().end().append(horizontalDiv).find(".horizontalBar").width(barWidth);
};
switch (settings.position) {
case "x,y":
if (scrollH > innerH && scrollW > innerW) {
This.style.paddingRight = paddingR + settings.barWidth + 'px';
innerH = $(obj).height();
outerH = $(obj).innerHeight();
var barHeight = (outerH - settings.barWidth) * ((innerH - settings.barWidth) / scrollH);
if (!($(obj).find(".verticalBar").length)) {
$(obj).append(verticalDiv);
};
$(obj).find(".verticalBar").height(barHeight).parent().height(outerH - settings.barWidth);
This.style.paddingBottom = paddingB + settings.barWidth + 'px';
innerW = $(obj).width();
var barWidth = (outerW - settings.barWidth) * ((innerW - settings.barWidth) / scrollW);
if (!($(obj).find(".horizontalBar").length)) {
$(obj).append(horizontalDiv);
};
$(obj).find(".horizontalBar").width(barWidth).parent().width(outerW)
.css({
"padding-right": settings.barWidth + "px",
"box-sizing": "border-box"
});
} else if (scrollH > innerH) {
addVerticalBar(obj);
} else if (scrollW > innerW) {
addHorizontalBar(obj);
} else {
$(obj).find(".scrollBarBox").remove();
}
break;
case "x":
if (scrollW > innerW) {
addHorizontalBar(obj);
} else {
$(obj).find(".scrollBarBox").remove();
}
break;
case "y":
if (scrollH > innerH) {
addVerticalBar(obj);
} else {
$(obj).find(".scrollBarBox").remove();
}
break;
};
}
/**
* 循环给每一个Div添加
*/
function recycleThis() {
T.each(function () {
creatScrollBar(this);
});
};
recycleThis(); //执行循环
/**
*创建监听div内容变化的定时器
*/
function creatTimer(obj, oldWidth, oldHeight, oldInnerWidth, oldInnerHeight, timer) {
timer = setInterval(function () {
var newWidth = null;
var newHeight = null;
var newInnerWidth = null;
var newInnerHeight = null;
var topDiv = null;
var leftDiv = null;
var topBar = null;
var leftBar = null;
var scrollContentDiv = $(obj).find(".scrollContentDiv");
if (scrollContentDiv.length) {
newWidth = scrollContentDiv[0].scrollWidth;
newHeight = scrollContentDiv[0].scrollHeight;
newInnerWidth = scrollContentDiv.width();
newInnerHeight = scrollContentDiv.height();
} else {
newWidth = $(obj)[0].scrollWidth - parseFloat($(obj).css("padding-left"));
newHeight = $(obj)[0].scrollHeight - parseFloat($(obj).css("padding-top"));
newInnerWidth = $(obj).width();
newInnerHeight = $(obj).height();
};
if (newWidth != oldWidth || newHeight != oldHeight || newInnerWidth != oldInnerWidth || newInnerHeight != oldInnerHeight) {
//记录更新滚动条长短前的位置
if (scrollContentDiv.length) {
topDiv = parseFloat(scrollContentDiv.css("top"));
leftDiv = parseFloat(scrollContentDiv.css("left"));
};
if ($(obj).find(".verticalBar").length) {
topBar = parseFloat($(obj).find(".verticalBar").css("top"));
};
if ($(obj).find(".horizontalBar").length) {
leftBar = parseFloat($(obj).find(".horizontalBar").css("left"));
};
//更新滚动条长短或有无
creatScrollBar(obj);
if ($(obj).find(".scrollBarBox").length) {
if (topDiv) {
var maxTopBox = scrollContentDiv[0].scrollHeight - $(obj).height();
var maxLeftBox = scrollContentDiv[0].scrollWidth - $(obj).width();
if (-leftDiv > maxLeftBox) {
leftDiv = -maxLeftBox;
}
if (-topDiv > maxTopBox) {
topDiv = -maxTopBox;
}
scrollContentDiv.css({
"left": leftDiv + 'px',
"top": topDiv + 'px'
});
};
//将原来的位置赋值给现在的滚动条
if (topBar && $(obj).find(".verticalBar").length) {
var verticalBar = $(obj).find(".verticalBar");
var maxTop = verticalBar.parent().height() - verticalBar.height();
if (topBar > maxTop) {
topBar = maxTop;
}
verticalBar.css("top", topBar + 'px');
};
if (leftBar && $(obj).find(".horizontalBar").length) {
var horizontalBar = $(obj).find(".verticalBar");
var maxLeft = horizontalBar.parent().width() - horizontalBar.width();
if (leftBar > maxLeft) {
leftBar = maxLeft;
}
$(obj).find(".horizontalBar").css("left", leftBar + 'px');
};
}
oldWidth = newWidth;
oldHeight = newHeight;
oldInnerHeight = newInnerHeight;
oldInnerWidth = newInnerWidth;
}
}, 100);
}
/**
* 通过循环给每一个div添加上监听内容变化的定时器
*/
function addTimer() {
$.each(T, function (k, v) {
var obj = v;
var timer = "timer" + k;
var oldWidth = null;
var oldHeight = null;
var oldInnerWidth = null;
var oldInnerHeight = null;
if ($(v).find(".scrollContentDiv").length) {
oldWidth = $(v).find(".scrollContentDiv")[0].scrollWidth;
oldHeight = $(v).find(".scrollContentDiv")[0].scrollHeight;
oldInnerWidth = $(v).find(".scrollContentDiv").width();
oldInnerHeight = $(v).find(".scrollContentDiv").height();
} else {
oldWidth = $(obj)[0].scrollWidth - parseFloat($(obj).css("padding-left"));
oldHeight = $(obj)[0].scrollHeight - parseFloat($(obj).css("padding-top"));
oldInnerWidth = $(obj).width();
oldInnerHeight = $(obj).height();
}
creatTimer(obj, oldWidth, oldHeight, oldInnerWidth, oldInnerHeight, timer);
});
}
addTimer();
function clearTimer() {
$.each(T, function (index, item) {
var timer = "timer" + index;
clearInterval(timer);
});
};
/**
* 滚动条拖拽效果
*/
this.on("mousedown", ".scrollBar", function (ev) {
clearTimer(); //清除定时器
var direction = null;
if ($(this).hasClass("verticalBar")) {
direction = "0";
} else if ($(this).hasClass("horizontalBar")) {
direction = "1";
}
var This = $(this).get(0);
var height = $(this).parent().height() - $(this).height();
var width = $(this).parent().width() - $(this).width();
var contentDiv = $(this).parent().parent().find(".scrollContentDiv").get(0);
var scrollH = contentDiv.scrollHeight;
var innerH = $(this).parent().parent().height();
var scrollW = contentDiv.scrollWidth;
var innerW = $(this).parent().parent().width();
var ev = ev || event;
var disY = ev.clientY - This.offsetTop;
var disX = ev.clientX - This.offsetLeft;
var topCount = null;
var leftCount = null;
switch (direction) {
case "0":
document.onmousemove = function (ev) {
var ev = ev || event;
if (ev.clientY - disY <= 0) {
topCount = 0;
} else
if ((ev.clientY - disY) >= height) {
topCount = height;
} else {
topCount = ev.clientY - disY;
}
This.style.top = topCount + "px";
contentDiv.style.top = -(topCount * (scrollH - innerH) / height) + 'px';
};
break;
case "1":
document.onmousemove = function (ev) {
var ev = ev || event;
if (ev.clientX - disX <= 0) {
leftCount = 0;
} else
if ((ev.clientX - disX) >= width) {
leftCount = width;
} else {
leftCount = ev.clientX - disX;
}
This.style.left = leftCount + "px";
contentDiv.style.left = -(leftCount * (scrollW - innerW) / width) + 'px';
};
break;
}
document.onmouseup = function () {
document.onmousemove = null;
document.onmouseup = null;
addTimer(); //添加定时器
};
return false;
});
/**
*鼠标滚轮效果
*/
function fn(ev, a) {
if (a.find(".verticalBar").length) {
var b = true;
var height = a.find(".scrollBarBox").height() - a.find(".scrollBar").height();
var contentDiv = a.find(".scrollContentDiv").get(0);
var scrollH = contentDiv.scrollHeight;
var innerH = a.height();
if (ev.wheelDelta) {
b = ev.wheelDelta > 0 ? true : false;
} else {
b = ev.detail < 0 ? true : false;
}
var topDis = parseFloat(a.find(".scrollBar").css("top"));
if (b) {
topDis -= settings.wheelDis;
if (topDis < 0) {
topDis = 0;
}
} else {
topDis += settings.wheelDis;
if (topDis > height) {
topDis = height;
}
}
a.find(".scrollBar").get(0).style.top = topDis + "px";
a.find(".scrollContentDiv").get(0).style.top = -(topDis * (scrollH - innerH) / height) + 'px';
}
};
T.each(function () {
var oDiv = $(this).get(0);
if (oDiv.addEventListener) {
oDiv.addEventListener("DOMMouseScroll", function (ev) {
var ev = ev || event;
var $This = $(this);
fn(ev, $This);
ev.preventDefault();
}, false);
}
oDiv.onmousewheel = function (ev) {
if (baseLib.browserVersion() == "ios" || baseLib.browserVersion() == "android") return false;
var ev = ev || event;
var $This = $(this);
fn(ev, $This);
return false;
};
});
return this;
}
});
})(jQuery);
//v2版头部
Base.prototype.v2HeadFun = function () {
// 展开搜索
var win_W = $(window).width();
if (win_W > 920) {
$('.zl-pc-search-icon').on('click', function (event) {
event.stopPropagation();
$('.zl-pc-nav').addClass('narrow');
$('.zl-pc-searching-box').addClass('searching');
$('#txtSearch_Navigation').val($('#txtSearch_Navigation').next('.inputInfohint').val());
$(this).fadeOut();
})
} else {
$('.zl-pc-search-icon').on('click', function (event) {
event.stopPropagation();
$('.zl-pc-searching-box').addClass('wap-searching');
$(this).fadeOut();
})
};
// 关闭搜索
if (win_W > 920) {
$('.zl-pc-searching-box-close').on('click', function (event) {
event.stopPropagation();
$('.zl-pc-nav').removeClass('narrow');
$('.zl-pc-searching-box').removeClass('searching');
$('.zl-pc-search-icon').fadeIn();
$('.zl-pc-searching-tip').fadeOut();
})
} else {
$('.zl-pc-searching-box-close').on('click', function (event) {
event.stopPropagation();
$('.zl-pc-nav').removeClass('narrow');
$('.zl-pc-searching-box').removeClass('wap-searching');
$('.zl-pc-search-icon').fadeIn();
$('.zl-pc-searching-tip').fadeOut();
})
};
// 阻止事件,i6及ipad上点击input自动收起
$('.zl-pc-searching-box').click(function (event) {
event.stopPropagation();
});
$('.zl-pc-searching-box .nav-searchbit-text').click(function (event) {
event.stopPropagation();
});
// 鼠标放在products上,页面bg移动
$('.zl-pc-nav-column-li').on('mouseout', function () {
$('.zl-pc-nav-industry-box .pic').css({
"-webkit-transform": "matrix(1,0,0,1,0,0)",
"-moz-transform": "matrix(1,0,0,1,0,0)",
"-o-transform": "matrix(1,0,0,1,0,0)",
"transform": "matrix(1,0,0,1,0,0)"
});
})
$('.zl-pc-nav-products,.zl-pc-nav-column-li').on('mousemove', function (event) {
event.stopPropagation();
var newX = -event.clientX / 60;
var newY = event.clientY / 40;
$('.zl-pc-nav-industry-box .pic').css({
"-webkit-transform": "matrix(1,0,0,1," + newX + "," + newY + ")",
"-moz-transform": "matrix(1,0,0,1," + newX + "," + newY + ")",
"-o-transform": "matrix(1,0,0,1," + newX + "," + newY + ")",
"transform": "matrix(1,0,0,1," + newX + "," + newY + ")"
});
})
// 等高
setTimeout(function () {
baseLib.contourFun(".zl-pc-nav-products", ".con", ".setheight", 768);
baseLib.contourFun(".zl-pc-nav-supportbyproduct", ".con", ".setheight", 768);
baseLib.contourFun(".zl-pc-nav-services ul", "li", "a", 1024);
baseLib.contourFun(".zl-pc-nav-docymentation ul", "li", "a", 1024);
baseLib.contourFun("ul.zl-pc-nav-textul", "li", "a", 1024);
}, 1000);
//登录提示框相关事件
$(".zl-pc-login-icon").on("hover", function (event) {
event.stopPropagation();
if ($('#noshow_myspace').prop('checked')) {
$.cookie('SpaceTimes', "no_notice", {
expires: 90,
path: '/'
});
}
if ($(".zl-pc-logined-tip").length > 0) $(".zl-pc-logined-tip").hide();
});
$("body").on("click", function (event) {
if ($('#noshow_myspace').prop('checked')) {
$.cookie('SpaceTimes', "no_notice", {
expires: 90,
path: '/'
});
}
if ($(".zl-pc-logined-tip").length > 0) $(".zl-pc-logined-tip").hide();
if ($('.zl-pc-searching-box').hasClass('searching') || $('.zl-pc-searching-box').hasClass('wap-searching')) {
$(".zl-pc-searching-box-close").trigger("click");
}
});
$(".nav-quick").on("hover", function (event) {
event.stopPropagation();
if ($('#noshow_myspace').prop('checked')) {
$.cookie('SpaceTimes', "no_notice", {
expires: 90,
path: '/'
});
}
if ($(".zl-pc-logined-tip").length > 0) $(".logined-tip").hide();
});
$(".zl-pc-logined-tip").on("click", function (event) {
event.stopPropagation();
});
var zlPcTimeOutKey;
$(window).scroll(function () {
if ($('.zl-pc-header').data("scroll-lock")) {
return;
}
clearTimeout(zlPcTimeOutKey);
zlPcTimeOutKey = setTimeout(function () {
$(".zl-pc-header .zl-pc-nav-con").attr("style", "");
}, 200);
if (baseLib.browserVersion() === "ios" && window.scrollY < "40") {
return false;
} else {
if ($('.zl-pc-searching-box').hasClass('searching') || $('.zl-pc-searching-box').hasClass('wap-searching')) {
$(".zl-pc-searching-box-close").trigger("click");
}
}
var t = $(document).scrollTop();
// 判断头部是否显示声明20171116
var h = $('.zl-pc-header-box').offset() && $('.zl-pc-header-box').offset().top || 0;
if (t > h) {
$('.zl-pc-header').css({
'position': 'fixed'
});
} else {
$('.zl-pc-header').css({
'position': 'relative'
});
};
$('.zl-pc-nav-column-li.current').removeClass('current');
});
$(".zl-pc-nav-con").click(function (event) {
event.stopPropagation();
});
// IE8,IE9 导航延时效果导航hover效果
var headTimer, headerOutTimer, delayTimer,
delayTime = 100,
dx = 0,
dy = 0,
$ul = $(".zl-pc-nav-column-ul");
if (baseLib.browserVersion() < 12 || baseLib.browserVersion() == 'Edge') {
delayTime = 400;
}
$ul.on("mouseenter", '.zl-pc-nav-column-li', function (e) {
showHover($(this));
}).on("mouseleave", function () {
clearTimeout(headTimer);
clearTimeout(headerOutTimer);
headerOutTimer = setTimeout(function () {
$('.zl-pc-nav-column-li').removeClass('current');
}, 250)
});
$ul.find(".zl-pc-nav-column-li").on("mousemove", function (e) {
var _this = $(this);
if ((Math.abs(e.pageX - dx) > 6 || Math.abs(e.pageY - dy) > 6) && !_this.hasClass("current") && $ul.find(".zl-pc-nav-column-li.current").length != 0) {
dx = e.pageX;
dy = e.pageY;
showHover(_this);
}
});
function showHover(_this) {
clearTimeout(headTimer);
clearTimeout(headerOutTimer);
headTimer = setTimeout(function () {
// $('.zl-pc-nav-con').css('top', 68);
$('.lazyload img', this).trigger("appear");
_this.addClass('current').siblings().removeClass('current');
}, delayTime);
$('.zl-pc-nav-industry-box .lazyload img').trigger("appear");
}
// 搜索添加热搜块和历史搜索,失去焦点搜索框消失
$("#txtSearch_Navigation").on("focus input propertychange", function (event) {
event.stopPropagation();
if ($(this).val() == "" || $(this).val() == $(".zl-pc-searching-box .inputInfohint").val()) {
$(".zl-pc-searching-tip").show();
} else {
if ($(".zl-pc-searching-tip").siblings("ul").length > 0 && !$(".zl-pc-searching-tip").siblings("ul").is(":hidden")) {
$(".zl-pc-searching-tip").hide();
}
}
});
}
// v4版头部
Base.prototype.v4HeadFun = function () {
if (!(baseLib.browserVersion() == "ios" || baseLib.browserVersion() == "android")) {
$(".big-box").addClass("PC");
}
// ie10 特有样式
function ie10Compatible() {
if (window.ActiveXObject) {
var reg = /10\.0/;
var str = navigator.userAgent;
//reg.test(str);
if (reg.test(str)) {
$(".headerNew .pc-nav-box #puppetBtn").css({
"margin-left": "-10px",
"margin-right": "40px"
})
};
};
}
ie10Compatible();
$(window).resize(function () {
if ($(window).width() <= 993) {
$("#puppetBtn").removeAttr("style");
ie10Compatible();
if ($(".ic-pc-nav").css("display") == "block") {
$('.zl-pc-nav').removeClass('narrow');
$('.zl-pc-searching-box').removeClass('searching');
$('.zl-pc-search-icon').fadeIn();
$('#txtSearch_Navigation').val($('#txtSearch_Navigation').next('.inputInfohint').val());
$('.zl-pc-searching-tip').fadeOut();
$(".zl-pc-searching-box-close").hide();
fnCollapse();
} else {
if ($(".zl-pc-search-icon").css("display") == "none") {
$(".zl-pc-search-icon").removeAttr("style");
}
}
} else {
if ($(".ic-pc-nav").css("display") == "none") {
if ($(".zl-pc-search-icon").css("display") == "none") {
$(".zl-pc-search-icon").show();
}
if ($("#puppetBtn").css("display") == "none") {
$("#puppetBtn").removeAttr("style");
ie10Compatible();
}
}
}
});
// 展开搜索
var win_W = $(window).width();
var closeShow;
$('.zl-pc-search-icon').on('click', function (event) {
if (win_W > 992) {
event.stopPropagation();
$('.zl-pc-nav').addClass('narrow');
$('.zl-pc-searching-box').addClass('searching');
$('#txtSearch_Navigation').val($('#txtSearch_Navigation').next('.inputInfohint').val());
$(this).fadeOut();
closeShow = setTimeout(function () {
$(".zl-pc-searching-box-close").show();
}, 500);
fnUnfold($(".big-box>#plate1 ul:first li:first"));
// 图片懒加载
$('.zl-pc-header-box img').trigger("appear");
} else {
$('.zl-pc-searching-box').addClass('wap-searching');
$(this).fadeOut();
}
})
// 关闭搜索
$('.zl-pc-searching-box-close').on('click', function (event) {
event.stopPropagation();
if (win_W > 992) {
clearTimeout(closeShow);
$('.zl-pc-nav').removeClass('narrow');
$('.zl-pc-searching-box').removeClass('searching');
$('.zl-pc-search-icon').fadeIn();
$('.zl-pc-searching-tip').fadeOut();
$(".zl-pc-searching-box-close").hide();
$("#puppetBtn").removeAttr("style");
ie10Compatible();
fnCollapse();
} else {
$('.zl-pc-nav').removeClass('narrow');
$('.zl-pc-searching-box').removeClass('wap-searching');
$('.zl-pc-search-icon').fadeIn();
$('.zl-pc-searching-tip').fadeOut();
}
})
// 阻止事件,i6及ipad上点击input自动收起
$('.zl-pc-searching-box').click(function (event) {
event.stopPropagation();
});
$('.zl-pc-searching-box .nav-searchbit-text').click(function (event) {
event.stopPropagation();
});
//登录提示框相关事件
$(".zl-pc-login-icon").on("hover", function (event) {
event.stopPropagation();
if ($('#noshow_myspace').prop('checked')) {
$.cookie('SpaceTimes', "no_notice", {
expires: 90,
path: '/'
});
}
if ($(".zl-pc-logined-tip").length > 0) $(".zl-pc-logined-tip").hide();
});
$("body").on("click", function (event) {
if ($('#noshow_myspace').prop('checked')) {
$.cookie('SpaceTimes', "no_notice", {
expires: 90,
path: '/'
});
}
if ($(".zl-pc-logined-tip").length > 0) $(".zl-pc-logined-tip").hide();
if ($('.zl-pc-searching-box').hasClass('searching') || $('.zl-pc-searching-box').hasClass('wap-searching')) {
$(".zl-pc-searching-tip").hide();
}
});
$(".nav-quick").on("hover", function (event) {
event.stopPropagation();
if ($('#noshow_myspace').prop('checked')) {
$.cookie('SpaceTimes', "no_notice", {
expires: 90,
path: '/'
});
}
if ($(".zl-pc-logined-tip").length > 0) $(".logined-tip").hide();
});
$(".zl-pc-logined-tip").on("click", function (event) {
event.stopPropagation();
});
var zlPcTimeOutKey;
$(window).scroll(function () {
if ($('.zl-pc-header').data("scroll-lock")) {
return;
}
clearTimeout(zlPcTimeOutKey);
zlPcTimeOutKey = setTimeout(function () {
$(".zl-pc-header .zl-pc-nav-con").attr("style", "");
}, 200);
// if (baseLib.browserVersion() === "ios" && window.scrollY < "40") {
// return false;
// } else {}
var t = $(document).scrollTop();
// 判断头部是否显示声明20171116
var h = $('.zl-pc-header-box').offset() && $('.zl-pc-header-box').offset().top || 0;
if (t > h) {
$('.zl-pc-header').css({
'position': 'fixed'
});
} else {
$('.zl-pc-header').css({
'position': 'relative'
});
};
$('.zl-pc-nav-column-li.current').removeClass('current');
});
// 搜索添加热搜块和历史搜索,失去焦点搜索框消失
$("#txtSearch_Navigation").on("focus", function (event) {
// input propertychange
event.stopPropagation();
if ($(this).val() == "" || $(this).val() == $(".zl-pc-searching-box .inputInfohint").val()) {
$(".zl-pc-searching-tip").show();
} else {
if ($(".zl-pc-searching-tip").siblings("ul").length > 0 && !$(".zl-pc-searching-tip").siblings("ul").is(":hidden")) {
$(".zl-pc-searching-tip").hide();
}
}
})
// .on("blur focusout", function () {
// //判断是否该隐藏搜索提示框
// if ($(".zl-pc-searching-tip").siblings("ul").length == 0) {
// $(".zl-pc-searching-tip").hide();
// }
// })
if (win_W > 992) {
//主按钮点击
$("#puppetBtn").on("click", function (event) {
event.stopPropagation();
$(".zl-pc-search-icon").hide();
$("#puppetBtn").hide();
$('.zl-pc-nav').addClass('narrow');
$('.zl-pc-searching-box').addClass('searching');
$('#txtSearch_Navigation').val($('#txtSearch_Navigation').next('.inputInfohint').val());
closeShow = setTimeout(function () {
$(".zl-pc-searching-box-close").show();
}, 500);
fnUnfold($(".big-box>#plate1 ul:first li:first"));
// 图片懒加载
$('.zl-pc-header-box img').trigger("appear");
});
//nav板块 离开后 nav关闭 多次click会触发
// $(".pc-nav-box").on("mouseleave", function (event) {
// event.stopPropagation();
// //兼容谷歌click会触发mouseleave
// if (event.relatedTarget || event.toElement) {
// //判断nav 是否打开
// if ($(".ic-pc-nav").css("display") == "block") fnCollapse();
// }
// });
}
//默认选择第一个ul和li
$(".big-box #plate1,.big-box #plate2").on("click", "li", function (event) {
event.stopPropagation();
var thisHref = $(this).children("a").attr("href");
if (thisHref != "javascript:;" && thisHref != "javascript:void(0)" && thisHref == "undefined" && thisHref == false) return;
plateclick($(this));
});
//跳到菜单指定位置
$(".zl-pc-nav-column-ul").on("click", ".zl-pc-nav-column-li", function (event) {
event.stopPropagation();
var thisHref = $(this).children("a").attr("href");
if (thisHref != "javascript:;" && thisHref != "javascript:void(0)" && thisHref == "undefined" && thisHref == false) return;
var thisKey = $(this).data("key");
if (!thisKey) return;
//通过data找到plate1的li
var thisLi = $("#plate1").find("li").map(function (i, v) {
if ($(v).data("key") == thisKey) {
$(v).siblings().removeClass("current").end().addClass("current");
return $(v);
}
})[0];
closeShow = setTimeout(function () {
$(".zl-pc-searching-box-close").show();
}, 500);
plateclick(thisLi);
$(".zl-pc-search-icon").hide();
$("#puppetBtn").hide();
$('.zl-pc-nav').addClass('narrow');
$('.zl-pc-searching-box').addClass('searching');
$('#txtSearch_Navigation').val($('#txtSearch_Navigation').next('.inputInfohint').val());
// 图片懒加载
$('.zl-pc-header-box img').trigger("appear");
})
//屏幕后滚动消失
// $("html").on("mousewheel", function (e) {
// var event = e || window.event;
// var target = event.target || event.srcElement;
// if ($(".ic-pc-nav").css("display")=="block") {
// if (!$(e.target).parents(".scrollBox")[0]) {
// $('.zl-pc-nav').removeClass('narrow');
// $('.zl-pc-searching-box').removeClass('searching');
// $('.zl-pc-search-icon').fadeIn();
// $('#txtSearch_Navigation').val($('#txtSearch_Navigation').next('.inputInfohint').val());
// $('.zl-pc-searching-tip').fadeOut();
// $(".zl-pc-searching-box-close").hide();
// fnCollapse();
// }
// }
// });
//open nav
function fnUnfold(thisLi) {
if ((baseLib.browserVersion() == "ios" || baseLib.browserVersion() == "android")) {
$("body").addClass("oh");
}
$("#puppetBtn").hide();
var browsehappyH = 0;
var prevAll_H = 0;
if ($(".browsehappy.ReadPolicy").css("display") == "block") {
var browsehappyH = topourH($(".browsehappy.ReadPolicy"));
}
if ($(".zl-pc-header").css("position") == "fixed") {
prevAll_H = topourH($(".zl-pc-header-box"));
} else {
prevAll_H = topourH($(".zl-pc-header-box")) + topourH($(".nav-gblnav")) + browsehappyH;
}
var win_h = $(window).height();
//展开ic-pc-nav
$(".ic-pc-nav ").css({
display: "none",
height: win_h - prevAll_H
});
$(".big-box").find(".current").removeClass("current");
////展示第一级菜单
$(".big-box>#plate1").css("display", "block").find("ul:first").addClass("current").find("li:first").addClass("current");
if (thisLi) plateclick(thisLi);
//选取每一级的第一个元素
//$(".big-box>div").each(function (i, v) {
// $(v).css("display", "block");
// $(v).find("ul:first").addClass("current").find("li:first").addClass("current");
//});
$(".ic-pc-nav").slideDown(300);
}
//close nav
function fnCollapse() {
if ($("body").hasClass("oh")) $("body").removeClass("oh");
$("#puppetBtn").css("display", "inline-block");
//关闭ic-pc-nav
$(".ic-pc-nav").hide();
//移除所有选定
$(".big-box").find(".current").removeClass("current");
}
//plate联动
var TemporaryState;
function plateclick(thisLi) {
//判断nav是否展开
if ($(".ic-pc-nav").css("display") == "none") fnUnfold();
//性能优化
$(".big-box").css("display", "none");
//兼容防报错
if (!thisLi) return false;
// 当前的li高亮 同级li取消高亮
thisLi.siblings().removeClass("current").end().addClass("current");
//获取data-key
var thisKey = thisLi.data("key");
//获取当前板块
//增加滚动条后结构改变
var thisPlate = thisLi.parents("ul").parent().parent();
//获取后面所有板块
var nextPlates = thisPlate.nextAll();
//获取下一级板块所有的ul
var nextUl = thisPlate.next().find("ul");
nextPlates.find(".current").removeClass("current");
//后面模块循环
nextPlates.each(function (i, v) {
if (TemporaryState && thisLi[0] != TemporaryState[0]) {
$(v).find(".scrollContentDiv").css("top", 0);
}
//寻找后面每一块板块符合的ul li
var li = $(v).find("ul").map(function (i, v) {
if ($(v).data("key") == thisKey) {
thisKey = $(v).find("li:first").data("key");
$(v).addClass("current").find("li:first").addClass("current");
return true;
}
})[0];
// 判断层级 做plate展示 64 82
if ($(v).attr('id') == "plate2") {
if (li == undefined) {
$(v).css("width", "0%");
$("#plate3").css("width", "77%");
} else {
$(v).css("width", "23%");
$("#plate3").css("width", "54%");
}
}
});
$(".big-box").css("display", "block");
TemporaryState = thisLi;
};
function topourH(dom) {
//顶部高度过滤
if (dom.outerHeight()) {
return dom.outerHeight();
} else {
return 0;
}
}
//滚动条
$(".scrollBox").scrollBar();
var bgc;
$(".scrollBox").on("mouseenter", function () {
bgc = (("plate3" == $(this).attr("id")) || $(this).parents("#plate3")[0]) ? "bgc-333" : "bgc-ccc";
if ((baseLib.browserVersion() == "ios" || baseLib.browserVersion() == "android")) {
return false;
}
if ($(this).find(".scrollBar").length > 0 && !$(this).hasClass("fit flUl f4")) {
$(this).find(".scrollBar").addClass(bgc);
}
}).on("mouseleave", function () {
if ($(this).find(".scrollBar").length > 0) {
$(this).find(".scrollBar").removeClass(bgc);
}
})
baseLib.contourFun("#plate3 .fit.flUl.f4", "ol", "li", 768);
var flUls = $("#plate3").find('.fit.flUl.f4');
flUls.removeClass("scrollBox");
var html_lang = $("html").hasClass("LANG-cn");
if (flUls.length >= 1) {
flUls.each(function (i, v) {
$(v).find(".scrollContentDiv").css({
"overflow": "hidden"
});
var fl_lis = $(v).find("div>li");
if (fl_lis.length % 3 == 1) {
//正常
// if (fl_lis.length / 3 > 1 && html_lang) {
// $(fl_lis[fl_lis.length - 3]).css({
// "paddingBottom": "10px"
// });
// $(fl_lis[fl_lis.length - 2]).css({
// "paddingBottom": "10px"
// });
// $(fl_lis[fl_lis.length - 1]).css({
// "paddingBottom": "10px"
// });
// }
} else if (fl_lis.length % 3 == 2) {
//1个
// if (html_lang) {
// $(fl_lis[fl_lis.length - 1]).css({
// "width": "100%",
// // "paddingBottom": "10px"
// });
// } else {
// $(fl_lis[fl_lis.length - 1]).css({
// "width": "100%"
// });
// }
// $(fl_lis[fl_lis.length - 1]).css({
// "width": "100%"
// });
// $(fl_lis[fl_lis.length - 1]).find("li").css({
// "height": "auto"
// });
} else if (fl_lis.length % 3 == 0) {
//2个
// if (html_lang) {
// $(fl_lis[fl_lis.length - 2]).css({
// // "paddingBottom": "10px"
// });
// $(fl_lis[fl_lis.length - 1]).css({
// "width": "66.66%",
// // "paddingBottom": "10px"
// });
// } else {
// $(fl_lis[fl_lis.length - 1]).css({
// "width": "66.66%"
// });
// }
// $(fl_lis[fl_lis.length - 1]).css({
// "width": "66.66%"
// });
// $(fl_lis[fl_lis.length - 1]).find("li").css({
// "width": "33%"
// });
}
})
}
// IE8,IE9 导航延时效果导航hover效果
var headTimer,
delayTime = 60,
$ul = $("#plate1, #plate2");
$ul.on("mouseleave", "li", function () {
clearTimeout(headTimer);
});
$ul.find("li").on("mousemove", function (event) {
// if (event.relatedTarget || event.toElement) {return false}
var _this = $(this);
clearTimeout(headTimer);
headTimer = setTimeout(function () {
if (!_this.hasClass("current")) {
_this.trigger("click");
}
}, delayTime);
});
}
$(function () {
var flagNoY = $(".pc-nav-box").find(".big-box")[0];
if (flagNoY) {
baseLib.v4HeadFun(); //v4版头部
} else {
baseLib.v2HeadFun(); //v2版头部
}
if (baseLib.browserVersion() == "ios" || baseLib.browserVersion() == "android") {
// var record;
$(window).resize(function () {
// record = $(window).width() - 992 <= 0? false:true;
baseLib.v4HeadFun();
})
}
})