var base=new function(){ var o={}; return o={ data:{ "navbool":true, "navtimeout":null }, /*wapbtn*/ wapbtn:function(){; if(this.data.navbool){ var h=parseint($(document).height())-parseint($(".header").css("height")); $(".navbg").show(); $(".header .nav").css("height",h+"px").show(); $(".header .nav").animate({ "right":"0px" },500); this.data.navbool=false; }else{ $(".navbg").hide(); $(".header .nav").animate({ "right":"-180px" },500); this.data.navbool=true; } }, /*urlhref*/ urlhref:function(data){ data.time=data.time||500; var top=parseint($(data.element).offset().top); var headertop=parseint($(".header").css("height")); top=top-headertop; $('html,body').animate({scrolltop:top},data.time); }, /*animateclassadd */ anclasadd:function(e,keyframes,stime,dtime,an,status){ //animation:mcontentin .8s ease-in-out 0s both; var status=status||"both", an=an||"ease-in-out"; $(e).css({ "animation":keyframes+" "+stime+" "+an+" "+dtime+" "+status, "-moz-animation":keyframes+" "+stime+" "+an+" "+dtime+" "+status, "-webkit-animation":keyframes+" "+stime+" "+an+" "+dtime+" "+status, "-o-animation":keyframes+" "+stime+" "+an+" "+dtime+" "+status }); }, /*cutstring*/ cutstring:function(str, len) { if(str.length*2 <= len) {return str;} var strlen = 0;var s = ""; for(var i = 0;i < str.length; i++) { s = s + str.charat(i); if (str.charcodeat(i) > 128) { strlen = strlen + 2; if(strlen >= len){ return s.substring(0,s.length-1) + "..."; } } else { strlen = strlen + 1; if(strlen >= len){ return s.substring(0,s.length-2) + "..."; } } } return s; }, /*bool img status*/ imgload:function(img, callback) { var timer = setinterval(function() { if (img.complete) { callback(img) clearinterval(timer) } }, 50) }, /*auto height*/ tableheightbool:function(parent,child){ $(parent).find(child).css("height","auto"); $(parent).each(function(index, element) { var maxheight=$(parent+":eq("+index+")").find(child+":eq(0)").height(); $(parent+":eq("+index+")").find(child).each(function(index1, element1) { if($(parent+":eq("+index+")").find(child+":eq("+index1+")").height()>maxheight) maxheight=$(parent+":eq("+index+")").find(child+":eq("+index1+")").height(); }); $(parent+":eq("+index+")").find(child).css("height",maxheight+"px"); }); }, /*bg change*/ bgfunc:function(e,style){ var screenw=$(document).width(); $(e).each(function(index, element) { if(screenw<1024){ if($(element).attr("data-bg-wap")){ var src=$(element).attr("data-bg-wap"); if(style=="img") $(element).attr({"src":src}); else $(element).css({"background-image":"url("+src+")"}); } }else{ if($(element).attr("data-bg-pc")){ var src=$(element).attr("data-bg-pc"); if(style=="img") $(element).attr({"src":src}); else $(element).css({"background-image":"url("+src+")"}); } } }); } }; } $(function(){ var navindex=$(".header .nav li").index($(".header .nav li.on")); navtopan(navindex); $(".header .nav li").unbind("click").bind("mouseover",function(){ navindex=$(".header .nav li").index($(this)); navtopan(navindex); }).bind("mouseleave",function(){ var navindex=$(".header .nav li").index($(".header .nav li.on")); navtopan(navindex); }); /*生成loading效果*/ var loadi=0; setinterval(function(){ loadi++; if(loadi>=20)loadi=0 var a=-loadi*64; $(".loading").css({ "background-position":a+"px 0px" }); },60); }); /*nav top*/ function navtopan(index){ var navw=$(".nav li.on").width(); $(".nav .navtop").css({ "width":navw, "display":"block", "left":navw*index }); $(".header .nav li:eq("+index+") .list").show(); }