$.prototype.extend({ splitletter: function () { this.each(function (i, e) { if ($(e).hasclass('split')) { return; } var textwrapper = $(e)[0]; textwrapper.innerhtml = textwrapper.textcontent.replace(/./g, "$&"); $(e).addclass('split'); }); return this; } }); function isie() { return !!window.activexobject || "activexobject" in window; } function iswx() { //window.navigator.useragent属性包含了浏览器类型、版本、操作系统类型、浏览器引擎类型等信息,这个属性可以用来判断浏览器类型 var ua = window.navigator.useragent.tolowercase(); //通过正则表达式匹配ua中是否含有micromessenger字符串 return ua.match(/micromessenger/i) == 'micromessenger'; } $(function () { if (isie()) { $('body').addclass('ie'); } if (iswx()) { $('body').addclass('wx'); $('.btn-vid-play').click(function(){ $('.banner video')[0].play(); $('.banner video')[0].controls = true; $('.btn-vid-play').hide(); }) } $('.right-nav')[0].addeventlistener('mouseenter', function () { $('body').removeclass('search-active lang-active').addclass('menu-active'); }, { passive: true }); $('.site-header')[0].addeventlistener('mouseleave', function (e) { if(window.innerwidth<=960){ return; } if ($(e.target).hasclass('site-header')) { $('body').removeclass('menu-active'); $('.link-col').removeclass('active'); } }, { passive: true }); $('.right-nav-mobile').click(function () { $('body').toggleclass('menu-active'); if ($('body').hasclass('menu-active')) { window.mobilenavswiper && window.mobilenavswiper.update(); } }); $('.link-col').mouseenter(function () { var index = $(this).index(); $('.link-col:nth-of-type(' + (index + 1) + ')').addclass('active').siblings().removeclass('active'); //frombigswitch = true; //$('.site-menu .link-col:eq('+index+') a:eq(0)').trigger('mouseenter'); }) $('.btn-search').click(function (e) { e.stoppropagation(); $('body').removeclass('menu-active lang-active').toggleclass('search-active'); }); $('.btn-lang').click(function () { $('body').removeclass('menu-active search-active').toggleclass('lang-active'); }); //取消搜索显示 $('body').click(function (e) { if ($(e.target).is('li.next')) { return; } if (!$(e.target).hasclass('search-ctn') && !$(e.target).parents('.search-ctn').length) { $('body').removeclass('search-active'); } if (!$(e.target).hasclass('btn-lang') && !$(e.target).parents('.btn-lang').length) { $('body').removeclass('lang-active'); } }); //移动端导航 window.mobilenavswiper = new swiper('.mobile-nav-swiper', { allowtouchmove: false, slidesperview: 1, autoheight: true, speed: 600 }); $('.mobile-nav-swiper a').click(function (e) { var indexes = $(this).attr('data-index') || $(this).parent().attr('data-index'); if (!indexes) { return; } e.preventdefault(); var indexparts = indexes.split('-'); //var lastindex = indexparts[indexparts.length - 1]; var screen = $('.screen' + (indexparts.length + 1)); screen.find('[data-parent-index]').hide(); screen.find('[data-parent-index="' + indexes + '"]').show(); mobilenavswiper.slideto(indexparts.length); }); $('.mobile-nav-swiper .btn-back').click(function () { mobilenavswiper.slideprev(); }); $('a.block-title').each(function (i, e) { if (!$(e).siblings('a, .block-links').length) { $(e).parents('.block:not(.disabled)').addclass('link-box'); } }) $('.btn-to-top').click(function () { $('html, body').animate({ scrolltop: 0 }, 800) }); if(navigator.useragent.indexof('ipad') > -1){ } $(window).scroll(function () { if (document.documentelement.scrolltop || document.body.scrolltop || window.pageyoffset) { $('body').addclass('scrolled'); } else { $('body').removeclass('scrolled'); } }); })