MediaWiki:Tabber.js

function tabberObj(t){var e;this.div=null,this.classMain="tabber",this.classMainLive="tabberlive",this.classTab="tabbertab",this.classTabDefault="tabbertabdefault",this.classNav="tabbernav",this.classTabHide="tabbertabhide",this.classNavActive="tabberactive",this.titleElements=["h2","h3","h4","h5","h6"],this.titleElementsStripHTML=!1,this.removeTitle=!0,this.addLinkId=!1,this.linkIdFormat=" nav ";for(e in t)this[e]=t[e];this.REclassMain=new RegExp("\\b"+this.classMain+"\\b","gi"),this.REclassMainLive=new RegExp("\\b"+this.classMainLive+"\\b","gi"),this.REclassTab=new RegExp("\\b"+this.classTab+"\\b","gi"),this.REclassTabDefault=new RegExp("\\b"+this.classTabDefault+"\\b","gi"),this.REclassTabHide=new RegExp("\\b"+this.classTabHide+"\\b","gi"),this.tabs=new Array,this.div&&(this.init(this.div),this.div=null)}function tabberAutomatic(t){var e,a,i;for(t||(t={}),e=new tabberObj(t),a=document.getElementsByTagName("div"),i=0;i<a.length;i++)a[i].className&&a[i].className.match(e.REclassMain)&&(t.div=a[i],a[i].tabber=new tabberObj(t));return this}function tabberAutomaticOnLoad(t){t||(t={}),addOnloadHook(function{tabberAutomatic(t)})}tabberObj.prototype.init=function(t){var e,a,i,s,n,b,l,h,r,c=0;if(!document.getElementsByTagName)return!1;for(t.id&&(this.id=t.id),this.tabs.length=0,e=t.childNodes,a=0;a<e.length;a++)e[a].className&&e[a].className.match(this.REclassTab)&&((s=new Object).div=e[a],this.tabs[this.tabs.length]=s,e[a].className.match(this.REclassTabDefault)&&(c=this.tabs.length-1));for((n=document.createElement("ul")).className=this.classNav,a=0;a]+>/g,""));break}s.headingText||(s.headingText=a+1),b=document.createElement("li"),s.li=b,(l=document.createElement("a")).appendChild(document.createTextNode(s.headingText)),l.href="javascript:void(null);",l.title=s.headingText,l.onclick=this.navClick,l.tabber=this,l.tabberIndex=a,this.addLinkId&&this.linkIdFormat&&(h=(h=(h=(h=(h=this.linkIdFormat).replace(/ /gi,this.id)).replace(/ /gi,a)).replace(/ /gi,a+1)).replace(/ /gi,s.headingText.replace(/[^a-zA-Z0-9\-]/gi,"")),l.id=h),b.appendChild(l),n.appendChild(b)}return t.insertBefore(n,t.firstChild),t.className=t.className.replace(this.REclassMain,this.classMainLive),this.tabShow(c),"function"==typeof this.onLoad&&this.onLoad({tabber:this}),this},tabberObj.prototype.navClick=function(t){var e,a,i,s;return!!(e=this).tabber&&(a=e.tabber,i=e.tabberIndex,e.blur,("function"!=typeof a.onClick||(s={tabber:a,index:i,event:t},t||(s.event=window.event),!1!==a.onClick(s)))&&(a.tabShow(i),!1))},tabberObj.prototype.tabHideAll=function{var t;for(t=0;t<this.tabs.length;t++)this.tabHide(t)},tabberObj.prototype.tabHide=function(t){var e;return!!this.tabs[t]&&((e=this.tabs[t].div).className.match(this.REclassTabHide)||(e.className+=" "+this.classTabHide),this.navClearActive(t),this)},tabberObj.prototype.tabShow=function(t){var e;return!!this.tabs[t]&&(this.tabHideAll,e=this.tabs[t].div,e.className=e.className.replace(this.REclassTabHide,""),this.navSetActive(t),"function"==typeof this.onTabDisplay&&this.onTabDisplay({tabber:this,index:t}),this)},tabberObj.prototype.navSetActive=function(t){return this.tabs[t].li.className=this.classNavActive,this},tabberObj.prototype.navClearActive=function(t){return this.tabs[t].li.className="",this},"undefined"==typeof tabberOptions?tabberAutomaticOnLoad:tabberOptions.manualStartup||tabberAutomaticOnLoad(tabberOptions);