/** * Tabs widget for RightJS (http://rightjs.org/ui/tabs) * * Copyright (C) 2009-2010 Nikolay Nemshilov */ var Tabs=RightJS.Tabs=function(n,t,e){function u(){return h(e.Cookie?(v.get("right-tabs-indexes")||"").split(","):[])}function z(a,b,c){if(e.Cookie){var f=u();f=f.without.apply(f,b.map("id"));f.push(c.target.id);v.set("right-tabs-indexes",f.uniq().join(","),a)}}var h=e,r=e.$,A=e.$w,g=e.$E,B=e.Fx,C=e.Object,D=e.Browser,E=e.isArray,F=e.isNumber,w=e.Class,s=e.Element,v=e.Cookie,G=new e.Class(e.Element,{initialize:function(a){this.$super("div",{"class":"rui-spinner"});this.dots=[];for(var b=0;b<(a||4);b++)this.dots.push(new e.Element("div")); this.dots[0].addClass("glowing");this.insert(this.dots);e(this.shift).bind(this).periodical(300)},shift:function(){if(this.visible()){var a=this.dots.pop();this.dots.unshift(a);this.insert(a,"top")}}}),j=new (function(a,b){if(!b){b=a;a="DIV"}var c=new e.Class(e.Element.Wrappers[a]||e.Element,{initialize:function(f,d){this.key=f;var i=[{"class":"rui-"+f}];this instanceof e.Input||this instanceof e.Form||i.unshift(a);this.$super.apply(this,i);if(e.isString(d))d=e.$(d);if(d instanceof e.Element){this._= d._;if("$listeners"in d)d.$listeners=d.$listeners;d={}}this.setOptions(d,this);return e.Wrapper.Cache[e.$uid(this._)]=this},setOptions:function(f,d){d=d||this;e.Options.setOptions.call(this,e.Object.merge(f,eval("("+(d.get("data-"+this.key)||"{}")+")")));return this}});c=new e.Class(c,b);e.Observer.createShortcuts(c.prototype,c.EVENTS||[]);return c})("UL",{extend:{version:"2.2.0",EVENTS:A("select hide load disable enable add remove move"),Options:{idPrefix:"",tabsElement:null,resizeFx:"both",resizeDuration:400, scrollTabs:false,scrollDuration:400,selected:null,disabled:null,closable:false,loop:false,loopPause:true,url:false,cache:false,Xhr:null,Cookie:null},rescan:function(a){r(a||n).find(".rui-tabs,*[data-tabs]").each(function(b){b instanceof j||new j(b)})}},initialize:function(a,b){this.$super("tabs",a).setOptions(b).addClass("rui-tabs");this.isHarmonica=this._.tagName==="DL";this.isCarousel=this.hasClass("rui-tabs-carousel");this.isSimple=!this.isHarmonica&&!this.isCarousel;this.findTabs().initScrolls().findCurrent().setStyle("visibility:visible"); this.options.disabled&&this.disable(this.options.disabled);this.options.loop&&this.startLoop()},select:function(a){return this.callTab(a,"select")},disable:function(a){return this.callTab(a,"disable")},enable:function(a){return this.callTab(a,"enable")},current:function(){return this.tabs.first("current")},enabled:function(){return this.tabs.filter("enabled")},callTab:function(a,b){h(E(a)?a:[a]).each(function(c){if(F(c))c=this.tabs[c];c&&c instanceof o&&c[b]()},this);return this},findTabs:function(){this.tabsList= this.isHarmonica?this:r(this.options.tabsElement)||this.first(".rui-tabs-list")||(this.first("UL")||g("UL").insertTo(this)).addClass("rui-tabs-list");this.tabs=h([]);this.tabsList.children(this.isHarmonica?"dt":null).map(function(c){this.tabs.push(new o(c,this))},this);for(var a=0,b=this.tabsList.get("childNodes");a=d&&f-b&&d<=a.width()-b)f=a.width()-b}this.scrollTo(f)}},justScroll:function(a){if(!this.scroller)return this;var b=t(this.tabsList.getStyle("left")||0,10),c=this.scroller.size().x; this.scrollTo(b+c*a)},scrollTo:function(a){var b=this.scroller.size().x,c=this.tabs.map("width").sum();if(a0)a=0;this.tabsList.morph({left:a+"px"},{duration:this.options.scrollDuration});this.checkScrollButtons(c,b,a)},checkScrollButtons:function(a,b,c){var f=false,d=false;if(this.isCarousel){a=this.enabled();if(b=a.first("current")){d=a.indexOf(b);f=d>0;d=db-a}this.prevButton[f?"removeClass":"addClass"]("rui-tabs-scroller-disabled");this.nextButton[d? "removeClass":"addClass"]("rui-tabs-scroller-disabled")}});j.include({findCurrent:function(){var a=this.enabled();(a=this.tabs[this.options.selected]||this.tabs[this.urlIndex()]||this.tabs[this.cookieIndex()]||a.first("current")||a[0])&&a.select();this.options.Cookie&&this.onSelect(h(z).curry(this.options.Cookie,this.tabs));return this},urlIndex:function(){var a=-1,b=n.location.href.split("#")[1];if(b)for(var c=0;c