!function(a){a.fn.slide=function(b){return a.fn.slide.defaults={type:"slide",effect:"fade",autoplay:!1,delaytime:500,intertime:2500,triggertime:150,defaultindex:0,titcell:".hd li",maincell:".bd",targetcell:null,trigger:"mouseover",scroll:1,vis:1,titonclassname:"on",autopage:!1,prevcell:".prev",nextcell:".next",pagestatecell:".pagestate",opp:!1,pnloop:!0,easing:"swing",startfun:null,endfun:null,switchload:null,playstatecell:".playstate",mouseoverstop:!0,defaultplay:!0,returndefault:!1},this.each(function(){var c=a.extend({},a.fn.slide.defaults,b),d=a(this),e=c.effect,f=a(c.prevcell,d),g=a(c.nextcell,d),h=a(c.pagestatecell,d),i=a(c.playstatecell,d),j=a(c.titcell,d),k=j.size(),l=a(c.maincell,d),m=l.children().size(),n=c.switchload,o=a(c.targetcell,d),p=parseint(c.defaultindex),q=parseint(c.delaytime),r=parseint(c.intertime);parseint(c.triggertime);var q,t=parseint(c.scroll),u=parseint(c.vis),v="false"==c.autoplay||0==c.autoplay?!1:!0,w="false"==c.opp||0==c.opp?!1:!0,x="false"==c.autopage||0==c.autopage?!1:!0,y="false"==c.pnloop||0==c.pnloop?!1:!0,z="false"==c.mouseoverstop||0==c.mouseoverstop?!1:!0,a="false"==c.defaultplay||0==c.defaultplay?!1:!0,b="false"==c.returndefault||0==c.returndefault?!1:!0,c=0,d=0,e=0,f=0,g=c.easing,h=null,i=null,j=null,k=c.titonclassname,l=j.index(d.find("."+k)),m=p=-1==l?p:l,n=p,o=p,p=m>=u?0!=m%t?m%t:t:0,r="leftmarquee"==e||"topmarquee"==e?!0:!1,s=function(){a.isfunction(c.startfun)&&c.startfun(p,k,d,a(c.titcell,d),l,o,f,g)},t=function(){a.isfunction(c.endfun)&&c.endfun(p,k,d,a(c.titcell,d),l,o,f,g)},u=function(){j.removeclass(k),a&&j.eq(n).addclass(k)};if("menu"==c.type)return a&&j.removeclass(k).eq(p).addclass(k),j.hover(function(){q=a(this).find(c.targetcell);var b=j.index(a(this));i=settimeout(function(){switch(p=b,j.removeclass(k).eq(p).addclass(k),s(),e){case"fade":q.stop(!0,!0).animate({opacity:"show"},q,g,t);break;case"slidedown":q.stop(!0,!0).animate({height:"show"},q,g,t)}},c.triggertime)},function(){switch(cleartimeout(i),e){case"fade":q.animate({opacity:"hide"},q,g);break;case"slidedown":q.animate({height:"hide"},q,g)}}),b&&d.hover(function(){cleartimeout(j)},function(){j=settimeout(u,q)}),void 0;if(0==k&&(k=m),r&&(k=2),x){if(m>=u)if("leftloop"==e||"toploop"==e)k=0!=m%t?(0^m/t)+1:m/t;else{var v=m-u;k=1+parseint(0!=v%t?v/t+1:v/t),0>=k&&(k=1)}else k=1;j.html("");var w="";if(1==c.autopage||"true"==c.autopage)for(var x=0;k>x;x++)w+="
  • "+(x+1)+"
  • ";else for(var x=0;k>x;x++)w+=c.autopage.replace("$",x+1);j.html(w);var j=j.children()}if(m>=u){l.children().each(function(){a(this).width()>e&&(e=a(this).width(),d=a(this).outerwidth(!0)),a(this).height()>f&&(f=a(this).height(),c=a(this).outerheight(!0))});var y=l.children(),z=function(){for(var a=0;u>a;a++)y.eq(a).clone().addclass("clone").appendto(l);for(var a=0;p>a;a++)y.eq(m-a-1).clone().addclass("clone").prependto(l)};switch(e){case"fold":l.css({position:"relative",width:d,height:c}).children().css({position:"absolute",width:e,left:0,top:0,display:"none"});break;case"top":l.wrap('
    ').css({top:-(p*t)*c,position:"relative",padding:"0",margin:"0"}).children().css({height:f});break;case"left":l.wrap('
    ').css({width:m*d,left:-(p*t)*d,position:"relative",overflow:"hidden",padding:"0",margin:"0"}).children().css({"float":"left",width:e});break;case"leftloop":case"leftmarquee":z(),l.wrap('
    ').css({width:(m+u+p)*d,position:"relative",overflow:"hidden",padding:"0",margin:"0",left:-(p+p*t)*d}).children().css({"float":"left",width:e});break;case"toploop":case"topmarquee":z(),l.wrap('
    ').css({height:(m+u+p)*c,position:"relative",padding:"0",margin:"0",top:-(p+p*t)*c}).children().css({height:f})}}var $=function(a){var b=a*t;return a==k?b=m:-1==a&&0!=m%t&&(b=-m%t),b},_=function(b){var c=function(c){for(var d=c;u+c>d;d++)b.eq(d).find("img["+n+"]").each(function(){var b=a(this);if(b.attr("src",b.attr(n)).removeattr(n),l.find(".clone")[0])for(var c=l.children(),d=0;d=1?p=1:0>=p&&(p=0):(o=p,p>=k?p=0:0>p&&(p=k-1)),s(),null!=n&&_(l.children()),o[0]&&(q=o.eq(p),null!=n&&_(o),"slidedown"==e?(o.not(q).stop(!0,!0).slideup(q),q.slidedown(q,g,function(){l[0]||t()})):(o.not(q).stop(!0,!0).hide(),q.animate({opacity:"show"},q,function(){l[0]||t()}))),m>=u)switch(e){case"fade":l.children().stop(!0,!0).eq(p).animate({opacity:"show"},q,g,function(){t()}).siblings().hide();break;case"fold":l.children().stop(!0,!0).eq(p).animate({opacity:"show"},q,g,function(){t()}).siblings().animate({opacity:"hide"},q,g);break;case"top":l.stop(!0,!1).animate({top:-p*t*c},q,g,function(){t()});break;case"left":l.stop(!0,!1).animate({left:-p*t*d},q,g,function(){t()});break;case"leftloop":var b=o;l.stop(!0,!0).animate({left:-($(o)+p)*d},q,g,function(){-1>=b?l.css("left",-(p+(k-1)*t)*d):b>=k&&l.css("left",-p*d),t()});break;case"toploop":var b=o;l.stop(!0,!0).animate({top:-($(o)+p)*c},q,g,function(){-1>=b?l.css("top",-(p+(k-1)*t)*c):b>=k&&l.css("top",-p*c),t()});break;case"leftmarquee":var c=l.css("left").replace("px","");0==p?l.animate({left:++c},0,function(){l.css("left").replace("px","")>=0&&l.css("left",-m*d)}):l.animate({left:--c},0,function(){l.css("left").replace("px","")<=-(m+p)*d&&l.css("left",-p*d)});break;case"topmarquee":var d=l.css("top").replace("px","");0==p?l.animate({top:++d},0,function(){l.css("top").replace("px","")>=0&&l.css("top",-m*c)}):l.animate({top:--d},0,function(){l.css("top").replace("px","")<=-(m+p)*c&&l.css("top",-p*c)})}j.removeclass(k).eq(p).addclass(k),m=p,y||(g.removeclass("nextstop"),f.removeclass("prevstop"),0==p&&f.addclass("prevstop"),p==k-1&&g.addclass("nextstop")),h.html(""+(p+1)+"/"+k)}};a&&ab(!0),b&&d.hover(function(){cleartimeout(j)},function(){j=settimeout(function(){p=n,a?ab():"slidedown"==e?q.slideup(q,u):q.animate({opacity:"hide"},q,u),m=p},300)});var bb=function(a){h=setinterval(function(){w?p--:p++,ab()},a?a:r)},cb=function(a){h=setinterval(ab,a?a:r)},db=function(){z||(clearinterval(h),bb())},eb=function(){(y||p!=k-1)&&(p++,ab(),r||db())},fb=function(){(y||0!=p)&&(p--,ab(),r||db())},gb=function(){clearinterval(h),r?cb():bb(),i.removeclass("pausestate")},hb=function(){clearinterval(h),i.addclass("pausestate")};if(v?r?(w?p--:p++,cb(),z&&l.hover(hb,gb)):(bb(),z&&d.hover(hb,gb)):(r&&(w?p--:p++),i.addclass("pausestate")),i.click(function(){i.hasclass("pausestate")?gb():hb()}),"mouseover"==c.trigger?j.hover(function(){var a=j.index(this);i=settimeout(function(){p=a,ab(),db()},c.triggertime)},function(){cleartimeout(i)}):j.click(function(){p=j.index(this),ab(),db()}),r){if(g.mousedown(eb),f.mousedown(fb),y){var ib,jb=function(){ib=settimeout(function(){clearinterval(h),cb(0^r/10)},150)},kb=function(){cleartimeout(ib),clearinterval(h),cb()};g.mousedown(jb),g.mouseup(kb),f.mousedown(jb),f.mouseup(kb)}"mouseover"==c.trigger&&(g.hover(eb,function(){}),f.hover(fb,function(){}))}else g.click(eb),f.click(fb)})}}(jquery),jquery.easing.jswing=jquery.easing.swing,jquery.extend(jquery.easing,{def:"easeoutquad",swing:function(a,b,c,d,e){return jquery.easing[jquery.easing.def](a,b,c,d,e)},easeinquad:function(a,b,c,d,e){return d*(b/=e)*b+c},easeoutquad:function(a,b,c,d,e){return-d*(b/=e)*(b-2)+c},easeinoutquad:function(a,b,c,d,e){return(b/=e/2)<1?d/2*b*b+c:-d/2*(--b*(b-2)-1)+c},easeincubic:function(a,b,c,d,e){return d*(b/=e)*b*b+c},easeoutcubic:function(a,b,c,d,e){return d*((b=b/e-1)*b*b+1)+c},easeinoutcubic:function(a,b,c,d,e){return(b/=e/2)<1?d/2*b*b*b+c:d/2*((b-=2)*b*b+2)+c},easeinquart:function(a,b,c,d,e){return d*(b/=e)*b*b*b+c},easeoutquart:function(a,b,c,d,e){return-d*((b=b/e-1)*b*b*b-1)+c},easeinoutquart:function(a,b,c,d,e){return(b/=e/2)<1?d/2*b*b*b*b+c:-d/2*((b-=2)*b*b*b-2)+c},easeinquint:function(a,b,c,d,e){return d*(b/=e)*b*b*b*b+c},easeoutquint:function(a,b,c,d,e){return d*((b=b/e-1)*b*b*b*b+1)+c},easeinoutquint:function(a,b,c,d,e){return(b/=e/2)<1?d/2*b*b*b*b*b+c:d/2*((b-=2)*b*b*b*b+2)+c},easeinsine:function(a,b,c,d,e){return-d*math.cos(b/e*(math.pi/2))+d+c},easeoutsine:function(a,b,c,d,e){return d*math.sin(b/e*(math.pi/2))+c},easeinoutsine:function(a,b,c,d,e){return-d/2*(math.cos(math.pi*b/e)-1)+c},easeinexpo:function(a,b,c,d,e){return 0==b?c:d*math.pow(2,10*(b/e-1))+c},easeoutexpo:function(a,b,c,d,e){return b==e?c+d:d*(-math.pow(2,-10*b/e)+1)+c},easeinoutexpo:function(a,b,c,d,e){return 0==b?c:b==e?c+d:(b/=e/2)<1?d/2*math.pow(2,10*(b-1))+c:d/2*(-math.pow(2,-10*--b)+2)+c},easeincirc:function(a,b,c,d,e){return-d*(math.sqrt(1-(b/=e)*b)-1)+c},easeoutcirc:function(a,b,c,d,e){return d*math.sqrt(1-(b=b/e-1)*b)+c},easeinoutcirc:function(a,b,c,d,e){return(b/=e/2)<1?-d/2*(math.sqrt(1-b*b)-1)+c:d/2*(math.sqrt(1-(b-=2)*b)+1)+c},easeinelastic:function(a,b,c,d,e){var f=1.70158,g=0,h=d;if(0==b)return c;if(1==(b/=e))return c+d;if(g||(g=.3*e),hb?-.5*h*math.pow(2,10*(b-=1))*math.sin((b*e-f)*2*math.pi/g)+c:.5*h*math.pow(2,-10*(b-=1))*math.sin((b*e-f)*2*math.pi/g)+d+c},easeinback:function(a,b,c,d,e,f){return void 0==f&&(f=1.70158),d*(b/=e)*b*((f+1)*b-f)+c},easeoutback:function(a,b,c,d,e,f){return void 0==f&&(f=1.70158),d*((b=b/e-1)*b*((f+1)*b+f)+1)+c},easeinoutback:function(a,b,c,d,e,f){return void 0==f&&(f=1.70158),(b/=e/2)<1?d/2*b*b*(((f*=1.525)+1)*b-f)+c:d/2*((b-=2)*b*(((f*=1.525)+1)*b+f)+2)+c},easeinbounce:function(a,b,c,d,e){return d-jquery.easing.easeoutbounce(a,e-b,0,d,e)+c},easeoutbounce:function(a,b,c,d,e){return(b/=e)<1/2.75?d*7.5625*b*b+c:2/2.75>b?d*(7.5625*(b-=1.5/2.75)*b+.75)+c:2.5/2.75>b?d*(7.5625*(b-=2.25/2.75)*b+.9375)+c:d*(7.5625*(b-=2.625/2.75)*b+.984375)+c},easeinoutbounce:function(a,b,c,d,e){return e/2>b?.5*jquery.easing.easeinbounce(a,2*b,0,d,e)+c:.5*jquery.easing.easeoutbounce(a,2*b-e,0,d,e)+.5*d+c}}); //--------------------------------滑动门 js-----------------------------------// $(document).ready(function(){ var $tab_li = $('#tab ul li'); $tab_li.hover(function(){ $(this).addclass('selected').siblings().removeclass('selected'); var index = $tab_li.index(this); $('div.tab_box > div').eq(index).show().siblings().hide(); }); }); $(document).ready(function(){ var $tab_li = $('#tab01 ul li'); $tab_li.hover(function(){ $(this).addclass('selected').siblings().removeclass('selected'); var index = $tab_li.index(this); $('div.tab_box01 > div').eq(index).show().siblings().hide(); }); }); $(document).ready(function(){ var $tab_li = $('#tab_c ul li'); $tab_li.hover(function(){ $(this).addclass('selected').siblings().removeclass('selected'); var index = $tab_li.index(this); $('div.tab_box_c > div').eq(index).show().siblings().hide(); }); }); //纵向// $(document).ready(function(){ var $tab_li = $('#tab_2 ul li'); $tab_li.hover(function(){ $(this).addclass('selected').siblings().removeclass('selected'); var index = $tab_li.index(this); $('div.tab_box_2 > div').eq(index).show().siblings().hide(); }); }); $(document).ready(function(){ var $tab_li = $('#tab_3 ul li'); $tab_li.hover(function(){ $(this).addclass('selected').siblings().removeclass('selected'); var index = $tab_li.index(this); $('div.tab_box_3 > div').eq(index).show().siblings().hide(); }); }); //--------------------------------图片滚动 js---------------------------------------// /*scrollpic.js*/ var sina = { $: function (objname) { if (document.getelementbyid) { return eval('document.getelementbyid("' + objname + '")') } else { return eval('document.all.' + objname) } }, isie: navigator.appversion.indexof("msie") != -1 ? true : false, addevent: function (l, i, i) { if (l.attachevent) { l.attachevent("on" + i, i) } else { l.addeventlistener(i, i, false) } }, delevent: function (l, i, i) { if (l.detachevent) { l.detachevent("on" + i, i) } else { l.removeeventlistener(i, i, false) } }, readcookie: function (o) { var o = "", l = o + "="; if (document.cookie.length > 0) { var i = document.cookie.indexof(l); if (i != -1) { i += l.length; var i = document.cookie.indexof(";", i); if (i == -1) i = document.cookie.length; o = unescape(document.cookie.substring(i, i)) } }; return o }, writecookie: function (i, l, o, c) { var o = "", i = ""; if (o != null) { o = new date((new date).gettime() + o * 3600000); o = "; expires=" + o.togmtstring() }; if (c != null) { i = ";domain=" + c }; document.cookie = i + "=" + escape(l) + o + i }, readstyle: function (i, l) { if (i.style[l]) { return i.style[l] } else if (i.currentstyle) { return i.currentstyle[l] } else if (document.defaultview && document.defaultview.getcomputedstyle) { var i = document.defaultview.getcomputedstyle(i, null); return i.getpropertyvalue(l) } else { return null } } }; //滚动图片构造函数 //ui&ue dept. mengjia //080623 function scrollpic(scrollcontid, arrleftid, arrrightid, dotlistid) { this.scrollcontid = scrollcontid; this.arrleftid = arrleftid; this.arrrightid = arrrightid; this.dotlistid = dotlistid; this.dotclassname = "dotitem"; this.dotonclassname = "dotitemon"; this.dotobjarr = []; this.pagewidth = 0; this.framewidth = 0; this.speed = 10; this.space = 10; this.pageindex = 0; this.autoplay = true; this.autoplaytime = 5; var _autotimeobj, _scrolltimeobj, _state = "ready"; this.stripdiv = document.createelement("div"); this.listdiv01 = document.createelement("div"); this.listdiv02 = document.createelement("div"); if (!scrollpic.childs) { scrollpic.childs = [] }; this.id = scrollpic.childs.length; scrollpic.childs.push(this); this.initialize = function () { if (!this.scrollcontid) { throw new error("必须指定scrollcontid."); return }; this.scrollcontdiv = sina.$(this.scrollcontid); if (!this.scrollcontdiv) { throw new error("scrollcontid不是正确的对象.(scrollcontid = \"" + this.scrollcontid + "\")"); return }; this.scrollcontdiv.style.width = this.framewidth + "px"; this.scrollcontdiv.style.overflow = "hidden"; this.listdiv01.innerhtml = this.listdiv02.innerhtml = this.scrollcontdiv.innerhtml; this.scrollcontdiv.innerhtml = ""; this.scrollcontdiv.appendchild(this.stripdiv); this.stripdiv.appendchild(this.listdiv01); this.stripdiv.appendchild(this.listdiv02); this.stripdiv.style.overflow = "hidden"; this.stripdiv.style.zoom = "1"; this.stripdiv.style.width = "32766px"; if(!+[1,]){this.listdiv01.style.stylefloat="left";this.listdiv02.style.stylefloat="left";}else{this.listdiv01.style.cssfloat="left";this.listdiv02.style.cssfloat="left";} sina.addevent(this.scrollcontdiv, "mouseover", function("scrollpic.childs[" + this.id + "].stop()")); sina.addevent(this.scrollcontdiv, "mouseout", function("scrollpic.childs[" + this.id + "].play()")); if (this.arrleftid) { this.arrleftobj = sina.$(this.arrleftid); if (this.arrleftobj) { sina.addevent(this.arrleftobj, "mousedown", function("scrollpic.childs[" + this.id + "].rightmousedown()")); sina.addevent(this.arrleftobj, "mouseup", function("scrollpic.childs[" + this.id + "].rightend()")); sina.addevent(this.arrleftobj, "mouseout", function("scrollpic.childs[" + this.id + "].rightend()")) } }; if (this.arrrightid) { this.arrrightobj = sina.$(this.arrrightid); if (this.arrrightobj) { sina.addevent(this.arrrightobj, "mousedown", function("scrollpic.childs[" + this.id + "].leftmousedown()")); sina.addevent(this.arrrightobj, "mouseup", function("scrollpic.childs[" + this.id + "].leftend()")); sina.addevent(this.arrrightobj, "mouseout", function("scrollpic.childs[" + this.id + "].leftend()")) } }; if (this.dotlistid) { this.dotlistobj = sina.$(this.dotlistid); if (this.dotlistobj) { var pages = math.round(this.listdiv01.offsetwidth / this.framewidth + 0.4), i, tempobj; for (i = 0; i < pages; i++) { tempobj = document.createelement("span"); this.dotlistobj.appendchild(tempobj); this.dotobjarr.push(tempobj); if (i == this.pageindex) { tempobj.classname = this.dotclassname } else { tempobj.classname = this.dotonclassname }; tempobj.title = "第" + (i + 1) + "页"; sina.addevent(tempobj, "click", function("scrollpic.childs[" + this.id + "].pageto(" + i + ")")) } } }; if (this.autoplay) { this.play() } }; this.leftmousedown = function () { if (_state != "ready") { return }; _state = "floating"; _scrolltimeobj = setinterval("scrollpic.childs[" + this.id + "].moveleft()", this.speed) }; this.rightmousedown = function () { if (_state != "ready") { return }; _state = "floating"; _scrolltimeobj = setinterval("scrollpic.childs[" + this.id + "].moveright()", this.speed) }; this.moveleft = function () { if (this.scrollcontdiv.scrollleft + this.space >= this.listdiv01.scrollwidth) { this.scrollcontdiv.scrollleft = this.scrollcontdiv.scrollleft + this.space - this.listdiv01.scrollwidth } else { this.scrollcontdiv.scrollleft += this.space }; this.accountpageindex() }; this.moveright = function () { if (this.scrollcontdiv.scrollleft - this.space <= 0) { this.scrollcontdiv.scrollleft = this.listdiv01.scrollwidth + this.scrollcontdiv.scrollleft - this.space } else { this.scrollcontdiv.scrollleft -= this.space }; this.accountpageindex() }; this.leftend = function () { if (_state != "floating") { return }; _state = "stoping"; clearinterval(_scrolltimeobj); var fill = this.pagewidth - this.scrollcontdiv.scrollleft % this.pagewidth; this.move(fill) }; this.rightend = function () { if (_state != "floating") { return }; _state = "stoping"; clearinterval(_scrolltimeobj); var fill = -this.scrollcontdiv.scrollleft % this.pagewidth; this.move(fill) }; this.move = function (num, quick) { var thismove = num / 5; if (!quick) { if (thismove > this.space) { thismove = this.space }; if (thismove < -this.space) { thismove = -this.space } }; if (math.abs(thismove) < 1 && thismove != 0) { thismove = thismove >= 0 ? 1 : -1 } else { thismove = math.round(thismove) }; var temp = this.scrollcontdiv.scrollleft + thismove; if (thismove > 0) { if (this.scrollcontdiv.scrollleft + thismove >= this.listdiv01.scrollwidth) { this.scrollcontdiv.scrollleft = this.scrollcontdiv.scrollleft + thismove - this.listdiv01.scrollwidth } else { this.scrollcontdiv.scrollleft += thismove } } else { if (this.scrollcontdiv.scrollleft - thismove <= 0) { this.scrollcontdiv.scrollleft = this.listdiv01.scrollwidth + this.scrollcontdiv.scrollleft - thismove } else { this.scrollcontdiv.scrollleft += thismove } }; num -= thismove; if (math.abs(num) == 0) { _state = "ready"; if (this.autoplay) { this.play() }; this.accountpageindex(); return } else { this.accountpageindex(); settimeout("scrollpic.childs[" + this.id + "].move(" + num + "," + quick + ")", this.speed) } }; this.next = function () { if (_state != "ready") { return }; _state = "stoping"; this.move(this.pagewidth, true) }; this.play = function () { if (!this.autoplay) { return }; clearinterval(_autotimeobj); _autotimeobj = setinterval("scrollpic.childs[" + this.id + "].next()", this.autoplaytime * 1000) }; this.stop = function () { clearinterval(_autotimeobj) }; this.pageto = function (num) { if (_state != "ready") { return }; _state = "stoping"; var fill = num * this.framewidth - this.scrollcontdiv.scrollleft; this.move(fill, true) }; this.accountpageindex = function () { this.pageindex = math.round(this.scrollcontdiv.scrollleft / this.framewidth); if (this.pageindex > math.round(this.listdiv01.offsetwidth / this.framewidth + 0.4) - 1) { this.pageindex = 0 }; var i; for (i = 0; i < this.dotobjarr.length; i++) { if (i == this.pageindex) { this.dotobjarr[i].classname = this.dotclassname } else { this.dotobjarr[i].classname = this.dotonclassname } } } }; //--------------------------------立体式旋转---------------------------------------// ;(function($){ var carousel = function(poster){ var self = this; //保存单个旋转木马对象 this.poster = poster; this.posteritemmain = poster.find("ul.poster-list"); this.nextbtn = poster.find("div.poster-next-btn"); this.prevbtn = poster.find("div.poster-prev-btn"); this.posteritems = poster.find("li.poster-item"); if( this.posteritems.size()%2 == 0 ){ this.posteritemmain.append( this.posteritems.eq(0).clone() ); this.posteritems = this.posteritemmain.children(); }; this.posterfirstitem = this.posteritems.first(); this.posterlastitem = this.posteritems.last(); this.rotateflag = true; //默认配置参数 this.setting = { "width" : 1080, //幻灯片的宽度 "height" : 275, //幻灯片的高度 "posterwidth" : 475, //幻灯片第一帧的宽度 "posterheight" : 275, //幻灯片第一帧的高度 "scale" : 0.8, //记录显示比例关系 "speed" : 300, "autoplay" : true, "delay" : 2000, "verticalalign" : "middle" //top bottom }; $.extend( this.setting,this.getsetting() ); //设置配置参数值 this.setsettingvalue(); //初始化幻灯片位置 this.setposterpos(); //左旋转按钮 this.nextbtn.click(function(){ if(self.rotateflag){ self.rotateflag = false; self.carouserotate("left"); }; }); //右旋转按钮 this.prevbtn.click(function(){ if(self.rotateflag){ self.rotateflag = false; self.carouserotate("right"); }; }); //是否开启自动播放 if(this.setting.autoplay){ this.autoplay(); this.poster.hover( function(){ //self.timer是setinterval的种子 window.clearinterval(self.timer); }, function(){ self.autoplay(); }); }; }; carousel.prototype = { autoplay:function(){ var self = this; this.timer = window.setinterval( function(){ self.nextbtn.click(); }, this.setting.delay ); }, //旋转 carouserotate:function(dir){ var _this_ = this; var zindexarr = []; //左旋转 if(dir === "left"){ this.posteritems.each(function(){ var self = $(this), prev = self.prev().get(0)?self.prev():_this_.posterlastitem, width = prev.width(), height =prev.height(), opacity = prev.css("opacity"), left = prev.css("left"), top = prev.css("top"), zindex = prev.css("zindex"); zindexarr.push(zindex); self.animate({ width :width, height :height, //zindex :zindex, opacity :opacity, left :left, top :top },_this_.setting.speed,function(){ _this_.rotateflag = true; }); }); //zindex需要单独保存再设置,防止循环时候设置再取的时候值永远是最后一个的zindex this.posteritems.each(function(i){ $(this).css("zindex",zindexarr[i]); }); }else if(dir === "right"){//右旋转 this.posteritems .each(function(){ var self = $(this), next = self.next().get(0)?self.next():_this_.posterfirstitem, width = next.width(), height =next.height(), opacity = next.css("opacity"), left = next.css("left"), top = next.css("top"), zindex = next.css("zindex"); zindexarr.push(zindex); self.animate({ width :width, height :height, //zindex :zindex, opacity :opacity, left :left, top :top },_this_.setting.speed,function(){ _this_.rotateflag = true; }); }); //zindex需要单独保存再设置,防止循环时候设置再取的时候值永远是最后一个的zindex this.posteritems.each(function(i){ $(this).css("zindex",zindexarr[i]); }); }; }, //设置剩余的帧的位置关系 setposterpos:function(){ var self = this, sliceitems = this.posteritems.slice(1), slicesize = sliceitems.size()/2, rightslice = sliceitems.slice(0,slicesize), //存在图片奇偶数问题 level = math.floor(this.posteritems.size()/2), leftslice = sliceitems.slice(slicesize); //设置右边帧的位置关系和宽度高度top var firstleft = (this.setting.width - this.setting.posterwidth)/2; var rw = this.setting.posterwidth, fixoffsetleft = firstleft + rw, rh = this.setting.posterheight, gap = ((this.setting.width - this.setting.posterwidth)/2)/level; //设置右边位置关系 rightslice.each(function(i){ level--; rw = rw * self.setting.scale; rh = rh * self.setting.scale; var j = i; $(this).css({ zindex :level, width :rw, height :rh, opacity :1/(++j), left :fixoffsetleft+(++i)*gap - rw, top :self.setverticalalign(rh) }); }); //设置左边的位置关系 var lw = rightslice.last().width(), lh =rightslice.last().height(), oloop = math.floor(this.posteritems.size()/2); leftslice.each(function(i){ $(this).css({ zindex:i, width:lw, height:lh, opacity:1/oloop, left:i*gap, top:self.setverticalalign(lh) }); lw = lw/self.setting.scale; lh = lh/self.setting.scale; oloop--; }); }, //设置垂直排列对齐 setverticalalign:function(height){ var verticaltype = this.setting.verticalalign, top = 0; if(verticaltype === "middle"){ top = (this.setting.height-height)/2; }else if(verticaltype === "top"){ top = 0; }else if(verticaltype === "bottom"){ top = this.setting.height-height; }else{ top = (this.setting.height-height)/2; }; return top; }, //设置配置参数值去控制基本的宽度高度。。。 setsettingvalue:function(){ this.poster.css({ width:this.setting.width, height:this.setting.height }); this.posteritemmain.css({ width:this.setting.width, height:this.setting.height }); //计算上下切换按钮的宽度 var w = (this.setting.width-this.setting.posterwidth)/2; //设置切换按钮的宽高,层级关系 this.nextbtn.css({ width:w, height:this.setting.height, zindex:math.ceil(this.posteritems.size()/2) }); this.prevbtn.css({ width:w, height:this.setting.height, zindex:math.ceil(this.posteritems.size()/2) }); this.posterfirstitem.css({ width:this.setting.posterwidth, height:this.setting.posterheight, left:w, top:0, zindex:math.floor(this.posteritems.size()/2) }); }, //获取人工配置参数 getsetting:function(){ var setting = this.poster.attr("data-setting"); if(setting && setting != ""){ return $.parsejson(setting); }else{ return {}; }; } }; carousel.init = function(posters){ var _this_ = this; posters.each(function(){ // console.log("halo louis;") new _this_($(this)); }); }; //挂载到window下 window.carousel = carousel; })(jquery);