]> wagnertech.de Git - mfinanz.git/blobdiff - js/tabcontent.js
Refactoring: DHTML-Tab-Dialog durch Variante aus jQuery-UI ersetzt
[mfinanz.git] / js / tabcontent.js
diff --git a/js/tabcontent.js b/js/tabcontent.js
deleted file mode 100644 (file)
index 62f842d..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-//** Tab Content script v2.0- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)\r
-//** Updated Oct 7th, 07 to version 2.0. Contains numerous improvements:\r
-//   -Added Auto Mode: Script auto rotates the tabs based on an interval, until a tab is explicitly selected\r
-//   -Ability to expand/contract arbitrary DIVs on the page as the tabbed content is expanded/ contracted\r
-//   -Ability to dynamically select a tab either based on its position within its peers, or its ID attribute (give the target tab one 1st)\r
-//   -Ability to set where the CSS classname "selected" get assigned- either to the target tab's link ("A"), or its parent container\r
-//** Updated Feb 18th, 08 to version 2.1: Adds a "tabinstance.cycleit(dir)" method to cycle forward or backward between tabs dynamically\r
-//** Updated April 8th, 08 to version 2.2: Adds support for expanding a tab using a URL parameter (ie: http://mysite.com/tabcontent.htm?tabinterfaceid=0) \r
-\r
-////NO NEED TO EDIT BELOW////////////////////////\r
-\r
-function ddtabcontent(tabinterfaceid){\r
-       this.tabinterfaceid=tabinterfaceid //ID of Tab Menu main container\r
-       this.tabs=document.getElementById(tabinterfaceid).getElementsByTagName("a") //Get all tab links within container\r
-       this.enabletabpersistence=true\r
-       this.hottabspositions=[] //Array to store position of tabs that have a "rel" attr defined, relative to all tab links, within container\r
-       this.currentTabIndex=0 //Index of currently selected hot tab (tab with sub content) within hottabspositions[] array\r
-       this.subcontentids=[] //Array to store ids of the sub contents ("rel" attr values)\r
-       this.revcontentids=[] //Array to store ids of arbitrary contents to expand/contact as well ("rev" attr values)\r
-       this.selectedClassTarget="link" //keyword to indicate which target element to assign "selected" CSS class ("linkparent" or "link")\r
-}\r
-\r
-ddtabcontent.getCookie=function(Name){ \r
-       var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair\r
-       if (document.cookie.match(re)) //if cookie found\r
-               return document.cookie.match(re)[0].split("=")[1] //return its value\r
-       return ""\r
-}\r
-\r
-ddtabcontent.setCookie=function(name, value){\r
-       document.cookie = name+"="+value+";path=/" //cookie value is domain wide (path=/)\r
-}\r
-\r
-ddtabcontent.prototype={\r
-\r
-       expandit:function(tabid_or_position){ //PUBLIC function to select a tab either by its ID or position(int) within its peers\r
-               this.cancelautorun() //stop auto cycling of tabs (if running)\r
-               var tabref=""\r
-               try{\r
-                       if (typeof tabid_or_position=="string" && document.getElementById(tabid_or_position).getAttribute("rel")) //if specified tab contains "rel" attr\r
-                               tabref=document.getElementById(tabid_or_position)\r
-                       else if (parseInt(tabid_or_position)!=NaN && this.tabs[tabid_or_position].getAttribute("rel")) //if specified tab contains "rel" attr\r
-                               tabref=this.tabs[tabid_or_position]\r
-               }\r
-               catch(err){alert("Invalid Tab ID or position entered!")}\r
-               if (tabref!="") //if a valid tab is found based on function parameter\r
-                       this.expandtab(tabref) //expand this tab\r
-       },\r
-\r
-       cycleit:function(dir, autorun){ //PUBLIC function to move foward or backwards through each hot tab (tabinstance.cycleit('foward/back') )\r
-               if (dir=="next"){\r
-                       var currentTabIndex=(this.currentTabIndex<this.hottabspositions.length-1)? this.currentTabIndex+1 : 0\r
-               }\r
-               else if (dir=="prev"){\r
-                       var currentTabIndex=(this.currentTabIndex>0)? this.currentTabIndex-1 : this.hottabspositions.length-1\r
-               }\r
-               if (typeof autorun=="undefined") //if cycleit() is being called by user, versus autorun() function\r
-                       this.cancelautorun() //stop auto cycling of tabs (if running)\r
-               this.expandtab(this.tabs[this.hottabspositions[currentTabIndex]])\r
-       },\r
-\r
-       setpersist:function(bool){ //PUBLIC function to toggle persistence feature\r
-                       this.enabletabpersistence=bool\r
-       },\r
-\r
-       setselectedClassTarget:function(objstr){ //PUBLIC function to set which target element to assign "selected" CSS class ("linkparent" or "link")\r
-               this.selectedClassTarget=objstr || "link"\r
-       },\r
-\r
-       getselectedClassTarget:function(tabref){ //Returns target element to assign "selected" CSS class to\r
-               return (this.selectedClassTarget==("linkparent".toLowerCase()))? tabref.parentNode : tabref\r
-       },\r
-\r
-       urlparamselect:function(tabinterfaceid){\r
-               var result=window.location.search.match(new RegExp(tabinterfaceid+"=(\\d+)", "i")) //check for "?tabinterfaceid=2" in URL\r
-               return (result==null)? null : parseInt(RegExp.$1) //returns null or index, where index (int) is the selected tab's index\r
-       },\r
-\r
-       expandtab:function(tabref){\r
-               var subcontentid=tabref.getAttribute("rel") //Get id of subcontent to expand\r
-               //Get "rev" attr as a string of IDs in the format ",john,george,trey,etc," to easily search through\r
-               var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : ""\r
-               this.expandsubcontent(subcontentid)\r
-               this.expandrevcontent(associatedrevids)\r
-               for (var i=0; i<this.tabs.length; i++){ //Loop through all tabs, and assign only the selected tab the CSS class "selected"\r
-                       this.getselectedClassTarget(this.tabs[i]).className=(this.tabs[i].getAttribute("rel")==subcontentid)? "selected" : ""\r
-               }\r
-               if (this.enabletabpersistence) //if persistence enabled, save selected tab position(int) relative to its peers\r
-                       ddtabcontent.setCookie(this.tabinterfaceid, tabref.tabposition)\r
-               this.setcurrenttabindex(tabref.tabposition) //remember position of selected tab within hottabspositions[] array\r
-       },\r
-\r
-       expandsubcontent:function(subcontentid){\r
-               for (var i=0; i<this.subcontentids.length; i++){\r
-                       var subcontent=document.getElementById(this.subcontentids[i]) //cache current subcontent obj (in for loop)\r
-                       subcontent.style.display=(subcontent.id==subcontentid)? "block" : "none" //"show" or hide sub content based on matching id attr value\r
-               }\r
-       },\r
-\r
-       expandrevcontent:function(associatedrevids){\r
-               var allrevids=this.revcontentids\r
-               for (var i=0; i<allrevids.length; i++){ //Loop through rev attributes for all tabs in this tab interface\r
-                       //if any values stored within associatedrevids matches one within allrevids, expand that DIV, otherwise, contract it\r
-                       document.getElementById(allrevids[i]).style.display=(associatedrevids.indexOf(","+allrevids[i]+",")!=-1)? "block" : "none"\r
-               }\r
-       },\r
-\r
-       setcurrenttabindex:function(tabposition){ //store current position of tab (within hottabspositions[] array)\r
-               for (var i=0; i<this.hottabspositions.length; i++){\r
-                       if (tabposition==this.hottabspositions[i]){\r
-                               this.currentTabIndex=i\r
-                               break\r
-                       }\r
-               }\r
-       },\r
-\r
-       autorun:function(){ //function to auto cycle through and select tabs based on a set interval\r
-               this.cycleit('next', true)\r
-       },\r
-\r
-       cancelautorun:function(){\r
-               if (typeof this.autoruntimer!="undefined")\r
-                       clearInterval(this.autoruntimer)\r
-       },\r
-\r
-       init:function(automodeperiod){\r
-               var persistedtab=ddtabcontent.getCookie(this.tabinterfaceid) //get position of persisted tab (applicable if persistence is enabled)\r
-               var selectedtab=-1 //Currently selected tab index (-1 meaning none)\r
-               var selectedtabfromurl=this.urlparamselect(this.tabinterfaceid) //returns null or index from: tabcontent.htm?tabinterfaceid=index\r
-               this.automodeperiod=automodeperiod || 0\r
-               for (var i=0; i<this.tabs.length; i++){\r
-                       this.tabs[i].tabposition=i //remember position of tab relative to its peers\r
-                       if (this.tabs[i].getAttribute("rel")){\r
-                               var tabinstance=this\r
-                               this.hottabspositions[this.hottabspositions.length]=i //store position of "hot" tab ("rel" attr defined) relative to its peers\r
-                               this.subcontentids[this.subcontentids.length]=this.tabs[i].getAttribute("rel") //store id of sub content ("rel" attr value)\r
-                               this.tabs[i].onclick=function(){\r
-                                       tabinstance.expandtab(this)\r
-                                       tabinstance.cancelautorun() //stop auto cycling of tabs (if running)\r
-                                       return false\r
-                               }\r
-                               if (this.tabs[i].getAttribute("rev")){ //if "rev" attr defined, store each value within "rev" as an array element\r
-                                       this.revcontentids=this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/))\r
-                               }\r
-                               if (selectedtabfromurl==i || this.enabletabpersistence && selectedtab==-1 && parseInt(persistedtab)==i || !this.enabletabpersistence && selectedtab==-1 && this.getselectedClassTarget(this.tabs[i]).className=="selected"){\r
-                                       selectedtab=i //Selected tab index, if found\r
-                               }\r
-                       }\r
-               } //END for loop\r
-               if (selectedtab!=-1) //if a valid default selected tab index is found\r
-                       this.expandtab(this.tabs[selectedtab]) //expand selected tab (either from URL parameter, persistent feature, or class="selected" class)\r
-               else //if no valid default selected index found\r
-                       this.expandtab(this.tabs[this.hottabspositions[0]]) //Just select first tab that contains a "rel" attr\r
-               if (parseInt(this.automodeperiod)>500 && this.hottabspositions.length>1){\r
-                       this.autoruntimer=setInterval(function(){tabinstance.autorun()}, this.automodeperiod)\r
-               }\r
-       } //END int() function\r
-\r
-} //END Prototype assignment
\ No newline at end of file