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.

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