let w = document.body.offsetwidth || document.body.clientwidth,
h = window.innerheight || document.documentelement.clientheight || document.body.clientheight,
_ = function (select) {
return document.queryselector(select)
},
_$ = function (select) {
return document.queryselectorall(select)
},
clickevent = (function () {
if ('ontouchstart' in document.documentelement === true) {
return 'touchstart';
} else {
return 'click';
}
})(),
active = function (node, active) {
return node.classlist.add(active); //添加类
},
inactive = function (node, active) { //移除类
return node.classlist.remove(active);
},
getscrollbarwidth = function () { // 得到滚动条宽度
const container = document.createelement('div');
container.style.visibility = 'hidden';
container.style.position = 'absolute';
container.style.left = '-9999px';
container.style.width = '100px';
container.style.overflow = 'scroll';
let fragment = document.createdocumentfragment();
fragment.appendchild(container);
document.body.appendchild(fragment);
const containerwidth = container.offsetwidth;
const inner = document.createelement('div');
inner.style.width = '100%';
let fragment1 = document.createdocumentfragment();
fragment1.appendchild(inner);
container.appendchild(fragment1);
const innerwidth = inner.offsetwidth;
container.parentnode.removechild(container);
return containerwidth - innerwidth;
},
hasscrollbar = function() {
return document.body.scrollheight > window.innerheight;
},
scrollmarginrighttruefun = function(arrays){
array.prototype.foreach.call(arrays, function (item) {
if(item){
item.style.boxsizing = 'border-box';
item.style.paddingright = getscrollbarwidth() + 'px';
}
});
},
scrollmarginrightfalsefun = function(arrays){
array.prototype.foreach.call(arrays, function (item) {
if(item){
item.style.paddingright = '0';
}
});
},
scrollmarginrighttrue = function () { // 禁止滚动
if ('ontouchstart' in document.documentelement === false && hasscrollbar()) {
scrollmarginrighttruefun([_('html'),_('header'),_('.subnavhead .subnavbody')]);
document.documentelement.style.overflowy = 'hidden';
}
},
scrollmarginrightfalse = function () { // 开启滚动
if ('ontouchstart' in document.documentelement === false && hasscrollbar()) {
scrollmarginrightfalsefun([_('html'),_('header'),_('.subnavhead .subnavbody')]);
document.documentelement.style.overflowy = 'auto';
}
},
calculatedanage = function (min, max) {
return math.max(math.floor(math.random() * max) + 1, min);
},
xmlhttp = function () { // 封装 xmlhttprequest
let request = new xmlhttprequest(),
_url = "";
return {
requestfun: function (method, url, data, success) {
request.open(method, _url + url);
if (method == 'get') {
request.send();
} else {
request.setrequestheader('content-type', 'application/json');
request.send(data);
}
request.onload = function () {
if (this.status >= 200 && this.status < 400) {
success(request.responsetext)
} else {
console.log('error');
}
};
}
}
},
debounce = function (func, delay) { // 防抖
var timeout;
return function () {
cleartimeout(timeout);
timeout = settimeout(function () {
func.apply(this, arguments);
}, delay);
}
};
const chin = (function () {
const itemanimates = function () {
let itemanimates = _$(".itemanimates");
for (let i = 0; i < itemanimates.length; i++) {
let itemanimate = itemanimates[i].queryselectorall('.itemanimate'),
delay = 0,
delaycount = parseint(itemanimates[i].getattribute('delay'));
if (!delaycount) {
delaycount = 300;
}
for (let j = 0; j < itemanimate.length; j++) {
if (itemanimates[i].getattribute('random') == '1') {
delay = math.random() * itemanimates[i].getattribute('randommax');
} else {
delay += delaycount;
}
itemanimate[j].style.animationdelay = delay + "ms";
}
}
};
const newspapertable = function () {
array.prototype.foreach.call(_$('.newspaper table'), function (el) {
let section = document.createelement('section');
section.classname = 'tablebox';
el.parentnode.replacechild(section, el);
section.appendchild(el);
// let fragment = document.createdocumentfragment();
// fragment.appendchild(rootsection);
});
};
const splitlist = function (splitlist, bool) {
array.prototype.foreach.call(_$(splitlist), function (item) {
let flag = false,
israndom = bool,
delays = parseint(item.getattribute('delay')),
speeds = parseint(item.getattribute('speed')),
arrays = item.innerhtml.replace(/
/g, "\n").replace(//g, "\\").replace(/<\/i>/g, "\t").replace(/&/g, "&").split("");
item.innerhtml = '';
if (!delays) {
delays = 200
}
if (!speeds) {
speeds = 50
}
array.prototype.foreach.call(arrays, function (letter, i) {
let span = document.createelement("span"),
br = document.createelement("br"),
random = 1;
if (letter.indexof("\n") >= 0) {
let fragment = document.createdocumentfragment();
fragment.appendchild(br);
item.appendchild(fragment);
return
}
if (letter.indexof("\\") >= 0) {
flag = true;
return
}
if (letter.indexof("\t") >= 0) {
flag = false;
return
}
if (flag) {
span.classname = 'letters';
}
if (israndom) {
random = math.random();
}
delays += speeds;
span.style.animationdelay = delays * random + 'ms';
span.innerhtml = letter;
let fragments = document.createdocumentfragment();
fragments.appendchild(span);
item.appendchild(fragments);
});
});
};
const haschild = function (item) {
if (item) {
array.prototype.foreach.call(item, function (slider) {
if (slider.haschildnodes()) {
active(slider, 'haschildactive');
}
});
}
};
const mobilemenu = function () {
let menu = _('.mobilemenu_box'),
nav = _('.mobilenav'),
header = _('header');
if (menu && nav) {
nav.style.display = 'block';
menu.addeventlistener(clickevent, function () {
if (menu.classlist.contains('active')) {
inactive(menu, 'active');
inactive(nav, 'active');
inactive(header, 'moblienavactive');
scrollmarginrightfalse();
} else {
active(menu, 'active');
active(nav, 'active');
active(header, 'moblienavactive');
scrollmarginrighttrue();
}
});
if (_$('.mobilenavitem .list a')) {
let link = _$('.mobilenavitem .list a');
for (let i = 0; i < link.length; i++) {
link[i].addeventlistener('click', function () {
if (link[i].href.match('#')) {
inactive(menu, 'active');
inactive(nav, 'active');
inactive(header, 'moblienavactive');
scrollmarginrightfalse();
};
});
};
}
}
};
const isautoheight = function (event, items, item, istrue) {
let height = [],
flag = istrue,
nodefather;
function publicif(index) {
if (items[index].classlist.contains('active')) {
item[index].style.height = height[index];
items[index].classlist.add('active');
}
};
function public(index) {
for (let i = 0; i < item.length; i++) {
nodefather[i] = items[i].parentnode;
item[i].style.height = 0;
items[i].classlist.remove('active');
nodefather[i].classlist.remove('active');
}
item[index].style.height = height[index];
items[index].classlist.add('active');
nodefather.classlist.add('active');
};
for (let j = 0; j < item.length; j++) {
item[j].style.height = 'auto';
// console.log(getcomputedstyle(item[j], null)['height'])
height.push(getcomputedstyle(item[j]).height);
item[j].style.height = '0px';
}
if (event == 'mouseover') {
for (let i = 0; i < items.length; i++) {
items[i].index = i;
publicif(i);
items[i].addeventlistener(event, function () {
nodefather = items[this.index].parentnode;
public(this.index);
});
if (flag == true) {
items[i].addeventlistener('mouseout', function () {
item[this.index].style.height = 0;
items[this.index].classlist.remove('active');
});
};
};
};
if (event == 'click') {
for (let i = 0; i < items.length; i++) {
items[i].index = i;
publicif(i);
items[i].addeventlistener(event, function (e) {
if (!!window.activexobject || "activexobject" in window){
}else{
if(item[i].haschildnodes()){
e.preventdefault();
}
}
nodefather = items[this.index].parentnode;
if (item[this.index].style.height == '0px') {
public(this.index);
} else {
item[this.index].style.height = 0;
items[this.index].classlist.remove('active');
nodefather.classlist.remove('active');
}
});
}
};
};
const needvideo = function () {
function need() {
let root = document.body,
rootsection = document.createelement('section'),
rootdiv = document.createelement('div'),
rootdom = document.createelement('div'),
rootvideo = document.createelement('video'),
rootremove = document.createelement('i');
rootsection.classname = 'videobox';
rootdiv.classname = 'bg';
rootdom.classname = 'videodom';
rootremove.classname = 'close';
rootvideo.controls = true;
rootvideo.loop = true;
rootvideo.oncontextmenu = "return false";
rootvideo.setattribute('x5-video-player-type', 'h5');
rootvideo.setattribute('playsinline', 'true');
rootvideo.setattribute('webkit-playsinline', 'true');
rootvideo.setattribute('x5-video-player-fullscreen', 'true');
rootvideo.setattribute('x-webkit-airplay', 'true');
rootdom.appendchild(rootvideo);
rootdom.appendchild(rootremove);
rootsection.appendchild(rootdiv);
rootsection.appendchild(rootdom);
let fragment = document.createdocumentfragment();
fragment.appendchild(rootsection);
root.appendchild(fragment);
};
let needs = _$('.needvideo');
if (needs.length > 0) {
need();
let videobox = _('.videobox'),
videobg = _('.videobox .bg'),
video = _('.videobox video'),
videoicon = _('.videobox .close');
for (let i = 0; i < needs.length; i++) {
needs[i].addeventlistener('click', function () {
if(!needs[i].getattribute('data-src')){
return
}
video.src = needs[i].getattribute('data-src');
videoicon.innerhtml = needs[i].getattribute('data-icon');
active(videobox,'active');
video.play();
scrollmarginrighttrue();
});
function videofun(){
video.load();
inactive(videobox,'active');
scrollmarginrightfalse();
};
videobg.addeventlistener('click', videofun);
videoicon.addeventlistener('click', videofun);
}
}
};
const needwechat = function () {
function need() {
let root = document.body,
rootsection = document.createelement('section'),
rootdiv = document.createelement('div'),
rootp = document.createelement('p'),
rootimg = document.createelement('img');
rootsection.classname = 'wechat';
rootsection.appendchild(rootdiv);
rootdiv.appendchild(rootimg);
rootdiv.appendchild(rootp);
let fragment = document.createdocumentfragment();
fragment.appendchild(rootsection);
root.appendchild(fragment);
};
let needs = _$('.needwechat');
if (needs.length > 0) {
need();
let wechat = _('.wechat'),
wechatimg = _('.wechat img'),
wechattext = _('.wechat p');
for (let i = 0; i < needs.length; i++) {
needs[i].addeventlistener(clickevent, function (e) {
e.preventdefault();
wechatimg.src = needs[i].getattribute('data-src');
wechattext.innertext = needs[i].getattribute('data-text');
active(wechat,'active');
scrollmarginrighttrue();
});
wechat.addeventlistener(clickevent, function () {
inactive(wechat,'active');
scrollmarginrightfalse();
});
}
}
};
const popup = function () {
function init() {
let root = document.body,
rootsection = document.createelement('section'),
rootbg = document.createelement('div'),
rootbox = document.createelement('div');
rootsection.classname = 'popup';
rootbg.classname = 'popupbg';
rootbox.classname = 'popupbox';
rootsection.appendchild(rootbg);
rootsection.appendchild(rootbox);
let fragment = document.createdocumentfragment();
fragment.appendchild(rootsection);
root.appendchild(fragment);
}
let need = _$('.xmlbox');
if (need.length > 0) {
init();
array.prototype.foreach.call(need, function (items) {
let item = items.queryselectorall('.xml');
for (let i = 0; i < item.length; i++) {
item[i].addeventlistener('click', function () {
scrollmarginrighttrue();
active(_('.popup'),'active');
xmlhttp().requestfun(
'get',
item[i].getattribute('data-url'),
'',
function (res) {
if (res) {
_('.popupbox').innerhtml = res;
}
}
)
});
};
});
_('.popupbg').addeventlistener('click', function () {
_('.popup').classlist.remove('active');
scrollmarginrightfalse();
if (_(".calendar-wrap")) {
document.body.removechild(_(".calendar-wrap"));
}
});
}
};
const nodeobserver = function (node, fn) {
let mutationobserver = window.mutationobserver || window.webkitmutationobserver || window.mozmutationobserver,
target = node,
observer = new mutationobserver(function (mutation) {
mutation.foreach(function (mutation) {
if (mutation.type === 'childlist') {
fn();
} else {
return
}
});
}),
config = {
childlist: true, //子节点的变动
// attributes : true,//属性的变动
// characterdata : true,//节点内容或节点文本的变动
// subtree : true,//所有后代节点的变动
// attributeoldvalue : true,//表示观察attributes变动时,是否需要记录变动前的属性
// characterdataoldvalue : true//表示观察characterdata变动时,是否需要记录变动前的值
};
observer.observe(target, config);
};
const bannerimg = function () {
array.prototype.foreach.call(_$('.bannerimg .imgs'), function (slider) {
let scrolly = window.scrolly || window.pageyoffset;
slider.style.transform = 'translate3d(0,' + scrolly / 2.3 + 'px,0)';
});
};
const bindraf = function (fn, throttle) {
var isrunning;
var that;
var args;
var run = function () {
isrunning = false;
fn.apply(that, args);
};
return function () {
that = this;
args = arguments;
if (isrunning && throttle) {
return;
}
isrunning = true;
requestanimationframe(run);
};
};
const onlyactive = function (item, itemactive) {
for (let i = 0; i < item.length; i++) {
item[i].index = i;
item[i].addeventlistener('mouseover', function (e) {
for (let i = 0; i < item.length; i++) {
item[i].classlist.remove('active');
}
item[this.index].classlist.add('active');
});
item[i].addeventlistener('mouseout', function (e) {
for (let i = 0; i < item.length; i++) {
item[i].classlist.remove('active');
}
if (itemactive) {
itemactive.classlist.add('active');
}
});
}
};
const mousecursorgradienttracking = function () {
let btn = _('.mousegradient');
btn.addeventlistener('mousemove', function (e) {
let rect = e.target.getboundingclientrect();
let x = (e.clientx - rect.left) / e.target.offsetwidth * 100;
btn.style.setproperty('--x', x + '%');
});
};
const headerscroll = function () {
// let header = _('header');
// if (w <= 1024) {
// active(header, 'scroll');
// }else{
// if (header.classlist.contains('noscroll')) {
// active(header,'scroll')
// } else {
// if (window.pageyoffset > 0) {
// active(header, 'scroll');
// } else {
// inactive(header, 'scroll');
// }
// }
// }
};
const swiperslider = function (itemclick, items, item, swiper, swipers) {
for (let i = 0; i < itemclick.length; i++) {
itemclick[0].classlist.add('active');
itemclick[i].addeventlistener(clickevent, function () {
for (let i = 0; i < itemclick.length; i++) {
itemclick[i].classlist.remove('active');
}
itemclick[i].classlist.add('active');
updatesliders(i);
});
};
function updatesliders(i) {
let index = i;
let arr = array.prototype.slice.call(item).filter(function (item) {
return item.getattribute('data-index') == index;
});
for (let i = 0; i < item.length; i++) {
items.appendchild(item[i]);
items.removechild(item[i]);
};
arr.foreach(function (item) {
items.appendchild(item);
items.classlist.remove('active');
settimeout(function () {
items.classlist.add('active');
swiper.update();
swiper.slideto(0, 0, true);
}, 30);
});
};
updatesliders(0);
};
const ifscroll = function (items, scrollleft) {
let parentnode, nodeact;
array.prototype.foreach.call(items, function (item) {
if (item.classlist.contains('active')) {
nodeact = item;
parentnode = item.parentnode;
if (!scrollleft) {
parentnode.scrollleft = nodeact.offsetleft;
} else {
parentnode.scrolltop = nodeact.offsettop;
}
}
});
};
const intersectionobserversimg = function (node) {
const config = {
rootmargin: '0px',
threshold: 0,
};
let observer = new intersectionobserver(function (entries, self) {
array.prototype.foreach.call(entries, function (entry) {
if (entry.isintersecting) {
let img = entry.target;
let src = img.dataset.src;
if (src) {
img.src = src;
img.removeattribute('data-src');
}
// 解除观察
self.unobserve(entry.target);
}
});
}, config)
array.prototype.foreach.call(node, function (el) {
observer.observe(el)
});
};
const intersectionobserversnode = function (node, flag) {
const config = {
rootmargin: '0px',
threshold: 0,
};
let observer = new intersectionobserver(function (entries, self) {
array.prototype.foreach.call(entries, function (entry) {
if (entry.isintersecting) {
entry.target.classlist.add(flag);
// 解除观察
self.unobserve(entry.target);
}
});
}, config)
array.prototype.foreach.call(node, function (el) {
observer.observe(el)
});
};
const pohtosliders = function () {
if (!!window.activexobject || "activexobject" in window){
array.prototype.foreach.call(_$('.photoslides'), function (item) {
active(item,'ifie');
return
});
}
var parsecolor = function (hexstr) {
return hexstr.length === 4 ? hexstr.substr(1).split('').map(function (s) {
return 0x11 * parseint(s, 16);
}) : [hexstr.substr(1, 2), hexstr.substr(3, 2), hexstr.substr(5, 2)].map(function (s) {
return parseint(s, 16);
})
};
var pad = function (s) {
return (s.length === 1) ? '0' + s : s;
};
var gradientcolors = function (start, end, steps, gamma) {
var i, j, ms, me, output = [],
so = [];
gamma = gamma || 1;
var normalize = function (channel) {
return math.pow(channel / 255, gamma);
};
start = parsecolor(start).map(normalize);
end = parsecolor(end).map(normalize);
for (i = 0; i < steps; i++) {
ms = i / (steps - 1);
me = 1 - ms;
for (j = 0; j < 3; j++) {
so[j] = pad(math.round(math.pow(start[j] * me + end[j] * ms, 1 / gamma) * 255).tostring(16));
}
output.push('#' + so.join(''));
}
return output;
};
const nodeobserverslide = function (node, fn) {
array.prototype.foreach.call(node, function (item) {
item.style.setproperty('--bg', gradientcolors('#28a7e1', '#f4a153', 100)[calculatedanage(0, 99)]);
let mutationobserver = window.mutationobserver || window.webkitmutationobserver || window.mozmutationobserver,
target = item,
observer = new mutationobserver(function (mutation) {
mutation.foreach(function (mutation) {
if (mutation.type === 'attributes') {
fn(mutation.target);
} else {
return
}
});
}),
config = {
attributes: true, //属性的变动
};
observer.observe(target, config);
});
};
nodeobserverslide(_$('.photoslides'), function (dom) {
let photoflag = true;
dom.addeventlistener('transitionend', function (e) {
if (e.target === e.currenttarget && photoflag) {
dom.queryselector('img').style.opacity = '1';
dom.classlist.add('reset');
}
});
});
};
const scrollnum = function() {
let scrollnumitem = _$('.scrollnumitem'),
scrollnumarr = [];
if (!!window.activexobject || "activexobject" in window){
return
}
// 999
if (scrollnumitem.length > 0) {
let fragment = document.createdocumentfragment();
let svg = document.createelement('div');
svg.style.display = 'none';
svg.innerhtml = ""
fragment.appendchild(svg);
document.body.appendchild(fragment);
}else{
return
};
const splitnum =function() {
for (let i = 0; i < scrollnumitem.length; i++) {
scrollnumarr.push(scrollnumitem[i].innerhtml);
};
for (let i = 0; i < scrollnumarr.length; i++) {
let newarr = [];
for (let j = 0; j < scrollnumarr[i].length; j++) {
newarr.push(scrollnumarr[i][j]);
}
for (let k = 0; k < newarr.length; k++) {
if (!isnan(newarr[k])) {
let li = '';
for (let i = 0; i < 10; i++) {
if (i == newarr[k]) {
li += ""+ i +""
} else {
li += "" + i + ""
}
}
newarr[k] = ""
}
}
scrollnumarr[i] = newarr;
};
for (let i = 0; i < scrollnumarr.length; i++) {
scrollnumitem[i].innerhtml = scrollnumarr[i].join().replace(/,/g, '');
};
};
const delaycom = function() {
for (let i = 0; i < scrollnumitem.length; i++) {
let scrollnumbox = scrollnumitem[i].queryselectorall('.scrollnumbox');
for (let j = 0; j < scrollnumbox.length; j++) {
scrollnumbox[j].setattribute('delay', number(scrollnumitem[i].getattribute('delay')) + (j * 0.1));
}
};
};
const renderingnum = function(){
let scrollnumbox = _$('.scrollnumbox'),
scrollnumul = _$('.scrollnumul'),
scrollnumliactive = _$('.scrollnumul li.active');
for (let i = 0; i < scrollnumul.length; i++) {
scrollnumbox[i].style.setproperty('--i', scrollnumliactive[i].innertext);
scrollnumbox[i].style.setproperty('--delay', scrollnumbox[i].getattribute('delay'));
settimeout(function(i){
scrollnumbox[i].style.width = getcomputedstyle(scrollnumliactive[i]).width;
scrollnumbox[i].style.height = getcomputedstyle(scrollnumliactive[i]).height;
},30,i)
const intersectionobserversnode = function (node) {
const config = {
rootmargin: '-10px',
threshold: 0,
};
let observer = new intersectionobserver(function(entries, self){
array.prototype.foreach.call(entries, function (entry) {
if (entry.isintersecting) {
if(equipmentclient() == 'ios'){
entry.target.setattribute('style', "animation: move .3s linear infinite")
settimeout(function() {
entry.target.setattribute('style', "animation: bounce-in-down 1s forwards")
}, 1000);
}else{
entry.target.setattribute('style', "animation: move .3s linear infinite,bounce-in-down 1s calc(var(--delay) * 1s) forwards;")
};
self.unobserve(entry.target);
}
});
}, config)
array.prototype.foreach.call(node, function (el) {
observer.observe(el)
});
};
intersectionobserversnode(_$('.scrollnumul'));
};
};
splitnum();
delaycom();
renderingnum();
};
const backtotop = function(node){
if(node){
node.addeventlistener(clickevent,function(){
if (userbrowser.userbrowsertype() == 'wechat') {
document.body.scrolltop = 0;
}else if (userbrowser.userbrowsertype() == 'uc') {
document.body.scrolltop = 0;
}else{
window.scrollto({
top: 0,
behavior: "smooth"
});
}
});
}
};
return {
itemanimates: itemanimates, //对多个项目进行动画延迟处理
newspapertable: newspapertable, // 对出现table标签进行父节点100%处理
mobilemenu: mobilemenu, // 移动端按钮
split: splitlist, // 分割文字 //true 开始随机速度
haschild: haschild, // 判断元素是否有子节点
isautoheight: isautoheight, // 用于'click'/'mouseover'事件时动画填充高度 true默认离开时高度归零
needvideo: needvideo, // 弹出视频
needwechat: needwechat, // 弹出图片
popup: popup, // xmlhttprequest请求弹出层
nodeobserver: nodeobserver, // 监听dom变化
bannerimg: bannerimg, // 顶部banner滚动模拟定位
bindraf: bindraf, // 回调 requestanimationframe
onlyactive: onlyactive, // 仅允许出现一个激活块
mousecursorgradienttracking: mousecursorgradienttracking, // 渐变色按钮根据鼠标移动
headerscroll: headerscroll, // 滚动时增加导航样式
swiperslider: swiperslider, // swiper配合分页
ifscroll: ifscroll, // 自适应滚动距离
intersectionobserversimg: intersectionobserversimg, //懒加载图片
intersectionobserversnode: intersectionobserversnode, //dom节点进入可视区域执行
pohtosliders: pohtosliders, //生成蒙版 图片出现效果
scrollnum: scrollnum, //数字出现效果
backtotop: backtotop // 点击按钮网页回到顶部
}
})();
chin.itemanimates();
chin.mobilemenu();
chin.split('.splitlist', true);
chin.haschild(_$('.mobilelinkitems'));
chin.needvideo();
chin.needwechat();
chin.bannerimg();
// chin.newspapertable();
// chin.intersectionobserversimg(_$('img[data-src]'));
// chin.popup();
// chin.scrollnum();
// chin.backtotop(_('.backtotop'));
// chin.swiperslider(
// _$('item'),
// _( '.swiper .swiper-wrapper'),
// _$('.swiper .swiper-wrapper .swiper-slide'),
// myswiper
// );
// chin.ifscroll(_$('.subnavbody a'));
// chin.mousecursorgradienttracking();
chin.onlyactive(_$('.subnavbody .w1720 a'),_('.subnavbody .w1720 a.active'));
chin.headerscroll();
if(w <= 1024){
chin.isautoheight('click',_$('.mobilenavitem .head'),_$('.mobilenavitem .list'),'true')
}
// window.onload = function () {
// };
const yqlj = function(){
let yqlj = _('.yqlj'),
ul = _('.yqlj ul');
if(!yqlj){return}
yqlj.addeventlistener('click',function(e){
active(yqlj,'active');
if(_('.last')){
_('.last').style.overflow = 'visible';
}
});
document.addeventlistener(clickevent,function(e) {
if(e.target == yqlj || yqlj.contains(e.target)){
}else{
inactive(yqlj,'active');
if(_('.last')){
_('.last').style.overflow = 'hidden';
}
}
});
};
const fixednav = function(){
if(!_('.subnavbody')) {return};
let dom = _('.subnavbody'),
domy = dom.getboundingclientrect().top,
domh = dom.offsetheight,
head = _('header'),
headh = head.offsetheight,
subnavhead = _('.subnavhead'),
subnavheadh = subnavhead.offsetheight;
if(w > 1024){
if(domy <= 0){
active(dom,'isfixed');
dom.style.top = 0 + 'px';
dom.style.bottom = 'auto';
dom.style.zindex = 6;
}
if(window.scrolly <= subnavheadh - domh){
inactive(dom,'isfixed');
dom.style.top = 'auto';
dom.style.bottom = '0';
dom.style.zindex = 3;
}
}else{
if(domy <= headh){
active(dom,'isfixed');
dom.style.top = headh + 'px';
dom.style.bottom = 'auto';
dom.style.zindex = 6;
}
if(window.scrolly <= subnavheadh - headh - domh){
inactive(dom,'isfixed');
dom.style.top = 'auto';
dom.style.bottom = '0';
dom.style.zindex = 3;
}
}
};
window.onload = function(){
chin.intersectionobserversnode(_$('.flags'), 'flag');
chin.pohtosliders();
fixednav();
};
window.addeventlistener('scroll', function () {
chin.bindraf(chin.bannerimg());
chin.headerscroll();
fixednav();
});
window.addeventlistener('resize', function () {
fixednav();
w = document.body.offsetwidth || document.body.clientwidth;
h = window.innerheight || document.documentelement.clientheight || document.body.clientheight;
});