Web Interface For Lite Argus Control modules
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.

590 lines
24 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. /**
  8. * @class Ext.BoxComponent
  9. * @extends Ext.Component
  10. * <p>Base class for any {@link Ext.Component Component} that is to be sized as a box, using width and height.</p>
  11. * <p>BoxComponent provides automatic box model adjustments for sizing and positioning and will work correctly
  12. * within the Component rendering model.</p>
  13. * <p>A BoxComponent may be created as a custom Component which encapsulates any HTML element, either a pre-existing
  14. * element, or one that is created to your specifications at render time. Usually, to participate in layouts,
  15. * a Component will need to be a <b>Box</b>Component in order to have its width and height managed.</p>
  16. * <p>To use a pre-existing element as a BoxComponent, configure it so that you preset the <b>el</b> property to the
  17. * element to reference:<pre><code>
  18. var pageHeader = new Ext.BoxComponent({
  19. el: 'my-header-div'
  20. });</code></pre>
  21. * This may then be {@link Ext.Container#add added} to a {@link Ext.Container Container} as a child item.</p>
  22. * <p>To create a BoxComponent based around a HTML element to be created at render time, use the
  23. * {@link Ext.Component#autoEl autoEl} config option which takes the form of a
  24. * {@link Ext.DomHelper DomHelper} specification:<pre><code>
  25. var myImage = new Ext.BoxComponent({
  26. autoEl: {
  27. tag: 'img',
  28. src: '/images/my-image.jpg'
  29. }
  30. });</code></pre></p>
  31. * @constructor
  32. * @param {Ext.Element/String/Object} config The configuration options.
  33. * @xtype box
  34. */
  35. Ext.BoxComponent = Ext.extend(Ext.Component, {
  36. // Configs below are used for all Components when rendered by BoxLayout.
  37. /**
  38. * @cfg {Number} flex
  39. * <p><b>Note</b>: this config is only used when this Component is rendered
  40. * by a Container which has been configured to use a <b>{@link Ext.layout.BoxLayout BoxLayout}.</b>
  41. * Each child Component with a <code>flex</code> property will be flexed either vertically (by a VBoxLayout)
  42. * or horizontally (by an HBoxLayout) according to the item's <b>relative</b> <code>flex</code> value
  43. * compared to the sum of all Components with <code>flex</flex> value specified. Any child items that have
  44. * either a <code>flex = 0</code> or <code>flex = undefined</code> will not be 'flexed' (the initial size will not be changed).
  45. */
  46. // Configs below are used for all Components when rendered by AnchorLayout.
  47. /**
  48. * @cfg {String} anchor <p><b>Note</b>: this config is only used when this Component is rendered
  49. * by a Container which has been configured to use an <b>{@link Ext.layout.AnchorLayout AnchorLayout} (or subclass thereof).</b>
  50. * based layout manager, for example:<div class="mdetail-params"><ul>
  51. * <li>{@link Ext.form.FormPanel}</li>
  52. * <li>specifying <code>layout: 'anchor' // or 'form', or 'absolute'</code></li>
  53. * </ul></div></p>
  54. * <p>See {@link Ext.layout.AnchorLayout}.{@link Ext.layout.AnchorLayout#anchor anchor} also.</p>
  55. */
  56. // tabTip config is used when a BoxComponent is a child of a TabPanel
  57. /**
  58. * @cfg {String} tabTip
  59. * <p><b>Note</b>: this config is only used when this BoxComponent is a child item of a TabPanel.</p>
  60. * A string to be used as innerHTML (html tags are accepted) to show in a tooltip when mousing over
  61. * the associated tab selector element. {@link Ext.QuickTips}.init()
  62. * must be called in order for the tips to render.
  63. */
  64. // Configs below are used for all Components when rendered by BorderLayout.
  65. /**
  66. * @cfg {String} region <p><b>Note</b>: this config is only used when this BoxComponent is rendered
  67. * by a Container which has been configured to use the <b>{@link Ext.layout.BorderLayout BorderLayout}</b>
  68. * layout manager (e.g. specifying <tt>layout:'border'</tt>).</p><br>
  69. * <p>See {@link Ext.layout.BorderLayout} also.</p>
  70. */
  71. // margins config is used when a BoxComponent is rendered by BorderLayout or BoxLayout.
  72. /**
  73. * @cfg {Object} margins <p><b>Note</b>: this config is only used when this BoxComponent is rendered
  74. * by a Container which has been configured to use the <b>{@link Ext.layout.BorderLayout BorderLayout}</b>
  75. * or one of the two <b>{@link Ext.layout.BoxLayout BoxLayout} subclasses.</b></p>
  76. * <p>An object containing margins to apply to this BoxComponent in the
  77. * format:</p><pre><code>
  78. {
  79. top: (top margin),
  80. right: (right margin),
  81. bottom: (bottom margin),
  82. left: (left margin)
  83. }</code></pre>
  84. * <p>May also be a string containing space-separated, numeric margin values. The order of the
  85. * sides associated with each value matches the way CSS processes margin values:</p>
  86. * <p><div class="mdetail-params"><ul>
  87. * <li>If there is only one value, it applies to all sides.</li>
  88. * <li>If there are two values, the top and bottom borders are set to the first value and the
  89. * right and left are set to the second.</li>
  90. * <li>If there are three values, the top is set to the first value, the left and right are set
  91. * to the second, and the bottom is set to the third.</li>
  92. * <li>If there are four values, they apply to the top, right, bottom, and left, respectively.</li>
  93. * </ul></div></p>
  94. * <p>Defaults to:</p><pre><code>
  95. * {top:0, right:0, bottom:0, left:0}
  96. * </code></pre>
  97. */
  98. /**
  99. * @cfg {Number} x
  100. * The local x (left) coordinate for this component if contained within a positioning container.
  101. */
  102. /**
  103. * @cfg {Number} y
  104. * The local y (top) coordinate for this component if contained within a positioning container.
  105. */
  106. /**
  107. * @cfg {Number} pageX
  108. * The page level x coordinate for this component if contained within a positioning container.
  109. */
  110. /**
  111. * @cfg {Number} pageY
  112. * The page level y coordinate for this component if contained within a positioning container.
  113. */
  114. /**
  115. * @cfg {Number} height
  116. * The height of this component in pixels (defaults to auto).
  117. * <b>Note</b> to express this dimension as a percentage or offset see {@link Ext.Component#anchor}.
  118. */
  119. /**
  120. * @cfg {Number} width
  121. * The width of this component in pixels (defaults to auto).
  122. * <b>Note</b> to express this dimension as a percentage or offset see {@link Ext.Component#anchor}.
  123. */
  124. /**
  125. * @cfg {Number} boxMinHeight
  126. * <p>The minimum value in pixels which this BoxComponent will set its height to.</p>
  127. * <p><b>Warning:</b> This will override any size management applied by layout managers.</p>
  128. */
  129. /**
  130. * @cfg {Number} boxMinWidth
  131. * <p>The minimum value in pixels which this BoxComponent will set its width to.</p>
  132. * <p><b>Warning:</b> This will override any size management applied by layout managers.</p>
  133. */
  134. /**
  135. * @cfg {Number} boxMaxHeight
  136. * <p>The maximum value in pixels which this BoxComponent will set its height to.</p>
  137. * <p><b>Warning:</b> This will override any size management applied by layout managers.</p>
  138. */
  139. /**
  140. * @cfg {Number} boxMaxWidth
  141. * <p>The maximum value in pixels which this BoxComponent will set its width to.</p>
  142. * <p><b>Warning:</b> This will override any size management applied by layout managers.</p>
  143. */
  144. /**
  145. * @cfg {Boolean} autoHeight
  146. * <p>True to use height:'auto', false to use fixed height (or allow it to be managed by its parent
  147. * Container's {@link Ext.Container#layout layout manager}. Defaults to false.</p>
  148. * <p><b>Note</b>: Although many components inherit this config option, not all will
  149. * function as expected with a height of 'auto'. Setting autoHeight:true means that the
  150. * browser will manage height based on the element's contents, and that Ext will not manage it at all.</p>
  151. * <p>If the <i>browser</i> is managing the height, be aware that resizes performed by the browser in response
  152. * to changes within the structure of the Component cannot be detected. Therefore changes to the height might
  153. * result in elements needing to be synchronized with the new height. Example:</p><pre><code>
  154. var w = new Ext.Window({
  155. title: 'Window',
  156. width: 600,
  157. autoHeight: true,
  158. items: {
  159. title: 'Collapse Me',
  160. height: 400,
  161. collapsible: true,
  162. border: false,
  163. listeners: {
  164. beforecollapse: function() {
  165. w.el.shadow.hide();
  166. },
  167. beforeexpand: function() {
  168. w.el.shadow.hide();
  169. },
  170. collapse: function() {
  171. w.syncShadow();
  172. },
  173. expand: function() {
  174. w.syncShadow();
  175. }
  176. }
  177. }
  178. }).show();
  179. </code></pre>
  180. */
  181. /**
  182. * @cfg {Boolean} autoWidth
  183. * <p>True to use width:'auto', false to use fixed width (or allow it to be managed by its parent
  184. * Container's {@link Ext.Container#layout layout manager}. Defaults to false.</p>
  185. * <p><b>Note</b>: Although many components inherit this config option, not all will
  186. * function as expected with a width of 'auto'. Setting autoWidth:true means that the
  187. * browser will manage width based on the element's contents, and that Ext will not manage it at all.</p>
  188. * <p>If the <i>browser</i> is managing the width, be aware that resizes performed by the browser in response
  189. * to changes within the structure of the Component cannot be detected. Therefore changes to the width might
  190. * result in elements needing to be synchronized with the new width. For example, where the target element is:</p><pre><code>
  191. &lt;div id='grid-container' style='margin-left:25%;width:50%'>&lt;/div>
  192. </code></pre>
  193. * A Panel rendered into that target element must listen for browser window resize in order to relay its
  194. * child items when the browser changes its width:<pre><code>
  195. var myPanel = new Ext.Panel({
  196. renderTo: 'grid-container',
  197. monitorResize: true, // relay on browser resize
  198. title: 'Panel',
  199. height: 400,
  200. autoWidth: true,
  201. layout: 'hbox',
  202. layoutConfig: {
  203. align: 'stretch'
  204. },
  205. defaults: {
  206. flex: 1
  207. },
  208. items: [{
  209. title: 'Box 1',
  210. }, {
  211. title: 'Box 2'
  212. }, {
  213. title: 'Box 3'
  214. }],
  215. });
  216. </code></pre>
  217. */
  218. /**
  219. * @cfg {Boolean} autoScroll
  220. * <code>true</code> to use overflow:'auto' on the components layout element and show scroll bars automatically when
  221. * necessary, <code>false</code> to clip any overflowing content (defaults to <code>false</code>).
  222. */
  223. /* // private internal config
  224. * {Boolean} deferHeight
  225. * True to defer height calculations to an external component, false to allow this component to set its own
  226. * height (defaults to false).
  227. */
  228. // private
  229. initComponent : function(){
  230. Ext.BoxComponent.superclass.initComponent.call(this);
  231. this.addEvents(
  232. /**
  233. * @event resize
  234. * Fires after the component is resized.
  235. * @param {Ext.Component} this
  236. * @param {Number} adjWidth The box-adjusted width that was set
  237. * @param {Number} adjHeight The box-adjusted height that was set
  238. * @param {Number} rawWidth The width that was originally specified
  239. * @param {Number} rawHeight The height that was originally specified
  240. */
  241. 'resize',
  242. /**
  243. * @event move
  244. * Fires after the component is moved.
  245. * @param {Ext.Component} this
  246. * @param {Number} x The new x position
  247. * @param {Number} y The new y position
  248. */
  249. 'move'
  250. );
  251. },
  252. // private, set in afterRender to signify that the component has been rendered
  253. boxReady : false,
  254. // private, used to defer height settings to subclasses
  255. deferHeight: false,
  256. /**
  257. * Sets the width and height of this BoxComponent. This method fires the {@link #resize} event. This method can accept
  258. * either width and height as separate arguments, or you can pass a size object like <code>{width:10, height:20}</code>.
  259. * @param {Mixed} width The new width to set. This may be one of:<div class="mdetail-params"><ul>
  260. * <li>A Number specifying the new width in the {@link #getEl Element}'s {@link Ext.Element#defaultUnit}s (by default, pixels).</li>
  261. * <li>A String used to set the CSS width style.</li>
  262. * <li>A size object in the format <code>{width: widthValue, height: heightValue}</code>.</li>
  263. * <li><code>undefined</code> to leave the width unchanged.</li>
  264. * </ul></div>
  265. * @param {Mixed} height The new height to set (not required if a size object is passed as the first arg).
  266. * This may be one of:<div class="mdetail-params"><ul>
  267. * <li>A Number specifying the new height in the {@link #getEl Element}'s {@link Ext.Element#defaultUnit}s (by default, pixels).</li>
  268. * <li>A String used to set the CSS height style. Animation may <b>not</b> be used.</li>
  269. * <li><code>undefined</code> to leave the height unchanged.</li>
  270. * </ul></div>
  271. * @return {Ext.BoxComponent} this
  272. */
  273. setSize : function(w, h){
  274. // support for standard size objects
  275. if(typeof w == 'object'){
  276. h = w.height;
  277. w = w.width;
  278. }
  279. if (Ext.isDefined(w) && Ext.isDefined(this.boxMinWidth) && (w < this.boxMinWidth)) {
  280. w = this.boxMinWidth;
  281. }
  282. if (Ext.isDefined(h) && Ext.isDefined(this.boxMinHeight) && (h < this.boxMinHeight)) {
  283. h = this.boxMinHeight;
  284. }
  285. if (Ext.isDefined(w) && Ext.isDefined(this.boxMaxWidth) && (w > this.boxMaxWidth)) {
  286. w = this.boxMaxWidth;
  287. }
  288. if (Ext.isDefined(h) && Ext.isDefined(this.boxMaxHeight) && (h > this.boxMaxHeight)) {
  289. h = this.boxMaxHeight;
  290. }
  291. // not rendered
  292. if(!this.boxReady){
  293. this.width = w;
  294. this.height = h;
  295. return this;
  296. }
  297. // prevent recalcs when not needed
  298. if(this.cacheSizes !== false && this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
  299. return this;
  300. }
  301. this.lastSize = {width: w, height: h};
  302. var adj = this.adjustSize(w, h),
  303. aw = adj.width,
  304. ah = adj.height,
  305. rz;
  306. if(aw !== undefined || ah !== undefined){ // this code is nasty but performs better with floaters
  307. rz = this.getResizeEl();
  308. if(!this.deferHeight && aw !== undefined && ah !== undefined){
  309. rz.setSize(aw, ah);
  310. }else if(!this.deferHeight && ah !== undefined){
  311. rz.setHeight(ah);
  312. }else if(aw !== undefined){
  313. rz.setWidth(aw);
  314. }
  315. this.onResize(aw, ah, w, h);
  316. this.fireEvent('resize', this, aw, ah, w, h);
  317. }
  318. return this;
  319. },
  320. /**
  321. * Sets the width of the component. This method fires the {@link #resize} event.
  322. * @param {Mixed} width The new width to set. This may be one of:<div class="mdetail-params"><ul>
  323. * <li>A Number specifying the new width in the {@link #getEl Element}'s {@link Ext.Element#defaultUnit defaultUnit}s (by default, pixels).</li>
  324. * <li>A String used to set the CSS width style.</li>
  325. * </ul></div>
  326. * @return {Ext.BoxComponent} this
  327. */
  328. setWidth : function(width){
  329. return this.setSize(width);
  330. },
  331. /**
  332. * Sets the height of the component. This method fires the {@link #resize} event.
  333. * @param {Mixed} height The new height to set. This may be one of:<div class="mdetail-params"><ul>
  334. * <li>A Number specifying the new height in the {@link #getEl Element}'s {@link Ext.Element#defaultUnit defaultUnit}s (by default, pixels).</li>
  335. * <li>A String used to set the CSS height style.</li>
  336. * <li><i>undefined</i> to leave the height unchanged.</li>
  337. * </ul></div>
  338. * @return {Ext.BoxComponent} this
  339. */
  340. setHeight : function(height){
  341. return this.setSize(undefined, height);
  342. },
  343. /**
  344. * Gets the current size of the component's underlying element.
  345. * @return {Object} An object containing the element's size {width: (element width), height: (element height)}
  346. */
  347. getSize : function(){
  348. return this.getResizeEl().getSize();
  349. },
  350. /**
  351. * Gets the current width of the component's underlying element.
  352. * @return {Number}
  353. */
  354. getWidth : function(){
  355. return this.getResizeEl().getWidth();
  356. },
  357. /**
  358. * Gets the current height of the component's underlying element.
  359. * @return {Number}
  360. */
  361. getHeight : function(){
  362. return this.getResizeEl().getHeight();
  363. },
  364. /**
  365. * Gets the current size of the component's underlying element, including space taken by its margins.
  366. * @return {Object} An object containing the element's size {width: (element width + left/right margins), height: (element height + top/bottom margins)}
  367. */
  368. getOuterSize : function(){
  369. var el = this.getResizeEl();
  370. return {width: el.getWidth() + el.getMargins('lr'),
  371. height: el.getHeight() + el.getMargins('tb')};
  372. },
  373. /**
  374. * Gets the current XY position of the component's underlying element.
  375. * @param {Boolean} local (optional) If true the element's left and top are returned instead of page XY (defaults to false)
  376. * @return {Array} The XY position of the element (e.g., [100, 200])
  377. */
  378. getPosition : function(local){
  379. var el = this.getPositionEl();
  380. if(local === true){
  381. return [el.getLeft(true), el.getTop(true)];
  382. }
  383. return this.xy || el.getXY();
  384. },
  385. /**
  386. * Gets the current box measurements of the component's underlying element.
  387. * @param {Boolean} local (optional) If true the element's left and top are returned instead of page XY (defaults to false)
  388. * @return {Object} box An object in the format {x, y, width, height}
  389. */
  390. getBox : function(local){
  391. var pos = this.getPosition(local);
  392. var s = this.getSize();
  393. s.x = pos[0];
  394. s.y = pos[1];
  395. return s;
  396. },
  397. /**
  398. * Sets the current box measurements of the component's underlying element.
  399. * @param {Object} box An object in the format {x, y, width, height}
  400. * @return {Ext.BoxComponent} this
  401. */
  402. updateBox : function(box){
  403. this.setSize(box.width, box.height);
  404. this.setPagePosition(box.x, box.y);
  405. return this;
  406. },
  407. /**
  408. * <p>Returns the outermost Element of this Component which defines the Components overall size.</p>
  409. * <p><i>Usually</i> this will return the same Element as <code>{@link #getEl}</code>,
  410. * but in some cases, a Component may have some more wrapping Elements around its main
  411. * active Element.</p>
  412. * <p>An example is a ComboBox. It is encased in a <i>wrapping</i> Element which
  413. * contains both the <code>&lt;input></code> Element (which is what would be returned
  414. * by its <code>{@link #getEl}</code> method, <i>and</i> the trigger button Element.
  415. * This Element is returned as the <code>resizeEl</code>.
  416. * @return {Ext.Element} The Element which is to be resized by size managing layouts.
  417. */
  418. getResizeEl : function(){
  419. return this.resizeEl || this.el;
  420. },
  421. /**
  422. * Sets the overflow on the content element of the component.
  423. * @param {Boolean} scroll True to allow the Component to auto scroll.
  424. * @return {Ext.BoxComponent} this
  425. */
  426. setAutoScroll : function(scroll){
  427. if(this.rendered){
  428. this.getContentTarget().setOverflow(scroll ? 'auto' : '');
  429. }
  430. this.autoScroll = scroll;
  431. return this;
  432. },
  433. /**
  434. * Sets the left and top of the component. To set the page XY position instead, use {@link #setPagePosition}.
  435. * This method fires the {@link #move} event.
  436. * @param {Number} left The new left
  437. * @param {Number} top The new top
  438. * @return {Ext.BoxComponent} this
  439. */
  440. setPosition : function(x, y){
  441. if(x && typeof x[1] == 'number'){
  442. y = x[1];
  443. x = x[0];
  444. }
  445. this.x = x;
  446. this.y = y;
  447. if(!this.boxReady){
  448. return this;
  449. }
  450. var adj = this.adjustPosition(x, y);
  451. var ax = adj.x, ay = adj.y;
  452. var el = this.getPositionEl();
  453. if(ax !== undefined || ay !== undefined){
  454. if(ax !== undefined && ay !== undefined){
  455. el.setLeftTop(ax, ay);
  456. }else if(ax !== undefined){
  457. el.setLeft(ax);
  458. }else if(ay !== undefined){
  459. el.setTop(ay);
  460. }
  461. this.onPosition(ax, ay);
  462. this.fireEvent('move', this, ax, ay);
  463. }
  464. return this;
  465. },
  466. /**
  467. * Sets the page XY position of the component. To set the left and top instead, use {@link #setPosition}.
  468. * This method fires the {@link #move} event.
  469. * @param {Number} x The new x position
  470. * @param {Number} y The new y position
  471. * @return {Ext.BoxComponent} this
  472. */
  473. setPagePosition : function(x, y){
  474. if(x && typeof x[1] == 'number'){
  475. y = x[1];
  476. x = x[0];
  477. }
  478. this.pageX = x;
  479. this.pageY = y;
  480. if(!this.boxReady){
  481. return;
  482. }
  483. if(x === undefined || y === undefined){ // cannot translate undefined points
  484. return;
  485. }
  486. var p = this.getPositionEl().translatePoints(x, y);
  487. this.setPosition(p.left, p.top);
  488. return this;
  489. },
  490. // private
  491. afterRender : function(){
  492. Ext.BoxComponent.superclass.afterRender.call(this);
  493. if(this.resizeEl){
  494. this.resizeEl = Ext.get(this.resizeEl);
  495. }
  496. if(this.positionEl){
  497. this.positionEl = Ext.get(this.positionEl);
  498. }
  499. this.boxReady = true;
  500. Ext.isDefined(this.autoScroll) && this.setAutoScroll(this.autoScroll);
  501. this.setSize(this.width, this.height);
  502. if(this.x || this.y){
  503. this.setPosition(this.x, this.y);
  504. }else if(this.pageX || this.pageY){
  505. this.setPagePosition(this.pageX, this.pageY);
  506. }
  507. },
  508. /**
  509. * Force the component's size to recalculate based on the underlying element's current height and width.
  510. * @return {Ext.BoxComponent} this
  511. */
  512. syncSize : function(){
  513. delete this.lastSize;
  514. this.setSize(this.autoWidth ? undefined : this.getResizeEl().getWidth(), this.autoHeight ? undefined : this.getResizeEl().getHeight());
  515. return this;
  516. },
  517. /* // protected
  518. * Called after the component is resized, this method is empty by default but can be implemented by any
  519. * subclass that needs to perform custom logic after a resize occurs.
  520. * @param {Number} adjWidth The box-adjusted width that was set
  521. * @param {Number} adjHeight The box-adjusted height that was set
  522. * @param {Number} rawWidth The width that was originally specified
  523. * @param {Number} rawHeight The height that was originally specified
  524. */
  525. onResize : function(adjWidth, adjHeight, rawWidth, rawHeight){
  526. },
  527. /* // protected
  528. * Called after the component is moved, this method is empty by default but can be implemented by any
  529. * subclass that needs to perform custom logic after a move occurs.
  530. * @param {Number} x The new x position
  531. * @param {Number} y The new y position
  532. */
  533. onPosition : function(x, y){
  534. },
  535. // private
  536. adjustSize : function(w, h){
  537. if(this.autoWidth){
  538. w = 'auto';
  539. }
  540. if(this.autoHeight){
  541. h = 'auto';
  542. }
  543. return {width : w, height: h};
  544. },
  545. // private
  546. adjustPosition : function(x, y){
  547. return {x : x, y: y};
  548. }
  549. });
  550. Ext.reg('box', Ext.BoxComponent);
  551. /**
  552. * @class Ext.Spacer
  553. * @extends Ext.BoxComponent
  554. * <p>Used to provide a sizable space in a layout.</p>
  555. * @constructor
  556. * @param {Object} config
  557. */
  558. Ext.Spacer = Ext.extend(Ext.BoxComponent, {
  559. autoEl:'div'
  560. });
  561. Ext.reg('spacer', Ext.Spacer);