$(function(){
aa();
if($(window).width()>767){
wowInt();
}
findTel();
phoneTargetSelf();
nav();
if($(window).width()>1024){
ScollText(".scolltext02")
}
if($(window).width()<767){
ScollText(".am_p01")
}
$(document).on("click",".about_tab li",function(){
$(this).addClass("on").siblings().removeClass("on");
$(".about_company .wrap_1440 ul").eq($(this).index()).show().siblings().hide();
})
$(document).on("click",".contact_tab li",function(){
$(this).addClass("on").siblings().removeClass("on");
$(".contact_box li").eq($(this).index()).show().siblings().hide();
})
$(".news_top .right li").hover(function(){
$(this).addClass("on").siblings().removeClass("on");
$(".news_top .left li").eq($(this).index()).stop().fadeIn().siblings().stop().fadeOut();
})
$(".headr_bg").on('touchmove',function(event){
event.preventDefault();
event.stopPropagation();
})
$(document).on("click",".am_close",function(){
$(".am_tac").stop().fadeOut();
})
})
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 nav(){
$(window).scroll(function () {
if ($(this).scrollTop() > 0) {
$('body').addClass('scrollHeader');
} else {
$('body').removeClass('scrollHeader');
}
});
if ($(window).width() >= 1024) {
// 瀵艰埅鑿滃崟
$('.header .nav>li').hover(function() {
$(this).find('.sub-nav').stop().slideDown();
}, function() {
$(this).find('.sub-nav').stop().slideUp();
})
$('.header .search').hover(function() {
$(this).find('.search-wrap').stop().animate({ width: 'toggle' }, 350);
}, function() {
$(this).find('.search-wrap').stop().animate({ width: 'toggle' }, 350);
})
} else {
$('.header .search>i').click(function(){
$(".header .search").toggleClass("cur");
})
$('.header .nav>li').find('.sub-nav').parents('li').find('>a').append('')
$(document).on('click', '.header .nav>li>a i', function(e) {
if (!$(this).parents('li').hasClass("on")) {
$(this).parents('li').find('.sub-nav').stop().slideUp().parents('li').addClass('on');
} else {
$(this).parents('li').find('.sub-nav').stop().slideDown().parents('li').removeClass('on');
}
e.stopPropagation();
if (e && e.preventDefault) {
e.preventDefault();
//IE涓樆姝㈠嚱鏁板櫒榛樿鍔ㄤ綔鐨勬柟寮
} else {
window.event.returnValue = false;
}
return false;
})
$(document).on('click', '.phoneNav', function(e) {
$(".header .search").removeClass("cur");
$('.nav-wrap').stop().animate({ width: 'toggle' }, 150);
})
$(document).on('click', '.nav-wrap .close', function(e) {
$('.nav-wrap').stop().animate({ width: 'toggle' }, 150);
})
$(document).on('click', '.header .nav ol li', function(e) {
$('.nav-wrap').hide();
})
}
}
/*鎵嬫満绔摼鎺ユ敼涓烘湰绐楀彛鎵撳紑*/
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: ""
}
});
}
}
function aa(){
//绂佹鍙屾寚鏀惧ぇ
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);
//绂佹鍙屾寚鏀惧ぇ 鍏煎鑻规灉娴忚鍣
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();
})
}
}