[ Index ] |
|
Code source de Joomla 1.0.13 |
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 function hasSupport() { if (typeof hasSupport.support != "undefined") 48 return hasSupport.support; var ie55 = /msie 5\.[56789]/i.test( navigator.userAgent ); hasSupport.support = ( typeof document.implementation != "undefined" && 49 document.implementation.hasFeature( "html", "1.0" ) || ie55 ) 50 if ( ie55 ) { document._getElementsByTagName = document.getElementsByTagName; document.getElementsByTagName = function ( sTagName ) { if ( sTagName == "*" ) 51 return document.all; else 52 return document._getElementsByTagName( sTagName );};} 53 return hasSupport.support;} 54 function WebFXTabPane( el, bUseCookie ) { if ( !hasSupport() || el == null ) return; this.element = el; this.element.tabPane = this; this.pages = []; this.selectedIndex = null; this.useCookie = bUseCookie != null ? bUseCookie : true; this.element.className = this.classNameTag + " " + this.element.className; this.tabRow = document.createElement( "div" ); this.tabRow.className = "tab-row"; el.insertBefore( this.tabRow, el.firstChild ); var tabIndex = 0; if ( this.useCookie ) { tabIndex = Number( WebFXTabPane.getCookie( "webfxtab_" + this.element.id ) ); if ( isNaN( tabIndex ) ) 55 tabIndex = 0;} 56 this.selectedIndex = tabIndex; var cs = el.childNodes; var n; for (var i = 0; i < cs.length; i++) { if (cs[i].nodeType == 1 && cs[i].className == "tab-page") { this.addTabPage( cs[i] );} 57 } 58 } 59 WebFXTabPane.prototype.classNameTag = "dynamic-tab-pane-control"; WebFXTabPane.prototype.setSelectedIndex = function ( n ) { if (this.selectedIndex != n) { if (this.selectedIndex != null && this.pages[ this.selectedIndex ] != null ) 60 this.pages[ this.selectedIndex ].hide(); this.selectedIndex = n; this.pages[ this.selectedIndex ].show(); if ( this.useCookie ) 61 WebFXTabPane.setCookie( "webfxtab_" + this.element.id, n );} 62 }; WebFXTabPane.prototype.getSelectedIndex = function () { return this.selectedIndex;}; WebFXTabPane.prototype.addTabPage = function ( oElement ) { if ( !hasSupport() ) return; if ( oElement.tabPage == this ) 63 return oElement.tabPage; var n = this.pages.length; var tp = this.pages[n] = new WebFXTabPage( oElement, this, n ); tp.tabPane = this; this.tabRow.appendChild( tp.tab ); if ( n == this.selectedIndex ) 64 tp.show(); else 65 tp.hide(); return tp;}; WebFXTabPane.prototype.dispose = function () { this.element.tabPane = null; this.element = null; this.tabRow = null; for (var i = 0; i < this.pages.length; i++) { this.pages[i].dispose(); this.pages[i] = null;} 66 this.pages = null;}; WebFXTabPane.setCookie = function ( sName, sValue, nDays ) { var expires = ""; if ( nDays ) { var d = new Date(); d.setTime( d.getTime() + nDays * 24 * 60 * 60 * 1000 ); expires = "; expires=" + d.toGMTString();} 67 document.cookie = sName + "=" + sValue + expires + "; path=/";}; WebFXTabPane.getCookie = function (sName) { var re = new RegExp( "(\;|^)[^;]*(" + sName + ")\=([^;]*)(;|$)" ); var res = re.exec( document.cookie ); return res != null ? res[3] : null;}; WebFXTabPane.removeCookie = function ( name ) { setCookie( name, "", -1 );}; function WebFXTabPage( el, tabPane, nIndex ) { if ( !hasSupport() || el == null ) return; this.element = el; this.element.tabPage = this; this.index = nIndex; var cs = el.childNodes; for (var i = 0; i < cs.length; i++) { if (cs[i].nodeType == 1 && cs[i].className == "tab") { this.tab = cs[i]; break;} 68 } 69 var a = document.createElement( "A" ); this.aElement = a; a.href = "#"; a.onclick = function () { return false;}; while ( this.tab.hasChildNodes() ) 70 a.appendChild( this.tab.firstChild ); this.tab.appendChild( a ); var oThis = this; this.tab.onclick = function () { oThis.select();}; this.tab.onmouseover = function () { WebFXTabPage.tabOver( oThis );}; this.tab.onmouseout = function () { WebFXTabPage.tabOut( oThis );};} 71 WebFXTabPage.prototype.show = function () { var el = this.tab; var s = el.className + " selected"; s = s.replace(/ +/g, " "); el.className = s; this.element.style.display = "block";}; WebFXTabPage.prototype.hide = function () { var el = this.tab; var s = el.className; s = s.replace(/ selected/g, ""); el.className = s; this.element.style.display = "none";}; WebFXTabPage.prototype.select = function () { this.tabPane.setSelectedIndex( this.index );}; WebFXTabPage.prototype.dispose = function () { this.aElement.onclick = null; this.aElement = null; this.element.tabPage = null; this.tab.onclick = null; this.tab.onmouseover = null; this.tab.onmouseout = null; this.tab = null; this.tabPane = null; this.element = null;}; WebFXTabPage.tabOver = function ( tabpage ) { var el = tabpage.tab; var s = el.className + " hover"; s = s.replace(/ +/g, " "); el.className = s;}; WebFXTabPage.tabOut = function ( tabpage ) { var el = tabpage.tab; var s = el.className; s = s.replace(/ hover/g, ""); el.className = s;}; function setupAllTabs() { if ( !hasSupport() ) return; var all = document.getElementsByTagName( "*" ); var l = all.length; var tabPaneRe = /tab\-pane/; var tabPageRe = /tab\-page/; var cn, el; var parentTabPane; for ( var i = 0; i < l; i++ ) { el = all[i] 72 cn = el.className; if ( cn == "" ) continue; if ( tabPaneRe.test( cn ) && !el.tabPane ) 73 new WebFXTabPane( el ); else if ( tabPageRe.test( cn ) && !el.tabPage && 74 tabPaneRe.test( el.parentNode.className ) ) { el.parentNode.tabPane.addTabPage( el );} 75 } 76 } 77 function disposeAllTabs() { if ( !hasSupport() ) return; var all = document.getElementsByTagName( "*" ); var l = all.length; var tabPaneRe = /tab\-pane/; var cn, el; var tabPanes = []; for ( var i = 0; i < l; i++ ) { el = all[i] 78 cn = el.className; if ( cn == "" ) continue; if ( tabPaneRe.test( cn ) && el.tabPane ) 79 tabPanes[tabPanes.length] = el.tabPane;} 80 for (var i = tabPanes.length - 1; i >= 0; i--) { tabPanes[i].dispose(); tabPanes[i] = null;} 81 } 82 if ( typeof window.addEventListener != "undefined" ) 83 window.addEventListener( "load", setupAllTabs, false ); else if ( typeof window.attachEvent != "undefined" ) { window.attachEvent( "onload", setupAllTabs ); window.attachEvent( "onunload", disposeAllTabs );} 84 else { if ( window.onload != null ) { var oldOnload = window.onload; window.onload = function ( e ) { oldOnload( e ); setupAllTabs();};} 85 else 86 window.onload = setupAllTabs;}
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 14:43:32 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |