//初始化 (function($){ smoothscroll.init({offset:180}); if($(window).width()<=785){ document.body.addeventlistener('touchstart', function(){ }); }else{ new wow().init(); $('[data-animated="fadein"]').addclass('wow animated fadein'); $('[data-animated="fadeinright"]').addclass('wow animated fadeinright'); $('[data-animated="fadeindown"]').addclass('wow animated fadeindown'); $('[data-animated="fadeinleft"]').addclass('wow animated fadeinleft'); $('[data-animated="fadeinup"]').addclass('wow animated fadeinup'); $('[data-animated="zoomin"]').addclass('wow animated zoomin'); $('[data-animated="lhwidth"]').addclass('wow animated lhwidth'); $('[data-animated="lhheight"]').addclass('wow animated lhheight'); new rellax('.rellax'); } if($('.timer').length>0){ $(window).scroll(function(){ var a = math.round($('.lh-power').offset().top+100); var b = math.round($(window).scrolltop()+$(window).height()); if(a=200){ $('body').addclass('header'); }else{ $('body').removeclass('header'); } $(window).scroll(function(){ var s = $(this).scrolltop(); if(s>=200){ $('body').addclass('header'); }else{ $('body').removeclass('header'); } }); //ban if($('.lh-ban').length>=0){ $(window).scroll(function(){ var s= $(this).scrolltop()/3; $('.lh-ban').css({ 'background-position':'center '+-s+'px' }); }); } //二级导航 if($('#othernav').length>=1){ var wraptop = $('#othernav').offset().top-100; var a = $(window).scrolltop(); if(a>=wraptop){ $('body').addclass('othernav1600'); }else{ $('body').removeclass('othernav1600'); } $(window).scroll(function(){ var s = $(this).scrolltop(); if(s>=wraptop){ $('body').addclass('othernav1600'); }else{ $('body').removeclass('othernav1600'); } }); } var goto = window.location.hash; if(goto){ if(goto=='#go'){ var gototop = $('#othernav').offset().top-100; $('html,body').animate({scrolltop:gototop+'px'}); }else{ settimeout(function(){ var gototop = $(''+goto+'').offset().top-180; $('html,body').animate({scrolltop:gototop+'px'}); },300) /* var gototop = $(''+goto+'').offset().top-180; $('html,body').animate({scrolltop:gototop+'px'}); */ } } } }, returntop : function(){ $('.lhtop').on('click',function(){ $('html,body').animate({scrolltop:'0px'}); }); }, lhbanner : function(a){ var a = a || {}; var opt = $.extend({ 'boxcell' : '.lh-banner', 'titcell' : '.hd', 'maincell' : '.bd', 'prev':'.prev', 'next':'.next', 'interval':6000 },a); var index = 0; var length = $(opt.boxcell).find(opt.maincell).children().length; init(); //init function init(){ $(opt.boxcell).find(opt.maincell).css({ width:$(window).width(), height:$(window).height(), overflow:'hidden' }); $(opt.boxcell).find(opt.maincell).children().eq(0).addclass('first'); next(); prev(); /*$(opt.boxcell).hover(autostop, autoplay);*/ autoplay(); }; //自动播放 function autoplay(){ timer = settimeout(function () { nextplay(); autoplay(); },opt.interval); } function nextplay(){ if(index==length-1){ index=0; }else{ index++; } $(opt.boxcell).find(opt.maincell).children().removeclass('first'); $(opt.boxcell).find(opt.maincell).children().removeclass('old').eq(index-1).addclass('old'); $(opt.boxcell).find(opt.maincell).children().removeclass('cur').eq(index).addclass('cur'); } //结束播放 function autostop(){ cleartimeout(timer); } //next function next(){ $(opt.boxcell).find(opt.next).on('click',function(){ if(index==length-1){ index=0; }else{ index++; } $(opt.boxcell).find(opt.maincell).children().removeclass('first'); $(opt.boxcell).find(opt.maincell).children().removeclass('old').eq(index-1).addclass('old'); $(opt.boxcell).find(opt.maincell).children().removeclass('cur').eq(index).addclass('cur'); }); }; //prev function prev(){ $(opt.boxcell).find(opt.prev).on('click',function(){ if(index==0){ index=length-1; }else{ index--; } var a = index+1; if(index==length-1){ a=0; } $(opt.boxcell).find(opt.maincell).children().removeclass('first'); $(opt.boxcell).find(opt.maincell).children().removeclass('old').eq(a).addclass('old'); $(opt.boxcell).find(opt.maincell).children().removeclass('cur').eq(index).addclass('cur'); }); }; } } public.nav(); //banner图片自适应 $.fn.fullscreen = function(width,height){ $bg = $(this); function setfull(){ var w = $(window).width(); var h = $(window).height(); $('.lh-banner .bd').css({ width:$(window).width(), height:$(window).height(), overflow:'hidden' }); if(w/h < width/height) $bg.height(h).width('auto').css({'margin-left':(w - width*h/height)/2}); else $bg.width(w).height('auto').css({'margin-top':(h - height*w/width)/2}); } setfull(); $(window).resize(setfull); } //计算滚动条宽度 function getscrollwidth() { var noscroll, scroll, odiv = document.createelement("div"); odiv.style.csstext = "position:absolute; top:-1000px; width:100px; height:100px; overflow:hidden;"; noscroll = document.body.appendchild(odiv).clientwidth; odiv.style.overflowy = "scroll"; scroll = odiv.clientwidth; document.body.removechild(odiv); return noscroll-scroll; } //select跳页 function s_click(obj) { var num = 0; for (var i = 0; i < obj.options.length; i++) { if (obj.options[i].selected == true) { num++; } } if (num == 1) { var url = obj.options[obj.selectedindex].value; window.open(url); //这里修改打开连接方式 } }