/*
Copyright (c) 2007, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
version: 2.3.0
*/
(function() {
/**
* The tabview module provides a widget for managing content bound to tabs.
* @module tabview
* @requires yahoo, dom, event, element
*
*/
/**
* A widget to control tabbed views.
* @namespace YAHOO.widget
* @class TabView
* @extends YAHOO.util.Element
* @constructor
* @param {HTMLElement | String | Object} el(optional) The html
* element that represents the TabView, or the attribute object to use.
* An element will be created if none provided.
* @param {Object} attr (optional) A key map of the tabView's
* initial attributes. Ignored if first arg is attributes object.
*/
}
}
};
/**
* The className to add when building from scratch.
* @property CLASSNAME
* @default "navset"
*/
/**
* The className of the HTMLElement containing the TabView's tab elements
* to look for when building from existing markup, or to add when building
* from scratch.
* All childNodes of the tab container are treated as Tabs when building
* from existing markup.
* @property TAB_PARENT_CLASSNAME
* @default "nav"
*/
/**
* The className of the HTMLElement containing the TabView's label elements
* to look for when building from existing markup, or to add when building
* from scratch.
* All childNodes of the content container are treated as content elements when
* building from existing markup.
* @property CONTENT_PARENT_CLASSNAME
* @default "nav-content"
*/
proto._tabParent = null;
proto._contentParent = null;
/**
* Adds a Tab to the TabView instance.
* If no index is specified, the tab is added to the end of the tab list.
* @method addTab
* @param {YAHOO.widget.Tab} tab A Tab instance to add.
* @param {Integer} index The position to add the tab.
* @return void
*/
if (!tabs) { // not ready yet
return false;
}
var self = this;
var tabParent = this._tabParent;
var contentParent = this._contentParent;
if ( before ) {
} else {
}
}
} else {
}
var activate = function(e) {
var silent = false;
silent = true; // dont fire activeTabChange if already active
}
};
}
});
};
/**
* Routes childNode events.
* @method DOMEventHandler
* @param {event} e The Dom event that is being handled.
* @return void
*/
proto.DOMEventHandler = function(e) {
var tabParent = this._tabParent;
var tabEl;
var tab = null;
var contentEl;
break; // note break
}
}
if (tab) {
}
}
};
/**
* Returns the Tab instance at the specified index.
* @method getTab
* @param {Integer} index The position of the Tab.
* @return YAHOO.widget.Tab
*/
};
/**
* Returns the index of given tab.
* @method getTabIndex
* @param {YAHOO.widget.Tab} tab The tab whose index will be returned.
* @return int
*/
var index = null;
index = i;
break;
}
}
return index;
};
/**
* Removes the specified Tab from the TabView.
* @method removeTab
* @param {YAHOO.widget.Tab} item The Tab instance to be removed.
* @return void
*/
if (tabCount > 1) {
} else {
}
}
}
};
/**
* Provides a readable name for the TabView instance.
* @method toString
* @return String
*/
return "TabView " + name;
};
/**
* The transiton to use when switching between tabs.
* @method contentTransition
*/
};
/**
* setAttributeConfigs TabView specific properties.
* @method initAttributes
* @param {Object} attr Hash of initial attributes
*/
if (!attr.orientation) {
}
}
/**
* The Tabs belonging to the TabView instance.
* @config tabs
* @type Array
*/
this.setAttributeConfig('tabs', {
value: [],
readOnly: true
});
/**
* The container of the tabView's label elements.
* @property _tabParent
* @private
* @type HTMLElement
*/
this._tabParent =
this.getElementsByClassName(this.TAB_PARENT_CLASSNAME,
/**
* The container of the tabView's content elements.
* @property _contentParent
* @type HTMLElement
* @private
*/
this._contentParent =
this.getElementsByClassName(this.CONTENT_PARENT_CLASSNAME,
/**
* How the Tabs should be oriented relative to the TabView.
* @config orientation
* @type String
* @default "top"
*/
this.setAttributeConfig('orientation', {
}
switch(value) {
case 'bottom':
this.appendChild(this._tabParent);
break;
}
}
});
/**
* The index of the tab currently active.
* @config activeIndex
* @type Int
*/
this.setAttributeConfig('activeIndex', {
},
}
});
/**
* The tab currently active.
* @config activeTab
* @type YAHOO.widget.Tab
*/
this.setAttributeConfig('activeTab', {
if (tab) {
}
}
} else if (tab) {
}
},
}
});
if ( this._tabParent ) {
}
// Due to delegation we add all DOM_EVENTS to the TabView container
// but IE will leak when unsupported events are added, so remove these
this.DOM_EVENTS.submit = false;
this.DOM_EVENTS.focus = false;
this.DOM_EVENTS.blur = false;
for (var type in this.DOM_EVENTS) {
}
}
};
/**
* Creates Tab instances from a collection of HTMLElements.
* @method initTabs
* @private
* @return void
*/
var _initTabs = function() {
var tab,
attr,
attr = {};
if (contentElements[i]) {
}
}
}
};
if ( this.CLASSNAME ) {
}
return el;
};
if ( this.TAB_PARENT_CLASSNAME ) {
}
return el;
};
if ( this.CONTENT_PARENT_CLASSNAME ) {
}
return el;
};
var nodes = [];
}
}
return nodes;
};
/**
* Fires before the activeTab is changed.
* <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p>
* <p>If handler returns false, the change will be cancelled, and the value will not
* be set.</p>
* <p><strong>Event fields:</strong><br>
* <code><String> type</code> beforeActiveTabChange<br>
* <code><<a href="YAHOO.widget.Tab.html">YAHOO.widget.Tab</a>>
* prevValue</code> the currently active tab<br>
* <code><<a href="YAHOO.widget.Tab.html">YAHOO.widget.Tab</a>>
* newValue</code> the tab to be made active</p>
* <p><strong>Usage:</strong><br>
* <code>var handler = function(e) {var previous = e.prevValue};<br>
* myTabs.addListener('beforeActiveTabChange', handler);</code></p>
* @event beforeActiveTabChange
*/
/**
* Fires after the activeTab is changed.
* <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p>
* <p><strong>Event fields:</strong><br>
* <code><String> type</code> activeTabChange<br>
* <code><<a href="YAHOO.widget.Tab.html">YAHOO.widget.Tab</a>>
* prevValue</code> the formerly active tab<br>
* <code><<a href="YAHOO.widget.Tab.html">YAHOO.widget.Tab</a>>
* newValue</code> the new active tab</p>
* <p><strong>Usage:</strong><br>
* <code>var handler = function(e) {var previous = e.prevValue};<br>
* myTabs.addListener('activeTabChange', handler);</code></p>
* @event activeTabChange
*/
/**
* Fires before the orientation is changed.
* <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p>
* <p>If handler returns false, the change will be cancelled, and the value will not
* be set.</p>
* <p><strong>Event fields:</strong><br>
* <code><String> type</code> beforeOrientationChange<br>
* <code><String>
* prevValue</code> the current orientation<br>
* <code><String>
* newValue</code> the new orientation to be applied</p>
* <p><strong>Usage:</strong><br>
* <code>var handler = function(e) {var previous = e.prevValue};<br>
* myTabs.addListener('beforeOrientationChange', handler);</code></p>
* @event beforeOrientationChange
*/
/**
* Fires after the orientation is changed.
* <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p>
* <p><strong>Event fields:</strong><br>
* <code><String> type</code> orientationChange<br>
* <code><String>
* prevValue</code> the former orientation<br>
* <code><String>
* newValue</code> the new orientation</p>
* <p><strong>Usage:</strong><br>
* <code>var handler = function(e) {var previous = e.prevValue};<br>
* myTabs.addListener('orientationChange', handler);</code></p>
* @event orientationChange
*/
})();
(function() {
/**
* A representation of a Tab's label and content.
* @namespace YAHOO.widget
* @class Tab
* @extends YAHOO.util.Element
* @constructor
* @param element {HTMLElement | String} (optional) The html element that
* represents the TabView. An element will be created if none provided.
* @param {Object} properties A key map of initial properties
*/
}
}
this.loadHandler = {
success: function(o) {
},
failure: function(o) {
'error', 'Tab');
}
};
this.DOM_EVENTS = {}; // delegating to tabView
};
/**
* The default tag name for a Tab's inner element.
* @property LABEL_INNER_TAGNAME
* @type String
* @default "em"
*/
/**
* The class name applied to active tabs.
* @property ACTIVE_CLASSNAME
* @type String
* @default "on"
*/
/**
* The class name applied to disabled tabs.
* @property DISABLED_CLASSNAME
* @type String
* @default "disabled"
*/
/**
* The class name applied to dynamic tabs while loading.
* @property LOADING_CLASSNAME
* @type String
* @default "disabled"
*/
/**
* Provides a reference to the connection request object when data is
* loaded dynamically.
* @property dataConnection
* @type Object
*/
proto.dataConnection = null;
/**
* Object containing success and failure callbacks for loading data.
* @property loadHandler
* @type object
*/
proto.loadHandler = null;
/**
* Provides a readable name for the tab.
* @method toString
* @return String
*/
return "Tab " + id;
};
/**
* setAttributeConfigs TabView specific properties.
* @method initAttributes
* @param {Object} attr Hash of initial attributes
*/
/**
* The event that triggers the tab's activation.
* @config activationEvent
* @type String
*/
this.setAttributeConfig('activationEvent', {
});
/**
* The element that contains the tab's label.
* @config labelEl
* @type HTMLElement
*/
this.setAttributeConfig('labelEl', {
if (current) {
return false; // already set
}
} else {
this.appendChild(value);
}
}
});
/**
* The tab's label text (or innerHTML).
* @config label
* @type String
*/
this.setAttributeConfig('label', {
if (!labelEl) { // create if needed
}
}
});
/**
* The HTMLElement that contains the tab's content.
* @config contentEl
* @type HTMLElement
*/
this.setAttributeConfig('contentEl', {
if (current) {
return false; // already set
}
}
}
});
/**
* The tab's content.
* @config content
* @type String
*/
this.setAttributeConfig('content', {
}
});
var _dataLoaded = false;
/**
* The tab's data source, used for loading content dynamically.
* @config dataSrc
* @type String
*/
this.setAttributeConfig('dataSrc', {
});
/**
* Whether or not content should be reloaded for every view.
* @config cacheData
* @type Boolean
* @default false
*/
this.setAttributeConfig('cacheData', {
});
/**
* The method to use for the data request.
* @config loadMethod
* @type String
* @default "GET"
*/
this.setAttributeConfig('loadMethod', {
});
/**
* Whether or not any data has been loaded from the server.
* @config dataLoaded
* @type Boolean
*/
this.setAttributeConfig('dataLoaded', {
value: false,
writeOnce: true
});
/**
* Number if milliseconds before aborting and calling failure handler.
* @config dataTimeout
* @type Number
* @default null
*/
this.setAttributeConfig('dataTimeout', {
});
/**
* Whether or not the tab is currently active.
* If a dataSrc is set for the tab, the content will be loaded from
* the given source.
* @config active
* @type Boolean
*/
this.setAttributeConfig('active', {
if (value === true) {
this.addClass(this.ACTIVE_CLASSNAME);
} else {
this.removeClass(this.ACTIVE_CLASSNAME);
}
},
}
});
/**
* Whether or not the tab is disabled.
* @config disabled
* @type Boolean
*/
this.setAttributeConfig('disabled', {
if (value === true) {
} else {
}
},
});
/**
* The href of the tab's anchor element.
* @config href
* @type String
* @default '#'
*/
this.setAttributeConfig('href', {
},
});
/**
* The Whether or not the tab's content is visible.
* @config contentVisible
* @type Boolean
* @default false
*/
this.setAttributeConfig('contentVisible', {
if (value) {
if ( this.get('dataSrc') ) {
// load dynamic content unless already loading or loaded and caching
_dataConnect.call(this);
}
}
} else {
}
},
});
};
el.appendChild(a);
if (labelEl) { // user supplied labelEl
if (!label) { // user supplied label
}
} else {
}
a.appendChild(labelEl);
return el;
};
var _getlabelEl = function() {
};
var _createlabelEl = function() {
return el;
};
};
var _getLabel = function() {
var label,
if (!el) {
return undefined;
}
};
var _dataConnect = function() {
'error', 'Tab');
return false;
}
this._loading = true;
this.get('loadMethod'),
this.get('dataSrc'),
{
success: function(o) {
this.set('dataLoaded', true);
this.dataConnection = null;
this.LOADING_CLASSNAME);
this._loading = false;
},
failure: function(o) {
this.dataConnection = null;
this.LOADING_CLASSNAME);
this._loading = false;
},
scope: this,
}
);
};
/**
* Fires before the active state is changed.
* <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p>
* <p>If handler returns false, the change will be cancelled, and the value will not
* be set.</p>
* <p><strong>Event fields:</strong><br>
* <code><String> type</code> beforeActiveChange<br>
* <code><Boolean>
* prevValue</code> the current value<br>
* <code><Boolean>
* newValue</code> the new value</p>
* <p><strong>Usage:</strong><br>
* <code>var handler = function(e) {var previous = e.prevValue};<br>
* myTabs.addListener('beforeActiveChange', handler);</code></p>
* @event beforeActiveChange
*/
/**
* Fires after the active state is changed.
* <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p>
* <p><strong>Event fields:</strong><br>
* <code><String> type</code> activeChange<br>
* <code><Boolean>
* prevValue</code> the previous value<br>
* <code><Boolean>
* newValue</code> the updated value</p>
* <p><strong>Usage:</strong><br>
* <code>var handler = function(e) {var previous = e.prevValue};<br>
* myTabs.addListener('activeChange', handler);</code></p>
* @event activeChange
*/
/**
* Fires before the tab label is changed.
* <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p>
* <p>If handler returns false, the change will be cancelled, and the value will not
* be set.</p>
* <p><strong>Event fields:</strong><br>
* <code><String> type</code> beforeLabelChange<br>
* <code><String>
* prevValue</code> the current value<br>
* <code><String>
* newValue</code> the new value</p>
* <p><strong>Usage:</strong><br>
* <code>var handler = function(e) {var previous = e.prevValue};<br>
* myTabs.addListener('beforeLabelChange', handler);</code></p>
* @event beforeLabelChange
*/
/**
* Fires after the tab label is changed.
* <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p>
* <p><strong>Event fields:</strong><br>
* <code><String> type</code> labelChange<br>
* <code><String>
* prevValue</code> the previous value<br>
* <code><String>
* newValue</code> the updated value</p>
* <p><strong>Usage:</strong><br>
* <code>var handler = function(e) {var previous = e.prevValue};<br>
* myTabs.addListener('labelChange', handler);</code></p>
* @event labelChange
*/
/**
* Fires before the tab content is changed.
* <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p>
* <p>If handler returns false, the change will be cancelled, and the value will not
* be set.</p>
* <p><strong>Event fields:</strong><br>
* <code><String> type</code> beforeContentChange<br>
* <code><String>
* prevValue</code> the current value<br>
* <code><String>
* newValue</code> the new value</p>
* <p><strong>Usage:</strong><br>
* <code>var handler = function(e) {var previous = e.prevValue};<br>
* myTabs.addListener('beforeContentChange', handler);</code></p>
* @event beforeContentChange
*/
/**
* Fires after the tab content is changed.
* <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p>
* <p><strong>Event fields:</strong><br>
* <code><String> type</code> contentChange<br>
* <code><String>
* prevValue</code> the previous value<br>
* <code><Boolean>
* newValue</code> the updated value</p>
* <p><strong>Usage:</strong><br>
* <code>var handler = function(e) {var previous = e.prevValue};<br>
* myTabs.addListener('contentChange', handler);</code></p>
* @event contentChange
*/
})();