Вход Регистрация
Файл: protected/extensions/yii-mail/doc/media/lib/tabpane.js
Строк: 336
<?php
/*
 * Tab Pane
 *
 * This script was created by Erik Arvidsson (erik(at)eae.net)
 * for WebFX (http://webfx.eae.net)
 * Copyright 2002
 * 
 * For usage see license at http://webfx.eae.net/license.html    
 *
 * Version: 1.0
 * Created: 2002-01-??    First working version
 * Updated: 2002-02-17    Cleaned up for 1.0 public version
 *
 * Dependencies: *.css - a css file to define the layout
 *
 */


// This function is used to define if the browser supports the needed
// features
function hasSupport() {

    if (
typeof hasSupport.support != "undefined")
        return 
hasSupport.support;
    
    var 
ie55 = /msie 5.[56789]/i.testnavigator.userAgent );
    
    
hasSupport.support = ( typeof document.implementation != "undefined" &&
            
document.implementation.hasFeature"html""1.0" ) || ie55 )
            
    
// IE55 has a serious DOM1 bug... Patch it!
    
if ( ie55 ) {
        
document._getElementsByTagName document.getElementsByTagName;
        
document.getElementsByTagName = function ( sTagName ) {
            if ( 
sTagName == "*" )
                return 
document.all;
            else
                return 
document._getElementsByTagNamesTagName );
        };
    }

    return 
hasSupport.support;
}

///////////////////////////////////////////////////////////////////////////////////
// The constructor for tab panes
//
// el : HTMLElement        The html element used to represent the tab pane
// bUseCookie : Boolean    Optional. Default is true. Used to determine whether to us
//                        persistance using cookies or not
//
function WebFXTabPaneelbUseCookie ) {
    if ( !
hasSupport() || el == null ) return;
    
    
this.element el;
    
this.element.tabPane this;
    
this.pages = [];
    
this.selectedIndex null;
    
this.useCookie bUseCookie != null bUseCookie false;
    
    
// add class name tag to class name
    
this.element.className this.classNameTag " " this.element.className;
    
    
// add tab row
    
this.tabRow document.createElement"div" );
    
this.tabRow.className "tab-row";
    
el.insertBeforethis.tabRowel.firstChild );

    var 
tabIndex 0;
    if ( 
this.useCookie ) {
        
tabIndex NumberWebFXTabPane.getCookie"webfxtab_" this.element.id ) );
        if ( 
isNaNtabIndex ) )
            
tabIndex 0;
    }

    
this.selectedIndex tabIndex;
    
    
// loop through child nodes and add them
    
var cs el.childNodes;
    var 
n;
    for (var 
0cs.lengthi++) {
        if (
cs[i].nodeType == && cs[i].className == "tab-page") {
            
this.addTabPagecs[i] );
        }
    }
}

WebFXTabPane.prototype = {

    
classNameTag:        "dynamic-tab-pane-control",

    
setSelectedIndex:    function ( ) {
        if (
this.selectedIndex != n) {
            if (
this.selectedIndex != null && this.pagesthis.selectedIndex ] != null )
                
this.pagesthis.selectedIndex ].hide();
            
this.selectedIndex n;
            
this.pagesthis.selectedIndex ].show();
            
            if ( 
this.useCookie )
                
WebFXTabPane.setCookie"webfxtab_" this.element.id);    // session cookie
        
}
    },
    
    
getSelectedIndex:    function () {
        return 
this.selectedIndex;
    },
    
    
addTabPage:    function ( oElement ) {
        if ( !
hasSupport() ) return;
        
        if ( 
oElement.tabPage == this )    // already added
            
return oElement.tabPage;
    
        var 
this.pages.length;
        var 
tp this.pages[n] = new WebFXTabPageoElementthis);
        
tp.tabPane this;
        
        
// move the tab out of the box
        
this.tabRow.appendChildtp.tab );
                
        if ( 
== this.selectedIndex )
            
tp.show();
        else
            
tp.hide();
            
        return 
tp;
    }    
};

// Cookie handling
WebFXTabPane.setCookie = function ( sNamesValuenDays ) {
    var 
expires "";
    if ( 
nDays ) {
        var 
= new Date();
        
d.setTimed.getTime() + nDays 24 60 60 1000 );
        
expires "; expires=" d.toGMTString();
    }

    
document.cookie sName "=" sValue expires "; path=/";
};

WebFXTabPane.getCookie = function (sName) {
    var 
re = new RegExp"(;|^)[^;]*(" sName ")=([^;]*)(;|$)" );
    var 
res re.execdocument.cookie );
    return 
res != null res[3] : null;
};

WebFXTabPane.removeCookie = function ( name ) {
    
setCookiename"", -);
};








///////////////////////////////////////////////////////////////////////////////////
// The constructor for tab pages. This one should not be used.
// Use WebFXTabPage.addTabPage instead
//
// el : HTMLElement            The html element used to represent the tab pane
// tabPane : WebFXTabPane    The parent tab pane
// nindex :    Number            The index of the page in the parent pane page array
//
function WebFXTabPageeltabPanenIndex ) {
    if ( !
hasSupport() || el == null ) return;
    
    
this.element el;
    
this.element.tabPage this;
    
this.index nIndex;
    
    var 
cs el.childNodes;
    for (var 
0cs.lengthi++) {
        if (
cs[i].nodeType == && cs[i].className == "tab") {
            
this.tab cs[i];
            break;
        }
    }

    
// insert a tag around content to support keyboard navigation
    
var document.createElement"A" );
    
a.href "javascript:void 0;";
    while ( 
this.tab.hasChildNodes() )
        
a.appendChildthis.tab.firstChild );
    
this.tab.appendChild);
    
    
    
anchor '';
    if ( 
document.URL.indexOf'#' ) != -) {
        
anchor document.URL.substrdocument.URL.indexOf'#' ) + 1);
    }
    
0;
    if ( 
anchor.length ) {
        
finalList = new Array();
        
listOfAnchors el.getElementsByTagName('A');
        for (
i=0i<listOfAnchors.lengthi++) {
            if (
listOfAnchors[i].name.length) {
                
finalList[j++] = listOfAnchors[i].name;
            }
        }
        for(
i=0i<finalList.lengthi++) {
            if ( 
anchor == finalList[i] ) {
                if (
tabPane.selectedIndex != nIndextabPane.pagestabPane.selectedIndex ].hide();
                
tabPane.selectedIndex nIndex ;
            }
        }
    }
    
    
// hook up events, using DOM0
    
var oThis this;
    
this.tab.onclick = function () { oThis.select(); };
    
this.tab.onmouseover = function () { WebFXTabPage.tabOveroThis ); };
    
this.tab.onmouseout = function () { WebFXTabPage.tabOutoThis ); };
}

WebFXTabPage.prototype = {
    
show:    function () {
        var 
el this.tab;
        var 
el.className " selected";
        
s.replace(/ +/g" ");
        
el.className s;
        
        
this.element.style.display "block";
    },

    
hide:    function () {
        var 
el this.tab;
        var 
el.className;
        
s.replace(/ selected/g"");
        
el.className s;

        
this.element.style.display "none";
    },
    
    
select:    function () {
        
this.tabPane.setSelectedIndexthis.index );
    }
};

WebFXTabPage.tabOver = function ( tabpage ) {
    var 
el tabpage.tab;
    var 
el.className " hover";
    
s.replace(/ +/g" ");
    
el.className s;
};

WebFXTabPage.tabOut = function ( tabpage ) {
    var 
el tabpage.tab;
    var 
el.className;
    
s.replace(/ hover/g"");
    
el.className s;
};


// This function initializes all uninitialized tab panes and tab pages
function setupAllTabs() {
    if ( !
hasSupport() ) return;

    var 
all document.getElementsByTagName"*" );
    var 
all.length;
    var 
tabPaneRe = /tab-pane/;
    var 
tabPageRe = /tab-page/;
    var 
cnel;
    var 
parentTabPane;
    
    for ( var 
0li++ ) {
        
el all[i]
        
cn el.className;

        
// no className
        
if ( cn == "" ) continue;
        
        
// uninitiated tab pane
        
if ( tabPaneRe.testcn ) && !el.tabPane )
            new 
WebFXTabPaneel );
    
        
// unitiated tab page wit a valid tab pane parent
        
else if ( tabPageRe.testcn ) && !el.tabPage &&
                    
tabPaneRe.testel.parentNode.className ) ) {
            
el.parentNode.tabPane.addTabPageel );            
        }
    }
}


// initialization hook up

// DOM2
if ( typeof window.addEventListener != "undefined" )
    
window.addEventListener"load"setupAllTabsfalse );

// IE 
else if ( typeof window.attachEvent != "undefined" )
    
window.attachEvent"onload"setupAllTabs );

else {
    if ( 
window.onload != null ) {
        var 
oldOnload window.onload;
        
window.onload = function ( ) {
            
oldOnload);
            
setupAllTabs();
        };
    }
    else 
        
window.onload setupAllTabs;
}
?>
Онлайн: 2
Реклама