Вход Регистрация
Файл: framework/thirdparty/tabstrip/tabstrip.js
Строк: 403
<?php
var _CUR_TABS = [];
var 
_TABS_ON_PAGE = [];
var 
_TAB_DIVS_ON_PAGE = [];

Behaviour.register({
    
'ul.tabstrip': {
        
initialize: function() {
            
initTabstrip(this);
        if(
window.ontabschangedwindow.ontabschanged();
        }
    }
});

function 
initTabstrip(tabstripnamedAnchors) {
    var 
ianchorcontaineranchorNameli;
    var 
childAnchors tabstrip.getElementsByTagName('a');
    var 
basecurTab nullcurURL window.location.href;
    var 
previousTab null;
    var 
firstTabfoundATab false;

    
// Strip query string from current URL
    
var curQuery window.location.search;

    
// Detect a current tab from the # link
    
if(curURL.indexOf('#') == -1) {
        
base curURL.length curQuery.length;
    } else {
        
base curURL.indexOf('#') - curQuery.length;
        
curTab curURL.substr(curURL.indexOf('#')+1);
    }

    
// Get a stored current tab, used when Ajax-switching between pages
    
if(_CUR_TABS[tabstrip.parentNode.id] && $(_CUR_TABS[tabstrip.parentNode.id]) ) {
        
curTab _CUR_TABS[tabstrip.parentNode.id];
        
    } else {
        
// Default to showing the first tab
        
for(i=0;i<childAnchors.length;i++) {
            var 
child childAnchors[i];
            
            var 
anchorPos child.href.indexOf('#');
            
            if(
anchorPos != -1) {
                
anchorName child.href.substr(anchorPos+1);
                if(
firstTab == nullfirstTab anchorName;
                if(
anchorName == curTabfoundATab true;
            }
        }
        if(!
foundATabcurTab firstTab;
    }
    

    
_CUR_TABS[tabstrip.parentNode.id] = curTab;
    
    
    for(
i=0;i<childAnchors.length;i++) {
        
// Detect an anchor reference
        
        
var anchorBase childAnchors[i].href.indexOf('#');
        
        
// if(childAnchors[i].href.substr(base,1) == '#') {
        
        
if( anchorBase != -) {
            
anchorName childAnchors[i].href.substr(anchorBase+1);
            
li childAnchors[i].parentNode;
            
container document.getElementById(anchorName);
            
            if(
containertabstrip_initTab(childAnchors[i], anchorNametabstripcontainer);
            
// else throw("Cannot find ID: " + anchorName);
            
            // Hook up previousTab / nextTab suppoort
            
if(previousTab) {                
                
previousTab.nextTab li;
                
li.previousTab previousTab;
            }
            
previousTab li;
            
            
// Default to showing the first tab
            // if(curTab == null && anchorName) curTab = anchorName;
            
            // Show current tab
            
if(curTab && anchorName == curTab) {
                
tabstrip.currentlyShowing li;
                
addClass(li'current');
                if(
container) {
                    
container.style.display '';
                    
                    
/*
                    // Show any parent tab that might be lurking about
                    var p = container.parentNode;
                    while(p.tagName.toLowerCase() != 'body') {
                        if(p.ownerTab) p.ownerTab.onclick('init');
                        p = p.parentNode;
                    }
                    */
                
}
            } else {
                if(
containercontainer.style.display 'none';
            }
        }
    }
    
    
// store the tabs in the window for window.ontabschanged
    
if($('Form_EditForm')) {
        var 
divs = $('Form_EditForm').getElementsByTagName('div');
    } else {
        var 
divs document.getElementsBySelector('form div');
    }
    for(
i=0;i<divs.length;i++) {
        if( ( 
Element.hasClassName(divs[i],'tab') || Element.hasClassName(divs[i],'tabset') ) ) {
            
_TAB_DIVS_ON_PAGE.push(divs[i]);
        }
    }
    
// Add nextTab() and previousTab() functions to the tabstrip
    
tabstrip.openNextTab tabstrip_openNextTab;
    
tabstrip.openPreviousTab tabstrip_openPreviousTab;
    
    
// Hook this into the destroyer, to prevent memory leaks
    
if(Class && Class.registerForDestruction) {
        
tabstrip.destroy tabstrip_destroy;
        Class.
registerForDestruction(tabstrip);
    }
}

function 
tabstrip_destroy() {
    
this.currentlyShowing null;
    
    
_CUR_TABS null;
    
    var 
childAnchors this.getElementsByTagName('a');
    var 
i,a,li;
    for(
i=0;a=childAnchors[i];i++) {
        
a.onclick null;

        
li a.parentNode;
        
li.onclick null;
        
li.onmouseover null;
        
li.onmouseout null;
        
li.tabstrip null;
        
li.previousTab null;
        
li.nextTab null;
        
        if(
li.container) {
            
li.container.ownerTab null;
            
li.container null;
        }
        
    }
}


function 
tabstrip_initTab(aanchorNametabstripcontainer) {
    
// Hook up information / events
    
a.onclick tabstrip_showTab;
    
a.onclick a.onclick.bindAsEventListener(a);
    
    
a.openTab tabstrip_showTab;
    
    
    
li a.parentNode;
    
li.container container;
    
li.anchorName anchorName;
    
li.tabstrip tabstrip;
    
li.onclick li.openTab tabstrip_showTab;
    
li.onmouseover tabstrip_mouseOver;
    
li.onmouseout tabstrip_mouseOut;
    
_TABS_ON_PAGE[anchorName] = li;
    
container.ownerTab li;
}

function 
openTabanchorName ) {

    if( 
typeof anchorName != 'string' )
        return;

    var 
tabNames anchorName.split'set' );
    
        
    if( 
tabNames.length )
        
anchorName tabNames.shift() + 'set';
    while( 
anchorName ) {
        if( 
_TABS_ON_PAGE[anchorName] ) _TABS_ON_PAGE[anchorName].openTab_TABS_ON_PAGE[anchorName].getElementsByTagName('a')[0] );
    
        if( 
tabNames.length == )
            
anchorName null;
        else {
            
anchorName anchorName tabNames.shift() + 'set';
        }        
    }
}

/*
 * Returns the form object that the given element is
 * inside; or null if it's not inside a form
 */
function findParentForm(el) {
    var 
ownerForm el.parentNodetn;
    while((
tn ownerForm.tagName.toLowerCase()) != "body" && tn != "form") {
        
ownerForm ownerForm.parentNode;
    }
    if(
tn == "form") return ownerForm;
    else return 
null;
}


function 
tabstrip_showTab(evt) {
    if(
this.tagName.toLowerCase() == "a") var el this.parentNode;
    else 
el this;
    
    
_CUR_TABS[el.tabstrip.parentNode.id] = el.container.id;

    if(
el.tabstrip.currentlyShowing && el.tabstrip.currentlyShowing.container && el.tabstrip.currentlyShowing != el) {
        
el.tabstrip.currentlyShowing.container.style.display 'none';
        
removeClass(el.tabstrip.currentlyShowing.container'current');
        
removeClass(el.tabstrip.currentlyShowing'current');        
    }
    
    var 
container document.getElementByIdel.container.id );
    
    if( 
container && container.style.display == 'none' ) {
        
container.style.display 'block';
        
addClasscontainer'current' );
    }
    
    
// el.container.style.display = '';
    
addClass(el'current');

    
el.tabstrip.currentlyShowing el;
    
    
setHashLink(el.anchorName);

    if(
evt != 'init') {
        if(
window.ontabschangedwindow.ontabschanged();
        else if(
window.onresizewindow.onresize();
    }
    
    return 
false;
}

/*
 * Redirect to the given hash link
 * It won't actually reload the page, but it will update the current URL
 */
function setHashLink(hashLink) {
    return; 
//temporarily disabled this
    
    
var preserveScroll preserveScrollPosition(hashLink);
    
    
// Mac/IE5 cannot handle this
    
if(navigator.userAgent.indexOf("Mac") > -&& navigator.userAgent.indexOf("MSIE") > -1)
        return;
    
    if(
window.location.href.indexOf('#') == -1)
        
window.location.href += '#' hashLink;
    else
        
window.location.href window.location.href.replace(/#.*$/, '#' + hashLink);
        
    
if(typeof preserveScroll != 'undefined'
        
restoreScrollPosition(preserveScroll);
}

/**
 * Preserve the scroll position prior to visiting the given hashlink.
 * Returns an object that you can pass to restoreScrollPosition
 */
function preserveScrollPosition(hashLink) {
    var 
el document.getElementById(hashLink);
    var 
preserved = [];
    while(
el) {
        
preserved[preserved.length] = el;
        
el.oldScroll el.scrollTop;
        
        if(
el.tagName && el.tagName.toLowerCase() == "body") break;
        
el el.parentNode;    
    }
    return 
preserved;
}

/*
 * Restores the preserved scroll position
 */
function restoreScrollPosition(preserved) {
    var 
i;
    for(
i=0;i<preserved.length;i++) {
        
preserved[i].scrollTop preserved[i].oldScroll;
        
delete preserved[i].oldScroll;
    }
}


function 
tabstrip_mouseOver() {
    if(
self.addClassaddClass(this'over');
}

function 
tabstrip_mouseOut() {
    if(
self.removeClassremoveClass(this'over');
}

function 
tabstrip_openNextTab() {
    if(
this.currentlyShowing && this.currentlyShowing.nextTab)
        
this.currentlyShowing.nextTab.onclick();
}
function 
tabstrip_openPreviousTab() {
    if(
this.currentlyShowing && this.currentlyShowing.previousTab)
        
this.currentlyShowing.previousTab.onclick();
}
?>
Онлайн: 0
Реклама