1/** 2 * @version 1.3 3 * @package SimpleTabs 4 * @author Fotis Evangelou - http://nuevvo.com/labs/simpletabs 5 * @copyright Copyright (c) 2009-2011 Fotis Evangelou / Nuevvo Webware Ltd. All rights reserved. 6 * @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html 7 */ 8 9// Main SimpleTabs function 10var kmrSimpleTabs = { 11 12 sbContainerClass: "simpleTabs", 13 sbNavClass: "simpleTabsNavigation", 14 sbContentClass: "simpleTabsContent", 15 sbCurrentNavClass: "current", 16 sbCurrentTabClass: "currentTab", 17 sbIdPrefix: "tabber", 18 19 init: function(){ 20 if(!document.getElementsByTagName) return false; 21 if(!document.getElementById) return false; 22 23 var containerDiv = document.getElementsByTagName("div"); 24 25 for(var i=0; i<containerDiv.length; i++){ 26 if (containerDiv[i].className == kmrSimpleTabs.sbContainerClass) { 27 28 // assign a unique ID for this tab block and then grab it 29 containerDiv[i].setAttribute("id",kmrSimpleTabs.sbIdPrefix+[i]); 30 var containerDivId = containerDiv[i].getAttribute("id"); 31 32 // Navigation 33 var ul = containerDiv[i].getElementsByTagName("ul"); 34 35 for(var j=0; j<ul.length; j++){ 36 if (ul[j].className == kmrSimpleTabs.sbNavClass) { 37 38 var a = ul[j].getElementsByTagName("a"); 39 for(var k=0; k<a.length; k++){ 40 a[k].setAttribute("id",containerDivId+"_a_"+k); 41 // get current 42 if(kmrSimpleTabs.readCookie('simpleTabsCookie')){ 43 /* var cookieElements = kmrSimpleTabs.readCookie('simpleTabsCookie').split("_"); 44 var curTabCont = cookieElements[1]; 45 var curAnchor = cookieElements[2]; 46 if(a[k].parentNode.parentNode.parentNode.getAttribute("id")==kmrSimpleTabs.sbIdPrefix+curTabCont){ 47 if(a[k].getAttribute("id")==kmrSimpleTabs.sbIdPrefix+curTabCont+"_a_"+curAnchor){ 48 a[k].className = kmrSimpleTabs.sbCurrentNavClass; 49 } else { 50 a[k].className = ""; 51 } 52 } else { 53 a[0].className = kmrSimpleTabs.sbCurrentNavClass; 54 }*/ 55 56 a[0].className = kmrSimpleTabs.sbCurrentNavClass; 57 } else { 58 a[0].className = kmrSimpleTabs.sbCurrentNavClass; 59 } 60 61 a[k].onclick = function(){ 62 kmrSimpleTabs.setCurrent(this,'simpleTabsCookie'); 63 return false; 64 } 65 } 66 } 67 } 68 69 // Tab Content 70 var div = containerDiv[i].getElementsByTagName("div"); 71 var countDivs = 0; 72 for(var l=0; l<div.length; l++){ 73 if (div[l].className == kmrSimpleTabs.sbContentClass) { 74 div[l].setAttribute("id",containerDivId+"_div_"+[countDivs]); 75 /* if(kmrSimpleTabs.readCookie('simpleTabsCookie')){ 76 var cookieElements = kmrSimpleTabs.readCookie('simpleTabsCookie').split("_"); 77 var curTabCont = cookieElements[1]; 78 var curAnchor = cookieElements[2]; 79 if(div[l].parentNode.getAttribute("id")==kmrSimpleTabs.sbIdPrefix+curTabCont){ 80 if(div[l].getAttribute("id")==kmrSimpleTabs.sbIdPrefix+curTabCont+"_div_"+curAnchor){ 81 div[l].className = kmrSimpleTabs.sbContentClass+" "+kmrSimpleTabs.sbCurrentTabClass; 82 } else { 83 div[l].className = kmrSimpleTabs.sbContentClass; 84 } 85 } else { 86 div[0].className = kmrSimpleTabs.sbContentClass+" "+kmrSimpleTabs.sbCurrentTabClass; 87 } 88 } else {*/ 89 div[0].className = kmrSimpleTabs.sbContentClass+" "+kmrSimpleTabs.sbCurrentTabClass; 90 //} 91 countDivs++; 92 } 93 } 94 95 // End navigation and content block handling 96 } 97 } 98 }, 99 100 // Function to set the current tab 101 setCurrent: function(elm,cookie){ 102 103 this.eraseCookie(cookie); 104 105 //get container ID 106 var thisContainerID = elm.parentNode.parentNode.parentNode.getAttribute("id"); 107 108 // get current anchor position 109 var regExpAnchor = thisContainerID+"_a_"; 110 var thisLinkPosition = elm.getAttribute("id").replace(regExpAnchor,""); 111 112 // change to clicked anchor 113 var otherLinks = elm.parentNode.parentNode.getElementsByTagName("a"); 114 for(var n=0; n<otherLinks.length; n++){ 115 otherLinks[n].className = ""; 116 } 117 elm.className = kmrSimpleTabs.sbCurrentNavClass; 118 119 // change to associated div 120 var otherDivs = document.getElementById(thisContainerID).getElementsByTagName("div"); 121 var RegExpForContentClass = new RegExp(kmrSimpleTabs.sbContentClass); 122 for(var i=0; i<otherDivs.length; i++){ 123 if ( RegExpForContentClass.test(otherDivs[i].className) ) { 124 otherDivs[i].className = kmrSimpleTabs.sbContentClass; 125 } 126 } 127 document.getElementById(thisContainerID+"_div_"+thisLinkPosition).className = kmrSimpleTabs.sbContentClass+" "+kmrSimpleTabs.sbCurrentTabClass; 128 129 // get Tabs container ID 130 var RegExpForPrefix = new RegExp(kmrSimpleTabs.sbIdPrefix); 131 var thisContainerPosition = thisContainerID.replace(RegExpForPrefix,""); 132 133 // set cookie 134 this.createCookie(cookie,'simpleTabsCookie_'+thisContainerPosition+'_'+thisLinkPosition,1); 135 }, 136 137 // Cookies
138 createCookie: function(name,value,days) { 139 if (days) { 140 var date = new Date(); 141 date.setTime(date.getTime()+(days*24*60*60*1000)); 142 var expires = "; expires="+date.toGMTString(); 143 } 144 else var expires = ""; 145 document.cookie = name+"="+value+expires+"; path=/"; 146 }, 147 148 readCookie: function(name) { 149 var nameEQ = name + "="; 150 var ca = document.cookie.split(';'); 151 for(var i=0;i < ca.length;i++) { 152 var c = ca[i]; 153 while (c.charAt(0)==' ') c = c.substring(1,c.length); 154 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); 155 } 156 return null; 157 }, 158 159 eraseCookie: function(name) { 160 this.createCookie(name,"",-1); 161 }, 162 163 // Loader 164 addLoadEvent: function(func) { 165 var oldonload = window.onload; 166 if (typeof window.onload != 'function') { 167 window.onload = func; 168 } else { 169 window.onload = function() { 170 if (oldonload) { 171 oldonload(); 172 } 173 func(); 174 } 175 } 176 } 177 178 // END 179}; 180 181// Load SimpleTabs 182kmrSimpleTabs.addLoadEvent(kmrSimpleTabs.init);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.