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.

1014 lines
47 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-Container'>/**
  19. </span> * @class Ext.Container
  20. * @extends Ext.BoxComponent
  21. * &lt;p&gt;Base class for any {@link Ext.BoxComponent} that may contain other Components. Containers handle the
  22. * basic behavior of containing items, namely adding, inserting and removing items.&lt;/p&gt;
  23. *
  24. * &lt;p&gt;The most commonly used Container classes are {@link Ext.Panel}, {@link Ext.Window} and {@link Ext.TabPanel}.
  25. * If you do not need the capabilities offered by the aforementioned classes you can create a lightweight
  26. * Container to be encapsulated by an HTML element to your specifications by using the
  27. * &lt;code&gt;&lt;b&gt;{@link Ext.Component#autoEl autoEl}&lt;/b&gt;&lt;/code&gt; config option. This is a useful technique when creating
  28. * embedded {@link Ext.layout.ColumnLayout column} layouts inside {@link Ext.form.FormPanel FormPanels}
  29. * for example.&lt;/p&gt;
  30. *
  31. * &lt;p&gt;The code below illustrates both how to explicitly create a Container, and how to implicitly
  32. * create one using the &lt;b&gt;&lt;code&gt;'container'&lt;/code&gt;&lt;/b&gt; xtype:&lt;pre&gt;&lt;code&gt;
  33. // explicitly create a Container
  34. var embeddedColumns = new Ext.Container({
  35. autoEl: 'div', // This is the default
  36. layout: 'column',
  37. defaults: {
  38. // implicitly create Container by specifying xtype
  39. xtype: 'container',
  40. autoEl: 'div', // This is the default.
  41. layout: 'form',
  42. columnWidth: 0.5,
  43. style: {
  44. padding: '10px'
  45. }
  46. },
  47. // The two items below will be Ext.Containers, each encapsulated by a &amp;lt;DIV&gt; element.
  48. items: [{
  49. items: {
  50. xtype: 'datefield',
  51. name: 'startDate',
  52. fieldLabel: 'Start date'
  53. }
  54. }, {
  55. items: {
  56. xtype: 'datefield',
  57. name: 'endDate',
  58. fieldLabel: 'End date'
  59. }
  60. }]
  61. });&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
  62. *
  63. * &lt;p&gt;&lt;u&gt;&lt;b&gt;Layout&lt;/b&gt;&lt;/u&gt;&lt;/p&gt;
  64. * &lt;p&gt;Container classes delegate the rendering of child Components to a layout
  65. * manager class which must be configured into the Container using the
  66. * &lt;code&gt;&lt;b&gt;{@link #layout}&lt;/b&gt;&lt;/code&gt; configuration property.&lt;/p&gt;
  67. * &lt;p&gt;When either specifying child &lt;code&gt;{@link #items}&lt;/code&gt; of a Container,
  68. * or dynamically {@link #add adding} Components to a Container, remember to
  69. * consider how you wish the Container to arrange those child elements, and
  70. * whether those child elements need to be sized using one of Ext's built-in
  71. * &lt;b&gt;&lt;code&gt;{@link #layout}&lt;/code&gt;&lt;/b&gt; schemes. By default, Containers use the
  72. * {@link Ext.layout.ContainerLayout ContainerLayout} scheme which only
  73. * renders child components, appending them one after the other inside the
  74. * Container, and &lt;b&gt;does not apply any sizing&lt;/b&gt; at all.&lt;/p&gt;
  75. * &lt;p&gt;A common mistake is when a developer neglects to specify a
  76. * &lt;b&gt;&lt;code&gt;{@link #layout}&lt;/code&gt;&lt;/b&gt; (e.g. widgets like GridPanels or
  77. * TreePanels are added to Containers for which no &lt;code&gt;&lt;b&gt;{@link #layout}&lt;/b&gt;&lt;/code&gt;
  78. * has been specified). If a Container is left to use the default
  79. * {@link Ext.layout.ContainerLayout ContainerLayout} scheme, none of its
  80. * child components will be resized, or changed in any way when the Container
  81. * is resized.&lt;/p&gt;
  82. * &lt;p&gt;Certain layout managers allow dynamic addition of child components.
  83. * Those that do include {@link Ext.layout.CardLayout},
  84. * {@link Ext.layout.AnchorLayout}, {@link Ext.layout.FormLayout}, and
  85. * {@link Ext.layout.TableLayout}. For example:&lt;pre&gt;&lt;code&gt;
  86. // Create the GridPanel.
  87. var myNewGrid = new Ext.grid.GridPanel({
  88. store: myStore,
  89. columns: myColumnModel,
  90. title: 'Results', // the title becomes the title of the tab
  91. });
  92. myTabPanel.add(myNewGrid); // {@link Ext.TabPanel} implicitly uses {@link Ext.layout.CardLayout CardLayout}
  93. myTabPanel.{@link Ext.TabPanel#setActiveTab setActiveTab}(myNewGrid);
  94. * &lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
  95. * &lt;p&gt;The example above adds a newly created GridPanel to a TabPanel. Note that
  96. * a TabPanel uses {@link Ext.layout.CardLayout} as its layout manager which
  97. * means all its child items are sized to {@link Ext.layout.FitLayout fit}
  98. * exactly into its client area.
  99. * &lt;p&gt;&lt;b&gt;&lt;u&gt;Overnesting is a common problem&lt;/u&gt;&lt;/b&gt;.
  100. * An example of overnesting occurs when a GridPanel is added to a TabPanel
  101. * by wrapping the GridPanel &lt;i&gt;inside&lt;/i&gt; a wrapping Panel (that has no
  102. * &lt;code&gt;&lt;b&gt;{@link #layout}&lt;/b&gt;&lt;/code&gt; specified) and then add that wrapping Panel
  103. * to the TabPanel. The point to realize is that a GridPanel &lt;b&gt;is&lt;/b&gt; a
  104. * Component which can be added directly to a Container. If the wrapping Panel
  105. * has no &lt;code&gt;&lt;b&gt;{@link #layout}&lt;/b&gt;&lt;/code&gt; configuration, then the overnested
  106. * GridPanel will not be sized as expected.&lt;p&gt;
  107. *
  108. * &lt;p&gt;&lt;u&gt;&lt;b&gt;Adding via remote configuration&lt;/b&gt;&lt;/u&gt;&lt;/p&gt;
  109. *
  110. * &lt;p&gt;A server side script can be used to add Components which are generated dynamically on the server.
  111. * An example of adding a GridPanel to a TabPanel where the GridPanel is generated by the server
  112. * based on certain parameters:
  113. * &lt;/p&gt;&lt;pre&gt;&lt;code&gt;
  114. // execute an Ajax request to invoke server side script:
  115. Ext.Ajax.request({
  116. url: 'gen-invoice-grid.php',
  117. // send additional parameters to instruct server script
  118. params: {
  119. startDate: Ext.getCmp('start-date').getValue(),
  120. endDate: Ext.getCmp('end-date').getValue()
  121. },
  122. // process the response object to add it to the TabPanel:
  123. success: function(xhr) {
  124. var newComponent = eval(xhr.responseText); // see discussion below
  125. myTabPanel.add(newComponent); // add the component to the TabPanel
  126. myTabPanel.setActiveTab(newComponent);
  127. },
  128. failure: function() {
  129. Ext.Msg.alert(&quot;Grid create failed&quot;, &quot;Server communication failure&quot;);
  130. }
  131. });
  132. &lt;/code&gt;&lt;/pre&gt;
  133. * &lt;p&gt;The server script needs to return an executable Javascript statement which, when processed
  134. * using &lt;code&gt;eval()&lt;/code&gt;, will return either a config object with an {@link Ext.Component#xtype xtype},
  135. * or an instantiated Component. The server might return this for example:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;
  136. (function() {
  137. function formatDate(value){
  138. return value ? value.dateFormat('M d, Y') : '';
  139. };
  140. var store = new Ext.data.Store({
  141. url: 'get-invoice-data.php',
  142. baseParams: {
  143. startDate: '01/01/2008',
  144. endDate: '01/31/2008'
  145. },
  146. reader: new Ext.data.JsonReader({
  147. record: 'transaction',
  148. idProperty: 'id',
  149. totalRecords: 'total'
  150. }, [
  151. 'customer',
  152. 'invNo',
  153. {name: 'date', type: 'date', dateFormat: 'm/d/Y'},
  154. {name: 'value', type: 'float'}
  155. ])
  156. });
  157. var grid = new Ext.grid.GridPanel({
  158. title: 'Invoice Report',
  159. bbar: new Ext.PagingToolbar(store),
  160. store: store,
  161. columns: [
  162. {header: &quot;Customer&quot;, width: 250, dataIndex: 'customer', sortable: true},
  163. {header: &quot;Invoice Number&quot;, width: 120, dataIndex: 'invNo', sortable: true},
  164. {header: &quot;Invoice Date&quot;, width: 100, dataIndex: 'date', renderer: formatDate, sortable: true},
  165. {header: &quot;Value&quot;, width: 120, dataIndex: 'value', renderer: 'usMoney', sortable: true}
  166. ],
  167. });
  168. store.load();
  169. return grid; // return instantiated component
  170. })();
  171. &lt;/code&gt;&lt;/pre&gt;
  172. * &lt;p&gt;When the above code fragment is passed through the &lt;code&gt;eval&lt;/code&gt; function in the success handler
  173. * of the Ajax request, the code is executed by the Javascript processor, and the anonymous function
  174. * runs, and returns the instantiated grid component.&lt;/p&gt;
  175. * &lt;p&gt;Note: since the code above is &lt;i&gt;generated&lt;/i&gt; by a server script, the &lt;code&gt;baseParams&lt;/code&gt; for
  176. * the Store, the metadata to allow generation of the Record layout, and the ColumnModel
  177. * can all be generated into the code since these are all known on the server.&lt;/p&gt;
  178. *
  179. * @xtype container
  180. */
  181. Ext.Container = Ext.extend(Ext.BoxComponent, {
  182. <span id='Ext-Container-cfg-monitorResize'> /**
  183. </span> * @cfg {Boolean} monitorResize
  184. * True to automatically monitor window resize events to handle anything that is sensitive to the current size
  185. * of the viewport. This value is typically managed by the chosen &lt;code&gt;{@link #layout}&lt;/code&gt; and should not need
  186. * to be set manually.
  187. */
  188. <span id='Ext-Container-cfg-layout'> /**
  189. </span> * @cfg {String/Object} layout
  190. * &lt;p&gt;&lt;b&gt;*Important&lt;/b&gt;: In order for child items to be correctly sized and
  191. * positioned, typically a layout manager &lt;b&gt;must&lt;/b&gt; be specified through
  192. * the &lt;code&gt;layout&lt;/code&gt; configuration option.&lt;/p&gt;
  193. * &lt;br&gt;&lt;p&gt;The sizing and positioning of child {@link items} is the responsibility of
  194. * the Container's layout manager which creates and manages the type of layout
  195. * you have in mind. For example:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;
  196. new Ext.Window({
  197. width:300, height: 300,
  198. layout: 'fit', // explicitly set layout manager: override the default (layout:'auto')
  199. items: [{
  200. title: 'Panel inside a Window'
  201. }]
  202. }).show();
  203. * &lt;/code&gt;&lt;/pre&gt;
  204. * &lt;p&gt;If the {@link #layout} configuration is not explicitly specified for
  205. * a general purpose container (e.g. Container or Panel) the
  206. * {@link Ext.layout.ContainerLayout default layout manager} will be used
  207. * which does nothing but render child components sequentially into the
  208. * Container (no sizing or positioning will be performed in this situation).
  209. * Some container classes implicitly specify a default layout
  210. * (e.g. FormPanel specifies &lt;code&gt;layout:'form'&lt;/code&gt;). Other specific
  211. * purpose classes internally specify/manage their internal layout (e.g.
  212. * GridPanel, TabPanel, TreePanel, Toolbar, Menu, etc.).&lt;/p&gt;
  213. * &lt;br&gt;&lt;p&gt;&lt;b&gt;&lt;code&gt;layout&lt;/code&gt;&lt;/b&gt; may be specified as either as an Object or
  214. * as a String:&lt;/p&gt;&lt;div&gt;&lt;ul class=&quot;mdetail-params&quot;&gt;
  215. *
  216. * &lt;li&gt;&lt;u&gt;Specify as an Object&lt;/u&gt;&lt;/li&gt;
  217. * &lt;div&gt;&lt;ul class=&quot;mdetail-params&quot;&gt;
  218. * &lt;li&gt;Example usage:&lt;/li&gt;
  219. &lt;pre&gt;&lt;code&gt;
  220. layout: {
  221. type: 'vbox',
  222. padding: '5',
  223. align: 'left'
  224. }
  225. &lt;/code&gt;&lt;/pre&gt;
  226. *
  227. * &lt;li&gt;&lt;code&gt;&lt;b&gt;type&lt;/b&gt;&lt;/code&gt;&lt;/li&gt;
  228. * &lt;br/&gt;&lt;p&gt;The layout type to be used for this container. If not specified,
  229. * a default {@link Ext.layout.ContainerLayout} will be created and used.&lt;/p&gt;
  230. * &lt;br/&gt;&lt;p&gt;Valid layout &lt;code&gt;type&lt;/code&gt; values are:&lt;/p&gt;
  231. * &lt;div class=&quot;sub-desc&quot;&gt;&lt;ul class=&quot;mdetail-params&quot;&gt;
  232. * &lt;li&gt;&lt;code&gt;&lt;b&gt;{@link Ext.layout.AbsoluteLayout absolute}&lt;/b&gt;&lt;/code&gt;&lt;/li&gt;
  233. * &lt;li&gt;&lt;code&gt;&lt;b&gt;{@link Ext.layout.AccordionLayout accordion}&lt;/b&gt;&lt;/code&gt;&lt;/li&gt;
  234. * &lt;li&gt;&lt;code&gt;&lt;b&gt;{@link Ext.layout.AnchorLayout anchor}&lt;/b&gt;&lt;/code&gt;&lt;/li&gt;
  235. * &lt;li&gt;&lt;code&gt;&lt;b&gt;{@link Ext.layout.ContainerLayout auto}&lt;/b&gt;&lt;/code&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;Default&lt;/b&gt;&lt;/li&gt;
  236. * &lt;li&gt;&lt;code&gt;&lt;b&gt;{@link Ext.layout.BorderLayout border}&lt;/b&gt;&lt;/code&gt;&lt;/li&gt;
  237. * &lt;li&gt;&lt;code&gt;&lt;b&gt;{@link Ext.layout.CardLayout card}&lt;/b&gt;&lt;/code&gt;&lt;/li&gt;
  238. * &lt;li&gt;&lt;code&gt;&lt;b&gt;{@link Ext.layout.ColumnLayout column}&lt;/b&gt;&lt;/code&gt;&lt;/li&gt;
  239. * &lt;li&gt;&lt;code&gt;&lt;b&gt;{@link Ext.layout.FitLayout fit}&lt;/b&gt;&lt;/code&gt;&lt;/li&gt;
  240. * &lt;li&gt;&lt;code&gt;&lt;b&gt;{@link Ext.layout.FormLayout form}&lt;/b&gt;&lt;/code&gt;&lt;/li&gt;
  241. * &lt;li&gt;&lt;code&gt;&lt;b&gt;{@link Ext.layout.HBoxLayout hbox}&lt;/b&gt;&lt;/code&gt;&lt;/li&gt;
  242. * &lt;li&gt;&lt;code&gt;&lt;b&gt;{@link Ext.layout.MenuLayout menu}&lt;/b&gt;&lt;/code&gt;&lt;/li&gt;
  243. * &lt;li&gt;&lt;code&gt;&lt;b&gt;{@link Ext.layout.TableLayout table}&lt;/b&gt;&lt;/code&gt;&lt;/li&gt;
  244. * &lt;li&gt;&lt;code&gt;&lt;b&gt;{@link Ext.layout.ToolbarLayout toolbar}&lt;/b&gt;&lt;/code&gt;&lt;/li&gt;
  245. * &lt;li&gt;&lt;code&gt;&lt;b&gt;{@link Ext.layout.VBoxLayout vbox}&lt;/b&gt;&lt;/code&gt;&lt;/li&gt;
  246. * &lt;/ul&gt;&lt;/div&gt;
  247. *
  248. * &lt;li&gt;Layout specific configuration properties&lt;/li&gt;
  249. * &lt;br/&gt;&lt;p&gt;Additional layout specific configuration properties may also be
  250. * specified. For complete details regarding the valid config options for
  251. * each layout type, see the layout class corresponding to the &lt;code&gt;type&lt;/code&gt;
  252. * specified.&lt;/p&gt;
  253. *
  254. * &lt;/ul&gt;&lt;/div&gt;
  255. *
  256. * &lt;li&gt;&lt;u&gt;Specify as a String&lt;/u&gt;&lt;/li&gt;
  257. * &lt;div&gt;&lt;ul class=&quot;mdetail-params&quot;&gt;
  258. * &lt;li&gt;Example usage:&lt;/li&gt;
  259. &lt;pre&gt;&lt;code&gt;
  260. layout: 'vbox',
  261. layoutConfig: {
  262. padding: '5',
  263. align: 'left'
  264. }
  265. &lt;/code&gt;&lt;/pre&gt;
  266. * &lt;li&gt;&lt;code&gt;&lt;b&gt;layout&lt;/b&gt;&lt;/code&gt;&lt;/li&gt;
  267. * &lt;br/&gt;&lt;p&gt;The layout &lt;code&gt;type&lt;/code&gt; to be used for this container (see list
  268. * of valid layout type values above).&lt;/p&gt;&lt;br/&gt;
  269. * &lt;li&gt;&lt;code&gt;&lt;b&gt;{@link #layoutConfig}&lt;/b&gt;&lt;/code&gt;&lt;/li&gt;
  270. * &lt;br/&gt;&lt;p&gt;Additional layout specific configuration properties. For complete
  271. * details regarding the valid config options for each layout type, see the
  272. * layout class corresponding to the &lt;code&gt;layout&lt;/code&gt; specified.&lt;/p&gt;
  273. * &lt;/ul&gt;&lt;/div&gt;&lt;/ul&gt;&lt;/div&gt;
  274. */
  275. <span id='Ext-Container-cfg-layoutConfig'> /**
  276. </span> * @cfg {Object} layoutConfig
  277. * This is a config object containing properties specific to the chosen
  278. * &lt;b&gt;&lt;code&gt;{@link #layout}&lt;/code&gt;&lt;/b&gt; if &lt;b&gt;&lt;code&gt;{@link #layout}&lt;/code&gt;&lt;/b&gt;
  279. * has been specified as a &lt;i&gt;string&lt;/i&gt;.&lt;/p&gt;
  280. */
  281. <span id='Ext-Container-cfg-bufferResize'> /**
  282. </span> * @cfg {Boolean/Number} bufferResize
  283. * When set to true (50 milliseconds) or a number of milliseconds, the layout assigned for this container will buffer
  284. * the frequency it calculates and does a re-layout of components. This is useful for heavy containers or containers
  285. * with a large quantity of sub-components for which frequent layout calls would be expensive. Defaults to &lt;code&gt;50&lt;/code&gt;.
  286. */
  287. bufferResize: 50,
  288. <span id='Ext-Container-cfg-activeItem'> /**
  289. </span> * @cfg {String/Number} activeItem
  290. * A string component id or the numeric index of the component that should be initially activated within the
  291. * container's layout on render. For example, activeItem: 'item-1' or activeItem: 0 (index 0 = the first
  292. * item in the container's collection). activeItem only applies to layout styles that can display
  293. * items one at a time (like {@link Ext.layout.AccordionLayout}, {@link Ext.layout.CardLayout} and
  294. * {@link Ext.layout.FitLayout}). Related to {@link Ext.layout.ContainerLayout#activeItem}.
  295. */
  296. <span id='Ext-Container-cfg-items'> /**
  297. </span> * @cfg {Object/Array} items
  298. * &lt;pre&gt;&lt;b&gt;** IMPORTANT&lt;/b&gt;: be sure to &lt;b&gt;{@link #layout specify a &lt;code&gt;layout&lt;/code&gt;} if needed ! **&lt;/b&gt;&lt;/pre&gt;
  299. * &lt;p&gt;A single item, or an array of child Components to be added to this container,
  300. * for example:&lt;/p&gt;
  301. * &lt;pre&gt;&lt;code&gt;
  302. // specifying a single item
  303. items: {...},
  304. layout: 'fit', // specify a layout!
  305. // specifying multiple items
  306. items: [{...}, {...}],
  307. layout: 'anchor', // specify a layout!
  308. * &lt;/code&gt;&lt;/pre&gt;
  309. * &lt;p&gt;Each item may be:&lt;/p&gt;
  310. * &lt;div&gt;&lt;ul class=&quot;mdetail-params&quot;&gt;
  311. * &lt;li&gt;any type of object based on {@link Ext.Component}&lt;/li&gt;
  312. * &lt;li&gt;a fully instanciated object or&lt;/li&gt;
  313. * &lt;li&gt;an object literal that:&lt;/li&gt;
  314. * &lt;div&gt;&lt;ul class=&quot;mdetail-params&quot;&gt;
  315. * &lt;li&gt;has a specified &lt;code&gt;{@link Ext.Component#xtype xtype}&lt;/code&gt;&lt;/li&gt;
  316. * &lt;li&gt;the {@link Ext.Component#xtype} specified is associated with the Component
  317. * desired and should be chosen from one of the available xtypes as listed
  318. * in {@link Ext.Component}.&lt;/li&gt;
  319. * &lt;li&gt;If an &lt;code&gt;{@link Ext.Component#xtype xtype}&lt;/code&gt; is not explicitly
  320. * specified, the {@link #defaultType} for that Container is used.&lt;/li&gt;
  321. * &lt;li&gt;will be &quot;lazily instanciated&quot;, avoiding the overhead of constructing a fully
  322. * instanciated Component object&lt;/li&gt;
  323. * &lt;/ul&gt;&lt;/div&gt;&lt;/ul&gt;&lt;/div&gt;
  324. * &lt;p&gt;&lt;b&gt;Notes&lt;/b&gt;:&lt;/p&gt;
  325. * &lt;div&gt;&lt;ul class=&quot;mdetail-params&quot;&gt;
  326. * &lt;li&gt;Ext uses lazy rendering. Child Components will only be rendered
  327. * should it become necessary. Items are automatically laid out when they are first
  328. * shown (no sizing is done while hidden), or in response to a {@link #doLayout} call.&lt;/li&gt;
  329. * &lt;li&gt;Do not specify &lt;code&gt;{@link Ext.Panel#contentEl contentEl}&lt;/code&gt;/
  330. * &lt;code&gt;{@link Ext.Panel#html html}&lt;/code&gt; with &lt;code&gt;items&lt;/code&gt;.&lt;/li&gt;
  331. * &lt;/ul&gt;&lt;/div&gt;
  332. */
  333. <span id='Ext-Container-cfg-defaults'> /**
  334. </span> * @cfg {Object|Function} defaults
  335. * &lt;p&gt;This option is a means of applying default settings to all added items whether added through the {@link #items}
  336. * config or via the {@link #add} or {@link #insert} methods.&lt;/p&gt;
  337. * &lt;p&gt;If an added item is a config object, and &lt;b&gt;not&lt;/b&gt; an instantiated Component, then the default properties are
  338. * unconditionally applied. If the added item &lt;b&gt;is&lt;/b&gt; an instantiated Component, then the default properties are
  339. * applied conditionally so as not to override existing properties in the item.&lt;/p&gt;
  340. * &lt;p&gt;If the defaults option is specified as a function, then the function will be called using this Container as the
  341. * scope (&lt;code&gt;this&lt;/code&gt; reference) and passing the added item as the first parameter. Any resulting object
  342. * from that call is then applied to the item as default properties.&lt;/p&gt;
  343. * &lt;p&gt;For example, to automatically apply padding to the body of each of a set of
  344. * contained {@link Ext.Panel} items, you could pass: &lt;code&gt;defaults: {bodyStyle:'padding:15px'}&lt;/code&gt;.&lt;/p&gt;
  345. * &lt;p&gt;Usage:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;
  346. defaults: { // defaults are applied to items, not the container
  347. autoScroll:true
  348. },
  349. items: [
  350. {
  351. xtype: 'panel', // defaults &lt;b&gt;do not&lt;/b&gt; have precedence over
  352. id: 'panel1', // options in config objects, so the defaults
  353. autoScroll: false // will not be applied here, panel1 will be autoScroll:false
  354. },
  355. new Ext.Panel({ // defaults &lt;b&gt;do&lt;/b&gt; have precedence over options
  356. id: 'panel2', // options in components, so the defaults
  357. autoScroll: false // will be applied here, panel2 will be autoScroll:true.
  358. })
  359. ]
  360. * &lt;/code&gt;&lt;/pre&gt;
  361. */
  362. <span id='Ext-Container-cfg-autoDestroy'> /** @cfg {Boolean} autoDestroy
  363. </span> * If true the container will automatically destroy any contained component that is removed from it, else
  364. * destruction must be handled manually (defaults to true).
  365. */
  366. autoDestroy : true,
  367. <span id='Ext-Container-cfg-forceLayout'> /** @cfg {Boolean} forceLayout
  368. </span> * If true the container will force a layout initially even if hidden or collapsed. This option
  369. * is useful for forcing forms to render in collapsed or hidden containers. (defaults to false).
  370. */
  371. forceLayout: false,
  372. <span id='Ext-Container-cfg-hideBorders'> /** @cfg {Boolean} hideBorders
  373. </span> * True to hide the borders of each contained component, false to defer to the component's existing
  374. * border settings (defaults to false).
  375. */
  376. <span id='Ext-Container-cfg-defaultType'> /** @cfg {String} defaultType
  377. </span> * &lt;p&gt;The default {@link Ext.Component xtype} of child Components to create in this Container when
  378. * a child item is specified as a raw configuration object, rather than as an instantiated Component.&lt;/p&gt;
  379. * &lt;p&gt;Defaults to &lt;code&gt;'panel'&lt;/code&gt;, except {@link Ext.menu.Menu} which defaults to &lt;code&gt;'menuitem'&lt;/code&gt;,
  380. * and {@link Ext.Toolbar} and {@link Ext.ButtonGroup} which default to &lt;code&gt;'button'&lt;/code&gt;.&lt;/p&gt;
  381. */
  382. defaultType : 'panel',
  383. <span id='Ext-Container-cfg-resizeEvent'> /** @cfg {String} resizeEvent
  384. </span> * The event to listen to for resizing in layouts. Defaults to &lt;code&gt;'resize'&lt;/code&gt;.
  385. */
  386. resizeEvent: 'resize',
  387. <span id='Ext-Container-cfg-bubbleEvents'> /**
  388. </span> * @cfg {Array} bubbleEvents
  389. * &lt;p&gt;An array of events that, when fired, should be bubbled to any parent container.
  390. * See {@link Ext.util.Observable#enableBubble}.
  391. * Defaults to &lt;code&gt;['add', 'remove']&lt;/code&gt;.
  392. */
  393. bubbleEvents: ['add', 'remove'],
  394. <span id='Ext-Container-method-initComponent'> // private
  395. </span> initComponent : function(){
  396. Ext.Container.superclass.initComponent.call(this);
  397. this.addEvents(
  398. <span id='Ext-Container-event-afterlayout'> /**
  399. </span> * @event afterlayout
  400. * Fires when the components in this container are arranged by the associated layout manager.
  401. * @param {Ext.Container} this
  402. * @param {ContainerLayout} layout The ContainerLayout implementation for this container
  403. */
  404. 'afterlayout',
  405. <span id='Ext-Container-event-beforeadd'> /**
  406. </span> * @event beforeadd
  407. * Fires before any {@link Ext.Component} is added or inserted into the container.
  408. * A handler can return false to cancel the add.
  409. * @param {Ext.Container} this
  410. * @param {Ext.Component} component The component being added
  411. * @param {Number} index The index at which the component will be added to the container's items collection
  412. */
  413. 'beforeadd',
  414. <span id='Ext-Container-event-beforeremove'> /**
  415. </span> * @event beforeremove
  416. * Fires before any {@link Ext.Component} is removed from the container. A handler can return
  417. * false to cancel the remove.
  418. * @param {Ext.Container} this
  419. * @param {Ext.Component} component The component being removed
  420. */
  421. 'beforeremove',
  422. <span id='Ext-Container-event-add'> /**
  423. </span> * @event add
  424. * @bubbles
  425. * Fires after any {@link Ext.Component} is added or inserted into the container.
  426. * @param {Ext.Container} this
  427. * @param {Ext.Component} component The component that was added
  428. * @param {Number} index The index at which the component was added to the container's items collection
  429. */
  430. 'add',
  431. <span id='Ext-Container-event-remove'> /**
  432. </span> * @event remove
  433. * @bubbles
  434. * Fires after any {@link Ext.Component} is removed from the container.
  435. * @param {Ext.Container} this
  436. * @param {Ext.Component} component The component that was removed
  437. */
  438. 'remove'
  439. );
  440. <span id='Ext-Container-property-items'> /**
  441. </span> * The collection of components in this container as a {@link Ext.util.MixedCollection}
  442. * @type MixedCollection
  443. * @property items
  444. */
  445. var items = this.items;
  446. if(items){
  447. delete this.items;
  448. this.add(items);
  449. }
  450. },
  451. <span id='Ext-Container-method-initItems'> // private
  452. </span> initItems : function(){
  453. if(!this.items){
  454. this.items = new Ext.util.MixedCollection(false, this.getComponentId);
  455. this.getLayout(); // initialize the layout
  456. }
  457. },
  458. <span id='Ext-Container-method-setLayout'> // private
  459. </span> setLayout : function(layout){
  460. if(this.layout &amp;&amp; this.layout != layout){
  461. this.layout.setContainer(null);
  462. }
  463. this.layout = layout;
  464. this.initItems();
  465. layout.setContainer(this);
  466. },
  467. <span id='Ext-Container-method-afterRender'> afterRender: function(){
  468. </span> // Render this Container, this should be done before setLayout is called which
  469. // will hook onResize
  470. Ext.Container.superclass.afterRender.call(this);
  471. if(!this.layout){
  472. this.layout = 'auto';
  473. }
  474. if(Ext.isObject(this.layout) &amp;&amp; !this.layout.layout){
  475. this.layoutConfig = this.layout;
  476. this.layout = this.layoutConfig.type;
  477. }
  478. if(Ext.isString(this.layout)){
  479. this.layout = new Ext.Container.LAYOUTS[this.layout.toLowerCase()](this.layoutConfig);
  480. }
  481. this.setLayout(this.layout);
  482. // If a CardLayout, the active item set
  483. if(this.activeItem !== undefined &amp;&amp; this.layout.setActiveItem){
  484. var item = this.activeItem;
  485. delete this.activeItem;
  486. this.layout.setActiveItem(item);
  487. }
  488. // If we have no ownerCt, render and size all children
  489. if(!this.ownerCt){
  490. this.doLayout(false, true);
  491. }
  492. // This is a manually configured flag set by users in conjunction with renderTo.
  493. // Not to be confused with the flag by the same name used in Layouts.
  494. if(this.monitorResize === true){
  495. Ext.EventManager.onWindowResize(this.doLayout, this, [false]);
  496. }
  497. },
  498. <span id='Ext-Container-method-getLayoutTarget'> /**
  499. </span> * &lt;p&gt;Returns the Element to be used to contain the child Components of this Container.&lt;/p&gt;
  500. * &lt;p&gt;An implementation is provided which returns the Container's {@link #getEl Element}, but
  501. * if there is a more complex structure to a Container, this may be overridden to return
  502. * the element into which the {@link #layout layout} renders child Components.&lt;/p&gt;
  503. * @return {Ext.Element} The Element to render child Components into.
  504. */
  505. getLayoutTarget : function(){
  506. return this.el;
  507. },
  508. <span id='Ext-Container-method-getComponentId'> // private - used as the key lookup function for the items collection
  509. </span> getComponentId : function(comp){
  510. return comp.getItemId();
  511. },
  512. <span id='Ext-Container-method-add'> /**
  513. </span> * &lt;p&gt;Adds {@link Ext.Component Component}(s) to this Container.&lt;/p&gt;
  514. * &lt;br&gt;&lt;p&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/u&gt; :
  515. * &lt;div&gt;&lt;ul class=&quot;mdetail-params&quot;&gt;
  516. * &lt;li&gt;Fires the {@link #beforeadd} event before adding&lt;/li&gt;
  517. * &lt;li&gt;The Container's {@link #defaults default config values} will be applied
  518. * accordingly (see &lt;code&gt;{@link #defaults}&lt;/code&gt; for details).&lt;/li&gt;
  519. * &lt;li&gt;Fires the {@link #add} event after the component has been added.&lt;/li&gt;
  520. * &lt;/ul&gt;&lt;/div&gt;
  521. * &lt;br&gt;&lt;p&gt;&lt;b&gt;Notes&lt;/b&gt;&lt;/u&gt; :
  522. * &lt;div&gt;&lt;ul class=&quot;mdetail-params&quot;&gt;
  523. * &lt;li&gt;If the Container is &lt;i&gt;already rendered&lt;/i&gt; when &lt;code&gt;add&lt;/code&gt;
  524. * is called, you may need to call {@link #doLayout} to refresh the view which causes
  525. * any unrendered child Components to be rendered. This is required so that you can
  526. * &lt;code&gt;add&lt;/code&gt; multiple child components if needed while only refreshing the layout
  527. * once. For example:&lt;pre&gt;&lt;code&gt;
  528. var tb = new {@link Ext.Toolbar}();
  529. tb.render(document.body); // toolbar is rendered
  530. tb.add({text:'Button 1'}); // add multiple items ({@link #defaultType} for {@link Ext.Toolbar Toolbar} is 'button')
  531. tb.add({text:'Button 2'});
  532. tb.{@link #doLayout}(); // refresh the layout
  533. * &lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
  534. * &lt;li&gt;&lt;i&gt;Warning:&lt;/i&gt; Containers directly managed by the BorderLayout layout manager
  535. * may not be removed or added. See the Notes for {@link Ext.layout.BorderLayout BorderLayout}
  536. * for more details.&lt;/li&gt;
  537. * &lt;/ul&gt;&lt;/div&gt;
  538. * @param {...Object/Array} component
  539. * &lt;p&gt;Either one or more Components to add or an Array of Components to add. See
  540. * &lt;code&gt;{@link #items}&lt;/code&gt; for additional information.&lt;/p&gt;
  541. * @return {Ext.Component/Array} The Components that were added.
  542. */
  543. add : function(comp){
  544. this.initItems();
  545. var args = arguments.length &gt; 1;
  546. if(args || Ext.isArray(comp)){
  547. var result = [];
  548. Ext.each(args ? arguments : comp, function(c){
  549. result.push(this.add(c));
  550. }, this);
  551. return result;
  552. }
  553. var c = this.lookupComponent(this.applyDefaults(comp));
  554. var index = this.items.length;
  555. if(this.fireEvent('beforeadd', this, c, index) !== false &amp;&amp; this.onBeforeAdd(c) !== false){
  556. this.items.add(c);
  557. // *onAdded
  558. c.onAdded(this, index);
  559. this.onAdd(c);
  560. this.fireEvent('add', this, c, index);
  561. }
  562. return c;
  563. },
  564. <span id='Ext-Container-method-onAdd'> onAdd : function(c){
  565. </span> // Empty template method
  566. },
  567. <span id='Ext-Container-method-onAdded'> // private
  568. </span> onAdded : function(container, pos) {
  569. //overridden here so we can cascade down, not worth creating a template method.
  570. this.ownerCt = container;
  571. this.initRef();
  572. //initialize references for child items
  573. this.cascade(function(c){
  574. c.initRef();
  575. });
  576. this.fireEvent('added', this, container, pos);
  577. },
  578. <span id='Ext-Container-method-insert'> /**
  579. </span> * Inserts a Component into this Container at a specified index. Fires the
  580. * {@link #beforeadd} event before inserting, then fires the {@link #add} event after the
  581. * Component has been inserted.
  582. * @param {Number} index The index at which the Component will be inserted
  583. * into the Container's items collection
  584. * @param {Ext.Component} component The child Component to insert.&lt;br&gt;&lt;br&gt;
  585. * Ext uses lazy rendering, and will only render the inserted Component should
  586. * it become necessary.&lt;br&gt;&lt;br&gt;
  587. * A Component config object may be passed in order to avoid the overhead of
  588. * constructing a real Component object if lazy rendering might mean that the
  589. * inserted Component will not be rendered immediately. To take advantage of
  590. * this 'lazy instantiation', set the {@link Ext.Component#xtype} config
  591. * property to the registered type of the Component wanted.&lt;br&gt;&lt;br&gt;
  592. * For a list of all available xtypes, see {@link Ext.Component}.
  593. * @return {Ext.Component} component The Component (or config object) that was
  594. * inserted with the Container's default config values applied.
  595. */
  596. insert : function(index, comp) {
  597. var args = arguments,
  598. length = args.length,
  599. result = [],
  600. i, c;
  601. this.initItems();
  602. if (length &gt; 2) {
  603. for (i = length - 1; i &gt;= 1; --i) {
  604. result.push(this.insert(index, args[i]));
  605. }
  606. return result;
  607. }
  608. c = this.lookupComponent(this.applyDefaults(comp));
  609. index = Math.min(index, this.items.length);
  610. if (this.fireEvent('beforeadd', this, c, index) !== false &amp;&amp; this.onBeforeAdd(c) !== false) {
  611. if (c.ownerCt == this) {
  612. this.items.remove(c);
  613. }
  614. this.items.insert(index, c);
  615. c.onAdded(this, index);
  616. this.onAdd(c);
  617. this.fireEvent('add', this, c, index);
  618. }
  619. return c;
  620. },
  621. <span id='Ext-Container-method-applyDefaults'> // private
  622. </span> applyDefaults : function(c){
  623. var d = this.defaults;
  624. if(d){
  625. if(Ext.isFunction(d)){
  626. d = d.call(this, c);
  627. }
  628. if(Ext.isString(c)){
  629. c = Ext.ComponentMgr.get(c);
  630. Ext.apply(c, d);
  631. }else if(!c.events){
  632. Ext.applyIf(c.isAction ? c.initialConfig : c, d);
  633. }else{
  634. Ext.apply(c, d);
  635. }
  636. }
  637. return c;
  638. },
  639. <span id='Ext-Container-method-onBeforeAdd'> // private
  640. </span> onBeforeAdd : function(item){
  641. if(item.ownerCt){
  642. item.ownerCt.remove(item, false);
  643. }
  644. if(this.hideBorders === true){
  645. item.border = (item.border === true);
  646. }
  647. },
  648. <span id='Ext-Container-method-remove'> /**
  649. </span> * Removes a component from this container. Fires the {@link #beforeremove} event before removing, then fires
  650. * the {@link #remove} event after the component has been removed.
  651. * @param {Component/String} component The component reference or id to remove.
  652. * @param {Boolean} autoDestroy (optional) True to automatically invoke the removed Component's {@link Ext.Component#destroy} function.
  653. * Defaults to the value of this Container's {@link #autoDestroy} config.
  654. * @return {Ext.Component} component The Component that was removed.
  655. */
  656. remove : function(comp, autoDestroy){
  657. this.initItems();
  658. var c = this.getComponent(comp);
  659. if(c &amp;&amp; this.fireEvent('beforeremove', this, c) !== false){
  660. this.doRemove(c, autoDestroy);
  661. this.fireEvent('remove', this, c);
  662. }
  663. return c;
  664. },
  665. <span id='Ext-Container-method-onRemove'> onRemove: function(c){
  666. </span> // Empty template method
  667. },
  668. <span id='Ext-Container-method-doRemove'> // private
  669. </span> doRemove: function(c, autoDestroy){
  670. var l = this.layout,
  671. hasLayout = l &amp;&amp; this.rendered;
  672. if(hasLayout){
  673. l.onRemove(c);
  674. }
  675. this.items.remove(c);
  676. c.onRemoved();
  677. this.onRemove(c);
  678. if(autoDestroy === true || (autoDestroy !== false &amp;&amp; this.autoDestroy)){
  679. c.destroy();
  680. }
  681. if(hasLayout){
  682. l.afterRemove(c);
  683. }
  684. },
  685. <span id='Ext-Container-method-removeAll'> /**
  686. </span> * Removes all components from this container.
  687. * @param {Boolean} autoDestroy (optional) True to automatically invoke the removed Component's {@link Ext.Component#destroy} function.
  688. * Defaults to the value of this Container's {@link #autoDestroy} config.
  689. * @return {Array} Array of the destroyed components
  690. */
  691. removeAll: function(autoDestroy){
  692. this.initItems();
  693. var item, rem = [], items = [];
  694. this.items.each(function(i){
  695. rem.push(i);
  696. });
  697. for (var i = 0, len = rem.length; i &lt; len; ++i){
  698. item = rem[i];
  699. this.remove(item, autoDestroy);
  700. if(item.ownerCt !== this){
  701. items.push(item);
  702. }
  703. }
  704. return items;
  705. },
  706. <span id='Ext-Container-method-getComponent'> /**
  707. </span> * Examines this container's &lt;code&gt;{@link #items}&lt;/code&gt; &lt;b&gt;property&lt;/b&gt;
  708. * and gets a direct child component of this container.
  709. * @param {String/Number} comp This parameter may be any of the following:
  710. * &lt;div&gt;&lt;ul class=&quot;mdetail-params&quot;&gt;
  711. * &lt;li&gt;a &lt;b&gt;&lt;code&gt;String&lt;/code&gt;&lt;/b&gt; : representing the &lt;code&gt;{@link Ext.Component#itemId itemId}&lt;/code&gt;
  712. * or &lt;code&gt;{@link Ext.Component#id id}&lt;/code&gt; of the child component &lt;/li&gt;
  713. * &lt;li&gt;a &lt;b&gt;&lt;code&gt;Number&lt;/code&gt;&lt;/b&gt; : representing the position of the child component
  714. * within the &lt;code&gt;{@link #items}&lt;/code&gt; &lt;b&gt;property&lt;/b&gt;&lt;/li&gt;
  715. * &lt;/ul&gt;&lt;/div&gt;
  716. * &lt;p&gt;For additional information see {@link Ext.util.MixedCollection#get}.
  717. * @return Ext.Component The component (if found).
  718. */
  719. getComponent : function(comp){
  720. if(Ext.isObject(comp)){
  721. comp = comp.getItemId();
  722. }
  723. return this.items.get(comp);
  724. },
  725. <span id='Ext-Container-method-lookupComponent'> // private
  726. </span> lookupComponent : function(comp){
  727. if(Ext.isString(comp)){
  728. return Ext.ComponentMgr.get(comp);
  729. }else if(!comp.events){
  730. return this.createComponent(comp);
  731. }
  732. return comp;
  733. },
  734. <span id='Ext-Container-method-createComponent'> // private
  735. </span> createComponent : function(config, defaultType){
  736. if (config.render) {
  737. return config;
  738. }
  739. // add in ownerCt at creation time but then immediately
  740. // remove so that onBeforeAdd can handle it
  741. var c = Ext.create(Ext.apply({
  742. ownerCt: this
  743. }, config), defaultType || this.defaultType);
  744. delete c.initialConfig.ownerCt;
  745. delete c.ownerCt;
  746. return c;
  747. },
  748. <span id='Ext-Container-method-canLayout'> /**
  749. </span> * @private
  750. * We can only lay out if there is a view area in which to layout.
  751. * display:none on the layout target, *or any of its parent elements* will mean it has no view area.
  752. */
  753. canLayout : function() {
  754. var el = this.getVisibilityEl();
  755. return el &amp;&amp; el.dom &amp;&amp; !el.isStyle(&quot;display&quot;, &quot;none&quot;);
  756. },
  757. <span id='Ext-Container-method-doLayout'> /**
  758. </span> * Force this container's layout to be recalculated. A call to this function is required after adding a new component
  759. * to an already rendered container, or possibly after changing sizing/position properties of child components.
  760. * @param {Boolean} shallow (optional) True to only calc the layout of this component, and let child components auto
  761. * calc layouts as required (defaults to false, which calls doLayout recursively for each subcontainer)
  762. * @param {Boolean} force (optional) True to force a layout to occur, even if the item is hidden.
  763. * @return {Ext.Container} this
  764. */
  765. doLayout : function(shallow, force){
  766. var rendered = this.rendered,
  767. forceLayout = force || this.forceLayout;
  768. if(this.collapsed || !this.canLayout()){
  769. this.deferLayout = this.deferLayout || !shallow;
  770. if(!forceLayout){
  771. return;
  772. }
  773. shallow = shallow &amp;&amp; !this.deferLayout;
  774. } else {
  775. delete this.deferLayout;
  776. }
  777. if(rendered &amp;&amp; this.layout){
  778. this.layout.layout();
  779. }
  780. if(shallow !== true &amp;&amp; this.items){
  781. var cs = this.items.items;
  782. for(var i = 0, len = cs.length; i &lt; len; i++){
  783. var c = cs[i];
  784. if(c.doLayout){
  785. c.doLayout(false, forceLayout);
  786. }
  787. }
  788. }
  789. if(rendered){
  790. this.onLayout(shallow, forceLayout);
  791. }
  792. // Initial layout completed
  793. this.hasLayout = true;
  794. delete this.forceLayout;
  795. },
  796. <span id='Ext-Container-method-onLayout'> onLayout : Ext.emptyFn,
  797. </span>
  798. <span id='Ext-Container-method-shouldBufferLayout'> // private
  799. </span> shouldBufferLayout: function(){
  800. /*
  801. * Returns true if the container should buffer a layout.
  802. * This is true only if the container has previously been laid out
  803. * and has a parent container that is pending a layout.
  804. */
  805. var hl = this.hasLayout;
  806. if(this.ownerCt){
  807. // Only ever buffer if we've laid out the first time and we have one pending.
  808. return hl ? !this.hasLayoutPending() : false;
  809. }
  810. // Never buffer initial layout
  811. return hl;
  812. },
  813. <span id='Ext-Container-method-hasLayoutPending'> // private
  814. </span> hasLayoutPending: function(){
  815. // Traverse hierarchy to see if any parent container has a pending layout.
  816. var pending = false;
  817. this.ownerCt.bubble(function(c){
  818. if(c.layoutPending){
  819. pending = true;
  820. return false;
  821. }
  822. });
  823. return pending;
  824. },
  825. <span id='Ext-Container-method-onShow'> onShow : function(){
  826. </span> // removes css classes that were added to hide
  827. Ext.Container.superclass.onShow.call(this);
  828. // If we were sized during the time we were hidden, layout.
  829. if(Ext.isDefined(this.deferLayout)){
  830. delete this.deferLayout;
  831. this.doLayout(true);
  832. }
  833. },
  834. <span id='Ext-Container-method-getLayout'> /**
  835. </span> * Returns the layout currently in use by the container. If the container does not currently have a layout
  836. * set, a default {@link Ext.layout.ContainerLayout} will be created and set as the container's layout.
  837. * @return {ContainerLayout} layout The container's layout
  838. */
  839. getLayout : function(){
  840. if(!this.layout){
  841. var layout = new Ext.layout.AutoLayout(this.layoutConfig);
  842. this.setLayout(layout);
  843. }
  844. return this.layout;
  845. },
  846. <span id='Ext-Container-method-beforeDestroy'> // private
  847. </span> beforeDestroy : function(){
  848. var c;
  849. if(this.items){
  850. while(c = this.items.first()){
  851. this.doRemove(c, true);
  852. }
  853. }
  854. if(this.monitorResize){
  855. Ext.EventManager.removeResizeListener(this.doLayout, this);
  856. }
  857. Ext.destroy(this.layout);
  858. Ext.Container.superclass.beforeDestroy.call(this);
  859. },
  860. <span id='Ext-Container-method-cascade'> /**
  861. </span> * Cascades down the component/container heirarchy from this component (called first), calling the specified function with
  862. * each component. The scope (&lt;i&gt;this&lt;/i&gt;) of
  863. * function call will be the scope provided or the current component. The arguments to the function
  864. * will be the args provided or the current component. If the function returns false at any point,
  865. * the cascade is stopped on that branch.
  866. * @param {Function} fn The function to call
  867. * @param {Object} scope (optional) The scope of the function (defaults to current component)
  868. * @param {Array} args (optional) The args to call the function with (defaults to passing the current component)
  869. * @return {Ext.Container} this
  870. */
  871. cascade : function(fn, scope, args){
  872. if(fn.apply(scope || this, args || [this]) !== false){
  873. if(this.items){
  874. var cs = this.items.items;
  875. for(var i = 0, len = cs.length; i &lt; len; i++){
  876. if(cs[i].cascade){
  877. cs[i].cascade(fn, scope, args);
  878. }else{
  879. fn.apply(scope || cs[i], args || [cs[i]]);
  880. }
  881. }
  882. }
  883. }
  884. return this;
  885. },
  886. <span id='Ext-Container-method-findById'> /**
  887. </span> * Find a component under this container at any level by id
  888. * @param {String} id
  889. * @deprecated Fairly useless method, since you can just use Ext.getCmp. Should be removed for 4.0
  890. * If you need to test if an id belongs to a container, you can use getCmp and findParent*.
  891. * @return Ext.Component
  892. */
  893. findById : function(id){
  894. var m = null,
  895. ct = this;
  896. this.cascade(function(c){
  897. if(ct != c &amp;&amp; c.id === id){
  898. m = c;
  899. return false;
  900. }
  901. });
  902. return m;
  903. },
  904. <span id='Ext-Container-method-findByType'> /**
  905. </span> * Find a component under this container at any level by xtype or class
  906. * @param {String/Class} xtype The xtype string for a component, or the class of the component directly
  907. * @param {Boolean} shallow (optional) False to check whether this Component is descended from the xtype (this is
  908. * the default), or true to check whether this Component is directly of the specified xtype.
  909. * @return {Array} Array of Ext.Components
  910. */
  911. findByType : function(xtype, shallow){
  912. return this.findBy(function(c){
  913. return c.isXType(xtype, shallow);
  914. });
  915. },
  916. <span id='Ext-Container-method-find'> /**
  917. </span> * Find a component under this container at any level by property
  918. * @param {String} prop
  919. * @param {String} value
  920. * @return {Array} Array of Ext.Components
  921. */
  922. find : function(prop, value){
  923. return this.findBy(function(c){
  924. return c[prop] === value;
  925. });
  926. },
  927. <span id='Ext-Container-method-findBy'> /**
  928. </span> * Find a component under this container at any level by a custom function. If the passed function returns
  929. * true, the component will be included in the results. The passed function is called with the arguments (component, this container).
  930. * @param {Function} fn The function to call
  931. * @param {Object} scope (optional)
  932. * @return {Array} Array of Ext.Components
  933. */
  934. findBy : function(fn, scope){
  935. var m = [], ct = this;
  936. this.cascade(function(c){
  937. if(ct != c &amp;&amp; fn.call(scope || c, c, ct) === true){
  938. m.push(c);
  939. }
  940. });
  941. return m;
  942. },
  943. <span id='Ext-Container-method-get'> /**
  944. </span> * Get a component contained by this container (alias for items.get(key))
  945. * @param {String/Number} key The index or id of the component
  946. * @deprecated Should be removed in 4.0, since getComponent does the same thing.
  947. * @return {Ext.Component} Ext.Component
  948. */
  949. get : function(key){
  950. return this.getComponent(key);
  951. }
  952. });
  953. Ext.Container.LAYOUTS = {};
  954. Ext.reg('container', Ext.Container);
  955. </pre>
  956. </body>
  957. </html>