import v1.1.0_beta1 | 2009-08-21
This commit is contained in:
@ -1,53 +1,49 @@
|
||||
/*
|
||||
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 2.6.0
|
||||
version: 2.7.0
|
||||
*/
|
||||
.yui-navset .yui-nav li a,
|
||||
.yui-navset .yui-content {
|
||||
.yui-navset .yui-nav li a, .yui-navset .yui-content {
|
||||
border:1px solid #000; /* label and content borders */
|
||||
}
|
||||
|
||||
.yui-navset .yui-nav .selected a,
|
||||
.yui-navset .yui-nav a:hover,
|
||||
.yui-navset .yui-content {
|
||||
.yui-navset .yui-nav .selected a, .yui-navset .yui-nav a:hover, .yui-navset .yui-content {
|
||||
background-color:#f6f7ee; /* active tab, tab hover, and content bgcolor */
|
||||
}
|
||||
|
||||
.yui-navset .yui-nav li em { padding:.5em; } /* tab padding */
|
||||
|
||||
/* defaults to orientation "top" */
|
||||
.yui-navset .yui-nav .selected a,
|
||||
.yui-navset .yui-navset-top .yui-nav .selected a {
|
||||
border-width:1px 1px 0; /* no bottom border for active tab */
|
||||
padding:0 0 1px; /* to match height of other tabs */
|
||||
.yui-navset .yui-nav .selected a {
|
||||
border-bottom-width:0; /* no bottom border for active tab */
|
||||
padding-bottom:1px; /* to match height of other tabs */
|
||||
}
|
||||
.yui-navset .yui-content,
|
||||
.yui-navset .yui-navset-top .yui-content {
|
||||
margin:-1px 0 0; /* for active tab overlap */
|
||||
|
||||
.yui-navset .yui-content {
|
||||
margin-top:-1px; /* for active tab overlap */
|
||||
}
|
||||
|
||||
/* overrides for other orientations */
|
||||
.yui-navset .yui-navset-bottom .yui-nav .selected a,
|
||||
|
||||
.yui-navset-bottom .yui-nav .selected a {
|
||||
border-width:0 1px 1px; /* no top border for active tab */
|
||||
padding:1px 0 0; /* to match height of other tabs */
|
||||
}
|
||||
.yui-navset .yui-navset-bottom .yui-content,
|
||||
|
||||
.yui-navset-bottom .yui-content {
|
||||
margin:0 0 -1px; /* for active tab overlap */
|
||||
}
|
||||
.yui-navset .yui-navset-left .yui-nav li.selected a,
|
||||
|
||||
.yui-navset-left .yui-nav li.selected a {
|
||||
border-width:1px 0 1px 1px; /* no right border for active tab */
|
||||
padding:0 1px 0 0; /* to match width of other tabs */
|
||||
}
|
||||
.yui-navset .yui-navset-left .yui-content,
|
||||
|
||||
.yui-navset-left .yui-content {
|
||||
margin:0 0 0 -1px; /* for active tab overlap */
|
||||
}
|
||||
.yui-navset .yui-navset-right .yui-nav li.selected a,
|
||||
|
||||
.yui-navset-right .yui-nav li.selected a {
|
||||
border-width:1px 1px 1px 0; /* no left border for active tab */
|
||||
padding:0 0 0 1px; /* to match width of other tabs */
|
||||
@ -55,4 +51,4 @@ version: 2.6.0
|
||||
|
||||
.yui-navset-right .yui-content {
|
||||
margin:0 -1px 0 0; /* for active tab overlap */
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 2.6.0
|
||||
version: 2.7.0
|
||||
*/
|
||||
.yui-navset .yui-nav li {
|
||||
margin-right:0.16em; /* space between tabs */
|
||||
|
@ -1,15 +1,14 @@
|
||||
/*
|
||||
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 2.6.0
|
||||
version: 2.7.0
|
||||
*/
|
||||
/* .yui-navset defaults to .yui-navset-top */
|
||||
.yui-skin-sam .yui-navset .yui-nav,
|
||||
.yui-skin-sam .yui-navset .yui-navset-top .yui-nav { /* protect nested tabviews from other orientations */
|
||||
border:solid #2647a0; /* color between tab list and content */
|
||||
border-width:0 0 5px;
|
||||
Xposition:relative;
|
||||
zoom:1;
|
||||
}
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,8 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 2.6.0
|
||||
version: 2.7.0
|
||||
*/
|
||||
/* default space between tabs */
|
||||
.yui-navset .yui-nav li,
|
||||
@ -16,7 +16,9 @@ version: 2.6.0
|
||||
}
|
||||
|
||||
.yui-navset .yui-content .yui-hidden {
|
||||
display:none;
|
||||
position:absolute;
|
||||
left:-999999px;
|
||||
visibility:hidden;
|
||||
}
|
||||
|
||||
/* default width for side tabs */
|
||||
@ -52,7 +54,8 @@ version: 2.6.0
|
||||
zoom:1;
|
||||
}
|
||||
|
||||
.yui-navset .yui-content {
|
||||
.yui-navset .yui-content,
|
||||
.yui-navset .yui-content div {
|
||||
zoom:1;
|
||||
}
|
||||
|
||||
|
@ -1,41 +1,25 @@
|
||||
/*
|
||||
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 2.6.0
|
||||
version: 2.7.0
|
||||
*/
|
||||
/* default space between tabs */
|
||||
.yui-navset .yui-nav li,
|
||||
.yui-navset .yui-navset-top .yui-nav li,
|
||||
.yui-navset .yui-navset-bottom .yui-nav li {
|
||||
margin:0 0.5em 0 0; /* horizontal tabs */
|
||||
.yui-navset .yui-nav li {
|
||||
margin-right:0.5em; /* horizontal tabs */
|
||||
}
|
||||
.yui-navset-left .yui-nav li,
|
||||
.yui-navset-right .yui-nav li {
|
||||
.yui-navset-left .yui-nav li, .yui-navset-right .yui-nav li {
|
||||
margin:0 0 0.5em; /* vertical tabs */
|
||||
}
|
||||
|
||||
/* default width for side tabs */
|
||||
.yui-navset .yui-navset-left .yui-nav,
|
||||
.yui-navset .yui-navset-right .yui-nav,
|
||||
.yui-navset-left .yui-nav,
|
||||
.yui-navset-right .yui-nav { width:6em; }
|
||||
.yui-navset-top .yui-nav,
|
||||
.yui-navset-bottom .yui-nav {
|
||||
width:auto;
|
||||
}
|
||||
.yui-navset .yui-navset-left,
|
||||
.yui-navset-left { padding:0 0 0 6em; } /* map to nav width */
|
||||
.yui-navset-right { padding:0 6em 0 0; } /* ditto */
|
||||
.yui-navset-left .yui-nav, .yui-navset-right .yui-nav { width:6em; }
|
||||
.yui-navset-left { padding-left:6em; } /* map to nav width */
|
||||
.yui-navset-right { padding-right:6em; } /* ditto */
|
||||
|
||||
.yui-navset-top,
|
||||
.yui-navset-bottom {
|
||||
padding:auto;
|
||||
}
|
||||
/* core */
|
||||
|
||||
.yui-nav,
|
||||
.yui-nav li {
|
||||
.yui-nav, .yui-nav li {
|
||||
margin:0;
|
||||
padding:0;
|
||||
list-style:none;
|
||||
@ -49,9 +33,9 @@ version: 2.6.0
|
||||
|
||||
.yui-navset .yui-content { zoom:1; }
|
||||
|
||||
.yui-navset .yui-nav li,
|
||||
.yui-navset .yui-navset-top .yui-nav li, /* in case nested */
|
||||
.yui-navset .yui-navset-bottom .yui-nav li {
|
||||
.yui-navset .yui-hidden { display:none; }
|
||||
|
||||
.yui-navset .yui-nav li {
|
||||
display:inline-block;
|
||||
display:-moz-inline-stack;
|
||||
*display:inline; /* IE */
|
||||
@ -60,8 +44,7 @@ version: 2.6.0
|
||||
zoom:1; /* IE: kill space between horizontal tabs */
|
||||
}
|
||||
|
||||
.yui-navset-left .yui-nav li,
|
||||
.yui-navset-right .yui-nav li {
|
||||
.yui-navset-left .yui-nav li, .yui-navset-right .yui-nav li {
|
||||
display:block;
|
||||
}
|
||||
|
||||
@ -71,43 +54,24 @@ version: 2.6.0
|
||||
|
||||
.yui-navset .yui-nav a { position:relative; } /* IE: to allow overlap */
|
||||
|
||||
.yui-navset .yui-nav li a,
|
||||
.yui-navset-top .yui-nav li a,
|
||||
.yui-navset-bottom .yui-nav li a {
|
||||
.yui-navset .yui-nav li a {
|
||||
display:block;
|
||||
display:inline-block;
|
||||
vertical-align:bottom; /* safari: for overlap */
|
||||
zoom:1;
|
||||
}
|
||||
|
||||
.yui-navset-left .yui-nav li a,
|
||||
.yui-navset-right .yui-nav li a {
|
||||
.yui-navset-left .yui-nav li a, .yui-navset-right .yui-nav li a {
|
||||
display:block;
|
||||
}
|
||||
|
||||
.yui-navset-bottom .yui-nav li a {
|
||||
vertical-align:text-top; /* for inline overlap (reverse for Opera border bug) */
|
||||
vertical-align:text-top; /* for inline overlap (reverse for Op border bug) */
|
||||
}
|
||||
|
||||
.yui-navset .yui-nav li a em,
|
||||
.yui-navset-top .yui-nav li a em,
|
||||
.yui-navset-bottom .yui-nav li a em { display:block; }
|
||||
.yui-navset .yui-nav li a em { display:block; }
|
||||
|
||||
/* position left and right oriented tabs */
|
||||
.yui-navset .yui-navset-left .yui-nav,
|
||||
.yui-navset .yui-navset-right .yui-nav,
|
||||
.yui-navset-left .yui-nav,
|
||||
.yui-navset-right .yui-nav {
|
||||
position:absolute;
|
||||
z-index:1;
|
||||
}
|
||||
|
||||
.yui-navset-top .yui-nav,
|
||||
.yui-navset-bottom .yui-nav {
|
||||
position:static;
|
||||
}
|
||||
.yui-navset .yui-navset-left .yui-nav,
|
||||
.yui-navset-left .yui-nav { left:0; right:auto; }
|
||||
|
||||
.yui-navset .yui-navset-right .yui-nav,
|
||||
.yui-navset-right .yui-nav { right:0; left:auto; }
|
||||
.yui-navset-left .yui-nav, .yui-navset-right .yui-nav { position:absolute; z-index:1; }
|
||||
.yui-navset-left .yui-nav { left:0; }
|
||||
.yui-navset-right .yui-nav { right:0; }
|
||||
|
513
webdir/javascript/yui/tabview/tabview-debug.js
vendored
513
webdir/javascript/yui/tabview/tabview-debug.js
vendored
@ -1,8 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 2.6.0
|
||||
version: 2.7.0
|
||||
*/
|
||||
(function() {
|
||||
|
||||
@ -13,13 +13,17 @@ version: 2.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
var Dom = YAHOO.util.Dom,
|
||||
Event = YAHOO.util.Event,
|
||||
Tab = YAHOO.widget.Tab,
|
||||
doc = document;
|
||||
var Y = YAHOO.util,
|
||||
Dom = Y.Dom,
|
||||
Event = Y.Event,
|
||||
document = window.document,
|
||||
|
||||
// STRING CONSTANTS
|
||||
var ELEMENT = 'element';
|
||||
// STRING CONSTANTS
|
||||
ACTIVE = 'active',
|
||||
ACTIVE_INDEX = 'activeIndex',
|
||||
ACTIVE_TAB = 'activeTab',
|
||||
CONTENT_EL = 'contentEl',
|
||||
ELEMENT = 'element',
|
||||
|
||||
/**
|
||||
* A widget to control tabbed views.
|
||||
@ -33,7 +37,7 @@ version: 2.6.0
|
||||
* @param {Object} attr (optional) A key map of the tabView's
|
||||
* initial attributes. Ignored if first arg is attributes object.
|
||||
*/
|
||||
var TabView = function(el, attr) {
|
||||
TabView = function(el, attr) {
|
||||
attr = attr || {};
|
||||
if (arguments.length == 1 && !YAHOO.lang.isString(el) && !el.nodeName) {
|
||||
attr = el; // treat first arg as attr object
|
||||
@ -41,12 +45,12 @@ version: 2.6.0
|
||||
}
|
||||
|
||||
if (!el && !attr.element) { // create if we dont have one
|
||||
el = _createTabViewElement.call(this, attr);
|
||||
el = this._createTabViewElement(attr);
|
||||
}
|
||||
TabView.superclass.constructor.call(this, el, attr);
|
||||
TabView.superclass.constructor.call(this, el, attr);
|
||||
};
|
||||
|
||||
YAHOO.extend(TabView, YAHOO.util.Element, {
|
||||
YAHOO.extend(TabView, Y.Element, {
|
||||
/**
|
||||
* The className to add when building from scratch.
|
||||
* @property CLASSNAME
|
||||
@ -88,7 +92,13 @@ version: 2.6.0
|
||||
* @return void
|
||||
*/
|
||||
addTab: function(tab, index) {
|
||||
var tabs = this.get('tabs');
|
||||
var tabs = this.get('tabs'),
|
||||
before = this.getTab(index),
|
||||
tabParent = this._tabParent,
|
||||
contentParent = this._contentParent,
|
||||
tabElement = tab.get(ELEMENT),
|
||||
contentEl = tab.get(CONTENT_EL);
|
||||
|
||||
if (!tabs) { // not ready yet
|
||||
this._queue[this._queue.length] = ['addTab', arguments];
|
||||
return false;
|
||||
@ -96,16 +106,6 @@ version: 2.6.0
|
||||
|
||||
index = (index === undefined) ? tabs.length : index;
|
||||
|
||||
var before = this.getTab(index);
|
||||
|
||||
var self = this;
|
||||
var el = this.get(ELEMENT);
|
||||
var tabParent = this._tabParent;
|
||||
var contentParent = this._contentParent;
|
||||
|
||||
var tabElement = tab.get(ELEMENT);
|
||||
var contentEl = tab.get('contentEl');
|
||||
|
||||
if ( before ) {
|
||||
tabParent.insertBefore(tabElement, before.get(ELEMENT));
|
||||
} else {
|
||||
@ -116,33 +116,26 @@ version: 2.6.0
|
||||
contentParent.appendChild(contentEl);
|
||||
}
|
||||
|
||||
if ( !tab.get('active') ) {
|
||||
if ( !tab.get(ACTIVE) ) {
|
||||
tab.set('contentVisible', false, true); /* hide if not active */
|
||||
} else {
|
||||
this.set('activeTab', tab, true);
|
||||
this.set(ACTIVE_TAB, tab, true);
|
||||
|
||||
}
|
||||
|
||||
var activate = function(e) {
|
||||
YAHOO.util.Event.preventDefault(e);
|
||||
var silent = false;
|
||||
this._initTabEvents(tab);
|
||||
tabs.splice(index, 0, tab);
|
||||
},
|
||||
|
||||
if (this == self.get('activeTab')) {
|
||||
silent = true; // dont fire activeTabChange if already active
|
||||
}
|
||||
self.set('activeTab', this, silent);
|
||||
};
|
||||
|
||||
tab.addListener( tab.get('activationEvent'), activate);
|
||||
_initTabEvents: function(tab) {
|
||||
tab.addListener( tab.get('activationEvent'), tab._onActivate, this, tab);
|
||||
|
||||
tab.addListener('activationEventChange', function(e) {
|
||||
if (e.prevValue != e.newValue) {
|
||||
tab.removeListener(e.prevValue, activate);
|
||||
tab.addListener(e.newValue, activate);
|
||||
tab.removeListener(e.prevValue, tab._onActivate);
|
||||
tab.addListener(e.newValue, tab._onActivate, this, tab);
|
||||
}
|
||||
});
|
||||
|
||||
tabs.splice(index, 0, tab);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -152,19 +145,18 @@ version: 2.6.0
|
||||
* @return void
|
||||
*/
|
||||
DOMEventHandler: function(e) {
|
||||
var el = this.get(ELEMENT);
|
||||
var target = YAHOO.util.Event.getTarget(e);
|
||||
var tabParent = this._tabParent;
|
||||
var target = Event.getTarget(e),
|
||||
tabParent = this._tabParent,
|
||||
tabs = this.get('tabs'),
|
||||
tab,
|
||||
tabEl,
|
||||
contentEl;
|
||||
|
||||
|
||||
if (Dom.isAncestor(tabParent, target) ) {
|
||||
var tabEl;
|
||||
var tab = null;
|
||||
var contentEl;
|
||||
var tabs = this.get('tabs');
|
||||
|
||||
for (var i = 0, len = tabs.length; i < len; i++) {
|
||||
tabEl = tabs[i].get(ELEMENT);
|
||||
contentEl = tabs[i].get('contentEl');
|
||||
contentEl = tabs[i].get(CONTENT_EL);
|
||||
|
||||
if ( target == tabEl || Dom.isAncestor(tabEl, target) ) {
|
||||
tab = tabs[i];
|
||||
@ -195,8 +187,8 @@ version: 2.6.0
|
||||
* @return int
|
||||
*/
|
||||
getTabIndex: function(tab) {
|
||||
var index = null;
|
||||
var tabs = this.get('tabs');
|
||||
var index = null,
|
||||
tabs = this.get('tabs');
|
||||
for (var i = 0, len = tabs.length; i < len; ++i) {
|
||||
if (tab == tabs[i]) {
|
||||
index = i;
|
||||
@ -214,24 +206,26 @@ version: 2.6.0
|
||||
* @return void
|
||||
*/
|
||||
removeTab: function(tab) {
|
||||
var tabCount = this.get('tabs').length;
|
||||
var tabCount = this.get('tabs').length,
|
||||
index = this.getTabIndex(tab);
|
||||
|
||||
var index = this.getTabIndex(tab);
|
||||
var nextIndex = index + 1;
|
||||
if ( tab == this.get('activeTab') ) { // select next tab
|
||||
if (tabCount > 1) {
|
||||
if (index + 1 == tabCount) {
|
||||
this.set('activeIndex', index - 1);
|
||||
} else {
|
||||
this.set('activeIndex', index + 1);
|
||||
if ( tab === this.get(ACTIVE_TAB) ) {
|
||||
if (tabCount > 1) { // select another tab
|
||||
if (index + 1 === tabCount) { // if last, activate previous
|
||||
this.set(ACTIVE_INDEX, index - 1);
|
||||
} else { // activate next tab
|
||||
this.set(ACTIVE_INDEX, index + 1);
|
||||
}
|
||||
} else { // no more tabs
|
||||
this.set(ACTIVE_TAB, null);
|
||||
}
|
||||
}
|
||||
|
||||
this._tabParent.removeChild( tab.get(ELEMENT) );
|
||||
this._contentParent.removeChild( tab.get('contentEl') );
|
||||
this._contentParent.removeChild( tab.get(CONTENT_EL) );
|
||||
this._configs.tabs.value.splice(index, 1);
|
||||
|
||||
|
||||
tab.fireEvent('remove', { type: 'remove', tabview: this });
|
||||
},
|
||||
|
||||
/**
|
||||
@ -249,8 +243,12 @@ version: 2.6.0
|
||||
* @method contentTransition
|
||||
*/
|
||||
contentTransition: function(newTab, oldTab) {
|
||||
newTab.set('contentVisible', true);
|
||||
oldTab.set('contentVisible', false);
|
||||
if (newTab) {
|
||||
newTab.set('contentVisible', true);
|
||||
}
|
||||
if (oldTab) {
|
||||
oldTab.set('contentVisible', false);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -289,7 +287,7 @@ version: 2.6.0
|
||||
*/
|
||||
this._tabParent =
|
||||
this.getElementsByClassName(this.TAB_PARENT_CLASSNAME,
|
||||
'ul' )[0] || _createTabParent.call(this);
|
||||
'ul' )[0] || this._createTabParent();
|
||||
|
||||
/**
|
||||
* The container of the tabView's content elements.
|
||||
@ -299,7 +297,7 @@ version: 2.6.0
|
||||
*/
|
||||
this._contentParent =
|
||||
this.getElementsByClassName(this.CONTENT_PARENT_CLASSNAME,
|
||||
'div')[0] || _createContentParent.call(this);
|
||||
'div')[0] || this._createContentParent();
|
||||
|
||||
/**
|
||||
* How the Tabs should be oriented relative to the TabView.
|
||||
@ -317,10 +315,8 @@ version: 2.6.0
|
||||
this.removeClass('yui-navset-' + current);
|
||||
}
|
||||
|
||||
switch(value) {
|
||||
case 'bottom':
|
||||
if (value === 'bottom') {
|
||||
this.appendChild(this._tabParent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -330,13 +326,16 @@ version: 2.6.0
|
||||
* @attribute activeIndex
|
||||
* @type Int
|
||||
*/
|
||||
this.setAttributeConfig('activeIndex', {
|
||||
this.setAttributeConfig(ACTIVE_INDEX, {
|
||||
value: attr.activeIndex,
|
||||
method: function(value) {
|
||||
//this.set('activeTab', this.getTab(value));
|
||||
},
|
||||
validator: function(value) {
|
||||
return !this.getTab(value).get('disabled'); // cannot activate if disabled
|
||||
var ret = true;
|
||||
if (value && this.getTab(value).get('disabled')) { // cannot activate if disabled
|
||||
ret = false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
});
|
||||
|
||||
@ -345,37 +344,40 @@ version: 2.6.0
|
||||
* @attribute activeTab
|
||||
* @type YAHOO.widget.Tab
|
||||
*/
|
||||
this.setAttributeConfig('activeTab', {
|
||||
this.setAttributeConfig(ACTIVE_TAB, {
|
||||
value: attr.activeTab,
|
||||
method: function(tab) {
|
||||
var activeTab = this.get('activeTab');
|
||||
var activeTab = this.get(ACTIVE_TAB);
|
||||
|
||||
if (tab) {
|
||||
tab.set('active', true);
|
||||
//this._configs['activeIndex'].value = this.getTabIndex(tab); // keep in sync
|
||||
tab.set(ACTIVE, true);
|
||||
}
|
||||
|
||||
if (activeTab && activeTab != tab) {
|
||||
activeTab.set('active', false);
|
||||
if (activeTab && activeTab !== tab) {
|
||||
activeTab.set(ACTIVE, false);
|
||||
}
|
||||
|
||||
if (activeTab && tab != activeTab) { // no transition if only 1
|
||||
if (activeTab && tab !== activeTab) { // no transition if only 1
|
||||
this.contentTransition(tab, activeTab);
|
||||
} else if (tab) {
|
||||
tab.set('contentVisible', true);
|
||||
}
|
||||
},
|
||||
validator: function(value) {
|
||||
return !value.get('disabled'); // cannot activate if disabled
|
||||
var ret = true;
|
||||
if (value && value.get('disabled')) { // cannot activate if disabled
|
||||
ret = false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
});
|
||||
|
||||
this.on('activeTabChange', this._handleActiveTabChange);
|
||||
this.on('activeIndexChange', this._handleActiveIndexChange);
|
||||
this.on('activeTabChange', this._onActiveTabChange);
|
||||
this.on('activeIndexChange', this._onActiveIndexChange);
|
||||
|
||||
YAHOO.log('attributes initialized', 'info', 'TabView');
|
||||
if ( this._tabParent ) {
|
||||
_initTabs.call(this);
|
||||
this._initTabs();
|
||||
}
|
||||
|
||||
// Due to delegation we add all DOM_EVENTS to the TabView container
|
||||
@ -391,110 +393,136 @@ version: 2.6.0
|
||||
}
|
||||
},
|
||||
|
||||
_handleActiveTabChange: function(e) {
|
||||
var activeIndex = this.get('activeIndex'),
|
||||
/**
|
||||
* Removes selected state from the given tab if it is the activeTab
|
||||
* @method deselectTab
|
||||
* @param {Int} index The tab index to deselect
|
||||
*/
|
||||
deselectTab: function(index) {
|
||||
if (this.getTab(index) === this.get('activeTab')) {
|
||||
this.set('activeTab', null);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Makes the tab at the given index the active tab
|
||||
* @method selectTab
|
||||
* @param {Int} index The tab index to be made active
|
||||
*/
|
||||
selectTab: function(index) {
|
||||
this.set('activeTab', this.getTab(index));
|
||||
},
|
||||
|
||||
_onActiveTabChange: function(e) {
|
||||
var activeIndex = this.get(ACTIVE_INDEX),
|
||||
newIndex = this.getTabIndex(e.newValue);
|
||||
|
||||
if (activeIndex !== newIndex) {
|
||||
if (!(this.set('activeIndex', newIndex)) ) { // NOTE: setting
|
||||
if (!(this.set(ACTIVE_INDEX, newIndex)) ) { // NOTE: setting
|
||||
// revert if activeIndex update fails (cancelled via beforeChange)
|
||||
this.set('activeTab', e.prevValue);
|
||||
this.set(ACTIVE_TAB, e.prevValue);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_handleActiveIndexChange: function(e) {
|
||||
_onActiveIndexChange: function(e) {
|
||||
// no set if called from ActiveTabChange event
|
||||
if (e.newValue !== this.getTabIndex(this.get('activeTab'))) {
|
||||
if (!(this.set('activeTab', this.getTab(e.newValue))) ) { // NOTE: setting
|
||||
if (e.newValue !== this.getTabIndex(this.get(ACTIVE_TAB))) {
|
||||
if (!(this.set(ACTIVE_TAB, this.getTab(e.newValue))) ) { // NOTE: setting
|
||||
// revert if activeTab update fails (cancelled via beforeChange)
|
||||
this.set('activeIndex', e.prevValue);
|
||||
this.set(ACTIVE_INDEX, e.prevValue);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates Tab instances from a collection of HTMLElements.
|
||||
* @method _initTabs
|
||||
* @private
|
||||
* @return void
|
||||
*/
|
||||
_initTabs: function() {
|
||||
var tabs = Dom.getChildren(this._tabParent),
|
||||
contentElements = Dom.getChildren(this._contentParent),
|
||||
activeIndex = this.get(ACTIVE_INDEX),
|
||||
tab,
|
||||
attr,
|
||||
active;
|
||||
|
||||
for (var i = 0, len = tabs.length; i < len; ++i) {
|
||||
attr = {};
|
||||
|
||||
if (contentElements[i]) {
|
||||
attr.contentEl = contentElements[i];
|
||||
}
|
||||
|
||||
tab = new YAHOO.widget.Tab(tabs[i], attr);
|
||||
this.addTab(tab);
|
||||
|
||||
if (tab.hasClass(tab.ACTIVE_CLASSNAME) ) {
|
||||
active = tab;
|
||||
}
|
||||
}
|
||||
if (activeIndex) {
|
||||
this.set(ACTIVE_TAB, this.getTab(activeIndex));
|
||||
} else {
|
||||
this._configs.activeTab.value = active; // dont invoke method
|
||||
this._configs.activeIndex.value = this.getTabIndex(active);
|
||||
}
|
||||
},
|
||||
|
||||
_createTabViewElement: function(attr) {
|
||||
var el = document.createElement('div');
|
||||
|
||||
if ( this.CLASSNAME ) {
|
||||
el.className = this.CLASSNAME;
|
||||
}
|
||||
|
||||
YAHOO.log('TabView Dom created', 'info', 'TabView');
|
||||
return el;
|
||||
},
|
||||
|
||||
_createTabParent: function(attr) {
|
||||
var el = document.createElement('ul');
|
||||
|
||||
if ( this.TAB_PARENT_CLASSNAME ) {
|
||||
el.className = this.TAB_PARENT_CLASSNAME;
|
||||
}
|
||||
|
||||
this.get(ELEMENT).appendChild(el);
|
||||
|
||||
return el;
|
||||
},
|
||||
|
||||
_createContentParent: function(attr) {
|
||||
var el = document.createElement('div');
|
||||
|
||||
if ( this.CONTENT_PARENT_CLASSNAME ) {
|
||||
el.className = this.CONTENT_PARENT_CLASSNAME;
|
||||
}
|
||||
|
||||
this.get(ELEMENT).appendChild(el);
|
||||
|
||||
return el;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Creates Tab instances from a collection of HTMLElements.
|
||||
* @method initTabs
|
||||
* @private
|
||||
* @return void
|
||||
*/
|
||||
var _initTabs = function() {
|
||||
var tab,
|
||||
attr,
|
||||
contentEl;
|
||||
|
||||
var el = this.get(ELEMENT);
|
||||
var tabs = Dom.getChildren(this._tabParent);
|
||||
var contentElements = Dom.getChildren(this._contentParent);
|
||||
|
||||
for (var i = 0, len = tabs.length; i < len; ++i) {
|
||||
attr = {};
|
||||
|
||||
if (contentElements[i]) {
|
||||
attr.contentEl = contentElements[i];
|
||||
}
|
||||
|
||||
tab = new YAHOO.widget.Tab(tabs[i], attr);
|
||||
this.addTab(tab);
|
||||
|
||||
if (tab.hasClass(tab.ACTIVE_CLASSNAME) ) {
|
||||
this._configs.activeTab.value = tab; // dont invoke method
|
||||
this._configs.activeIndex.value = this.getTabIndex(tab);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var _createTabViewElement = function(attr) {
|
||||
var el = doc.createElement('div');
|
||||
|
||||
if ( this.CLASSNAME ) {
|
||||
el.className = this.CLASSNAME;
|
||||
}
|
||||
|
||||
YAHOO.log('TabView Dom created', 'info', 'TabView');
|
||||
return el;
|
||||
};
|
||||
|
||||
var _createTabParent = function(attr) {
|
||||
var el = doc.createElement('ul');
|
||||
|
||||
if ( this.TAB_PARENT_CLASSNAME ) {
|
||||
el.className = this.TAB_PARENT_CLASSNAME;
|
||||
}
|
||||
|
||||
this.get(ELEMENT).appendChild(el);
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
var _createContentParent = function(attr) {
|
||||
var el = doc.createElement('div');
|
||||
|
||||
if ( this.CONTENT_PARENT_CLASSNAME ) {
|
||||
el.className = this.CONTENT_PARENT_CLASSNAME;
|
||||
}
|
||||
|
||||
this.get(ELEMENT).appendChild(el);
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
YAHOO.widget.TabView = TabView;
|
||||
})();
|
||||
|
||||
(function() {
|
||||
var Dom = YAHOO.util.Dom,
|
||||
Event = YAHOO.util.Event,
|
||||
Lang = YAHOO.lang;
|
||||
var Y = YAHOO.util,
|
||||
Dom = Y.Dom,
|
||||
Lang = YAHOO.lang,
|
||||
|
||||
|
||||
// STRING CONSTANTS
|
||||
var CONTENT_EL = 'contentEl',
|
||||
ACTIVE_TAB = 'activeTab',
|
||||
LABEL = 'label',
|
||||
LABEL_EL = 'labelEl',
|
||||
CONTENT = 'content',
|
||||
CONTENT_EL = 'contentEl',
|
||||
ELEMENT = 'element',
|
||||
CACHE_DATA = 'cacheData',
|
||||
DATA_SRC = 'dataSrc',
|
||||
@ -502,7 +530,7 @@ version: 2.6.0
|
||||
DATA_TIMEOUT = 'dataTimeout',
|
||||
LOAD_METHOD = 'loadMethod',
|
||||
POST_DATA = 'postData',
|
||||
DISABLED = 'disabled';
|
||||
DISABLED = 'disabled',
|
||||
|
||||
/**
|
||||
* A representation of a Tab's label and content.
|
||||
@ -514,7 +542,7 @@ version: 2.6.0
|
||||
* represents the TabView. An element will be created if none provided.
|
||||
* @param {Object} properties A key map of initial properties
|
||||
*/
|
||||
var Tab = function(el, attr) {
|
||||
Tab = function(el, attr) {
|
||||
attr = attr || {};
|
||||
if (arguments.length == 1 && !Lang.isString(el) && !el.nodeName) {
|
||||
attr = el;
|
||||
@ -522,7 +550,7 @@ version: 2.6.0
|
||||
}
|
||||
|
||||
if (!el && !attr.element) {
|
||||
el = _createTabElement.call(this, attr);
|
||||
el = this._createTabElement(attr);
|
||||
}
|
||||
|
||||
this.loadHandler = {
|
||||
@ -610,8 +638,8 @@ version: 2.6.0
|
||||
* @return String
|
||||
*/
|
||||
toString: function() {
|
||||
var el = this.get(ELEMENT);
|
||||
var id = el.id || el.tagName;
|
||||
var el = this.get(ELEMENT),
|
||||
id = el.id || el.tagName;
|
||||
return "Tab " + id;
|
||||
},
|
||||
|
||||
@ -624,8 +652,6 @@ version: 2.6.0
|
||||
attr = attr || {};
|
||||
Tab.superclass.initAttributes.call(this, attr);
|
||||
|
||||
var el = this.get(ELEMENT);
|
||||
|
||||
/**
|
||||
* The event that triggers the tab's activation.
|
||||
* @attribute activationEvent
|
||||
@ -641,8 +667,9 @@ version: 2.6.0
|
||||
* @type HTMLElement
|
||||
*/
|
||||
this.setAttributeConfig(LABEL_EL, {
|
||||
value: attr.labelEl || _getlabelEl.call(this),
|
||||
value: attr[LABEL_EL] || this._getLabelEl(),
|
||||
method: function(value) {
|
||||
value = Dom.get(value);
|
||||
var current = this.get(LABEL_EL);
|
||||
|
||||
if (current) {
|
||||
@ -650,12 +677,9 @@ version: 2.6.0
|
||||
return false; // already set
|
||||
}
|
||||
|
||||
this.replaceChild(value, current);
|
||||
} else if (el.firstChild) { // ensure label is firstChild by default
|
||||
this.insertBefore(value, el.firstChild);
|
||||
} else {
|
||||
this.appendChild(value);
|
||||
}
|
||||
current.parentNode.replaceChild(value, current);
|
||||
this.set(LABEL, value.innerHTML);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -664,15 +688,15 @@ version: 2.6.0
|
||||
* @attribute label
|
||||
* @type String
|
||||
*/
|
||||
this.setAttributeConfig('label', {
|
||||
value: attr.label || _getLabel.call(this),
|
||||
this.setAttributeConfig(LABEL, {
|
||||
value: attr.label || this._getLabel(),
|
||||
method: function(value) {
|
||||
var labelEl = this.get(LABEL_EL);
|
||||
if (!labelEl) { // create if needed
|
||||
this.set(LABEL_EL, _createlabelEl.call(this));
|
||||
this.set(LABEL_EL, this._createLabelEl());
|
||||
}
|
||||
|
||||
_setLabel.call(this, value);
|
||||
labelEl.innerHTML = value;
|
||||
}
|
||||
});
|
||||
|
||||
@ -682,15 +706,20 @@ version: 2.6.0
|
||||
* @type HTMLElement
|
||||
*/
|
||||
this.setAttributeConfig(CONTENT_EL, {
|
||||
value: attr.contentEl || document.createElement('div'),
|
||||
value: attr[CONTENT_EL] || document.createElement('div'),
|
||||
method: function(value) {
|
||||
value = Dom.get(value);
|
||||
var current = this.get(CONTENT_EL);
|
||||
|
||||
if (current) {
|
||||
if (current == value) {
|
||||
if (current === value) {
|
||||
return false; // already set
|
||||
}
|
||||
this.replaceChild(value, current);
|
||||
if (!this.get('selected')) {
|
||||
Dom.addClass(value, 'yui-hidden');
|
||||
}
|
||||
current.parentNode.replaceChild(value, current);
|
||||
this.set(CONTENT, value.innerHTML);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -701,14 +730,12 @@ version: 2.6.0
|
||||
* @type String
|
||||
*/
|
||||
this.setAttributeConfig(CONTENT, {
|
||||
value: attr.content,
|
||||
value: attr[CONTENT],
|
||||
method: function(value) {
|
||||
this.get(CONTENT_EL).innerHTML = value;
|
||||
}
|
||||
});
|
||||
|
||||
var _dataLoaded = false;
|
||||
|
||||
/**
|
||||
* The tab's data source, used for loading content dynamically.
|
||||
* @attribute dataSrc
|
||||
@ -836,7 +863,6 @@ version: 2.6.0
|
||||
value: attr.contentVisible,
|
||||
method: function(value) {
|
||||
if (value) {
|
||||
//this.get(CONTENT_EL).style.display = 'block';
|
||||
Dom.removeClass(this.get(CONTENT_EL), this.HIDDEN_CLASSNAME);
|
||||
|
||||
if ( this.get(DATA_SRC) ) {
|
||||
@ -855,7 +881,7 @@ version: 2.6.0
|
||||
},
|
||||
|
||||
_dataConnect: function() {
|
||||
if (!YAHOO.util.Connect) {
|
||||
if (!Y.Connect) {
|
||||
YAHOO.log('YAHOO.util.Connect dependency not met',
|
||||
'error', 'Tab');
|
||||
return false;
|
||||
@ -863,7 +889,7 @@ version: 2.6.0
|
||||
|
||||
Dom.addClass(this.get(CONTENT_EL).parentNode, this.LOADING_CLASSNAME);
|
||||
this._loading = true;
|
||||
this.dataConnection = YAHOO.util.Connect.asyncRequest(
|
||||
this.dataConnection = Y.Connect.asyncRequest(
|
||||
this.get(LOAD_METHOD),
|
||||
this.get(DATA_SRC),
|
||||
{
|
||||
@ -890,60 +916,73 @@ version: 2.6.0
|
||||
|
||||
this.get(POST_DATA)
|
||||
);
|
||||
},
|
||||
_createTabElement: function(attr) {
|
||||
var el = document.createElement('li'),
|
||||
a = document.createElement('a'),
|
||||
label = attr.label || null,
|
||||
labelEl = attr.labelEl || null;
|
||||
|
||||
a.href = attr.href || '#'; // TODO: Use Dom.setAttribute?
|
||||
el.appendChild(a);
|
||||
|
||||
if (labelEl) { // user supplied labelEl
|
||||
if (!label) { // user supplied label
|
||||
label = this._getLabel();
|
||||
}
|
||||
} else {
|
||||
labelEl = this._createLabelEl();
|
||||
}
|
||||
|
||||
a.appendChild(labelEl);
|
||||
|
||||
YAHOO.log('creating Tab Dom', 'info', 'Tab');
|
||||
return el;
|
||||
},
|
||||
|
||||
_getLabelEl: function() {
|
||||
return this.getElementsByTagName(this.LABEL_TAGNAME)[0];
|
||||
},
|
||||
|
||||
_createLabelEl: function() {
|
||||
var el = document.createElement(this.LABEL_TAGNAME);
|
||||
return el;
|
||||
},
|
||||
|
||||
|
||||
_getLabel: function() {
|
||||
var el = this.get(LABEL_EL);
|
||||
|
||||
if (!el) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return el.innerHTML;
|
||||
},
|
||||
|
||||
_onActivate: function(e, tabview) {
|
||||
var tab = this,
|
||||
silent = false;
|
||||
|
||||
|
||||
Y.Event.preventDefault(e);
|
||||
if (tab === tabview.get(ACTIVE_TAB)) {
|
||||
silent = true; // dont fire activeTabChange if already active
|
||||
}
|
||||
tabview.set(ACTIVE_TAB, tab, silent);
|
||||
}
|
||||
});
|
||||
|
||||
var _createTabElement = function(attr) {
|
||||
var el = document.createElement('li');
|
||||
var a = document.createElement('a');
|
||||
|
||||
a.href = attr.href || '#';
|
||||
|
||||
el.appendChild(a);
|
||||
|
||||
var label = attr.label || null;
|
||||
var labelEl = attr.labelEl || null;
|
||||
|
||||
if (labelEl) { // user supplied labelEl
|
||||
if (!label) { // user supplied label
|
||||
label = _getLabel.call(this, labelEl);
|
||||
}
|
||||
} else {
|
||||
labelEl = _createlabelEl.call(this);
|
||||
}
|
||||
|
||||
a.appendChild(labelEl);
|
||||
|
||||
YAHOO.log('creating Tab Dom', 'info', 'Tab');
|
||||
return el;
|
||||
};
|
||||
|
||||
var _getlabelEl = function() {
|
||||
return this.getElementsByTagName(this.LABEL_TAGNAME)[0];
|
||||
};
|
||||
|
||||
var _createlabelEl = function() {
|
||||
var el = document.createElement(this.LABEL_TAGNAME);
|
||||
return el;
|
||||
};
|
||||
|
||||
var _setLabel = function(label) {
|
||||
var el = this.get(LABEL_EL);
|
||||
el.innerHTML = label;
|
||||
};
|
||||
|
||||
var _getLabel = function() {
|
||||
var label,
|
||||
el = this.get(LABEL_EL);
|
||||
|
||||
if (!el) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return el.innerHTML;
|
||||
};
|
||||
/**
|
||||
* Fires when a tab is removed from the tabview
|
||||
* @event remove
|
||||
* @type CustomEvent
|
||||
* @param {Event} An event object with fields for "type" ("remove")
|
||||
* and "tabview" (the tabview instance it was removed from)
|
||||
*/
|
||||
|
||||
YAHOO.widget.Tab = Tab;
|
||||
})();
|
||||
|
||||
YAHOO.register("tabview", YAHOO.widget.TabView, {version: "2.6.0", build: "1321"});
|
||||
YAHOO.register("tabview", YAHOO.widget.TabView, {version: "2.7.0", build: "1799"});
|
||||
|
8
webdir/javascript/yui/tabview/tabview-min.js
vendored
8
webdir/javascript/yui/tabview/tabview-min.js
vendored
File diff suppressed because one or more lines are too long
509
webdir/javascript/yui/tabview/tabview.js
vendored
509
webdir/javascript/yui/tabview/tabview.js
vendored
@ -1,8 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 2.6.0
|
||||
version: 2.7.0
|
||||
*/
|
||||
(function() {
|
||||
|
||||
@ -13,13 +13,17 @@ version: 2.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
var Dom = YAHOO.util.Dom,
|
||||
Event = YAHOO.util.Event,
|
||||
Tab = YAHOO.widget.Tab,
|
||||
doc = document;
|
||||
var Y = YAHOO.util,
|
||||
Dom = Y.Dom,
|
||||
Event = Y.Event,
|
||||
document = window.document,
|
||||
|
||||
// STRING CONSTANTS
|
||||
var ELEMENT = 'element';
|
||||
// STRING CONSTANTS
|
||||
ACTIVE = 'active',
|
||||
ACTIVE_INDEX = 'activeIndex',
|
||||
ACTIVE_TAB = 'activeTab',
|
||||
CONTENT_EL = 'contentEl',
|
||||
ELEMENT = 'element',
|
||||
|
||||
/**
|
||||
* A widget to control tabbed views.
|
||||
@ -33,7 +37,7 @@ version: 2.6.0
|
||||
* @param {Object} attr (optional) A key map of the tabView's
|
||||
* initial attributes. Ignored if first arg is attributes object.
|
||||
*/
|
||||
var TabView = function(el, attr) {
|
||||
TabView = function(el, attr) {
|
||||
attr = attr || {};
|
||||
if (arguments.length == 1 && !YAHOO.lang.isString(el) && !el.nodeName) {
|
||||
attr = el; // treat first arg as attr object
|
||||
@ -41,12 +45,12 @@ version: 2.6.0
|
||||
}
|
||||
|
||||
if (!el && !attr.element) { // create if we dont have one
|
||||
el = _createTabViewElement.call(this, attr);
|
||||
el = this._createTabViewElement(attr);
|
||||
}
|
||||
TabView.superclass.constructor.call(this, el, attr);
|
||||
TabView.superclass.constructor.call(this, el, attr);
|
||||
};
|
||||
|
||||
YAHOO.extend(TabView, YAHOO.util.Element, {
|
||||
YAHOO.extend(TabView, Y.Element, {
|
||||
/**
|
||||
* The className to add when building from scratch.
|
||||
* @property CLASSNAME
|
||||
@ -88,7 +92,13 @@ version: 2.6.0
|
||||
* @return void
|
||||
*/
|
||||
addTab: function(tab, index) {
|
||||
var tabs = this.get('tabs');
|
||||
var tabs = this.get('tabs'),
|
||||
before = this.getTab(index),
|
||||
tabParent = this._tabParent,
|
||||
contentParent = this._contentParent,
|
||||
tabElement = tab.get(ELEMENT),
|
||||
contentEl = tab.get(CONTENT_EL);
|
||||
|
||||
if (!tabs) { // not ready yet
|
||||
this._queue[this._queue.length] = ['addTab', arguments];
|
||||
return false;
|
||||
@ -96,16 +106,6 @@ version: 2.6.0
|
||||
|
||||
index = (index === undefined) ? tabs.length : index;
|
||||
|
||||
var before = this.getTab(index);
|
||||
|
||||
var self = this;
|
||||
var el = this.get(ELEMENT);
|
||||
var tabParent = this._tabParent;
|
||||
var contentParent = this._contentParent;
|
||||
|
||||
var tabElement = tab.get(ELEMENT);
|
||||
var contentEl = tab.get('contentEl');
|
||||
|
||||
if ( before ) {
|
||||
tabParent.insertBefore(tabElement, before.get(ELEMENT));
|
||||
} else {
|
||||
@ -116,33 +116,26 @@ version: 2.6.0
|
||||
contentParent.appendChild(contentEl);
|
||||
}
|
||||
|
||||
if ( !tab.get('active') ) {
|
||||
if ( !tab.get(ACTIVE) ) {
|
||||
tab.set('contentVisible', false, true); /* hide if not active */
|
||||
} else {
|
||||
this.set('activeTab', tab, true);
|
||||
this.set(ACTIVE_TAB, tab, true);
|
||||
|
||||
}
|
||||
|
||||
var activate = function(e) {
|
||||
YAHOO.util.Event.preventDefault(e);
|
||||
var silent = false;
|
||||
this._initTabEvents(tab);
|
||||
tabs.splice(index, 0, tab);
|
||||
},
|
||||
|
||||
if (this == self.get('activeTab')) {
|
||||
silent = true; // dont fire activeTabChange if already active
|
||||
}
|
||||
self.set('activeTab', this, silent);
|
||||
};
|
||||
|
||||
tab.addListener( tab.get('activationEvent'), activate);
|
||||
_initTabEvents: function(tab) {
|
||||
tab.addListener( tab.get('activationEvent'), tab._onActivate, this, tab);
|
||||
|
||||
tab.addListener('activationEventChange', function(e) {
|
||||
if (e.prevValue != e.newValue) {
|
||||
tab.removeListener(e.prevValue, activate);
|
||||
tab.addListener(e.newValue, activate);
|
||||
tab.removeListener(e.prevValue, tab._onActivate);
|
||||
tab.addListener(e.newValue, tab._onActivate, this, tab);
|
||||
}
|
||||
});
|
||||
|
||||
tabs.splice(index, 0, tab);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -152,19 +145,18 @@ version: 2.6.0
|
||||
* @return void
|
||||
*/
|
||||
DOMEventHandler: function(e) {
|
||||
var el = this.get(ELEMENT);
|
||||
var target = YAHOO.util.Event.getTarget(e);
|
||||
var tabParent = this._tabParent;
|
||||
var target = Event.getTarget(e),
|
||||
tabParent = this._tabParent,
|
||||
tabs = this.get('tabs'),
|
||||
tab,
|
||||
tabEl,
|
||||
contentEl;
|
||||
|
||||
|
||||
if (Dom.isAncestor(tabParent, target) ) {
|
||||
var tabEl;
|
||||
var tab = null;
|
||||
var contentEl;
|
||||
var tabs = this.get('tabs');
|
||||
|
||||
for (var i = 0, len = tabs.length; i < len; i++) {
|
||||
tabEl = tabs[i].get(ELEMENT);
|
||||
contentEl = tabs[i].get('contentEl');
|
||||
contentEl = tabs[i].get(CONTENT_EL);
|
||||
|
||||
if ( target == tabEl || Dom.isAncestor(tabEl, target) ) {
|
||||
tab = tabs[i];
|
||||
@ -195,8 +187,8 @@ version: 2.6.0
|
||||
* @return int
|
||||
*/
|
||||
getTabIndex: function(tab) {
|
||||
var index = null;
|
||||
var tabs = this.get('tabs');
|
||||
var index = null,
|
||||
tabs = this.get('tabs');
|
||||
for (var i = 0, len = tabs.length; i < len; ++i) {
|
||||
if (tab == tabs[i]) {
|
||||
index = i;
|
||||
@ -214,24 +206,26 @@ version: 2.6.0
|
||||
* @return void
|
||||
*/
|
||||
removeTab: function(tab) {
|
||||
var tabCount = this.get('tabs').length;
|
||||
var tabCount = this.get('tabs').length,
|
||||
index = this.getTabIndex(tab);
|
||||
|
||||
var index = this.getTabIndex(tab);
|
||||
var nextIndex = index + 1;
|
||||
if ( tab == this.get('activeTab') ) { // select next tab
|
||||
if (tabCount > 1) {
|
||||
if (index + 1 == tabCount) {
|
||||
this.set('activeIndex', index - 1);
|
||||
} else {
|
||||
this.set('activeIndex', index + 1);
|
||||
if ( tab === this.get(ACTIVE_TAB) ) {
|
||||
if (tabCount > 1) { // select another tab
|
||||
if (index + 1 === tabCount) { // if last, activate previous
|
||||
this.set(ACTIVE_INDEX, index - 1);
|
||||
} else { // activate next tab
|
||||
this.set(ACTIVE_INDEX, index + 1);
|
||||
}
|
||||
} else { // no more tabs
|
||||
this.set(ACTIVE_TAB, null);
|
||||
}
|
||||
}
|
||||
|
||||
this._tabParent.removeChild( tab.get(ELEMENT) );
|
||||
this._contentParent.removeChild( tab.get('contentEl') );
|
||||
this._contentParent.removeChild( tab.get(CONTENT_EL) );
|
||||
this._configs.tabs.value.splice(index, 1);
|
||||
|
||||
|
||||
tab.fireEvent('remove', { type: 'remove', tabview: this });
|
||||
},
|
||||
|
||||
/**
|
||||
@ -249,8 +243,12 @@ version: 2.6.0
|
||||
* @method contentTransition
|
||||
*/
|
||||
contentTransition: function(newTab, oldTab) {
|
||||
newTab.set('contentVisible', true);
|
||||
oldTab.set('contentVisible', false);
|
||||
if (newTab) {
|
||||
newTab.set('contentVisible', true);
|
||||
}
|
||||
if (oldTab) {
|
||||
oldTab.set('contentVisible', false);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -289,7 +287,7 @@ version: 2.6.0
|
||||
*/
|
||||
this._tabParent =
|
||||
this.getElementsByClassName(this.TAB_PARENT_CLASSNAME,
|
||||
'ul' )[0] || _createTabParent.call(this);
|
||||
'ul' )[0] || this._createTabParent();
|
||||
|
||||
/**
|
||||
* The container of the tabView's content elements.
|
||||
@ -299,7 +297,7 @@ version: 2.6.0
|
||||
*/
|
||||
this._contentParent =
|
||||
this.getElementsByClassName(this.CONTENT_PARENT_CLASSNAME,
|
||||
'div')[0] || _createContentParent.call(this);
|
||||
'div')[0] || this._createContentParent();
|
||||
|
||||
/**
|
||||
* How the Tabs should be oriented relative to the TabView.
|
||||
@ -317,10 +315,8 @@ version: 2.6.0
|
||||
this.removeClass('yui-navset-' + current);
|
||||
}
|
||||
|
||||
switch(value) {
|
||||
case 'bottom':
|
||||
if (value === 'bottom') {
|
||||
this.appendChild(this._tabParent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -330,13 +326,16 @@ version: 2.6.0
|
||||
* @attribute activeIndex
|
||||
* @type Int
|
||||
*/
|
||||
this.setAttributeConfig('activeIndex', {
|
||||
this.setAttributeConfig(ACTIVE_INDEX, {
|
||||
value: attr.activeIndex,
|
||||
method: function(value) {
|
||||
//this.set('activeTab', this.getTab(value));
|
||||
},
|
||||
validator: function(value) {
|
||||
return !this.getTab(value).get('disabled'); // cannot activate if disabled
|
||||
var ret = true;
|
||||
if (value && this.getTab(value).get('disabled')) { // cannot activate if disabled
|
||||
ret = false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
});
|
||||
|
||||
@ -345,36 +344,39 @@ version: 2.6.0
|
||||
* @attribute activeTab
|
||||
* @type YAHOO.widget.Tab
|
||||
*/
|
||||
this.setAttributeConfig('activeTab', {
|
||||
this.setAttributeConfig(ACTIVE_TAB, {
|
||||
value: attr.activeTab,
|
||||
method: function(tab) {
|
||||
var activeTab = this.get('activeTab');
|
||||
var activeTab = this.get(ACTIVE_TAB);
|
||||
|
||||
if (tab) {
|
||||
tab.set('active', true);
|
||||
//this._configs['activeIndex'].value = this.getTabIndex(tab); // keep in sync
|
||||
tab.set(ACTIVE, true);
|
||||
}
|
||||
|
||||
if (activeTab && activeTab != tab) {
|
||||
activeTab.set('active', false);
|
||||
if (activeTab && activeTab !== tab) {
|
||||
activeTab.set(ACTIVE, false);
|
||||
}
|
||||
|
||||
if (activeTab && tab != activeTab) { // no transition if only 1
|
||||
if (activeTab && tab !== activeTab) { // no transition if only 1
|
||||
this.contentTransition(tab, activeTab);
|
||||
} else if (tab) {
|
||||
tab.set('contentVisible', true);
|
||||
}
|
||||
},
|
||||
validator: function(value) {
|
||||
return !value.get('disabled'); // cannot activate if disabled
|
||||
var ret = true;
|
||||
if (value && value.get('disabled')) { // cannot activate if disabled
|
||||
ret = false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
});
|
||||
|
||||
this.on('activeTabChange', this._handleActiveTabChange);
|
||||
this.on('activeIndexChange', this._handleActiveIndexChange);
|
||||
this.on('activeTabChange', this._onActiveTabChange);
|
||||
this.on('activeIndexChange', this._onActiveIndexChange);
|
||||
|
||||
if ( this._tabParent ) {
|
||||
_initTabs.call(this);
|
||||
this._initTabs();
|
||||
}
|
||||
|
||||
// Due to delegation we add all DOM_EVENTS to the TabView container
|
||||
@ -390,109 +392,135 @@ version: 2.6.0
|
||||
}
|
||||
},
|
||||
|
||||
_handleActiveTabChange: function(e) {
|
||||
var activeIndex = this.get('activeIndex'),
|
||||
/**
|
||||
* Removes selected state from the given tab if it is the activeTab
|
||||
* @method deselectTab
|
||||
* @param {Int} index The tab index to deselect
|
||||
*/
|
||||
deselectTab: function(index) {
|
||||
if (this.getTab(index) === this.get('activeTab')) {
|
||||
this.set('activeTab', null);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Makes the tab at the given index the active tab
|
||||
* @method selectTab
|
||||
* @param {Int} index The tab index to be made active
|
||||
*/
|
||||
selectTab: function(index) {
|
||||
this.set('activeTab', this.getTab(index));
|
||||
},
|
||||
|
||||
_onActiveTabChange: function(e) {
|
||||
var activeIndex = this.get(ACTIVE_INDEX),
|
||||
newIndex = this.getTabIndex(e.newValue);
|
||||
|
||||
if (activeIndex !== newIndex) {
|
||||
if (!(this.set('activeIndex', newIndex)) ) { // NOTE: setting
|
||||
if (!(this.set(ACTIVE_INDEX, newIndex)) ) { // NOTE: setting
|
||||
// revert if activeIndex update fails (cancelled via beforeChange)
|
||||
this.set('activeTab', e.prevValue);
|
||||
this.set(ACTIVE_TAB, e.prevValue);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_handleActiveIndexChange: function(e) {
|
||||
_onActiveIndexChange: function(e) {
|
||||
// no set if called from ActiveTabChange event
|
||||
if (e.newValue !== this.getTabIndex(this.get('activeTab'))) {
|
||||
if (!(this.set('activeTab', this.getTab(e.newValue))) ) { // NOTE: setting
|
||||
if (e.newValue !== this.getTabIndex(this.get(ACTIVE_TAB))) {
|
||||
if (!(this.set(ACTIVE_TAB, this.getTab(e.newValue))) ) { // NOTE: setting
|
||||
// revert if activeTab update fails (cancelled via beforeChange)
|
||||
this.set('activeIndex', e.prevValue);
|
||||
this.set(ACTIVE_INDEX, e.prevValue);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates Tab instances from a collection of HTMLElements.
|
||||
* @method _initTabs
|
||||
* @private
|
||||
* @return void
|
||||
*/
|
||||
_initTabs: function() {
|
||||
var tabs = Dom.getChildren(this._tabParent),
|
||||
contentElements = Dom.getChildren(this._contentParent),
|
||||
activeIndex = this.get(ACTIVE_INDEX),
|
||||
tab,
|
||||
attr,
|
||||
active;
|
||||
|
||||
for (var i = 0, len = tabs.length; i < len; ++i) {
|
||||
attr = {};
|
||||
|
||||
if (contentElements[i]) {
|
||||
attr.contentEl = contentElements[i];
|
||||
}
|
||||
|
||||
tab = new YAHOO.widget.Tab(tabs[i], attr);
|
||||
this.addTab(tab);
|
||||
|
||||
if (tab.hasClass(tab.ACTIVE_CLASSNAME) ) {
|
||||
active = tab;
|
||||
}
|
||||
}
|
||||
if (activeIndex) {
|
||||
this.set(ACTIVE_TAB, this.getTab(activeIndex));
|
||||
} else {
|
||||
this._configs.activeTab.value = active; // dont invoke method
|
||||
this._configs.activeIndex.value = this.getTabIndex(active);
|
||||
}
|
||||
},
|
||||
|
||||
_createTabViewElement: function(attr) {
|
||||
var el = document.createElement('div');
|
||||
|
||||
if ( this.CLASSNAME ) {
|
||||
el.className = this.CLASSNAME;
|
||||
}
|
||||
|
||||
return el;
|
||||
},
|
||||
|
||||
_createTabParent: function(attr) {
|
||||
var el = document.createElement('ul');
|
||||
|
||||
if ( this.TAB_PARENT_CLASSNAME ) {
|
||||
el.className = this.TAB_PARENT_CLASSNAME;
|
||||
}
|
||||
|
||||
this.get(ELEMENT).appendChild(el);
|
||||
|
||||
return el;
|
||||
},
|
||||
|
||||
_createContentParent: function(attr) {
|
||||
var el = document.createElement('div');
|
||||
|
||||
if ( this.CONTENT_PARENT_CLASSNAME ) {
|
||||
el.className = this.CONTENT_PARENT_CLASSNAME;
|
||||
}
|
||||
|
||||
this.get(ELEMENT).appendChild(el);
|
||||
|
||||
return el;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Creates Tab instances from a collection of HTMLElements.
|
||||
* @method initTabs
|
||||
* @private
|
||||
* @return void
|
||||
*/
|
||||
var _initTabs = function() {
|
||||
var tab,
|
||||
attr,
|
||||
contentEl;
|
||||
|
||||
var el = this.get(ELEMENT);
|
||||
var tabs = Dom.getChildren(this._tabParent);
|
||||
var contentElements = Dom.getChildren(this._contentParent);
|
||||
|
||||
for (var i = 0, len = tabs.length; i < len; ++i) {
|
||||
attr = {};
|
||||
|
||||
if (contentElements[i]) {
|
||||
attr.contentEl = contentElements[i];
|
||||
}
|
||||
|
||||
tab = new YAHOO.widget.Tab(tabs[i], attr);
|
||||
this.addTab(tab);
|
||||
|
||||
if (tab.hasClass(tab.ACTIVE_CLASSNAME) ) {
|
||||
this._configs.activeTab.value = tab; // dont invoke method
|
||||
this._configs.activeIndex.value = this.getTabIndex(tab);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var _createTabViewElement = function(attr) {
|
||||
var el = doc.createElement('div');
|
||||
|
||||
if ( this.CLASSNAME ) {
|
||||
el.className = this.CLASSNAME;
|
||||
}
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
var _createTabParent = function(attr) {
|
||||
var el = doc.createElement('ul');
|
||||
|
||||
if ( this.TAB_PARENT_CLASSNAME ) {
|
||||
el.className = this.TAB_PARENT_CLASSNAME;
|
||||
}
|
||||
|
||||
this.get(ELEMENT).appendChild(el);
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
var _createContentParent = function(attr) {
|
||||
var el = doc.createElement('div');
|
||||
|
||||
if ( this.CONTENT_PARENT_CLASSNAME ) {
|
||||
el.className = this.CONTENT_PARENT_CLASSNAME;
|
||||
}
|
||||
|
||||
this.get(ELEMENT).appendChild(el);
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
YAHOO.widget.TabView = TabView;
|
||||
})();
|
||||
|
||||
(function() {
|
||||
var Dom = YAHOO.util.Dom,
|
||||
Event = YAHOO.util.Event,
|
||||
Lang = YAHOO.lang;
|
||||
var Y = YAHOO.util,
|
||||
Dom = Y.Dom,
|
||||
Lang = YAHOO.lang,
|
||||
|
||||
|
||||
// STRING CONSTANTS
|
||||
var CONTENT_EL = 'contentEl',
|
||||
ACTIVE_TAB = 'activeTab',
|
||||
LABEL = 'label',
|
||||
LABEL_EL = 'labelEl',
|
||||
CONTENT = 'content',
|
||||
CONTENT_EL = 'contentEl',
|
||||
ELEMENT = 'element',
|
||||
CACHE_DATA = 'cacheData',
|
||||
DATA_SRC = 'dataSrc',
|
||||
@ -500,7 +528,7 @@ version: 2.6.0
|
||||
DATA_TIMEOUT = 'dataTimeout',
|
||||
LOAD_METHOD = 'loadMethod',
|
||||
POST_DATA = 'postData',
|
||||
DISABLED = 'disabled';
|
||||
DISABLED = 'disabled',
|
||||
|
||||
/**
|
||||
* A representation of a Tab's label and content.
|
||||
@ -512,7 +540,7 @@ version: 2.6.0
|
||||
* represents the TabView. An element will be created if none provided.
|
||||
* @param {Object} properties A key map of initial properties
|
||||
*/
|
||||
var Tab = function(el, attr) {
|
||||
Tab = function(el, attr) {
|
||||
attr = attr || {};
|
||||
if (arguments.length == 1 && !Lang.isString(el) && !el.nodeName) {
|
||||
attr = el;
|
||||
@ -520,7 +548,7 @@ version: 2.6.0
|
||||
}
|
||||
|
||||
if (!el && !attr.element) {
|
||||
el = _createTabElement.call(this, attr);
|
||||
el = this._createTabElement(attr);
|
||||
}
|
||||
|
||||
this.loadHandler = {
|
||||
@ -608,8 +636,8 @@ version: 2.6.0
|
||||
* @return String
|
||||
*/
|
||||
toString: function() {
|
||||
var el = this.get(ELEMENT);
|
||||
var id = el.id || el.tagName;
|
||||
var el = this.get(ELEMENT),
|
||||
id = el.id || el.tagName;
|
||||
return "Tab " + id;
|
||||
},
|
||||
|
||||
@ -622,8 +650,6 @@ version: 2.6.0
|
||||
attr = attr || {};
|
||||
Tab.superclass.initAttributes.call(this, attr);
|
||||
|
||||
var el = this.get(ELEMENT);
|
||||
|
||||
/**
|
||||
* The event that triggers the tab's activation.
|
||||
* @attribute activationEvent
|
||||
@ -639,8 +665,9 @@ version: 2.6.0
|
||||
* @type HTMLElement
|
||||
*/
|
||||
this.setAttributeConfig(LABEL_EL, {
|
||||
value: attr.labelEl || _getlabelEl.call(this),
|
||||
value: attr[LABEL_EL] || this._getLabelEl(),
|
||||
method: function(value) {
|
||||
value = Dom.get(value);
|
||||
var current = this.get(LABEL_EL);
|
||||
|
||||
if (current) {
|
||||
@ -648,12 +675,9 @@ version: 2.6.0
|
||||
return false; // already set
|
||||
}
|
||||
|
||||
this.replaceChild(value, current);
|
||||
} else if (el.firstChild) { // ensure label is firstChild by default
|
||||
this.insertBefore(value, el.firstChild);
|
||||
} else {
|
||||
this.appendChild(value);
|
||||
}
|
||||
current.parentNode.replaceChild(value, current);
|
||||
this.set(LABEL, value.innerHTML);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -662,15 +686,15 @@ version: 2.6.0
|
||||
* @attribute label
|
||||
* @type String
|
||||
*/
|
||||
this.setAttributeConfig('label', {
|
||||
value: attr.label || _getLabel.call(this),
|
||||
this.setAttributeConfig(LABEL, {
|
||||
value: attr.label || this._getLabel(),
|
||||
method: function(value) {
|
||||
var labelEl = this.get(LABEL_EL);
|
||||
if (!labelEl) { // create if needed
|
||||
this.set(LABEL_EL, _createlabelEl.call(this));
|
||||
this.set(LABEL_EL, this._createLabelEl());
|
||||
}
|
||||
|
||||
_setLabel.call(this, value);
|
||||
labelEl.innerHTML = value;
|
||||
}
|
||||
});
|
||||
|
||||
@ -680,15 +704,20 @@ version: 2.6.0
|
||||
* @type HTMLElement
|
||||
*/
|
||||
this.setAttributeConfig(CONTENT_EL, {
|
||||
value: attr.contentEl || document.createElement('div'),
|
||||
value: attr[CONTENT_EL] || document.createElement('div'),
|
||||
method: function(value) {
|
||||
value = Dom.get(value);
|
||||
var current = this.get(CONTENT_EL);
|
||||
|
||||
if (current) {
|
||||
if (current == value) {
|
||||
if (current === value) {
|
||||
return false; // already set
|
||||
}
|
||||
this.replaceChild(value, current);
|
||||
if (!this.get('selected')) {
|
||||
Dom.addClass(value, 'yui-hidden');
|
||||
}
|
||||
current.parentNode.replaceChild(value, current);
|
||||
this.set(CONTENT, value.innerHTML);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -699,14 +728,12 @@ version: 2.6.0
|
||||
* @type String
|
||||
*/
|
||||
this.setAttributeConfig(CONTENT, {
|
||||
value: attr.content,
|
||||
value: attr[CONTENT],
|
||||
method: function(value) {
|
||||
this.get(CONTENT_EL).innerHTML = value;
|
||||
}
|
||||
});
|
||||
|
||||
var _dataLoaded = false;
|
||||
|
||||
/**
|
||||
* The tab's data source, used for loading content dynamically.
|
||||
* @attribute dataSrc
|
||||
@ -834,7 +861,6 @@ version: 2.6.0
|
||||
value: attr.contentVisible,
|
||||
method: function(value) {
|
||||
if (value) {
|
||||
//this.get(CONTENT_EL).style.display = 'block';
|
||||
Dom.removeClass(this.get(CONTENT_EL), this.HIDDEN_CLASSNAME);
|
||||
|
||||
if ( this.get(DATA_SRC) ) {
|
||||
@ -852,13 +878,13 @@ version: 2.6.0
|
||||
},
|
||||
|
||||
_dataConnect: function() {
|
||||
if (!YAHOO.util.Connect) {
|
||||
if (!Y.Connect) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Dom.addClass(this.get(CONTENT_EL).parentNode, this.LOADING_CLASSNAME);
|
||||
this._loading = true;
|
||||
this.dataConnection = YAHOO.util.Connect.asyncRequest(
|
||||
this.dataConnection = Y.Connect.asyncRequest(
|
||||
this.get(LOAD_METHOD),
|
||||
this.get(DATA_SRC),
|
||||
{
|
||||
@ -883,59 +909,72 @@ version: 2.6.0
|
||||
|
||||
this.get(POST_DATA)
|
||||
);
|
||||
},
|
||||
_createTabElement: function(attr) {
|
||||
var el = document.createElement('li'),
|
||||
a = document.createElement('a'),
|
||||
label = attr.label || null,
|
||||
labelEl = attr.labelEl || null;
|
||||
|
||||
a.href = attr.href || '#'; // TODO: Use Dom.setAttribute?
|
||||
el.appendChild(a);
|
||||
|
||||
if (labelEl) { // user supplied labelEl
|
||||
if (!label) { // user supplied label
|
||||
label = this._getLabel();
|
||||
}
|
||||
} else {
|
||||
labelEl = this._createLabelEl();
|
||||
}
|
||||
|
||||
a.appendChild(labelEl);
|
||||
|
||||
return el;
|
||||
},
|
||||
|
||||
_getLabelEl: function() {
|
||||
return this.getElementsByTagName(this.LABEL_TAGNAME)[0];
|
||||
},
|
||||
|
||||
_createLabelEl: function() {
|
||||
var el = document.createElement(this.LABEL_TAGNAME);
|
||||
return el;
|
||||
},
|
||||
|
||||
|
||||
_getLabel: function() {
|
||||
var el = this.get(LABEL_EL);
|
||||
|
||||
if (!el) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return el.innerHTML;
|
||||
},
|
||||
|
||||
_onActivate: function(e, tabview) {
|
||||
var tab = this,
|
||||
silent = false;
|
||||
|
||||
|
||||
Y.Event.preventDefault(e);
|
||||
if (tab === tabview.get(ACTIVE_TAB)) {
|
||||
silent = true; // dont fire activeTabChange if already active
|
||||
}
|
||||
tabview.set(ACTIVE_TAB, tab, silent);
|
||||
}
|
||||
});
|
||||
|
||||
var _createTabElement = function(attr) {
|
||||
var el = document.createElement('li');
|
||||
var a = document.createElement('a');
|
||||
|
||||
a.href = attr.href || '#';
|
||||
|
||||
el.appendChild(a);
|
||||
|
||||
var label = attr.label || null;
|
||||
var labelEl = attr.labelEl || null;
|
||||
|
||||
if (labelEl) { // user supplied labelEl
|
||||
if (!label) { // user supplied label
|
||||
label = _getLabel.call(this, labelEl);
|
||||
}
|
||||
} else {
|
||||
labelEl = _createlabelEl.call(this);
|
||||
}
|
||||
|
||||
a.appendChild(labelEl);
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
var _getlabelEl = function() {
|
||||
return this.getElementsByTagName(this.LABEL_TAGNAME)[0];
|
||||
};
|
||||
|
||||
var _createlabelEl = function() {
|
||||
var el = document.createElement(this.LABEL_TAGNAME);
|
||||
return el;
|
||||
};
|
||||
|
||||
var _setLabel = function(label) {
|
||||
var el = this.get(LABEL_EL);
|
||||
el.innerHTML = label;
|
||||
};
|
||||
|
||||
var _getLabel = function() {
|
||||
var label,
|
||||
el = this.get(LABEL_EL);
|
||||
|
||||
if (!el) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return el.innerHTML;
|
||||
};
|
||||
/**
|
||||
* Fires when a tab is removed from the tabview
|
||||
* @event remove
|
||||
* @type CustomEvent
|
||||
* @param {Event} An event object with fields for "type" ("remove")
|
||||
* and "tabview" (the tabview instance it was removed from)
|
||||
*/
|
||||
|
||||
YAHOO.widget.Tab = Tab;
|
||||
})();
|
||||
|
||||
YAHOO.register("tabview", YAHOO.widget.TabView, {version: "2.6.0", build: "1321"});
|
||||
YAHOO.register("tabview", YAHOO.widget.TabView, {version: "2.7.0", build: "1799"});
|
||||
|
Reference in New Issue
Block a user