$(function () { // 初始化pc导航栏 initnavigation() // 初始化二级菜单面板 initsubmenupanel() // 移动端导航判断 initwapnavigation() // 产品页面切换 setprodtabs() // 搜索按钮控制 setsearcharea() // 页面滚动事件 hfade() // 底部友情链接 $('#fd-links-drop-button').bind({ click() { var target = $(this).parents('.links') if ($(this).hasclass('on')) { target.children('ul').slideup() $(this).removeclass('on') } else { target.children('ul').slidedown() $(this).addclass('on') } } }) //全场动画 new wow().init(); }); function iswap() { if ((navigator.useragent.match(/(iphone|ipod|android|ios|ios|ipad|backerry|webos|symbian|windows phone|phone)/i))) { return true; } return false; } function initwapnavigation() { if (!iswap()) { return } var target = $('.jh-sub-header .item') target.find('.t').bind({ click(e) { e.stoppropagation() var parenttarget = $(this).parent() if (parenttarget.hasclass('on')) { parenttarget.removeclass('on').find('.clear').slideup() return } parenttarget.siblings().each(function () { $(this).removeclass('on').find('.clear').slideup() }) parenttarget.addclass('on').find('.clear').slidedown() } }) $('.jh-sub-header .click-able').bind({ click() { $('.menu-button').removeclass('on') $('.jh-sub-header').slideup() } }) } function initnavigation() { $('.jh-nav li').bind({ mouseenter() { $(this).siblings().each(function () { $(this).removeclass('on').children('ul').slideup() }) $(this).addclass('on').children('ul').slidedown() }, mouseleave() { $(this).removeclass('on').children('ul').slideup() } }) } function initsubmenupanel() { var buttontarget = $('.menu-button') // console.log(iswap()) buttontarget.bind({ click() { if ($(this).hasclass('on')) { $('.menu-button').removeclass('on') $('.jh-sub-header').slideup() } else { $(this).addclass('on') $('.jh-sub-header').slidedown() } } }) } function setsearcharea() { var searchbutton = $('.search a'); searchbutton.bind({ click() { if ($(this).hasclass('is-show')) { $(this).removeclass('is-show') $('.r-side .links .ipt').css('display', 'none') // 获取输入内容 # 跳转搜索页面 /* var kw = $('#search-keyword').val() window.open('/search?k=' + kw) */ } else { $(this).addclass('is-show') $('.r-side .links .ipt').css('display', 'flex') } } }) $('.r-side .links .ipt .closed').bind({ click() { $('.search a').removeclass('is-show') $('.r-side .links .ipt').css('display', 'none') } }) } function hfade() { if (iswap()) { return } var crossheight = parseint($('html').css('fontsize').replace('px', '')); var distance = $(window).scrolltop(); $(window).scroll(function() { // console.log($(this).scrolltop(), distance) var scrolltop = $(this).scrolltop() if (scrolltop > distance && scrolltop > crossheight) { $('.menu-button').removeclass('on') $('.jh-sub-header').slideup(function () { $(".jh-header").addclass("fix-up"); }) } else { // distance = $(this).scrolltop(); $(".jh-header").removeclass("fix-up"); } distance = scrolltop }); } function setprodtabs() { var tabtarget = $('.jh-prod-tab-panel li'); if (!tabtarget.length) return showprodcontentindex(0); // 绑定事件 tabtarget.children('a').bind({ click() { var handle = $(this).parent(); handle.addclass('on').siblings().removeclass('on'); showprodcontentindex(handle.index()); } }) } function showprodcontentindex(index) { $('.jh-prod-cont-panel .sq').each(function () { $(this).css('display', 'none') }); $('.jh-prod-cont-panel .sq').eq(index).show(); }