$(function () { wowInt(); findTel(); search(); nav(); phoneTargetSelf(); $(window).resize(); $(window).scroll(function () { if ($(this).scrollTop() > 0) { $('body').addClass('scrollHeader'); } else { $('body').removeClass('scrollHeader'); } }); ScollText($(".navlist_6 .nav_iteam")) }) function nav(){ if($(window).width()>1024){ $(".nav li").hover(function(){ $(this).find(".navlist").stop().fadeIn(); $(this).siblings().find(".navlist").stop().fadeOut() },function(){ $(this).find(".navlist").stop().fadeOut() }) }else{ $(".nav_phone_btn").click(function(){ $(this).toggleClass("visible_nav"); $("body").toggleClass("navbody"); $(".nav>ul>li").removeClass("cur"); }) $(".nav_iteam dt span").click(function(){ $(this).parent("dt").toggleClass("on"); $(this).parent("dt").siblings("dd").slideToggle(); $(this).parents(".nav_iteam").siblings(".nav_iteam").find("dd").slideUp(); $(this).parents(".nav_iteam").siblings(".nav_iteam").find("dt").removeClass("on"); }) } $(".nav>ul>li>span").click(function(){ $(this).parent("li").addClass("cur"); }) $(".return_a").click(function(){ $(this).parents("li").removeClass("cur"); }) if($(window).width()<1025){ $(".header_box").on('touchmove',function(event){ event.preventDefault(); event.stopPropagation(); }) } } function search() { $(document).on("click",".search_btn",function(e){ e.preventDefault() e.stopPropagation() $(this).toggleClass('on') $(this).siblings('.search_box').toggleClass('on'); if($(window).width()>1024){ $(".language dd").stop().slideUp(); } }) $(document).on("click",".search_box",function(e){ e.preventDefault() e.stopPropagation() }) $(document).click(function () { $('.search_btn').removeClass('on'); $('.search_box').removeClass('on'); if($(window).width()>1024){ $(".language dd").stop().slideUp(); } }) if($(window).width()>1024){ $(document).on("click",".language dt",function(e){ e.preventDefault() e.stopPropagation() $(this).siblings().stop().slideToggle(); $('.search_btn').removeClass('on'); $('.search_box').removeClass('on'); }) } } function wowInt(){ if (!(/msie [6|7|8|9]/i.test(navigator.userAgent))){ var wow = new WOW({ boxClass: 'wow', animateClass: 'animated', offset: 100, mobile: false, live: true }); wow.init(); }; } /*手机端链接改为本窗口打开*/ function phoneTargetSelf(context){ if ($(window).width()<1024) { if(context==undefined){ context=$(document); } $('a',context).each(function(){ var target=$(this); var link=target.attr('target'); target.attr('target','_self'); }) } } /*电话链接取消默认事件并添加样式*/ function findTel(context){ if ($(window).width()>1024) { var condition = /^tel\:([0-9\-]+)|tel\:\+([0-9\-]+)$/; if(context==undefined){ context=$(document); } $('a',context).each(function(index, el) { var target=$(this); var href=target.attr('href'); if (condition.test(href)) { target.addClass('tel_link'); target.on('click',function(event){ event.preventDefault(); }) } }); } } /*ie9的placeholder包含密码框的兼容*/ $(function() { // 如果不支持placeholder,用jQuery来完成 if(!isSupportPlaceholder()) { // 遍历所有input对象, 除了密码框 $('input').not("input[type='password']").each( function() { var self = $(this); var val = self.attr("placeholder"); input(self, val); } ); /**//* 对password框的特殊处理 * 1.创建一个text框 * 2.获取焦点和失去焦点的时候切换 */ $('input[type="password"]').each( function(i) { var pwdField = $(this); var pwdVal = pwdField.attr('placeholder'); var pwdId = pwdField.attr('id'); // 重命名该input的id为原id后跟1 pwdField.after(''); var pwdPlaceholder = $('#' + pwdId + ''+i+''); pwdPlaceholder.show(); pwdField.hide(); pwdPlaceholder.focus(function(){ pwdPlaceholder.hide(); pwdField.show(); pwdField.focus(); }); pwdField.blur(function(){ if(pwdField.val() == '') { pwdPlaceholder.show(); pwdField.hide(); } }); } ); } }); // 判断浏览器是否支持placeholder属性 function isSupportPlaceholder() { var input = document.createElement('input'); return 'placeholder' in input; } // jQuery替换placeholder的处理 function input(obj, val) { var $input = obj; var val = val; $input.attr({value:val}); $input.focus(function() { if ($input.val() == val) { $(this).attr({value:""}); } }).blur(function() { if ($input.val() == "") { $(this).attr({value:val}); } }); } //end function ScollText(obj){ if($(obj).length>0){ $(obj).mCustomScrollbar({ mouseWheelPixels:500, autoDraggerLength:false, advanced: { autoScrollOnFocus: "" } }); } } //数字跳动 Element.prototype.elementInView = function() { var rect = this.getBoundingClientRect() var yInView = rect.top < window.innerHeight && rect.bottom > 0 var xInView = rect.left < window.innerWidth && rect.right > 0 return yInView && xInView } var wormDigitalScroll = function(options) { var that = this, dqtime this.setVal = function(e){ return e } for (var i in options) this[i] = options[i] if (!this.el) { console.error('el不能为空!') return false } var cc=this.el.innerHTML.replace(/,/g, "") var strnum = parseInt(this.el.innerHTML.replace(/,/g, "")) var mc = strnum / this.time var start = false; function update(str) { that.el.innerHTML = that.setVal(str) } function startnum() { if (that.el.elementInView() && !start) { start = true var startTimeOut = new Date().getTime() var time = setInterval(function() { dqtime = new Date().getTime() - startTimeOut if (dqtime >= that.time) { clearInterval(time) update(strnum.toLocaleString()) window.removeEventListener('scroll', scroll, false) } else { var decimal = String(strnum).split('.') if (decimal.length > 1) { decimal = String(strnum).split('.')[1].length } else { decimal = 0 } update((mc * dqtime).toFixed(decimal)) } }, 0) } } function scroll() { startnum() } startnum() window.addEventListener('scroll', scroll, false) } wormDigitalScroll.prototype = { el: null, time: 100 } function getUrlParam(name) { var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象 var r = window.location.search.substr(1).match(reg); //匹配目标参数 if (r!=null) return unescape(r[2]); return null; //返回参数值 }