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
48 KiB

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