var ismobile = false, w_width = 0, w_height = 0, $mtoph = 0; var $menubtn = $('.menu-handler'), // $nav = $('.header .nav'), $menubox = $('.menubox'), navitem = 0; //移动端事件和pc事件的切换 var _mousemove; var _click; var _mousedown; var _mouseup; if (modernizr.touch) { _mousemove = "touchmove"; _click = "touchend"; _mousedown = "touchstart"; _mouseup = "touchend"; _mouseenter = "touchend"; } else { _mousemove = "mousemove"; _click = "click"; _mousedown = "mousedown"; _mouseup = "mouseup"; _mouseenter = "mouseenter"; }; function pagebox() { w_width = $(window).width(); w_height = $(window).height(); $mtoph = $('.mtop').height(); if (w_width <= 1024) { ismobile = true; } else if (w_width > 1024) { ismobile = false; }; if(w_width <= 861){ var dannum=0; $('.pnav ul').css('display','none'); $('.pnav').bind(_click,function(){ if(dannum==1){ $(this).removeclass('show'); $(this).find('ul').stop().fadeout(); dannum = 0; }else{ $(this).addclass('show'); $(this).find('ul').stop().fadein(); dannum = 1; } }); }else{ $('.pnav').removeclass('show'); $('.pnav ul').css('display','block'); $('.pnav').unbind(_click); } }; pagebox(); $(window).resize(function () { pagebox(); }); $(function () { $('.nav>li>a').mouseenter(function() { if (ismobile) { return; } var $this = $(this), $next = $this.next(), len = $next.size(), $bg = $('.pull-nav-bg'); $('.nav>li>a').removeclass('cur'); $('.pull-nav').removeclass('show').hide(); if (len) { $this.addclass('cur'); $next.show(function() { $next.addclass('show'); }); $bg.stop().fadein(); } else { $bg.stop().fadeout(); } }); $('.header').mouseleave(function() { $('.nav>li>a').removeclass('cur'); $('.pull-nav').removeclass('show').hide(); $('.pull-nav-bg').stop().fadeout(); }); // 友情链接 // var isopen = 0; // $('.friendship-link').bind(_click, function(){ // if(isopen==0){ // isopen = 1; // $(this).addclass('act'); // $('.friendship-link .k').stop().slidedown(300); // }else{ // isopen = 0; // $(this).removeclass('act'); // $('.friendship-link .k').stop().slideup(300); // } // }); // $('.friendship-link').mouseleave(function(){ // isopen = 0; // $('.friendship-link').removeclass('act'); // $('.friendship-link .k').stop().slideup(300); // }); // 手机导航 $('.navmobile dd > a').bind(_click, function (e) { if($(this).next('.mtv').size() >= 1){ if(!$(this).hasclass('act')){ e.preventdefault(); $('.navmobile dd > a').removeclass('act'); $('.mtv').stop().slideup(300); $(this).addclass('act'); $(this).next('.mtv').stop().slidedown(300); }else{ $(this).removeclass('act'); $(this).next('.mtv').stop().slideup(300); } } }); $menubtn.bind(_click, function () { var w = $menubox.width(); if (navitem == 0) { $('html').addclass('open'); $('.menublack').stop().fadein(600); $(this).addclass('active').stop(false,false).animate({right:w+"px"}); $menubox.show().stop(false,false).animate({right:0}); navitem = 1; } else { $('html').removeclass('open'); $('.menublack').stop().fadeout(600); $(this).removeclass('active').stop(false,false).animate({right:0}); $menubox.stop(false,false).animate({right:-w+"px"},function(){ $(this).hide(); }); navitem = 0; }; }); $('.menublack').bind(_click, function () { var w = $menubox.width(); $('html').removeclass('open'); $menubtn.removeclass('active').stop(false,false).animate({right:0}); $('.menublack').stop().fadeout(600); $menubox.stop(false,false).animate({right:-w+"px"},function(){ $(this).hide(); }); navitem = 0; }); // pbanner animation $(window).scroll(function() { var windowtop = $(window).scrolltop(); if (windowtop < w_height && !ismobile) { $('.pbanner .pic2 img').css('transform', "translate(0px," + (windowtop) / 1.5 + "px)"); $('.pro-banner .pic2 img').css('transform', "translate(0px," + (windowtop) / 1.5 + "px)"); } }); // imitation placeholder function $('.s-input').bind({ focus:function(){ if (this.value == this.defaultvalue){ this.value=""; } },blur:function(){ if (this.value == ""){ this.value = this.defaultvalue; } } }); // back to top $('#top').bind(_click, function(){ $('html,body').stop().animate({scrolltop: 0}, 800); }); // scroll a screen $('#mouse').bind(_click, function(){ $('html,body').stop().animate({scrolltop: w_height}, 800); }); // video play $('.vwrap .close, .vwrap .videobtg').bind(_click, function(){ objplay.stop(); $('.vwrap').hide(); $('#videobox').html(''); }); $('.vi-btn').bind(_click, function(e){ e.stoppropagation(); e.preventdefault(); var img = $(this).attr('data-video-image'); var video = $(this).attr('data-video-url'); video.load({ vcontainer: 'videobox', vfimg: img, vfiles: video, isautoplay: 'true' }); $('.vwrap').fadein(); }); // weixin setpopup($('.weixin'), "官方微信"); function setpopup(obj, title){ obj.bind(_click, function(e){ e.preventdefault(); var str = '
'; $('body').append(str); $('.popupblack').fadein().addclass('show'); $('.popup .close, .popupblack').bind(_click, function(){ $(".popupblack").remove(); }) }) }; // hash function setscroll(anchorcur){ if(jquery(anchorcur).length>=1){ jquery("html,body").animate({ scrolltop: jquery(anchorcur).offset().top-$mtoph}, 0); } }; window.onload = function () { var hash = location.href.split("#")[1]; if (hash) { setscroll("#" + hash); } }; }); // 视频播放 var objplay; var video = { load: function (objs) { objplay = jwplayer(objs.vcontainer).setup({ flashplayer: 'js/video/flashplay.swf', html5player: 'js/video/html5player.js', file: objs.vfiles, image: objs.vfimg, width: '100%', height: '100%', aspectratio: '16:9', stretching: 'fill', controls: 'true', autostart: objs.isautoplay }); return objplay; } }; // 图片全屏 function setimgmax(img, imgw, imgh, tw, th) { var twidth = tw || w_width; var theight = th || w_height; var coe = imgh / imgw; var coe2 = theight / twidth; if (coe < coe2) { var imgwidth = theight / coe; img.css({ height: theight, width: imgwidth, left: -(imgwidth - twidth) / 2, top: 0 }); } else { var imgheight = twidth * coe; img.css({ height: imgheight, width: twidth, left: 0, top: -(imgheight - theight) / 2 }); }; }; // 弹出层 function setlayer(addr){ $.ajax({ url: addr, datatype: 'html', success: function(data){ if (data == "" || data == null) { return; } else { $('body').append(data); $('html').addclass('open'); settimeout(function(){ $('.ly-box').addclass('show'); }, 100); } }, error: function(xmlhttprequest, textstatus, errorthrown){ $('.ly-box').remove(); } }); $(document).on(_click, '.ly-close', function(e){ e.preventdefault(); $('.ly-box').remove(); $('html').removeclass('open'); }); $(document).on(_click, '.ly-box', function(e){ if ($(e.target).hasclass('ly-box')) { $('.ly-box').remove(); $('html').removeclass('open'); } }) }; $(document).on(_click, '.ly-btn', function(e){ e.preventdefault(); setlayer($(this).attr('href')); }); // 截图文字段为一个一个 function splitwords(el) { var _test = el.html().split('
'); el.html(''); for (var i = 0; i < _test.length; i++) { el.append(''); _test[i] = _test[i].split(''); var _span = el.find('span'); for (var j = 0; j < _test[i].length; j++) { _span.eq(i).append(''); var _i = _span.eq(i).find('i'); _i.eq(j).text(_test[i][j]).css({ 'animation-delay': 100*j + 'ms', '-webkit-animation-delay': 100*j + 'ms' }); } } };