1/*----------------------------------------------------------------------------\ 2| Tab Pane 1.02 | 3|-----------------------------------------------------------------------------| 4| Created by Erik Arvidsson | 5| (http://webfx.eae.net/contact.html#erik) | 6| For WebFX (http://webfx.eae.net/) | 7|-----------------------------------------------------------------------------| 8| Copyright (c) 1998 - 2003 Erik Arvidsson | 9|-----------------------------------------------------------------------------| 10| This software is provided "as is", without warranty of any kind, express or | 11| implied, including but not limited to the warranties of merchantability, | 12| fitness for a particular purpose and noninfringement. In no event shall the | 13| authors or copyright holders be liable for any claim, damages or other | 14| liability, whether in an action of contract, tort or otherwise, arising | 15| from, out of or in connection with the software or the use or other | 16| dealings in the software. | 17| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 18| This software is available under the three different licenses mentioned | 19| below. To use this software you must chose, and qualify, for one of those. | 20| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 21| The WebFX Non-Commercial License http://webfx.eae.net/license.html | 22| Permits anyone the right to use the software in a non-commercial context | 23| free of charge. | 24| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 25| The WebFX Commercial license http://webfx.eae.net/commercial.html | 26| Permits the license holder the right to use the software in a commercial | 27| context. Such license must be specifically obtained, however it's valid for | 28| any number of implementations of the licensed software. | 29| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 30| GPL - The GNU General Public License http://www.gnu.org/licenses/gpl.txt | 31| Permits anyone the right to use and modify the software without limitations | 32| as long as proper credits are given and the original and modified source | 33| code are included. Requires that the final product, software derivate from | 34| the original source or any software utilizing a GPL component, such as | 35| this, is also licensed under the GPL license. | 36|-----------------------------------------------------------------------------| 37| 2002-01-?? | First working version | 38| 2002-02-17 | Cleaned up for 1.0 public version | 39| 2003-02-18 | Changed from javascript uri for anchors to return false | 40| 2003-03-03 | Added dispose methods to release IE memory | 41|-----------------------------------------------------------------------------| 42| Dependencies: *.css a css file to define the layout | 43|-----------------------------------------------------------------------------| 44| Created 2002-01-?? | All changes are in the log above. | Updated 2003-03-03 | 45\----------------------------------------------------------------------------*/ 46 47// This function is used to define if the browser supports the needed 48// features 49function hasSupport() { 50 51 if (typeof hasSupport.support != "undefined") 52 return hasSupport.support; 53 54 var ie55 = /msie 5\.[56789]/i.test( navigator.userAgent ); 55 56 hasSupport.support = ( typeof document.implementation != "undefined" && 57 document.implementation.hasFeature( "html", "1.0" ) || ie55 ) 58 59 // IE55 has a serious DOM1 bug... Patch it! 60 if ( ie55 ) { 61 document._getElementsByTagName = document.getElementsByTagName; 62 document.getElementsByTagName = function ( sTagName ) { 63 if ( sTagName == "*" ) 64 return document.all; 65 else 66 return document._getElementsByTagName( sTagName ); 67 }; 68 } 69 70 return hasSupport.support; 71} 72
73/////////////////////////////////////////////////////////////////////////////////// 74// The constructor for tab panes 75// 76// el : HTMLElement The html element used to represent the tab pane 77// bUseCookie : Boolean Optional. Default is true. Used to determine whether to us 78// persistance using cookies or not 79// 80function WebFXTabPane( el, bUseCookie ) { 81 if ( !hasSupport() || el == null ) return; 82 83 this.element = el; 84 this.element.tabPane = this; 85 this.pages = []; 86 this.selectedIndex = null; 87 //disabling cookie not to keep active last selected tab 88 this.useCookie = false;//bUseCookie != null ? bUseCookie : true; 89 90 // add class name tag to class name 91 this.element.className = this.classNameTag + " " + this.element.className; 92 93 // add tab row 94 this.tabRow = document.createElement( "div" ); 95 this.tabRow.className = "tab-row"; 96 el.insertBefore( this.tabRow, el.firstChild ); 97 98 var tabIndex = 0; 99 if ( this.useCookie ) { 100 tabIndex = Number( WebFXTabPane.getCookie( "webfxtab_" + this.element.id ) ); 101 if ( isNaN( tabIndex ) ) 102 tabIndex = 0; 103 } 104 this.selectedIndex = tabIndex; 105 106 // loop through child nodes and add them 107 var cs = el.childNodes; 108 var n; 109 for (var i = 0; i < cs.length; i++) { 110 if (cs[i].nodeType == 1 && cs[i].className == "tab-page") { 111 this.addTabPage( cs[i] ); 112 } 113 } 114} 115 116WebFXTabPane.prototype.classNameTag = "dynamic-tab-pane-control"; 117 118WebFXTabPane.prototype.setSelectedIndex = function ( n ) { 119 if (this.selectedIndex != n) { 120 if (this.selectedIndex != null && this.pages[ this.selectedIndex ] != null ) 121 this.pages[ this.selectedIndex ].hide(); 122 this.selectedIndex = n; 123 this.pages[ this.selectedIndex ].show(); 124 125 if ( this.useCookie ) 126 WebFXTabPane.setCookie( "webfxtab_" + this.element.id, n ); // session cookie 127 } 128}; 129 130WebFXTabPane.prototype.getSelectedIndex = function () { 131 return this.selectedIndex; 132}; 133 134WebFXTabPane.prototype.addTabPage = function ( oElement ) { 135 if ( !hasSupport() ) return; 136 137 if ( oElement.tabPage == this ) // already added 138 return oElement.tabPage; 139 140 var n = this.pages.length; 141 var tp = this.pages[n] = new WebFXTabPage( oElement, this, n ); 142 tp.tabPane = this; 143 144 // move the tab out of the box 145 this.tabRow.appendChild( tp.tab ); 146 147 if ( n == this.selectedIndex ) 148 tp.show(); 149 else 150 tp.hide(); 151 152 return tp; 153}; 154 155WebFXTabPane.prototype.dispose = function () { 156 this.element.tabPane = null; 157 this.element = null; 158 this.tabRow = null; 159 160 for (var i = 0; i < this.pages.length; i++) { 161 this.pages[i].dispose(); 162 this.pages[i] = null; 163 } 164 this.pages = null; 165}; 166 167 168 169// Cookie handling 170WebFXTabPane.setCookie = function ( sName, sValue, nDays ) { 171 var expires = ""; 172 if ( nDays ) { 173 var d = new Date(); 174 d.setTime( d.getTime() + nDays * 24 * 60 * 60 * 1000 ); 175 expires = "; expires=" + d.toGMTString(); 176 } 177 178 document.cookie = sName + "=" + sValue + expires + "; path=/"; 179}; 180 181WebFXTabPane.getCookie = function (sName) { 182 var re = new RegExp( "(\;|^)[^;]*(" + sName + ")\=([^;]*)(;|$)" ); 183 var res = re.exec( document.cookie ); 184 return res != null ? res[3] : null; 185}; 186 187WebFXTabPane.removeCookie = function ( name ) { 188 setCookie( name, "", -1 ); 189}; 190 191 192 193 194 195 196 197 198/////////////////////////////////////////////////////////////////////////////////// 199// The constructor for tab pages. This one should not be used. 200// Use WebFXTabPage.addTabPage instead 201// 202// el : HTMLElement The html element used to represent the tab pane 203// tabPane : WebFXTabPane The parent tab pane 204// nindex : Number The index of the page in the parent pane page array 205// 206function WebFXTabPage( el, tabPane, nIndex ) { 207 if ( !hasSupport() || el == null ) return; 208 209 this.element = el; 210 this.element.tabPage = this; 211 this.index = nIndex; 212 213 var cs = el.childNodes; 214 for (var i = 0; i < cs.length; i++) { 215 if (cs[i].nodeType == 1 && cs[i].className == "tab") { 216 this.tab = cs[i]; 217 break; 218 } 219 } 220 221 // insert a tag around content to support keyboard navigation 222 223 224 var a = document.createElement( "A" ); 225 this.aElement = a; 226 a.href = "#"; 227 a.onclick = function () { return false; }; 228 while ( this.tab.hasChildNodes() ) 229 a.appendChild( this.tab.firstChild ); 230 this.tab.appendChild( a ); 231 232 233 // hook up events, using DOM0
234 var oThis = this; 235 this.tab.onclick = function () { oThis.select(); }; 236 this.tab.onmouseover = function () { WebFXTabPage.tabOver( oThis ); }; 237 this.tab.onmouseout = function () { WebFXTabPage.tabOut( oThis ); }; 238} 239 240WebFXTabPage.prototype.show = function () { 241 var el = this.tab; 242 var s = el.className + " selected"; 243 s = s.replace(/ +/g, " "); 244 el.className = s; 245 246 this.element.style.display = "block"; 247}; 248 249WebFXTabPage.prototype.hide = function () { 250 var el = this.tab; 251 var s = el.className; 252 s = s.replace(/ selected/g, ""); 253 el.className = s; 254 255 this.element.style.display = "none"; 256}; 257 258WebFXTabPage.prototype.select = function () { 259 this.tabPane.setSelectedIndex( this.index ); 260}; 261 262WebFXTabPage.prototype.dispose = function () { 263 this.aElement.onclick = null; 264 this.aElement = null; 265 this.element.tabPage = null; 266 this.tab.onclick = null; 267 this.tab.onmouseover = null; 268 this.tab.onmouseout = null; 269 this.tab = null; 270 this.tabPane = null; 271 this.element = null; 272}; 273 274WebFXTabPage.tabOver = function ( tabpage ) { 275 var el = tabpage.tab; 276 var s = el.className + " hover"; 277 s = s.replace(/ +/g, " "); 278 el.className = s; 279}; 280 281WebFXTabPage.tabOut = function ( tabpage ) { 282 var el = tabpage.tab; 283 var s = el.className; 284 s = s.replace(/ hover/g, ""); 285 el.className = s; 286}; 287 288 289// This function initializes all uninitialized tab panes and tab pages 290function setupAllTabs() { 291 if ( !hasSupport() ) return; 292 293 var all = document.getElementsByTagName( "*" ); 294 var l = all.length; 295 var tabPaneRe = /tab\-pane/; 296 var tabPageRe = /tab\-page/; 297 var cn, el; 298 var parentTabPane; 299 300 for ( var i = 0; i < l; i++ ) { 301 el = all[i] 302 cn = el.className; 303 304 // no className 305 if ( cn == "" ) continue; 306 307 // uninitiated tab pane 308 if ( tabPaneRe.test( cn ) && !el.tabPane ) 309 new WebFXTabPane( el ); 310 311 // unitiated tab page wit a valid tab pane parent 312 else if ( tabPageRe.test( cn ) && !el.tabPage && 313 tabPaneRe.test( el.parentNode.className ) ) { 314 el.parentNode.tabPane.addTabPage( el ); 315 } 316 } 317} 318 319function disposeAllTabs() { 320 if ( !hasSupport() ) return; 321 322 var all = document.getElementsByTagName( "*" ); 323 var l = all.length; 324 var tabPaneRe = /tab\-pane/; 325 var cn, el; 326 var tabPanes = []; 327 328 for ( var i = 0; i < l; i++ ) { 329 el = all[i] 330 cn = el.className; 331 332 // no className 333 if ( cn == "" ) continue; 334 335 // tab pane 336 if ( tabPaneRe.test( cn ) && el.tabPane ) 337 tabPanes[tabPanes.length] = el.tabPane; 338 } 339 340 for (var i = tabPanes.length - 1; i >= 0; i--) { 341 tabPanes[i].dispose(); 342 tabPanes[i] = null; 343 } 344} 345 346 347// initialization hook up 348 349// DOM2 350if ( typeof window.addEventListener != "undefined" ) 351 window.addEventListener( "load", setupAllTabs, false ); 352 353// IE 354else if ( typeof window.attachEvent != "undefined" ) { 355 window.attachEvent( "onload", setupAllTabs ); 356 window.attachEvent( "onunload", disposeAllTabs ); 357} 358 359else { 360 if ( window.onload != null ) { 361 var oldOnload = window.onload; 362 window.onload = function ( e ) { 363 oldOnload( e ); 364 setupAllTabs(); 365 }; 366 } 367 else 368 window.onload = setupAllTabs; 369}
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.