You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1148 lines
41 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. /**
  16. * @class Ext.TabPanel
  17. * <p>A basic tab container. TabPanels can be used exactly like a standard {@link Ext.Panel}
  18. * for layout purposes, but also have special support for containing child Components
  19. * (<tt>{@link Ext.Container#items items}</tt>) that are managed using a
  20. * {@link Ext.layout.CardLayout CardLayout layout manager}, and displayed as separate tabs.</p>
  21. *
  22. * <b>Note:</b> By default, a tab's close tool <i>destroys</i> the child tab Component
  23. * and all its descendants. This makes the child tab Component, and all its descendants <b>unusable</b>. To enable
  24. * re-use of a tab, configure the TabPanel with <b><code>{@link #autoDestroy autoDestroy: false}</code></b>.
  25. *
  26. * <p><b><u>TabPanel header/footer elements</u></b></p>
  27. * <p>TabPanels use their {@link Ext.Panel#header header} or {@link Ext.Panel#footer footer} element
  28. * (depending on the {@link #tabPosition} configuration) to accommodate the tab selector buttons.
  29. * This means that a TabPanel will not display any configured title, and will not display any
  30. * configured header {@link Ext.Panel#tools tools}.</p>
  31. * <p>To display a header, embed the TabPanel in a {@link Ext.Panel Panel} which uses
  32. * <b><tt>{@link Ext.Container#layout layout:'fit'}</tt></b>.</p>
  33. *
  34. * <p><b><u>Tab Events</u></b></p>
  35. * <p>There is no actual tab class &mdash; each tab is simply a {@link Ext.BoxComponent Component}
  36. * such as a {@link Ext.Panel Panel}. However, when rendered in a TabPanel, each child Component
  37. * can fire additional events that only exist for tabs and are not available from other Components.
  38. * These events are:</p>
  39. * <div><ul class="mdetail-params">
  40. * <li><tt><b>{@link Ext.Panel#activate activate}</b></tt> : Fires when this Component becomes
  41. * the active tab.</li>
  42. * <li><tt><b>{@link Ext.Panel#deactivate deactivate}</b></tt> : Fires when the Component that
  43. * was the active tab becomes deactivated.</li>
  44. * <li><tt><b>{@link Ext.Panel#beforeclose beforeclose}</b></tt> : Fires when the user clicks on the close tool of a closeable tab.
  45. * May be vetoed by returning <code>false</code> from a handler.</li>
  46. * <li><tt><b>{@link Ext.Panel#close close}</b></tt> : Fires a closeable tab has been closed by the user.</li>
  47. * </ul></div>
  48. * <p><b><u>Creating TabPanels from Code</u></b></p>
  49. * <p>TabPanels can be created and rendered completely in code, as in this example:</p>
  50. * <pre><code>
  51. var tabs = new Ext.TabPanel({
  52. renderTo: Ext.getBody(),
  53. activeTab: 0,
  54. items: [{
  55. title: 'Tab 1',
  56. html: 'A simple tab'
  57. },{
  58. title: 'Tab 2',
  59. html: 'Another one'
  60. }]
  61. });
  62. </code></pre>
  63. * <p><b><u>Creating TabPanels from Existing Markup</u></b></p>
  64. * <p>TabPanels can also be rendered from pre-existing markup in a couple of ways.</p>
  65. * <div><ul class="mdetail-params">
  66. *
  67. * <li>Pre-Structured Markup</li>
  68. * <div class="sub-desc">
  69. * <p>A container div with one or more nested tab divs with class <tt>'x-tab'</tt> can be rendered entirely
  70. * from existing markup (See the {@link #autoTabs} example).</p>
  71. * </div>
  72. *
  73. * <li>Un-Structured Markup</li>
  74. * <div class="sub-desc">
  75. * <p>A TabPanel can also be rendered from markup that is not strictly structured by simply specifying by id
  76. * which elements should be the container and the tabs. Using this method tab content can be pulled from different
  77. * elements within the page by id regardless of page structure. For example:</p>
  78. * <pre><code>
  79. var tabs = new Ext.TabPanel({
  80. renderTo: 'my-tabs',
  81. activeTab: 0,
  82. items:[
  83. {contentEl:'tab1', title:'Tab 1'},
  84. {contentEl:'tab2', title:'Tab 2'}
  85. ]
  86. });
  87. // Note that the tabs do not have to be nested within the container (although they can be)
  88. &lt;div id="my-tabs">&lt;/div>
  89. &lt;div id="tab1" class="x-hide-display">A simple tab&lt;/div>
  90. &lt;div id="tab2" class="x-hide-display">Another one&lt;/div>
  91. </code></pre>
  92. * Note that the tab divs in this example contain the class <tt>'x-hide-display'</tt> so that they can be rendered
  93. * deferred without displaying outside the tabs. You could alternately set <tt>{@link #deferredRender} = false </tt>
  94. * to render all content tabs on page load.
  95. * </div>
  96. *
  97. * </ul></div>
  98. *
  99. * @extends Ext.Panel
  100. * @constructor
  101. * @param {Object} config The configuration options
  102. * @xtype tabpanel
  103. */
  104. Ext.TabPanel = Ext.extend(Ext.Panel, {
  105. /**
  106. * @cfg {Boolean} layoutOnTabChange
  107. * Set to true to force a layout of the active tab when the tab is changed. Defaults to false.
  108. * See {@link Ext.layout.CardLayout}.<code>{@link Ext.layout.CardLayout#layoutOnCardChange layoutOnCardChange}</code>.
  109. */
  110. /**
  111. * @cfg {String} tabCls <b>This config option is used on <u>child Components</u> of ths TabPanel.</b> A CSS
  112. * class name applied to the tab strip item representing the child Component, allowing special
  113. * styling to be applied.
  114. */
  115. /**
  116. * @cfg {Boolean} deferredRender
  117. * <p><tt>true</tt> by default to defer the rendering of child <tt>{@link Ext.Container#items items}</tt>
  118. * to the browsers DOM until a tab is activated. <tt>false</tt> will render all contained
  119. * <tt>{@link Ext.Container#items items}</tt> as soon as the {@link Ext.layout.CardLayout layout}
  120. * is rendered. If there is a significant amount of content or a lot of heavy controls being
  121. * rendered into panels that are not displayed by default, setting this to <tt>true</tt> might
  122. * improve performance.</p>
  123. * <br><p>The <tt>deferredRender</tt> property is internally passed to the layout manager for
  124. * TabPanels ({@link Ext.layout.CardLayout}) as its {@link Ext.layout.CardLayout#deferredRender}
  125. * configuration value.</p>
  126. * <br><p><b>Note</b>: leaving <tt>deferredRender</tt> as <tt>true</tt> means that the content
  127. * within an unactivated tab will not be available. For example, this means that if the TabPanel
  128. * is within a {@link Ext.form.FormPanel form}, then until a tab is activated, any Fields within
  129. * unactivated tabs will not be rendered, and will therefore not be submitted and will not be
  130. * available to either {@link Ext.form.BasicForm#getValues getValues} or
  131. * {@link Ext.form.BasicForm#setValues setValues}.</p>
  132. */
  133. deferredRender : true,
  134. /**
  135. * @cfg {Number} tabWidth The initial width in pixels of each new tab (defaults to 120).
  136. */
  137. tabWidth : 120,
  138. /**
  139. * @cfg {Number} minTabWidth The minimum width in pixels for each tab when {@link #resizeTabs} = true (defaults to 30).
  140. */
  141. minTabWidth : 30,
  142. /**
  143. * @cfg {Boolean} resizeTabs True to automatically resize each tab so that the tabs will completely fill the
  144. * tab strip (defaults to false). Setting this to true may cause specific widths that might be set per tab to
  145. * be overridden in order to fit them all into view (although {@link #minTabWidth} will always be honored).
  146. */
  147. resizeTabs : false,
  148. /**
  149. * @cfg {Boolean} enableTabScroll True to enable scrolling to tabs that may be invisible due to overflowing the
  150. * overall TabPanel width. Only available with tabPosition:'top' (defaults to false).
  151. */
  152. enableTabScroll : false,
  153. /**
  154. * @cfg {Number} scrollIncrement The number of pixels to scroll each time a tab scroll button is pressed
  155. * (defaults to <tt>100</tt>, or if <tt>{@link #resizeTabs} = true</tt>, the calculated tab width). Only
  156. * applies when <tt>{@link #enableTabScroll} = true</tt>.
  157. */
  158. scrollIncrement : 0,
  159. /**
  160. * @cfg {Number} scrollRepeatInterval Number of milliseconds between each scroll while a tab scroll button is
  161. * continuously pressed (defaults to <tt>400</tt>).
  162. */
  163. scrollRepeatInterval : 400,
  164. /**
  165. * @cfg {Float} scrollDuration The number of milliseconds that each scroll animation should last (defaults
  166. * to <tt>.35</tt>). Only applies when <tt>{@link #animScroll} = true</tt>.
  167. */
  168. scrollDuration : 0.35,
  169. /**
  170. * @cfg {Boolean} animScroll True to animate tab scrolling so that hidden tabs slide smoothly into view (defaults
  171. * to <tt>true</tt>). Only applies when <tt>{@link #enableTabScroll} = true</tt>.
  172. */
  173. animScroll : true,
  174. /**
  175. * @cfg {String} tabPosition The position where the tab strip should be rendered (defaults to <tt>'top'</tt>).
  176. * The only other supported value is <tt>'bottom'</tt>. <b>Note</b>: tab scrolling is only supported for
  177. * <tt>tabPosition: 'top'</tt>.
  178. */
  179. tabPosition : 'top',
  180. /**
  181. * @cfg {String} baseCls The base CSS class applied to the panel (defaults to <tt>'x-tab-panel'</tt>).
  182. */
  183. baseCls : 'x-tab-panel',
  184. /**
  185. * @cfg {Boolean} autoTabs
  186. * <p><tt>true</tt> to query the DOM for any divs with a class of 'x-tab' to be automatically converted
  187. * to tabs and added to this panel (defaults to <tt>false</tt>). Note that the query will be executed within
  188. * the scope of the container element only (so that multiple tab panels from markup can be supported via this
  189. * method).</p>
  190. * <p>This method is only possible when the markup is structured correctly as a container with nested divs
  191. * containing the class <tt>'x-tab'</tt>. To create TabPanels without these limitations, or to pull tab content
  192. * from other elements on the page, see the example at the top of the class for generating tabs from markup.</p>
  193. * <p>There are a couple of things to note when using this method:<ul>
  194. * <li>When using the <tt>autoTabs</tt> config (as opposed to passing individual tab configs in the TabPanel's
  195. * {@link #items} collection), you must use <tt>{@link #applyTo}</tt> to correctly use the specified <tt>id</tt>
  196. * as the tab container. The <tt>autoTabs</tt> method <em>replaces</em> existing content with the TabPanel
  197. * components.</li>
  198. * <li>Make sure that you set <tt>{@link #deferredRender}: false</tt> so that the content elements for each
  199. * tab will be rendered into the TabPanel immediately upon page load, otherwise they will not be transformed
  200. * until each tab is activated and will be visible outside the TabPanel.</li>
  201. * </ul>Example usage:</p>
  202. * <pre><code>
  203. var tabs = new Ext.TabPanel({
  204. applyTo: 'my-tabs',
  205. activeTab: 0,
  206. deferredRender: false,
  207. autoTabs: true
  208. });
  209. // This markup will be converted to a TabPanel from the code above
  210. &lt;div id="my-tabs">
  211. &lt;div class="x-tab" title="Tab 1">A simple tab&lt;/div>
  212. &lt;div class="x-tab" title="Tab 2">Another one&lt;/div>
  213. &lt;/div>
  214. </code></pre>
  215. */
  216. autoTabs : false,
  217. /**
  218. * @cfg {String} autoTabSelector The CSS selector used to search for tabs in existing markup when
  219. * <tt>{@link #autoTabs} = true</tt> (defaults to <tt>'div.x-tab'</tt>). This can be any valid selector
  220. * supported by {@link Ext.DomQuery#select}. Note that the query will be executed within the scope of this
  221. * tab panel only (so that multiple tab panels from markup can be supported on a page).
  222. */
  223. autoTabSelector : 'div.x-tab',
  224. /**
  225. * @cfg {String/Number} activeTab A string id or the numeric index of the tab that should be initially
  226. * activated on render (defaults to undefined).
  227. */
  228. activeTab : undefined,
  229. /**
  230. * @cfg {Number} tabMargin The number of pixels of space to calculate into the sizing and scrolling of
  231. * tabs. If you change the margin in CSS, you will need to update this value so calculations are correct
  232. * with either <tt>{@link #resizeTabs}</tt> or scrolling tabs. (defaults to <tt>2</tt>)
  233. */
  234. tabMargin : 2,
  235. /**
  236. * @cfg {Boolean} plain </tt>true</tt> to render the tab strip without a background container image
  237. * (defaults to <tt>false</tt>).
  238. */
  239. plain : false,
  240. /**
  241. * @cfg {Number} wheelIncrement For scrolling tabs, the number of pixels to increment on mouse wheel
  242. * scrolling (defaults to <tt>20</tt>).
  243. */
  244. wheelIncrement : 20,
  245. /*
  246. * This is a protected property used when concatenating tab ids to the TabPanel id for internal uniqueness.
  247. * It does not generally need to be changed, but can be if external code also uses an id scheme that can
  248. * potentially clash with this one.
  249. */
  250. idDelimiter : '__',
  251. // private
  252. itemCls : 'x-tab-item',
  253. // private config overrides
  254. elements : 'body',
  255. headerAsText : false,
  256. frame : false,
  257. hideBorders :true,
  258. // private
  259. initComponent : function(){
  260. this.frame = false;
  261. Ext.TabPanel.superclass.initComponent.call(this);
  262. this.addEvents(
  263. /**
  264. * @event beforetabchange
  265. * Fires before the active tab changes. Handlers can <tt>return false</tt> to cancel the tab change.
  266. * @param {TabPanel} this
  267. * @param {Panel} newTab The tab being activated
  268. * @param {Panel} currentTab The current active tab
  269. */
  270. 'beforetabchange',
  271. /**
  272. * @event tabchange
  273. * Fires after the active tab has changed.
  274. * @param {TabPanel} this
  275. * @param {Panel} tab The new active tab
  276. */
  277. 'tabchange',
  278. /**
  279. * @event contextmenu
  280. * Relays the contextmenu event from a tab selector element in the tab strip.
  281. * @param {TabPanel} this
  282. * @param {Panel} tab The target tab
  283. * @param {EventObject} e
  284. */
  285. 'contextmenu'
  286. );
  287. /**
  288. * @cfg {Object} layoutConfig
  289. * TabPanel implicitly uses {@link Ext.layout.CardLayout} as its layout manager.
  290. * <code>layoutConfig</code> may be used to configure this layout manager.
  291. * <code>{@link #deferredRender}</code> and <code>{@link #layoutOnTabChange}</code>
  292. * configured on the TabPanel will be applied as configs to the layout manager.
  293. */
  294. this.setLayout(new Ext.layout.CardLayout(Ext.apply({
  295. layoutOnCardChange: this.layoutOnTabChange,
  296. deferredRender: this.deferredRender
  297. }, this.layoutConfig)));
  298. if(this.tabPosition == 'top'){
  299. this.elements += ',header';
  300. this.stripTarget = 'header';
  301. }else {
  302. this.elements += ',footer';
  303. this.stripTarget = 'footer';
  304. }
  305. if(!this.stack){
  306. this.stack = Ext.TabPanel.AccessStack();
  307. }
  308. this.initItems();
  309. },
  310. // private
  311. onRender : function(ct, position){
  312. Ext.TabPanel.superclass.onRender.call(this, ct, position);
  313. if(this.plain){
  314. var pos = this.tabPosition == 'top' ? 'header' : 'footer';
  315. this[pos].addClass('x-tab-panel-'+pos+'-plain');
  316. }
  317. var st = this[this.stripTarget];
  318. this.stripWrap = st.createChild({cls:'x-tab-strip-wrap', cn:{
  319. tag:'ul', cls:'x-tab-strip x-tab-strip-'+this.tabPosition}});
  320. var beforeEl = (this.tabPosition=='bottom' ? this.stripWrap : null);
  321. st.createChild({cls:'x-tab-strip-spacer'}, beforeEl);
  322. this.strip = new Ext.Element(this.stripWrap.dom.firstChild);
  323. // create an empty span with class x-tab-strip-text to force the height of the header element when there's no tabs.
  324. this.edge = this.strip.createChild({tag:'li', cls:'x-tab-edge', cn: [{tag: 'span', cls: 'x-tab-strip-text', cn: '&#160;'}]});
  325. this.strip.createChild({cls:'x-clear'});
  326. this.body.addClass('x-tab-panel-body-'+this.tabPosition);
  327. /**
  328. * @cfg {Template/XTemplate} itemTpl <p>(Optional) A {@link Ext.Template Template} or
  329. * {@link Ext.XTemplate XTemplate} which may be provided to process the data object returned from
  330. * <tt>{@link #getTemplateArgs}</tt> to produce a clickable selector element in the tab strip.</p>
  331. * <p>The main element created should be a <tt>&lt;li></tt> element. In order for a click event on
  332. * a selector element to be connected to its item, it must take its <i>id</i> from the TabPanel's
  333. * native <tt>{@link #getTemplateArgs}</tt>.</p>
  334. * <p>The child element which contains the title text must be marked by the CSS class
  335. * <tt>x-tab-strip-inner</tt>.</p>
  336. * <p>To enable closability, the created element should contain an element marked by the CSS class
  337. * <tt>x-tab-strip-close</tt>.</p>
  338. * <p>If a custom <tt>itemTpl</tt> is supplied, it is the developer's responsibility to create CSS
  339. * style rules to create the desired appearance.</p>
  340. * Below is an example of how to create customized tab selector items:<pre><code>
  341. new Ext.TabPanel({
  342. renderTo: document.body,
  343. minTabWidth: 115,
  344. tabWidth: 135,
  345. enableTabScroll: true,
  346. width: 600,
  347. height: 250,
  348. defaults: {autoScroll:true},
  349. itemTpl: new Ext.XTemplate(
  350. '&lt;li class="{cls}" id="{id}" style="overflow:hidden">',
  351. '&lt;tpl if="closable">',
  352. '&lt;a class="x-tab-strip-close">&lt;/a>',
  353. '&lt;/tpl>',
  354. '&lt;a class="x-tab-right" href="#" style="padding-left:6px">',
  355. '&lt;em class="x-tab-left">',
  356. '&lt;span class="x-tab-strip-inner">',
  357. '&lt;img src="{src}" style="float:left;margin:3px 3px 0 0">',
  358. '&lt;span style="margin-left:20px" class="x-tab-strip-text {iconCls}">{text} {extra}&lt;/span>',
  359. '&lt;/span>',
  360. '&lt;/em>',
  361. '&lt;/a>',
  362. '&lt;/li>'
  363. ),
  364. getTemplateArgs: function(item) {
  365. // Call the native method to collect the base data. Like the ID!
  366. var result = Ext.TabPanel.prototype.getTemplateArgs.call(this, item);
  367. // Add stuff used in our template
  368. return Ext.apply(result, {
  369. closable: item.closable,
  370. src: item.iconSrc,
  371. extra: item.extraText || ''
  372. });
  373. },
  374. items: [{
  375. title: 'New Tab 1',
  376. iconSrc: '../shared/icons/fam/grid.png',
  377. html: 'Tab Body 1',
  378. closable: true
  379. }, {
  380. title: 'New Tab 2',
  381. iconSrc: '../shared/icons/fam/grid.png',
  382. html: 'Tab Body 2',
  383. extraText: 'Extra stuff in the tab button'
  384. }]
  385. });
  386. </code></pre>
  387. */
  388. if(!this.itemTpl){
  389. var tt = new Ext.Template(
  390. '<li class="{cls}" id="{id}"><a class="x-tab-strip-close"></a>',
  391. '<a class="x-tab-right" href="#"><em class="x-tab-left">',
  392. '<span class="x-tab-strip-inner"><span class="x-tab-strip-text {iconCls}">{text}</span></span>',
  393. '</em></a></li>'
  394. );
  395. tt.disableFormats = true;
  396. tt.compile();
  397. Ext.TabPanel.prototype.itemTpl = tt;
  398. }
  399. this.items.each(this.initTab, this);
  400. },
  401. // private
  402. afterRender : function(){
  403. Ext.TabPanel.superclass.afterRender.call(this);
  404. if(this.autoTabs){
  405. this.readTabs(false);
  406. }
  407. if(this.activeTab !== undefined){
  408. var item = Ext.isObject(this.activeTab) ? this.activeTab : this.items.get(this.activeTab);
  409. delete this.activeTab;
  410. this.setActiveTab(item);
  411. }
  412. },
  413. // private
  414. initEvents : function(){
  415. Ext.TabPanel.superclass.initEvents.call(this);
  416. this.mon(this.strip, {
  417. scope: this,
  418. mousedown: this.onStripMouseDown,
  419. contextmenu: this.onStripContextMenu
  420. });
  421. if(this.enableTabScroll){
  422. this.mon(this.strip, 'mousewheel', this.onWheel, this);
  423. }
  424. },
  425. // private
  426. findTargets : function(e){
  427. var item = null,
  428. itemEl = e.getTarget('li:not(.x-tab-edge)', this.strip);
  429. if(itemEl){
  430. item = this.getComponent(itemEl.id.split(this.idDelimiter)[1]);
  431. if(item.disabled){
  432. return {
  433. close : null,
  434. item : null,
  435. el : null
  436. };
  437. }
  438. }
  439. return {
  440. close : e.getTarget('.x-tab-strip-close', this.strip),
  441. item : item,
  442. el : itemEl
  443. };
  444. },
  445. // private
  446. onStripMouseDown : function(e){
  447. if(e.button !== 0){
  448. return;
  449. }
  450. e.preventDefault();
  451. var t = this.findTargets(e);
  452. if(t.close){
  453. if (t.item.fireEvent('beforeclose', t.item) !== false) {
  454. t.item.fireEvent('close', t.item);
  455. this.remove(t.item);
  456. }
  457. return;
  458. }
  459. if(t.item && t.item != this.activeTab){
  460. this.setActiveTab(t.item);
  461. }
  462. },
  463. // private
  464. onStripContextMenu : function(e){
  465. e.preventDefault();
  466. var t = this.findTargets(e);
  467. if(t.item){
  468. this.fireEvent('contextmenu', this, t.item, e);
  469. }
  470. },
  471. /**
  472. * True to scan the markup in this tab panel for <tt>{@link #autoTabs}</tt> using the
  473. * <tt>{@link #autoTabSelector}</tt>
  474. * @param {Boolean} removeExisting True to remove existing tabs
  475. */
  476. readTabs : function(removeExisting){
  477. if(removeExisting === true){
  478. this.items.each(function(item){
  479. this.remove(item);
  480. }, this);
  481. }
  482. var tabs = this.el.query(this.autoTabSelector);
  483. for(var i = 0, len = tabs.length; i < len; i++){
  484. var tab = tabs[i],
  485. title = tab.getAttribute('title');
  486. tab.removeAttribute('title');
  487. this.add({
  488. title: title,
  489. contentEl: tab
  490. });
  491. }
  492. },
  493. // private
  494. initTab : function(item, index){
  495. var before = this.strip.dom.childNodes[index],
  496. p = this.getTemplateArgs(item),
  497. el = before ?
  498. this.itemTpl.insertBefore(before, p) :
  499. this.itemTpl.append(this.strip, p),
  500. cls = 'x-tab-strip-over',
  501. tabEl = Ext.get(el);
  502. tabEl.hover(function(){
  503. if(!item.disabled){
  504. tabEl.addClass(cls);
  505. }
  506. }, function(){
  507. tabEl.removeClass(cls);
  508. });
  509. if(item.tabTip){
  510. tabEl.child('span.x-tab-strip-text', true).qtip = item.tabTip;
  511. }
  512. item.tabEl = el;
  513. // Route *keyboard triggered* click events to the tab strip mouse handler.
  514. tabEl.select('a').on('click', function(e){
  515. if(!e.getPageX()){
  516. this.onStripMouseDown(e);
  517. }
  518. }, this, {preventDefault: true});
  519. item.on({
  520. scope: this,
  521. disable: this.onItemDisabled,
  522. enable: this.onItemEnabled,
  523. titlechange: this.onItemTitleChanged,
  524. iconchange: this.onItemIconChanged,
  525. beforeshow: this.onBeforeShowItem
  526. });
  527. },
  528. /**
  529. * <p>Provides template arguments for rendering a tab selector item in the tab strip.</p>
  530. * <p>This method returns an object hash containing properties used by the TabPanel's <tt>{@link #itemTpl}</tt>
  531. * to create a formatted, clickable tab selector element. The properties which must be returned
  532. * are:</p><div class="mdetail-params"><ul>
  533. * <li><b>id</b> : String<div class="sub-desc">A unique identifier which links to the item</div></li>
  534. * <li><b>text</b> : String<div class="sub-desc">The text to display</div></li>
  535. * <li><b>cls</b> : String<div class="sub-desc">The CSS class name</div></li>
  536. * <li><b>iconCls</b> : String<div class="sub-desc">A CSS class to provide appearance for an icon.</div></li>
  537. * </ul></div>
  538. * @param {Ext.BoxComponent} item The {@link Ext.BoxComponent BoxComponent} for which to create a selector element in the tab strip.
  539. * @return {Object} An object hash containing the properties required to render the selector element.
  540. */
  541. getTemplateArgs : function(item) {
  542. var cls = item.closable ? 'x-tab-strip-closable' : '';
  543. if(item.disabled){
  544. cls += ' x-item-disabled';
  545. }
  546. if(item.iconCls){
  547. cls += ' x-tab-with-icon';
  548. }
  549. if(item.tabCls){
  550. cls += ' ' + item.tabCls;
  551. }
  552. return {
  553. id: this.id + this.idDelimiter + item.getItemId(),
  554. text: item.title,
  555. cls: cls,
  556. iconCls: item.iconCls || ''
  557. };
  558. },
  559. // private
  560. onAdd : function(c){
  561. Ext.TabPanel.superclass.onAdd.call(this, c);
  562. if(this.rendered){
  563. var items = this.items;
  564. this.initTab(c, items.indexOf(c));
  565. this.delegateUpdates();
  566. }
  567. },
  568. // private
  569. onBeforeAdd : function(item){
  570. var existing = item.events ? (this.items.containsKey(item.getItemId()) ? item : null) : this.items.get(item);
  571. if(existing){
  572. this.setActiveTab(item);
  573. return false;
  574. }
  575. Ext.TabPanel.superclass.onBeforeAdd.apply(this, arguments);
  576. var es = item.elements;
  577. item.elements = es ? es.replace(',header', '') : es;
  578. item.border = (item.border === true);
  579. },
  580. // private
  581. onRemove : function(c){
  582. var te = Ext.get(c.tabEl);
  583. // check if the tabEl exists, it won't if the tab isn't rendered
  584. if(te){
  585. te.select('a').removeAllListeners();
  586. Ext.destroy(te);
  587. }
  588. Ext.TabPanel.superclass.onRemove.call(this, c);
  589. this.stack.remove(c);
  590. delete c.tabEl;
  591. c.un('disable', this.onItemDisabled, this);
  592. c.un('enable', this.onItemEnabled, this);
  593. c.un('titlechange', this.onItemTitleChanged, this);
  594. c.un('iconchange', this.onItemIconChanged, this);
  595. c.un('beforeshow', this.onBeforeShowItem, this);
  596. if(c == this.activeTab){
  597. var next = this.stack.next();
  598. if(next){
  599. this.setActiveTab(next);
  600. }else if(this.items.getCount() > 0){
  601. this.setActiveTab(0);
  602. }else{
  603. this.setActiveTab(null);
  604. }
  605. }
  606. if(!this.destroying){
  607. this.delegateUpdates();
  608. }
  609. },
  610. // private
  611. onBeforeShowItem : function(item){
  612. if(item != this.activeTab){
  613. this.setActiveTab(item);
  614. return false;
  615. }
  616. },
  617. // private
  618. onItemDisabled : function(item){
  619. var el = this.getTabEl(item);
  620. if(el){
  621. Ext.fly(el).addClass('x-item-disabled');
  622. }
  623. this.stack.remove(item);
  624. },
  625. // private
  626. onItemEnabled : function(item){
  627. var el = this.getTabEl(item);
  628. if(el){
  629. Ext.fly(el).removeClass('x-item-disabled');
  630. }
  631. },
  632. // private
  633. onItemTitleChanged : function(item){
  634. var el = this.getTabEl(item);
  635. if(el){
  636. Ext.fly(el).child('span.x-tab-strip-text', true).innerHTML = item.title;
  637. this.delegateUpdates();
  638. }
  639. },
  640. //private
  641. onItemIconChanged : function(item, iconCls, oldCls){
  642. var el = this.getTabEl(item);
  643. if(el){
  644. el = Ext.get(el);
  645. el.child('span.x-tab-strip-text').replaceClass(oldCls, iconCls);
  646. el[Ext.isEmpty(iconCls) ? 'removeClass' : 'addClass']('x-tab-with-icon');
  647. this.delegateUpdates();
  648. }
  649. },
  650. /**
  651. * Gets the DOM element for the tab strip item which activates the child panel with the specified
  652. * ID. Access this to change the visual treatment of the item, for example by changing the CSS class name.
  653. * @param {Panel/Number/String} tab The tab component, or the tab's index, or the tabs id or itemId.
  654. * @return {HTMLElement} The DOM node
  655. */
  656. getTabEl : function(item){
  657. var c = this.getComponent(item);
  658. return c ? c.tabEl : null;
  659. },
  660. // private
  661. onResize : function(){
  662. Ext.TabPanel.superclass.onResize.apply(this, arguments);
  663. this.delegateUpdates();
  664. },
  665. /**
  666. * Suspends any internal calculations or scrolling while doing a bulk operation. See {@link #endUpdate}
  667. */
  668. beginUpdate : function(){
  669. this.suspendUpdates = true;
  670. },
  671. /**
  672. * Resumes calculations and scrolling at the end of a bulk operation. See {@link #beginUpdate}
  673. */
  674. endUpdate : function(){
  675. this.suspendUpdates = false;
  676. this.delegateUpdates();
  677. },
  678. /**
  679. * Hides the tab strip item for the passed tab
  680. * @param {Number/String/Panel} item The tab index, id or item
  681. */
  682. hideTabStripItem : function(item){
  683. item = this.getComponent(item);
  684. var el = this.getTabEl(item);
  685. if(el){
  686. el.style.display = 'none';
  687. this.delegateUpdates();
  688. }
  689. this.stack.remove(item);
  690. },
  691. /**
  692. * Unhides the tab strip item for the passed tab
  693. * @param {Number/String/Panel} item The tab index, id or item
  694. */
  695. unhideTabStripItem : function(item){
  696. item = this.getComponent(item);
  697. var el = this.getTabEl(item);
  698. if(el){
  699. el.style.display = '';
  700. this.delegateUpdates();
  701. }
  702. },
  703. // private
  704. delegateUpdates : function(){
  705. var rendered = this.rendered;
  706. if(this.suspendUpdates){
  707. return;
  708. }
  709. if(this.resizeTabs && rendered){
  710. this.autoSizeTabs();
  711. }
  712. if(this.enableTabScroll && rendered){
  713. this.autoScrollTabs();
  714. }
  715. },
  716. // private
  717. autoSizeTabs : function(){
  718. var count = this.items.length,
  719. ce = this.tabPosition != 'bottom' ? 'header' : 'footer',
  720. ow = this[ce].dom.offsetWidth,
  721. aw = this[ce].dom.clientWidth;
  722. if(!this.resizeTabs || count < 1 || !aw){ // !aw for display:none
  723. return;
  724. }
  725. var each = Math.max(Math.min(Math.floor((aw-4) / count) - this.tabMargin, this.tabWidth), this.minTabWidth); // -4 for float errors in IE
  726. this.lastTabWidth = each;
  727. var lis = this.strip.query('li:not(.x-tab-edge)');
  728. for(var i = 0, len = lis.length; i < len; i++) {
  729. var li = lis[i],
  730. inner = Ext.fly(li).child('.x-tab-strip-inner', true),
  731. tw = li.offsetWidth,
  732. iw = inner.offsetWidth;
  733. inner.style.width = (each - (tw-iw)) + 'px';
  734. }
  735. },
  736. // private
  737. adjustBodyWidth : function(w){
  738. if(this.header){
  739. this.header.setWidth(w);
  740. }
  741. if(this.footer){
  742. this.footer.setWidth(w);
  743. }
  744. return w;
  745. },
  746. /**
  747. * Sets the specified tab as the active tab. This method fires the {@link #beforetabchange} event which
  748. * can <tt>return false</tt> to cancel the tab change.
  749. * @param {String/Number} item
  750. * The id or tab Panel to activate. This parameter may be any of the following:
  751. * <div><ul class="mdetail-params">
  752. * <li>a <b><tt>String</tt></b> : representing the <code>{@link Ext.Component#itemId itemId}</code>
  753. * or <code>{@link Ext.Component#id id}</code> of the child component </li>
  754. * <li>a <b><tt>Number</tt></b> : representing the position of the child component
  755. * within the <code>{@link Ext.Container#items items}</code> <b>property</b></li>
  756. * </ul></div>
  757. * <p>For additional information see {@link Ext.util.MixedCollection#get}.
  758. */
  759. setActiveTab : function(item){
  760. item = this.getComponent(item);
  761. if(this.fireEvent('beforetabchange', this, item, this.activeTab) === false){
  762. return;
  763. }
  764. if(!this.rendered){
  765. this.activeTab = item;
  766. return;
  767. }
  768. if(this.activeTab != item){
  769. if(this.activeTab){
  770. var oldEl = this.getTabEl(this.activeTab);
  771. if(oldEl){
  772. Ext.fly(oldEl).removeClass('x-tab-strip-active');
  773. }
  774. }
  775. this.activeTab = item;
  776. if(item){
  777. var el = this.getTabEl(item);
  778. Ext.fly(el).addClass('x-tab-strip-active');
  779. this.stack.add(item);
  780. this.layout.setActiveItem(item);
  781. // Need to do this here, since setting the active tab slightly changes the size
  782. this.delegateUpdates();
  783. if(this.scrolling){
  784. this.scrollToTab(item, this.animScroll);
  785. }
  786. }
  787. this.fireEvent('tabchange', this, item);
  788. }
  789. },
  790. /**
  791. * Returns the Component which is the currently active tab. <b>Note that before the TabPanel
  792. * first activates a child Component, this method will return whatever was configured in the
  793. * {@link #activeTab} config option.</b>
  794. * @return {BoxComponent} The currently active child Component if one <i>is</i> active, or the {@link #activeTab} config value.
  795. */
  796. getActiveTab : function(){
  797. return this.activeTab || null;
  798. },
  799. /**
  800. * Gets the specified tab by id.
  801. * @param {String} id The tab id
  802. * @return {Panel} The tab
  803. */
  804. getItem : function(item){
  805. return this.getComponent(item);
  806. },
  807. // private
  808. autoScrollTabs : function(){
  809. this.pos = this.tabPosition=='bottom' ? this.footer : this.header;
  810. var count = this.items.length,
  811. ow = this.pos.dom.offsetWidth,
  812. tw = this.pos.dom.clientWidth,
  813. wrap = this.stripWrap,
  814. wd = wrap.dom,
  815. cw = wd.offsetWidth,
  816. pos = this.getScrollPos(),
  817. l = this.edge.getOffsetsTo(this.stripWrap)[0] + pos;
  818. if(!this.enableTabScroll || cw < 20){ // 20 to prevent display:none issues
  819. return;
  820. }
  821. if(count == 0 || l <= tw){
  822. // ensure the width is set if there's no tabs
  823. wd.scrollLeft = 0;
  824. wrap.setWidth(tw);
  825. if(this.scrolling){
  826. this.scrolling = false;
  827. this.pos.removeClass('x-tab-scrolling');
  828. this.scrollLeft.hide();
  829. this.scrollRight.hide();
  830. // See here: http://extjs.com/forum/showthread.php?t=49308&highlight=isSafari
  831. if(Ext.isAir || Ext.isWebKit){
  832. wd.style.marginLeft = '';
  833. wd.style.marginRight = '';
  834. }
  835. }
  836. }else{
  837. if(!this.scrolling){
  838. this.pos.addClass('x-tab-scrolling');
  839. // See here: http://extjs.com/forum/showthread.php?t=49308&highlight=isSafari
  840. if(Ext.isAir || Ext.isWebKit){
  841. wd.style.marginLeft = '18px';
  842. wd.style.marginRight = '18px';
  843. }
  844. }
  845. tw -= wrap.getMargins('lr');
  846. wrap.setWidth(tw > 20 ? tw : 20);
  847. if(!this.scrolling){
  848. if(!this.scrollLeft){
  849. this.createScrollers();
  850. }else{
  851. this.scrollLeft.show();
  852. this.scrollRight.show();
  853. }
  854. }
  855. this.scrolling = true;
  856. if(pos > (l-tw)){ // ensure it stays within bounds
  857. wd.scrollLeft = l-tw;
  858. }else{ // otherwise, make sure the active tab is still visible
  859. this.scrollToTab(this.activeTab, false);
  860. }
  861. this.updateScrollButtons();
  862. }
  863. },
  864. // private
  865. createScrollers : function(){
  866. this.pos.addClass('x-tab-scrolling-' + this.tabPosition);
  867. var h = this.stripWrap.dom.offsetHeight;
  868. // left
  869. var sl = this.pos.insertFirst({
  870. cls:'x-tab-scroller-left'
  871. });
  872. sl.setHeight(h);
  873. sl.addClassOnOver('x-tab-scroller-left-over');
  874. this.leftRepeater = new Ext.util.ClickRepeater(sl, {
  875. interval : this.scrollRepeatInterval,
  876. handler: this.onScrollLeft,
  877. scope: this
  878. });
  879. this.scrollLeft = sl;
  880. // right
  881. var sr = this.pos.insertFirst({
  882. cls:'x-tab-scroller-right'
  883. });
  884. sr.setHeight(h);
  885. sr.addClassOnOver('x-tab-scroller-right-over');
  886. this.rightRepeater = new Ext.util.ClickRepeater(sr, {
  887. interval : this.scrollRepeatInterval,
  888. handler: this.onScrollRight,
  889. scope: this
  890. });
  891. this.scrollRight = sr;
  892. },
  893. // private
  894. getScrollWidth : function(){
  895. return this.edge.getOffsetsTo(this.stripWrap)[0] + this.getScrollPos();
  896. },
  897. // private
  898. getScrollPos : function(){
  899. return parseInt(this.stripWrap.dom.scrollLeft, 10) || 0;
  900. },
  901. // private
  902. getScrollArea : function(){
  903. return parseInt(this.stripWrap.dom.clientWidth, 10) || 0;
  904. },
  905. // private
  906. getScrollAnim : function(){
  907. return {duration:this.scrollDuration, callback: this.updateScrollButtons, scope: this};
  908. },
  909. // private
  910. getScrollIncrement : function(){
  911. return this.scrollIncrement || (this.resizeTabs ? this.lastTabWidth+2 : 100);
  912. },
  913. /**
  914. * Scrolls to a particular tab if tab scrolling is enabled
  915. * @param {Panel} item The item to scroll to
  916. * @param {Boolean} animate True to enable animations
  917. */
  918. scrollToTab : function(item, animate){
  919. if(!item){
  920. return;
  921. }
  922. var el = this.getTabEl(item),
  923. pos = this.getScrollPos(),
  924. area = this.getScrollArea(),
  925. left = Ext.fly(el).getOffsetsTo(this.stripWrap)[0] + pos,
  926. right = left + el.offsetWidth;
  927. if(left < pos){
  928. this.scrollTo(left, animate);
  929. }else if(right > (pos + area)){
  930. this.scrollTo(right - area, animate);
  931. }
  932. },
  933. // private
  934. scrollTo : function(pos, animate){
  935. this.stripWrap.scrollTo('left', pos, animate ? this.getScrollAnim() : false);
  936. if(!animate){
  937. this.updateScrollButtons();
  938. }
  939. },
  940. onWheel : function(e){
  941. var d = e.getWheelDelta()*this.wheelIncrement*-1;
  942. e.stopEvent();
  943. var pos = this.getScrollPos(),
  944. newpos = pos + d,
  945. sw = this.getScrollWidth()-this.getScrollArea();
  946. var s = Math.max(0, Math.min(sw, newpos));
  947. if(s != pos){
  948. this.scrollTo(s, false);
  949. }
  950. },
  951. // private
  952. onScrollRight : function(){
  953. var sw = this.getScrollWidth()-this.getScrollArea(),
  954. pos = this.getScrollPos(),
  955. s = Math.min(sw, pos + this.getScrollIncrement());
  956. if(s != pos){
  957. this.scrollTo(s, this.animScroll);
  958. }
  959. },
  960. // private
  961. onScrollLeft : function(){
  962. var pos = this.getScrollPos(),
  963. s = Math.max(0, pos - this.getScrollIncrement());
  964. if(s != pos){
  965. this.scrollTo(s, this.animScroll);
  966. }
  967. },
  968. // private
  969. updateScrollButtons : function(){
  970. var pos = this.getScrollPos();
  971. this.scrollLeft[pos === 0 ? 'addClass' : 'removeClass']('x-tab-scroller-left-disabled');
  972. this.scrollRight[pos >= (this.getScrollWidth()-this.getScrollArea()) ? 'addClass' : 'removeClass']('x-tab-scroller-right-disabled');
  973. },
  974. // private
  975. beforeDestroy : function() {
  976. Ext.destroy(this.leftRepeater, this.rightRepeater);
  977. this.deleteMembers('strip', 'edge', 'scrollLeft', 'scrollRight', 'stripWrap');
  978. this.activeTab = null;
  979. Ext.TabPanel.superclass.beforeDestroy.apply(this);
  980. }
  981. /**
  982. * @cfg {Boolean} collapsible
  983. * @hide
  984. */
  985. /**
  986. * @cfg {String} header
  987. * @hide
  988. */
  989. /**
  990. * @cfg {Boolean} headerAsText
  991. * @hide
  992. */
  993. /**
  994. * @property header
  995. * @hide
  996. */
  997. /**
  998. * @cfg title
  999. * @hide
  1000. */
  1001. /**
  1002. * @cfg {Array} tools
  1003. * @hide
  1004. */
  1005. /**
  1006. * @cfg {Array} toolTemplate
  1007. * @hide
  1008. */
  1009. /**
  1010. * @cfg {Boolean} hideCollapseTool
  1011. * @hide
  1012. */
  1013. /**
  1014. * @cfg {Boolean} titleCollapse
  1015. * @hide
  1016. */
  1017. /**
  1018. * @cfg {Boolean} collapsed
  1019. * @hide
  1020. */
  1021. /**
  1022. * @cfg {String} layout
  1023. * @hide
  1024. */
  1025. /**
  1026. * @cfg {Boolean} preventBodyReset
  1027. * @hide
  1028. */
  1029. });
  1030. Ext.reg('tabpanel', Ext.TabPanel);
  1031. /**
  1032. * See {@link #setActiveTab}. Sets the specified tab as the active tab. This method fires
  1033. * the {@link #beforetabchange} event which can <tt>return false</tt> to cancel the tab change.
  1034. * @param {String/Panel} tab The id or tab Panel to activate
  1035. * @method activate
  1036. */
  1037. Ext.TabPanel.prototype.activate = Ext.TabPanel.prototype.setActiveTab;
  1038. // private utility class used by TabPanel
  1039. Ext.TabPanel.AccessStack = function(){
  1040. var items = [];
  1041. return {
  1042. add : function(item){
  1043. items.push(item);
  1044. if(items.length > 10){
  1045. items.shift();
  1046. }
  1047. },
  1048. remove : function(item){
  1049. var s = [];
  1050. for(var i = 0, len = items.length; i < len; i++) {
  1051. if(items[i] != item){
  1052. s.push(items[i]);
  1053. }
  1054. }
  1055. items = s;
  1056. },
  1057. next : function(){
  1058. return items.pop();
  1059. }
  1060. };
  1061. };