/hudson-war/src/main/webapp/scripts/yui/tabview/tabview-debug.js

http://github.com/hudson/hudson · JavaScript · 897 lines · 494 code · 130 blank · 273 comment · 110 complexity · 473a916ad17cb22b42e295411e773e87 MD5 · raw file

  1. /*
  2. Copyright (c) 2008, Yahoo! Inc. All rights reserved.
  3. Code licensed under the BSD License:
  4. http://developer.yahoo.net/yui/license.txt
  5. version: 2.5.1
  6. */
  7. (function() {
  8. /**
  9. * The tabview module provides a widget for managing content bound to tabs.
  10. * @module tabview
  11. * @requires yahoo, dom, event, element
  12. *
  13. */
  14. /**
  15. * A widget to control tabbed views.
  16. * @namespace YAHOO.widget
  17. * @class TabView
  18. * @extends YAHOO.util.Element
  19. * @constructor
  20. * @param {HTMLElement | String | Object} el(optional) The html
  21. * element that represents the TabView, or the attribute object to use.
  22. * An element will be created if none provided.
  23. * @param {Object} attr (optional) A key map of the tabView's
  24. * initial attributes. Ignored if first arg is attributes object.
  25. */
  26. YAHOO.widget.TabView = function(el, attr) {
  27. attr = attr || {};
  28. if (arguments.length == 1 && !YAHOO.lang.isString(el) && !el.nodeName) {
  29. attr = el; // treat first arg as attr object
  30. el = attr.element || null;
  31. }
  32. if (!el && !attr.element) { // create if we dont have one
  33. el = _createTabViewElement.call(this, attr);
  34. }
  35. YAHOO.widget.TabView.superclass.constructor.call(this, el, attr);
  36. };
  37. YAHOO.extend(YAHOO.widget.TabView, YAHOO.util.Element);
  38. var proto = YAHOO.widget.TabView.prototype;
  39. var Dom = YAHOO.util.Dom;
  40. var Event = YAHOO.util.Event;
  41. var Tab = YAHOO.widget.Tab;
  42. /**
  43. * The className to add when building from scratch.
  44. * @property CLASSNAME
  45. * @default "navset"
  46. */
  47. proto.CLASSNAME = 'yui-navset';
  48. /**
  49. * The className of the HTMLElement containing the TabView's tab elements
  50. * to look for when building from existing markup, or to add when building
  51. * from scratch.
  52. * All childNodes of the tab container are treated as Tabs when building
  53. * from existing markup.
  54. * @property TAB_PARENT_CLASSNAME
  55. * @default "nav"
  56. */
  57. proto.TAB_PARENT_CLASSNAME = 'yui-nav';
  58. /**
  59. * The className of the HTMLElement containing the TabView's label elements
  60. * to look for when building from existing markup, or to add when building
  61. * from scratch.
  62. * All childNodes of the content container are treated as content elements when
  63. * building from existing markup.
  64. * @property CONTENT_PARENT_CLASSNAME
  65. * @default "nav-content"
  66. */
  67. proto.CONTENT_PARENT_CLASSNAME = 'yui-content';
  68. proto._tabParent = null;
  69. proto._contentParent = null;
  70. /**
  71. * Adds a Tab to the TabView instance.
  72. * If no index is specified, the tab is added to the end of the tab list.
  73. * @method addTab
  74. * @param {YAHOO.widget.Tab} tab A Tab instance to add.
  75. * @param {Integer} index The position to add the tab.
  76. * @return void
  77. */
  78. proto.addTab = function(tab, index) {
  79. var tabs = this.get('tabs');
  80. if (!tabs) { // not ready yet
  81. this._queue[this._queue.length] = ['addTab', arguments];
  82. return false;
  83. }
  84. index = (index === undefined) ? tabs.length : index;
  85. var before = this.getTab(index);
  86. var self = this;
  87. var el = this.get('element');
  88. var tabParent = this._tabParent;
  89. var contentParent = this._contentParent;
  90. var tabElement = tab.get('element');
  91. var contentEl = tab.get('contentEl');
  92. if ( before ) {
  93. tabParent.insertBefore(tabElement, before.get('element'));
  94. } else {
  95. tabParent.appendChild(tabElement);
  96. }
  97. if ( contentEl && !Dom.isAncestor(contentParent, contentEl) ) {
  98. contentParent.appendChild(contentEl);
  99. }
  100. if ( !tab.get('active') ) {
  101. tab.set('contentVisible', false, true); /* hide if not active */
  102. } else {
  103. this.set('activeTab', tab, true);
  104. }
  105. var activate = function(e) {
  106. YAHOO.util.Event.preventDefault(e);
  107. var silent = false;
  108. if (this == self.get('activeTab')) {
  109. silent = true; // dont fire activeTabChange if already active
  110. }
  111. self.set('activeTab', this, silent);
  112. };
  113. tab.addListener( tab.get('activationEvent'), activate);
  114. tab.addListener('activationEventChange', function(e) {
  115. if (e.prevValue != e.newValue) {
  116. tab.removeListener(e.prevValue, activate);
  117. tab.addListener(e.newValue, activate);
  118. }
  119. });
  120. tabs.splice(index, 0, tab);
  121. };
  122. /**
  123. * Routes childNode events.
  124. * @method DOMEventHandler
  125. * @param {event} e The Dom event that is being handled.
  126. * @return void
  127. */
  128. proto.DOMEventHandler = function(e) {
  129. var el = this.get('element');
  130. var target = YAHOO.util.Event.getTarget(e);
  131. var tabParent = this._tabParent;
  132. if (Dom.isAncestor(tabParent, target) ) {
  133. var tabEl;
  134. var tab = null;
  135. var contentEl;
  136. var tabs = this.get('tabs');
  137. for (var i = 0, len = tabs.length; i < len; i++) {
  138. tabEl = tabs[i].get('element');
  139. contentEl = tabs[i].get('contentEl');
  140. if ( target == tabEl || Dom.isAncestor(tabEl, target) ) {
  141. tab = tabs[i];
  142. break; // note break
  143. }
  144. }
  145. if (tab) {
  146. tab.fireEvent(e.type, e);
  147. }
  148. }
  149. };
  150. /**
  151. * Returns the Tab instance at the specified index.
  152. * @method getTab
  153. * @param {Integer} index The position of the Tab.
  154. * @return YAHOO.widget.Tab
  155. */
  156. proto.getTab = function(index) {
  157. return this.get('tabs')[index];
  158. };
  159. /**
  160. * Returns the index of given tab.
  161. * @method getTabIndex
  162. * @param {YAHOO.widget.Tab} tab The tab whose index will be returned.
  163. * @return int
  164. */
  165. proto.getTabIndex = function(tab) {
  166. var index = null;
  167. var tabs = this.get('tabs');
  168. for (var i = 0, len = tabs.length; i < len; ++i) {
  169. if (tab == tabs[i]) {
  170. index = i;
  171. break;
  172. }
  173. }
  174. return index;
  175. };
  176. /**
  177. * Removes the specified Tab from the TabView.
  178. * @method removeTab
  179. * @param {YAHOO.widget.Tab} item The Tab instance to be removed.
  180. * @return void
  181. */
  182. proto.removeTab = function(tab) {
  183. var tabCount = this.get('tabs').length;
  184. var index = this.getTabIndex(tab);
  185. var nextIndex = index + 1;
  186. if ( tab == this.get('activeTab') ) { // select next tab
  187. if (tabCount > 1) {
  188. if (index + 1 == tabCount) {
  189. this.set('activeIndex', index - 1);
  190. } else {
  191. this.set('activeIndex', index + 1);
  192. }
  193. }
  194. }
  195. this._tabParent.removeChild( tab.get('element') );
  196. this._contentParent.removeChild( tab.get('contentEl') );
  197. this._configs.tabs.value.splice(index, 1);
  198. };
  199. /**
  200. * Provides a readable name for the TabView instance.
  201. * @method toString
  202. * @return String
  203. */
  204. proto.toString = function() {
  205. var name = this.get('id') || this.get('tagName');
  206. return "TabView " + name;
  207. };
  208. /**
  209. * The transiton to use when switching between tabs.
  210. * @method contentTransition
  211. */
  212. proto.contentTransition = function(newTab, oldTab) {
  213. newTab.set('contentVisible', true);
  214. oldTab.set('contentVisible', false);
  215. };
  216. /**
  217. * setAttributeConfigs TabView specific properties.
  218. * @method initAttributes
  219. * @param {Object} attr Hash of initial attributes
  220. */
  221. proto.initAttributes = function(attr) {
  222. YAHOO.widget.TabView.superclass.initAttributes.call(this, attr);
  223. if (!attr.orientation) {
  224. attr.orientation = 'top';
  225. }
  226. var el = this.get('element');
  227. if (!YAHOO.util.Dom.hasClass(el, this.CLASSNAME)) {
  228. YAHOO.util.Dom.addClass(el, this.CLASSNAME);
  229. }
  230. /**
  231. * The Tabs belonging to the TabView instance.
  232. * @attribute tabs
  233. * @type Array
  234. */
  235. this.setAttributeConfig('tabs', {
  236. value: [],
  237. readOnly: true
  238. });
  239. /**
  240. * The container of the tabView's label elements.
  241. * @property _tabParent
  242. * @private
  243. * @type HTMLElement
  244. */
  245. this._tabParent =
  246. this.getElementsByClassName(this.TAB_PARENT_CLASSNAME,
  247. 'ul' )[0] || _createTabParent.call(this);
  248. /**
  249. * The container of the tabView's content elements.
  250. * @property _contentParent
  251. * @type HTMLElement
  252. * @private
  253. */
  254. this._contentParent =
  255. this.getElementsByClassName(this.CONTENT_PARENT_CLASSNAME,
  256. 'div')[0] || _createContentParent.call(this);
  257. /**
  258. * How the Tabs should be oriented relative to the TabView.
  259. * @attribute orientation
  260. * @type String
  261. * @default "top"
  262. */
  263. this.setAttributeConfig('orientation', {
  264. value: attr.orientation,
  265. method: function(value) {
  266. var current = this.get('orientation');
  267. this.addClass('yui-navset-' + value);
  268. if (current != value) {
  269. this.removeClass('yui-navset-' + current);
  270. }
  271. switch(value) {
  272. case 'bottom':
  273. this.appendChild(this._tabParent);
  274. break;
  275. }
  276. }
  277. });
  278. /**
  279. * The index of the tab currently active.
  280. * @attribute activeIndex
  281. * @type Int
  282. */
  283. this.setAttributeConfig('activeIndex', {
  284. value: attr.activeIndex,
  285. method: function(value) {
  286. this.set('activeTab', this.getTab(value));
  287. },
  288. validator: function(value) {
  289. return !this.getTab(value).get('disabled'); // cannot activate if disabled
  290. }
  291. });
  292. /**
  293. * The tab currently active.
  294. * @attribute activeTab
  295. * @type YAHOO.widget.Tab
  296. */
  297. this.setAttributeConfig('activeTab', {
  298. value: attr.activeTab,
  299. method: function(tab) {
  300. var activeTab = this.get('activeTab');
  301. if (tab) {
  302. tab.set('active', true);
  303. this._configs['activeIndex'].value = this.getTabIndex(tab); // keep in sync
  304. }
  305. if (activeTab && activeTab != tab) {
  306. activeTab.set('active', false);
  307. }
  308. if (activeTab && tab != activeTab) { // no transition if only 1
  309. this.contentTransition(tab, activeTab);
  310. } else if (tab) {
  311. tab.set('contentVisible', true);
  312. }
  313. },
  314. validator: function(value) {
  315. return !value.get('disabled'); // cannot activate if disabled
  316. }
  317. });
  318. YAHOO.log('attributes initialized', 'info', 'TabView');
  319. if ( this._tabParent ) {
  320. _initTabs.call(this);
  321. }
  322. // Due to delegation we add all DOM_EVENTS to the TabView container
  323. // but IE will leak when unsupported events are added, so remove these
  324. this.DOM_EVENTS.submit = false;
  325. this.DOM_EVENTS.focus = false;
  326. this.DOM_EVENTS.blur = false;
  327. for (var type in this.DOM_EVENTS) {
  328. if ( YAHOO.lang.hasOwnProperty(this.DOM_EVENTS, type) ) {
  329. this.addListener.call(this, type, this.DOMEventHandler);
  330. }
  331. }
  332. };
  333. /**
  334. * Creates Tab instances from a collection of HTMLElements.
  335. * @method initTabs
  336. * @private
  337. * @return void
  338. */
  339. var _initTabs = function() {
  340. var tab,
  341. attr,
  342. contentEl;
  343. var el = this.get('element');
  344. var tabs = _getChildNodes(this._tabParent);
  345. var contentElements = _getChildNodes(this._contentParent);
  346. for (var i = 0, len = tabs.length; i < len; ++i) {
  347. attr = {};
  348. if (contentElements[i]) {
  349. attr.contentEl = contentElements[i];
  350. }
  351. tab = new YAHOO.widget.Tab(tabs[i], attr);
  352. this.addTab(tab);
  353. if (tab.hasClass(tab.ACTIVE_CLASSNAME) ) {
  354. this._configs.activeTab.value = tab; // dont invoke method
  355. this._configs.activeIndex.value = this.getTabIndex(tab);
  356. }
  357. }
  358. };
  359. var _createTabViewElement = function(attr) {
  360. var el = document.createElement('div');
  361. if ( this.CLASSNAME ) {
  362. el.className = this.CLASSNAME;
  363. }
  364. YAHOO.log('TabView Dom created', 'info', 'TabView');
  365. return el;
  366. };
  367. var _createTabParent = function(attr) {
  368. var el = document.createElement('ul');
  369. if ( this.TAB_PARENT_CLASSNAME ) {
  370. el.className = this.TAB_PARENT_CLASSNAME;
  371. }
  372. this.get('element').appendChild(el);
  373. return el;
  374. };
  375. var _createContentParent = function(attr) {
  376. var el = document.createElement('div');
  377. if ( this.CONTENT_PARENT_CLASSNAME ) {
  378. el.className = this.CONTENT_PARENT_CLASSNAME;
  379. }
  380. this.get('element').appendChild(el);
  381. return el;
  382. };
  383. var _getChildNodes = function(el) {
  384. var nodes = [];
  385. var childNodes = el.childNodes;
  386. for (var i = 0, len = childNodes.length; i < len; ++i) {
  387. if (childNodes[i].nodeType == 1) {
  388. nodes[nodes.length] = childNodes[i];
  389. }
  390. }
  391. return nodes;
  392. };
  393. })();
  394. (function() {
  395. var Dom = YAHOO.util.Dom,
  396. Event = YAHOO.util.Event;
  397. /**
  398. * A representation of a Tab's label and content.
  399. * @namespace YAHOO.widget
  400. * @class Tab
  401. * @extends YAHOO.util.Element
  402. * @constructor
  403. * @param element {HTMLElement | String} (optional) The html element that
  404. * represents the TabView. An element will be created if none provided.
  405. * @param {Object} properties A key map of initial properties
  406. */
  407. var Tab = function(el, attr) {
  408. attr = attr || {};
  409. if (arguments.length == 1 && !YAHOO.lang.isString(el) && !el.nodeName) {
  410. attr = el;
  411. el = attr.element;
  412. }
  413. if (!el && !attr.element) {
  414. el = _createTabElement.call(this, attr);
  415. }
  416. this.loadHandler = {
  417. success: function(o) {
  418. this.set('content', o.responseText);
  419. },
  420. failure: function(o) {
  421. }
  422. };
  423. Tab.superclass.constructor.call(this, el, attr);
  424. this.DOM_EVENTS = {}; // delegating to tabView
  425. };
  426. YAHOO.extend(Tab, YAHOO.util.Element);
  427. var proto = Tab.prototype;
  428. /**
  429. * The default tag name for a Tab's inner element.
  430. * @property LABEL_INNER_TAGNAME
  431. * @type String
  432. * @default "em"
  433. */
  434. proto.LABEL_TAGNAME = 'em';
  435. /**
  436. * The class name applied to active tabs.
  437. * @property ACTIVE_CLASSNAME
  438. * @type String
  439. * @default "selected"
  440. */
  441. proto.ACTIVE_CLASSNAME = 'selected';
  442. /**
  443. * The title applied to active tabs.
  444. * @property ACTIVE_TITLE
  445. * @type String
  446. * @default "active"
  447. */
  448. proto.ACTIVE_TITLE = 'active';
  449. /**
  450. * The class name applied to disabled tabs.
  451. * @property DISABLED_CLASSNAME
  452. * @type String
  453. * @default "disabled"
  454. */
  455. proto.DISABLED_CLASSNAME = 'disabled';
  456. /**
  457. * The class name applied to dynamic tabs while loading.
  458. * @property LOADING_CLASSNAME
  459. * @type String
  460. * @default "disabled"
  461. */
  462. proto.LOADING_CLASSNAME = 'loading';
  463. /**
  464. * Provides a reference to the connection request object when data is
  465. * loaded dynamically.
  466. * @property dataConnection
  467. * @type Object
  468. */
  469. proto.dataConnection = null;
  470. /**
  471. * Object containing success and failure callbacks for loading data.
  472. * @property loadHandler
  473. * @type object
  474. */
  475. proto.loadHandler = null;
  476. proto._loading = false;
  477. /**
  478. * Provides a readable name for the tab.
  479. * @method toString
  480. * @return String
  481. */
  482. proto.toString = function() {
  483. var el = this.get('element');
  484. var id = el.id || el.tagName;
  485. return "Tab " + id;
  486. };
  487. /**
  488. * setAttributeConfigs TabView specific properties.
  489. * @method initAttributes
  490. * @param {Object} attr Hash of initial attributes
  491. */
  492. proto.initAttributes = function(attr) {
  493. attr = attr || {};
  494. Tab.superclass.initAttributes.call(this, attr);
  495. var el = this.get('element');
  496. /**
  497. * The event that triggers the tab's activation.
  498. * @attribute activationEvent
  499. * @type String
  500. */
  501. this.setAttributeConfig('activationEvent', {
  502. value: attr.activationEvent || 'click'
  503. });
  504. /**
  505. * The element that contains the tab's label.
  506. * @attribute labelEl
  507. * @type HTMLElement
  508. */
  509. this.setAttributeConfig('labelEl', {
  510. value: attr.labelEl || _getlabelEl.call(this),
  511. method: function(value) {
  512. var current = this.get('labelEl');
  513. if (current) {
  514. if (current == value) {
  515. return false; // already set
  516. }
  517. this.replaceChild(value, current);
  518. } else if (el.firstChild) { // ensure label is firstChild by default
  519. this.insertBefore(value, el.firstChild);
  520. } else {
  521. this.appendChild(value);
  522. }
  523. }
  524. });
  525. /**
  526. * The tab's label text (or innerHTML).
  527. * @attribute label
  528. * @type String
  529. */
  530. this.setAttributeConfig('label', {
  531. value: attr.label || _getLabel.call(this),
  532. method: function(value) {
  533. var labelEl = this.get('labelEl');
  534. if (!labelEl) { // create if needed
  535. this.set('labelEl', _createlabelEl.call(this));
  536. }
  537. _setLabel.call(this, value);
  538. }
  539. });
  540. /**
  541. * The HTMLElement that contains the tab's content.
  542. * @attribute contentEl
  543. * @type HTMLElement
  544. */
  545. this.setAttributeConfig('contentEl', {
  546. value: attr.contentEl || document.createElement('div'),
  547. method: function(value) {
  548. var current = this.get('contentEl');
  549. if (current) {
  550. if (current == value) {
  551. return false; // already set
  552. }
  553. this.replaceChild(value, current);
  554. }
  555. }
  556. });
  557. /**
  558. * The tab's content.
  559. * @attribute content
  560. * @type String
  561. */
  562. this.setAttributeConfig('content', {
  563. value: attr.content,
  564. method: function(value) {
  565. this.get('contentEl').innerHTML = value;
  566. }
  567. });
  568. var _dataLoaded = false;
  569. /**
  570. * The tab's data source, used for loading content dynamically.
  571. * @attribute dataSrc
  572. * @type String
  573. */
  574. this.setAttributeConfig('dataSrc', {
  575. value: attr.dataSrc
  576. });
  577. /**
  578. * Whether or not content should be reloaded for every view.
  579. * @attribute cacheData
  580. * @type Boolean
  581. * @default false
  582. */
  583. this.setAttributeConfig('cacheData', {
  584. value: attr.cacheData || false,
  585. validator: YAHOO.lang.isBoolean
  586. });
  587. /**
  588. * The method to use for the data request.
  589. * @attribute loadMethod
  590. * @type String
  591. * @default "GET"
  592. */
  593. this.setAttributeConfig('loadMethod', {
  594. value: attr.loadMethod || 'GET',
  595. validator: YAHOO.lang.isString
  596. });
  597. /**
  598. * Whether or not any data has been loaded from the server.
  599. * @attribute dataLoaded
  600. * @type Boolean
  601. */
  602. this.setAttributeConfig('dataLoaded', {
  603. value: false,
  604. validator: YAHOO.lang.isBoolean,
  605. writeOnce: true
  606. });
  607. /**
  608. * Number if milliseconds before aborting and calling failure handler.
  609. * @attribute dataTimeout
  610. * @type Number
  611. * @default null
  612. */
  613. this.setAttributeConfig('dataTimeout', {
  614. value: attr.dataTimeout || null,
  615. validator: YAHOO.lang.isNumber
  616. });
  617. /**
  618. * Whether or not the tab is currently active.
  619. * If a dataSrc is set for the tab, the content will be loaded from
  620. * the given source.
  621. * @attribute active
  622. * @type Boolean
  623. */
  624. this.setAttributeConfig('active', {
  625. value: attr.active || this.hasClass(this.ACTIVE_CLASSNAME),
  626. method: function(value) {
  627. if (value === true) {
  628. this.addClass(this.ACTIVE_CLASSNAME);
  629. this.set('title', this.ACTIVE_TITLE);
  630. } else {
  631. this.removeClass(this.ACTIVE_CLASSNAME);
  632. this.set('title', '');
  633. }
  634. },
  635. validator: function(value) {
  636. return YAHOO.lang.isBoolean(value) && !this.get('disabled') ;
  637. }
  638. });
  639. /**
  640. * Whether or not the tab is disabled.
  641. * @attribute disabled
  642. * @type Boolean
  643. */
  644. this.setAttributeConfig('disabled', {
  645. value: attr.disabled || this.hasClass(this.DISABLED_CLASSNAME),
  646. method: function(value) {
  647. if (value === true) {
  648. Dom.addClass(this.get('element'), this.DISABLED_CLASSNAME);
  649. } else {
  650. Dom.removeClass(this.get('element'), this.DISABLED_CLASSNAME);
  651. }
  652. },
  653. validator: YAHOO.lang.isBoolean
  654. });
  655. /**
  656. * The href of the tab's anchor element.
  657. * @attribute href
  658. * @type String
  659. * @default '#'
  660. */
  661. this.setAttributeConfig('href', {
  662. value: attr.href ||
  663. this.getElementsByTagName('a')[0].getAttribute('href', 2) || '#',
  664. method: function(value) {
  665. this.getElementsByTagName('a')[0].href = value;
  666. },
  667. validator: YAHOO.lang.isString
  668. });
  669. /**
  670. * The Whether or not the tab's content is visible.
  671. * @attribute contentVisible
  672. * @type Boolean
  673. * @default false
  674. */
  675. this.setAttributeConfig('contentVisible', {
  676. value: attr.contentVisible,
  677. method: function(value) {
  678. if (value) {
  679. this.get('contentEl').style.display = 'block';
  680. if ( this.get('dataSrc') ) {
  681. // load dynamic content unless already loading or loaded and caching
  682. if ( !this._loading && !(this.get('dataLoaded') && this.get('cacheData')) ) {
  683. _dataConnect.call(this);
  684. }
  685. }
  686. } else {
  687. this.get('contentEl').style.display = 'none';
  688. }
  689. },
  690. validator: YAHOO.lang.isBoolean
  691. });
  692. YAHOO.log('attributes initialized', 'info', 'Tab');
  693. };
  694. var _createTabElement = function(attr) {
  695. var el = document.createElement('li');
  696. var a = document.createElement('a');
  697. a.href = attr.href || '#';
  698. el.appendChild(a);
  699. var label = attr.label || null;
  700. var labelEl = attr.labelEl || null;
  701. if (labelEl) { // user supplied labelEl
  702. if (!label) { // user supplied label
  703. label = _getLabel.call(this, labelEl);
  704. }
  705. } else {
  706. labelEl = _createlabelEl.call(this);
  707. }
  708. a.appendChild(labelEl);
  709. YAHOO.log('creating Tab Dom', 'info', 'Tab');
  710. return el;
  711. };
  712. var _getlabelEl = function() {
  713. return this.getElementsByTagName(this.LABEL_TAGNAME)[0];
  714. };
  715. var _createlabelEl = function() {
  716. var el = document.createElement(this.LABEL_TAGNAME);
  717. return el;
  718. };
  719. var _setLabel = function(label) {
  720. var el = this.get('labelEl');
  721. el.innerHTML = label;
  722. };
  723. var _getLabel = function() {
  724. var label,
  725. el = this.get('labelEl');
  726. if (!el) {
  727. return undefined;
  728. }
  729. return el.innerHTML;
  730. };
  731. var _dataConnect = function() {
  732. if (!YAHOO.util.Connect) {
  733. YAHOO.log('YAHOO.util.Connect dependency not met',
  734. 'error', 'Tab');
  735. return false;
  736. }
  737. Dom.addClass(this.get('contentEl').parentNode, this.LOADING_CLASSNAME);
  738. this._loading = true;
  739. this.dataConnection = YAHOO.util.Connect.asyncRequest(
  740. this.get('loadMethod'),
  741. this.get('dataSrc'),
  742. {
  743. success: function(o) {
  744. YAHOO.log('content loaded successfully', 'info', 'Tab');
  745. this.loadHandler.success.call(this, o);
  746. this.set('dataLoaded', true);
  747. this.dataConnection = null;
  748. Dom.removeClass(this.get('contentEl').parentNode,
  749. this.LOADING_CLASSNAME);
  750. this._loading = false;
  751. },
  752. failure: function(o) {
  753. YAHOO.log('loading failed: ' + o.statusText, 'error', 'Tab');
  754. this.loadHandler.failure.call(this, o);
  755. this.dataConnection = null;
  756. Dom.removeClass(this.get('contentEl').parentNode,
  757. this.LOADING_CLASSNAME);
  758. this._loading = false;
  759. },
  760. scope: this,
  761. timeout: this.get('dataTimeout')
  762. }
  763. );
  764. };
  765. YAHOO.widget.Tab = Tab;
  766. })();
  767. YAHOO.register("tabview", YAHOO.widget.TabView, {version: "2.5.1", build: "984"});