$(function () { wowInt(); findTel(); search(); nav(); phoneTargetSelf(); $(window).resize(); $(window).scroll(function () { if ($(this).scrollTop() > 0) { $('body').addClass('scrollHeader'); } else { $('body').removeClass('scrollHeader'); } }); //绂佹鍙屾寚鏀惧ぇ document.documentElement.addEventListener('touchstart', function (event) { if (event.touches.length > 1) { event.preventDefault(); } }, false); //绂佹鍙屽嚮鏀惧ぇ var lastTouchEnd = 0; document.documentElement.addEventListener('touchend', function (event) { var now = Date.now(); if (now - lastTouchEnd <= 300) { event.preventDefault(); } lastTouchEnd = now; }, false); $(document).on("click",".d_span span.font_size a",function(){ $(this).addClass("on").siblings().removeClass("on") }) $("#small").click(function(){ $(".details_text").removeClass("zhong da").addClass("xiao") }) $("#middle").click(function(){ $(".details_text").removeClass("xiao da").addClass("zhong") }) $("#big").click(function(){ $(".details_text").removeClass("xiao zhong").addClass("da") }) }) //绂佹鍙屾寚鏀惧ぇ 鍏煎鑻规灉娴忚鍣 window.onload = function() { var lastTouchEnd = 0; document.addEventListener('touchstart', function(event) { if (event.touches.length > 1) { event.preventDefault(); } }); document.addEventListener('touchend', function(event) { var now = (new Date()).getTime(); if (now - lastTouchEnd <= 300) { event.preventDefault(); } lastTouchEnd = now; }, false); document.addEventListener('gesturestart', function(event) { event.preventDefault(); }); document.addEventListener('dblclick', function (event) { event.preventDefault(); }) } 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).parents("dl").addClass("on"); $(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"); }) $(".navlist>.wrap>.return_a").click(function(){ $(this).parents("li").removeClass("cur"); }) $(".navlist dd .return_a").click(function(){ $(this).parents("dl").removeClass("on"); }) 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鐨刾laceholder鍖呭惈瀵嗙爜妗嗙殑鍏煎*/ $(function() { // 濡傛灉涓嶆敮鎸乸laceholder锛岀敤jQuery鏉ュ畬鎴 if(!isSupportPlaceholder()) { // 閬嶅巻鎵€鏈塱nput瀵硅薄, 闄や簡瀵嗙爜妗 $('input').not("input[type='password']").each( function() { var self = $(this); var val = self.attr("placeholder"); input(self, val); } ); /**//* 瀵筽assword妗嗙殑鐗规畩澶勭悊 * 1.鍒涘缓涓€涓猼ext妗 * 2.鑾峰彇鐒︾偣鍜屽け鍘荤劍鐐圭殑鏃跺€欏垏鎹 */ $('input[type="password"]').each( function(i) { var pwdField = $(this); var pwdVal = pwdField.attr('placeholder'); var pwdId = pwdField.attr('id'); // 閲嶅懡鍚嶈input鐨刬d涓哄師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(); } }); } ); } }); // 鍒ゆ柇娴忚鍣ㄦ槸鍚︽敮鎸乸laceholder灞炴€ 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 +"=([^&]*)(&|$)"); //鏋勯€犱竴涓惈鏈夌洰鏍囧弬鏁扮殑姝e垯琛ㄨ揪寮忓璞 var r = window.location.search.substr(1).match(reg); //鍖归厤鐩爣鍙傛暟 if (r!=null) return unescape(r[2]); return null; //杩斿洖鍙傛暟鍊 }