src/web/app/themes/atahualpa/options/tabcontent/tabcontent.js
author ymh <ymh.work@gmail.com>
Fri, 06 Dec 2019 00:53:05 +0100
changeset 3 5301eb6ce6e2
parent 0 505fe5249d9c
permissions -rw-r--r--
add missing files
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
//** Tab Content script v2.0- � Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
//** Updated Oct 7th, 07 to version 2.0. Contains numerous improvements:
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
//   -Added Auto Mode: Script auto rotates the tabs based on an interval, until a tab is explicitly selected
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
//   -Ability to expand/contract arbitrary DIVs on the page as the tabbed content is expanded/ contracted
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
//   -Ability to dynamically select a tab either based on its position within its peers, or its ID attribute (give the target tab one 1st)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
//   -Ability to set where the CSS classname "selected" get assigned- either to the target tab's link ("A"), or its parent container
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
//** Updated Feb 18th, 08 to version 2.1: Adds a "tabinstance.cycleit(dir)" method to cycle forward or backward between tabs dynamically
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
//** 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) 
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
////NO NEED TO EDIT BELOW////////////////////////
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
function ddtabcontent(tabinterfaceid){
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
	this.tabinterfaceid=tabinterfaceid //ID of Tab Menu main container
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
	this.tabs=document.getElementById(tabinterfaceid).getElementsByTagName("a") //Get all tab links within container
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
	this.enabletabpersistence=true
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
	this.hottabspositions=[] //Array to store position of tabs that have a "rel" attr defined, relative to all tab links, within container
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
	this.currentTabIndex=0 //Index of currently selected hot tab (tab with sub content) within hottabspositions[] array
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
	this.subcontentids=[] //Array to store ids of the sub contents ("rel" attr values)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
	this.revcontentids=[] //Array to store ids of arbitrary contents to expand/contact as well ("rev" attr values)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
	this.selectedClassTarget="link" //keyword to indicate which target element to assign "selected" CSS class ("linkparent" or "link")
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
}
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
ddtabcontent.getCookie=function(Name){ 
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
	if (document.cookie.match(re)) //if cookie found
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
		return document.cookie.match(re)[0].split("=")[1] //return its value
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
	return ""
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
}
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
ddtabcontent.setCookie=function(name, value){
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
	document.cookie = name+"="+value+";path=/" //cookie value is domain wide (path=/)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
}
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
ddtabcontent.prototype={
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
	expandit:function(tabid_or_position){ //PUBLIC function to select a tab either by its ID or position(int) within its peers
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
		this.cancelautorun() //stop auto cycling of tabs (if running)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
		var tabref=""
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
		try{
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
			if (typeof tabid_or_position=="string" && document.getElementById(tabid_or_position).getAttribute("rel")) //if specified tab contains "rel" attr
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
				tabref=document.getElementById(tabid_or_position)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
			else if (parseInt(tabid_or_position)!=NaN && this.tabs[tabid_or_position].getAttribute("rel")) //if specified tab contains "rel" attr
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
				tabref=this.tabs[tabid_or_position]
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
		}
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
		catch(err){alert("Invalid Tab ID or position entered!")}
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
		if (tabref!="") //if a valid tab is found based on function parameter
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
			this.expandtab(tabref) //expand this tab
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
	},
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
	cycleit:function(dir, autorun){ //PUBLIC function to move foward or backwards through each hot tab (tabinstance.cycleit('foward/back') )
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
		if (dir=="next"){
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
			var currentTabIndex=(this.currentTabIndex<this.hottabspositions.length-1)? this.currentTabIndex+1 : 0
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
		}
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
		else if (dir=="prev"){
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
			var currentTabIndex=(this.currentTabIndex>0)? this.currentTabIndex-1 : this.hottabspositions.length-1
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
		}
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
		if (typeof autorun=="undefined") //if cycleit() is being called by user, versus autorun() function
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
			this.cancelautorun() //stop auto cycling of tabs (if running)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
		this.expandtab(this.tabs[this.hottabspositions[currentTabIndex]])
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
	},
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
	setpersist:function(bool){ //PUBLIC function to toggle persistence feature
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
			this.enabletabpersistence=bool
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
	},
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
	setselectedClassTarget:function(objstr){ //PUBLIC function to set which target element to assign "selected" CSS class ("linkparent" or "link")
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
		this.selectedClassTarget=objstr || "link"
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
	},
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
	getselectedClassTarget:function(tabref){ //Returns target element to assign "selected" CSS class to
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
		return (this.selectedClassTarget==("linkparent".toLowerCase()))? tabref.parentNode : tabref
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
	},
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
	urlparamselect:function(tabinterfaceid){
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
		var result=window.location.search.match(new RegExp(tabinterfaceid+"=(\\d+)", "i")) //check for "?tabinterfaceid=2" in URL
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
		return (result==null)? null : parseInt(RegExp.$1) //returns null or index, where index (int) is the selected tab's index
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
	},
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
	expandtab:function(tabref){
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
		var subcontentid=tabref.getAttribute("rel") //Get id of subcontent to expand
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
		//Get "rev" attr as a string of IDs in the format ",john,george,trey,etc," to easily search through
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
		var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : ""
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
		this.expandsubcontent(subcontentid)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
		this.expandrevcontent(associatedrevids)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
		for (var i=0; i<this.tabs.length; i++){ //Loop through all tabs, and assign only the selected tab the CSS class "selected"
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
			this.getselectedClassTarget(this.tabs[i]).className=(this.tabs[i].getAttribute("rel")==subcontentid)? "selected" : ""
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
		}
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
		if (this.enabletabpersistence) //if persistence enabled, save selected tab position(int) relative to its peers
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
			ddtabcontent.setCookie(this.tabinterfaceid, tabref.tabposition)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
		this.setcurrenttabindex(tabref.tabposition) //remember position of selected tab within hottabspositions[] array
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
	},
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
	expandsubcontent:function(subcontentid){
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
		for (var i=0; i<this.subcontentids.length; i++){
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
			var subcontent=document.getElementById(this.subcontentids[i]) //cache current subcontent obj (in for loop)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
			subcontent.style.display=(subcontent.id==subcontentid)? "block" : "none" //"show" or hide sub content based on matching id attr value
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
		}
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
	},
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
	expandrevcontent:function(associatedrevids){
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
		var allrevids=this.revcontentids
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
		for (var i=0; i<allrevids.length; i++){ //Loop through rev attributes for all tabs in this tab interface
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
			//if any values stored within associatedrevids matches one within allrevids, expand that DIV, otherwise, contract it
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
			document.getElementById(allrevids[i]).style.display=(associatedrevids.indexOf(","+allrevids[i]+",")!=-1)? "block" : "none"
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
		}
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
	},
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
	setcurrenttabindex:function(tabposition){ //store current position of tab (within hottabspositions[] array)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
		for (var i=0; i<this.hottabspositions.length; i++){
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
			if (tabposition==this.hottabspositions[i]){
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
				this.currentTabIndex=i
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
				break
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
			}
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
		}
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
	},
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
	autorun:function(){ //function to auto cycle through and select tabs based on a set interval
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
		this.cycleit('next', true)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
	},
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
	cancelautorun:function(){
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
		if (typeof this.autoruntimer!="undefined")
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
			clearInterval(this.autoruntimer)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
	},
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
	init:function(automodeperiod){
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
		var persistedtab=ddtabcontent.getCookie(this.tabinterfaceid) //get position of persisted tab (applicable if persistence is enabled)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
		var selectedtab=-1 //Currently selected tab index (-1 meaning none)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
		var selectedtabfromurl=this.urlparamselect(this.tabinterfaceid) //returns null or index from: tabcontent.htm?tabinterfaceid=index
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
		this.automodeperiod=automodeperiod || 0
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
		for (var i=0; i<this.tabs.length; i++){
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
			this.tabs[i].tabposition=i //remember position of tab relative to its peers
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
			if (this.tabs[i].getAttribute("rel")){
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
				var tabinstance=this
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
				this.hottabspositions[this.hottabspositions.length]=i //store position of "hot" tab ("rel" attr defined) relative to its peers
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
				this.subcontentids[this.subcontentids.length]=this.tabs[i].getAttribute("rel") //store id of sub content ("rel" attr value)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
				this.tabs[i].onclick=function(){
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
					tabinstance.expandtab(this)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
					tabinstance.cancelautorun() //stop auto cycling of tabs (if running)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
					return false
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
				}
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
				if (this.tabs[i].getAttribute("rev")){ //if "rev" attr defined, store each value within "rev" as an array element
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
					this.revcontentids=this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/))
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
				}
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
				if (selectedtabfromurl==i || this.enabletabpersistence && selectedtab==-1 && parseInt(persistedtab)==i || !this.enabletabpersistence && selectedtab==-1 && this.getselectedClassTarget(this.tabs[i]).className=="selected"){
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
					selectedtab=i //Selected tab index, if found
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
				}
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
			}
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
		} //END for loop
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
		if (selectedtab!=-1) //if a valid default selected tab index is found
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
			this.expandtab(this.tabs[selectedtab]) //expand selected tab (either from URL parameter, persistent feature, or class="selected" class)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
		else //if no valid default selected index found
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
			this.expandtab(this.tabs[this.hottabspositions[0]]) //Just select first tab that contains a "rel" attr
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
		if (parseInt(this.automodeperiod)>500 && this.hottabspositions.length>1){
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
			this.autoruntimer=setInterval(function(){tabinstance.autorun()}, this.automodeperiod)
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
		}
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
	} //END int() function
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
505fe5249d9c add foundations for pharmakon (bedrock + deploy)
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
} //END Prototype assignment