Web UI for ARGUS server
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.

1010 lines
42 KiB

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