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.

1050 lines
41 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-Window-method-constructor'><span id='Ext-Window'>/**
  19. </span></span> * @class Ext.Window
  20. * @extends Ext.Panel
  21. * &lt;p&gt;A specialized panel intended for use as an application window. Windows are floated, {@link #resizable}, and
  22. * {@link #draggable} by default. Windows can be {@link #maximizable maximized} to fill the viewport,
  23. * restored to their prior size, and can be {@link #minimize}d.&lt;/p&gt;
  24. * &lt;p&gt;Windows can also be linked to a {@link Ext.WindowGroup} or managed by the {@link Ext.WindowMgr} to provide
  25. * grouping, activation, to front, to back and other application-specific behavior.&lt;/p&gt;
  26. * &lt;p&gt;By default, Windows will be rendered to document.body. To {@link #constrain} a Window to another element
  27. * specify {@link Ext.Component#renderTo renderTo}.&lt;/p&gt;
  28. * &lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; By default, the &lt;code&gt;{@link #closable close}&lt;/code&gt; header tool &lt;i&gt;destroys&lt;/i&gt; the Window resulting in
  29. * destruction of any child Components. This makes the Window object, and all its descendants &lt;b&gt;unusable&lt;/b&gt;. To enable
  30. * re-use of a Window, use &lt;b&gt;&lt;code&gt;{@link #closeAction closeAction: 'hide'}&lt;/code&gt;&lt;/b&gt;.&lt;/p&gt;
  31. * @constructor
  32. * @param {Object} config The config object
  33. * @xtype window
  34. */
  35. Ext.Window = Ext.extend(Ext.Panel, {
  36. <span id='Ext-Window-cfg-x'> /**
  37. </span> * @cfg {Number} x
  38. * The X position of the left edge of the window on initial showing. Defaults to centering the Window within
  39. * the width of the Window's container {@link Ext.Element Element) (The Element that the Window is rendered to).
  40. */
  41. <span id='Ext-Window-cfg-y'> /**
  42. </span> * @cfg {Number} y
  43. * The Y position of the top edge of the window on initial showing. Defaults to centering the Window within
  44. * the height of the Window's container {@link Ext.Element Element) (The Element that the Window is rendered to).
  45. */
  46. <span id='Ext-Window-cfg-modal'> /**
  47. </span> * @cfg {Boolean} modal
  48. * True to make the window modal and mask everything behind it when displayed, false to display it without
  49. * restricting access to other UI elements (defaults to false).
  50. */
  51. <span id='Ext-Window-cfg-animateTarget'> /**
  52. </span> * @cfg {String/Element} animateTarget
  53. * Id or element from which the window should animate while opening (defaults to null with no animation).
  54. */
  55. <span id='Ext-Window-cfg-resizeHandles'> /**
  56. </span> * @cfg {String} resizeHandles
  57. * A valid {@link Ext.Resizable} handles config string (defaults to 'all'). Only applies when resizable = true.
  58. */
  59. <span id='Ext-Window-cfg-manager'> /**
  60. </span> * @cfg {Ext.WindowGroup} manager
  61. * A reference to the WindowGroup that should manage this window (defaults to {@link Ext.WindowMgr}).
  62. */
  63. <span id='Ext-Window-cfg-defaultButton'> /**
  64. </span> * @cfg {String/Number/Component} defaultButton
  65. * &lt;p&gt;Specifies a Component to receive focus when this Window is focussed.&lt;/p&gt;
  66. * &lt;p&gt;This may be one of:&lt;/p&gt;&lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
  67. * &lt;li&gt;The index of a footer Button.&lt;/li&gt;
  68. * &lt;li&gt;The id of a Component.&lt;/li&gt;
  69. * &lt;li&gt;A Component.&lt;/li&gt;
  70. * &lt;/ul&gt;&lt;/div&gt;
  71. */
  72. <span id='Ext-Window-cfg-onEsc'> /**
  73. </span> * @cfg {Function} onEsc
  74. * Allows override of the built-in processing for the escape key. Default action
  75. * is to close the Window (performing whatever action is specified in {@link #closeAction}.
  76. * To prevent the Window closing when the escape key is pressed, specify this as
  77. * Ext.emptyFn (See {@link Ext#emptyFn}).
  78. */
  79. <span id='Ext-Window-cfg-collapsed'> /**
  80. </span> * @cfg {Boolean} collapsed
  81. * True to render the window collapsed, false to render it expanded (defaults to false). Note that if
  82. * {@link #expandOnShow} is true (the default) it will override the &lt;tt&gt;collapsed&lt;/tt&gt; config and the window
  83. * will always be expanded when shown.
  84. */
  85. <span id='Ext-Window-cfg-maximized'> /**
  86. </span> * @cfg {Boolean} maximized
  87. * True to initially display the window in a maximized state. (Defaults to false).
  88. */
  89. <span id='Ext-Window-cfg-baseCls'> /**
  90. </span> * @cfg {String} baseCls
  91. * The base CSS class to apply to this panel's element (defaults to 'x-window').
  92. */
  93. baseCls : 'x-window',
  94. <span id='Ext-Window-cfg-resizable'> /**
  95. </span> * @cfg {Boolean} resizable
  96. * True to allow user resizing at each edge and corner of the window, false to disable resizing (defaults to true).
  97. */
  98. resizable : true,
  99. <span id='Ext-Window-cfg-draggable'> /**
  100. </span> * @cfg {Boolean} draggable
  101. * True to allow the window to be dragged by the header bar, false to disable dragging (defaults to true). Note
  102. * that by default the window will be centered in the viewport, so if dragging is disabled the window may need
  103. * to be positioned programmatically after render (e.g., myWindow.setPosition(100, 100);).
  104. */
  105. draggable : true,
  106. <span id='Ext-Window-cfg-closable'> /**
  107. </span> * @cfg {Boolean} closable
  108. * &lt;p&gt;True to display the 'close' tool button and allow the user to close the window, false to
  109. * hide the button and disallow closing the window (defaults to true).&lt;/p&gt;
  110. * &lt;p&gt;By default, when close is requested by either clicking the close button in the header
  111. * or pressing ESC when the Window has focus, the {@link #close} method will be called. This
  112. * will &lt;i&gt;{@link Ext.Component#destroy destroy}&lt;/i&gt; the Window and its content meaning that
  113. * it may not be reused.&lt;/p&gt;
  114. * &lt;p&gt;To make closing a Window &lt;i&gt;hide&lt;/i&gt; the Window so that it may be reused, set
  115. * {@link #closeAction} to 'hide'.
  116. */
  117. closable : true,
  118. <span id='Ext-Window-cfg-closeAction'> /**
  119. </span> * @cfg {String} closeAction
  120. * &lt;p&gt;The action to take when the close header tool is clicked:
  121. * &lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
  122. * &lt;li&gt;&lt;b&gt;&lt;code&gt;'{@link #close}'&lt;/code&gt;&lt;/b&gt; : &lt;b&gt;Default&lt;/b&gt;&lt;div class=&quot;sub-desc&quot;&gt;
  123. * {@link #close remove} the window from the DOM and {@link Ext.Component#destroy destroy}
  124. * it and all descendant Components. The window will &lt;b&gt;not&lt;/b&gt; be available to be
  125. * redisplayed via the {@link #show} method.
  126. * &lt;/div&gt;&lt;/li&gt;
  127. * &lt;li&gt;&lt;b&gt;&lt;code&gt;'{@link #hide}'&lt;/code&gt;&lt;/b&gt; : &lt;div class=&quot;sub-desc&quot;&gt;
  128. * {@link #hide} the window by setting visibility to hidden and applying negative offsets.
  129. * The window will be available to be redisplayed via the {@link #show} method.
  130. * &lt;/div&gt;&lt;/li&gt;
  131. * &lt;/ul&gt;&lt;/div&gt;
  132. * &lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; This setting does not affect the {@link #close} method
  133. * which will always {@link Ext.Component#destroy destroy} the window. To
  134. * programatically &lt;i&gt;hide&lt;/i&gt; a window, call {@link #hide}.&lt;/p&gt;
  135. */
  136. closeAction : 'close',
  137. <span id='Ext-Window-cfg-constrain'> /**
  138. </span> * @cfg {Boolean} constrain
  139. * True to constrain the window within its containing element, false to allow it to fall outside of its
  140. * containing element. By default the window will be rendered to document.body. To render and constrain the
  141. * window within another element specify {@link #renderTo}.
  142. * (defaults to false). Optionally the header only can be constrained using {@link #constrainHeader}.
  143. */
  144. constrain : false,
  145. <span id='Ext-Window-cfg-constrainHeader'> /**
  146. </span> * @cfg {Boolean} constrainHeader
  147. * True to constrain the window header within its containing element (allowing the window body to fall outside
  148. * of its containing element) or false to allow the header to fall outside its containing element (defaults to
  149. * false). Optionally the entire window can be constrained using {@link #constrain}.
  150. */
  151. constrainHeader : false,
  152. <span id='Ext-Window-cfg-plain'> /**
  153. </span> * @cfg {Boolean} plain
  154. * True to render the window body with a transparent background so that it will blend into the framing
  155. * elements, false to add a lighter background color to visually highlight the body element and separate it
  156. * more distinctly from the surrounding frame (defaults to false).
  157. */
  158. plain : false,
  159. <span id='Ext-Window-cfg-minimizable'> /**
  160. </span> * @cfg {Boolean} minimizable
  161. * True to display the 'minimize' tool button and allow the user to minimize the window, false to hide the button
  162. * and disallow minimizing the window (defaults to false). Note that this button provides no implementation --
  163. * the behavior of minimizing a window is implementation-specific, so the minimize event must be handled and a
  164. * custom minimize behavior implemented for this option to be useful.
  165. */
  166. minimizable : false,
  167. <span id='Ext-Window-cfg-maximizable'> /**
  168. </span> * @cfg {Boolean} maximizable
  169. * True to display the 'maximize' tool button and allow the user to maximize the window, false to hide the button
  170. * and disallow maximizing the window (defaults to false). Note that when a window is maximized, the tool button
  171. * will automatically change to a 'restore' button with the appropriate behavior already built-in that will
  172. * restore the window to its previous size.
  173. */
  174. maximizable : false,
  175. <span id='Ext-Window-cfg-minHeight'> /**
  176. </span> * @cfg {Number} minHeight
  177. * The minimum height in pixels allowed for this window (defaults to 100). Only applies when resizable = true.
  178. */
  179. minHeight : 100,
  180. <span id='Ext-Window-cfg-minWidth'> /**
  181. </span> * @cfg {Number} minWidth
  182. * The minimum width in pixels allowed for this window (defaults to 200). Only applies when resizable = true.
  183. */
  184. minWidth : 200,
  185. <span id='Ext-Window-cfg-expandOnShow'> /**
  186. </span> * @cfg {Boolean} expandOnShow
  187. * True to always expand the window when it is displayed, false to keep it in its current state (which may be
  188. * {@link #collapsed}) when displayed (defaults to true).
  189. */
  190. expandOnShow : true,
  191. <span id='Ext-Window-cfg-showAnimDuration'> /**
  192. </span> * @cfg {Number} showAnimDuration The number of seconds that the window show animation takes if enabled.
  193. * Defaults to 0.25
  194. */
  195. showAnimDuration: 0.25,
  196. <span id='Ext-Window-cfg-hideAnimDuration'> /**
  197. </span> * @cfg {Number} hideAnimDuration The number of seconds that the window hide animation takes if enabled.
  198. * Defaults to 0.25
  199. */
  200. hideAnimDuration: 0.25,
  201. <span id='Ext-Window-cfg-collapsible'> // inherited docs, same default
  202. </span> collapsible : false,
  203. <span id='Ext-Window-cfg-initHidden'> /**
  204. </span> * @cfg {Boolean} initHidden
  205. * True to hide the window until show() is explicitly called (defaults to true).
  206. * @deprecated
  207. */
  208. initHidden : undefined,
  209. <span id='Ext-Window-cfg-hidden'> /**
  210. </span> * @cfg {Boolean} hidden
  211. * Render this component hidden (default is &lt;tt&gt;true&lt;/tt&gt;). If &lt;tt&gt;true&lt;/tt&gt;, the
  212. * {@link #hide} method will be called internally.
  213. */
  214. hidden : true,
  215. // The following configs are set to provide the basic functionality of a window.
  216. // Changing them would require additional code to handle correctly and should
  217. // usually only be done in subclasses that can provide custom behavior. Changing them
  218. // may have unexpected or undesirable results.
  219. <span id='Ext-Window-cfg-elements'> /** @cfg {String} elements @hide */
  220. </span> elements : 'header,body',
  221. <span id='Ext-Window-cfg-frame'> /** @cfg {Boolean} frame @hide */
  222. </span> frame : true,
  223. <span id='Ext-Window-cfg-floating'> /** @cfg {Boolean} floating @hide */
  224. </span> floating : true,
  225. <span id='Ext-Window-method-initComponent'> // private
  226. </span> initComponent : function(){
  227. this.initTools();
  228. Ext.Window.superclass.initComponent.call(this);
  229. this.addEvents(
  230. <span id='Ext-Window-event-activate'> /**
  231. </span> * @event activate
  232. * Fires after the window has been visually activated via {@link #setActive}.
  233. * @param {Ext.Window} this
  234. */
  235. <span id='Ext-Window-event-deactivate'> /**
  236. </span> * @event deactivate
  237. * Fires after the window has been visually deactivated via {@link #setActive}.
  238. * @param {Ext.Window} this
  239. */
  240. <span id='Ext-Window-event-resize'> /**
  241. </span> * @event resize
  242. * Fires after the window has been resized.
  243. * @param {Ext.Window} this
  244. * @param {Number} width The window's new width
  245. * @param {Number} height The window's new height
  246. */
  247. 'resize',
  248. <span id='Ext-Window-event-maximize'> /**
  249. </span> * @event maximize
  250. * Fires after the window has been maximized.
  251. * @param {Ext.Window} this
  252. */
  253. 'maximize',
  254. <span id='Ext-Window-event-minimize'> /**
  255. </span> * @event minimize
  256. * Fires after the window has been minimized.
  257. * @param {Ext.Window} this
  258. */
  259. 'minimize',
  260. <span id='Ext-Window-event-restore'> /**
  261. </span> * @event restore
  262. * Fires after the window has been restored to its original size after being maximized.
  263. * @param {Ext.Window} this
  264. */
  265. 'restore'
  266. );
  267. // for backwards compat, this should be removed at some point
  268. if(Ext.isDefined(this.initHidden)){
  269. this.hidden = this.initHidden;
  270. }
  271. if(this.hidden === false){
  272. this.hidden = true;
  273. this.show();
  274. }
  275. },
  276. <span id='Ext-Window-method-getState'> // private
  277. </span> getState : function(){
  278. return Ext.apply(Ext.Window.superclass.getState.call(this) || {}, this.getBox(true));
  279. },
  280. <span id='Ext-Window-method-onRender'> // private
  281. </span> onRender : function(ct, position){
  282. Ext.Window.superclass.onRender.call(this, ct, position);
  283. if(this.plain){
  284. this.el.addClass('x-window-plain');
  285. }
  286. // this element allows the Window to be focused for keyboard events
  287. this.focusEl = this.el.createChild({
  288. tag: 'a', href:'#', cls:'x-dlg-focus',
  289. tabIndex:'-1', html: '&amp;#160;'});
  290. this.focusEl.swallowEvent('click', true);
  291. this.proxy = this.el.createProxy('x-window-proxy');
  292. this.proxy.enableDisplayMode('block');
  293. if(this.modal){
  294. this.mask = this.container.createChild({cls:'ext-el-mask'}, this.el.dom);
  295. this.mask.enableDisplayMode('block');
  296. this.mask.hide();
  297. this.mon(this.mask, 'click', this.focus, this);
  298. }
  299. if(this.maximizable){
  300. this.mon(this.header, 'dblclick', this.toggleMaximize, this);
  301. }
  302. },
  303. <span id='Ext-Window-method-initEvents'> // private
  304. </span> initEvents : function(){
  305. Ext.Window.superclass.initEvents.call(this);
  306. if(this.animateTarget){
  307. this.setAnimateTarget(this.animateTarget);
  308. }
  309. if(this.resizable){
  310. this.resizer = new Ext.Resizable(this.el, {
  311. minWidth: this.minWidth,
  312. minHeight:this.minHeight,
  313. handles: this.resizeHandles || 'all',
  314. pinned: true,
  315. resizeElement : this.resizerAction,
  316. handleCls: 'x-window-handle'
  317. });
  318. this.resizer.window = this;
  319. this.mon(this.resizer, 'beforeresize', this.beforeResize, this);
  320. }
  321. if(this.draggable){
  322. this.header.addClass('x-window-draggable');
  323. }
  324. this.mon(this.el, 'mousedown', this.toFront, this);
  325. this.manager = this.manager || Ext.WindowMgr;
  326. this.manager.register(this);
  327. if(this.maximized){
  328. this.maximized = false;
  329. this.maximize();
  330. }
  331. if(this.closable){
  332. var km = this.getKeyMap();
  333. km.on(27, this.onEsc, this);
  334. km.disable();
  335. }
  336. },
  337. <span id='Ext-Window-method-initDraggable'> initDraggable : function(){
  338. </span><span id='Ext-Window-property-dd'> /**
  339. </span> * &lt;p&gt;If this Window is configured {@link #draggable}, this property will contain
  340. * an instance of {@link Ext.dd.DD} which handles dragging the Window's DOM Element.&lt;/p&gt;
  341. * &lt;p&gt;This has implementations of &lt;code&gt;startDrag&lt;/code&gt;, &lt;code&gt;onDrag&lt;/code&gt; and &lt;code&gt;endDrag&lt;/code&gt;
  342. * which perform the dragging action. If extra logic is needed at these points, use
  343. * {@link Function#createInterceptor createInterceptor} or {@link Function#createSequence createSequence} to
  344. * augment the existing implementations.&lt;/p&gt;
  345. * @type Ext.dd.DD
  346. * @property dd
  347. */
  348. this.dd = new Ext.Window.DD(this);
  349. },
  350. <span id='Ext-Window-method-onEsc'> // private
  351. </span> onEsc : function(k, e){
  352. if (this.activeGhost) {
  353. this.unghost();
  354. }
  355. e.stopEvent();
  356. this[this.closeAction]();
  357. },
  358. <span id='Ext-Window-method-beforeDestroy'> // private
  359. </span> beforeDestroy : function(){
  360. if(this.rendered){
  361. this.hide();
  362. this.clearAnchor();
  363. Ext.destroy(
  364. this.focusEl,
  365. this.resizer,
  366. this.dd,
  367. this.proxy,
  368. this.mask
  369. );
  370. }
  371. Ext.Window.superclass.beforeDestroy.call(this);
  372. },
  373. <span id='Ext-Window-method-onDestroy'> // private
  374. </span> onDestroy : function(){
  375. if(this.manager){
  376. this.manager.unregister(this);
  377. }
  378. Ext.Window.superclass.onDestroy.call(this);
  379. },
  380. <span id='Ext-Window-method-initTools'> // private
  381. </span> initTools : function(){
  382. if(this.minimizable){
  383. this.addTool({
  384. id: 'minimize',
  385. handler: this.minimize.createDelegate(this, [])
  386. });
  387. }
  388. if(this.maximizable){
  389. this.addTool({
  390. id: 'maximize',
  391. handler: this.maximize.createDelegate(this, [])
  392. });
  393. this.addTool({
  394. id: 'restore',
  395. handler: this.restore.createDelegate(this, []),
  396. hidden:true
  397. });
  398. }
  399. if(this.closable){
  400. this.addTool({
  401. id: 'close',
  402. handler: this[this.closeAction].createDelegate(this, [])
  403. });
  404. }
  405. },
  406. <span id='Ext-Window-method-resizerAction'> // private
  407. </span> resizerAction : function(){
  408. var box = this.proxy.getBox();
  409. this.proxy.hide();
  410. this.window.handleResize(box);
  411. return box;
  412. },
  413. <span id='Ext-Window-method-beforeResize'> // private
  414. </span> beforeResize : function(){
  415. this.resizer.minHeight = Math.max(this.minHeight, this.getFrameHeight() + 40); // 40 is a magic minimum content size?
  416. this.resizer.minWidth = Math.max(this.minWidth, this.getFrameWidth() + 40);
  417. this.resizeBox = this.el.getBox();
  418. },
  419. <span id='Ext-Window-method-updateHandles'> // private
  420. </span> updateHandles : function(){
  421. if(Ext.isIE9m &amp;&amp; this.resizer){
  422. this.resizer.syncHandleHeight();
  423. this.el.repaint();
  424. }
  425. },
  426. <span id='Ext-Window-method-handleResize'> // private
  427. </span> handleResize : function(box){
  428. var rz = this.resizeBox;
  429. if(rz.x != box.x || rz.y != box.y){
  430. this.updateBox(box);
  431. }else{
  432. this.setSize(box);
  433. if (Ext.isIE6 &amp;&amp; Ext.isStrict) {
  434. this.doLayout();
  435. }
  436. }
  437. this.focus();
  438. this.updateHandles();
  439. this.saveState();
  440. },
  441. <span id='Ext-Window-method-focus'> /**
  442. </span> * Focuses the window. If a defaultButton is set, it will receive focus, otherwise the
  443. * window itself will receive focus.
  444. */
  445. focus : function(){
  446. var f = this.focusEl,
  447. db = this.defaultButton,
  448. t = typeof db,
  449. el,
  450. ct;
  451. if(Ext.isDefined(db)){
  452. if(Ext.isNumber(db) &amp;&amp; this.fbar){
  453. f = this.fbar.items.get(db);
  454. }else if(Ext.isString(db)){
  455. f = Ext.getCmp(db);
  456. }else{
  457. f = db;
  458. }
  459. el = f.getEl();
  460. ct = Ext.getDom(this.container);
  461. if (el &amp;&amp; ct) {
  462. if (ct != document.body &amp;&amp; !Ext.lib.Region.getRegion(ct).contains(Ext.lib.Region.getRegion(el.dom))){
  463. return;
  464. }
  465. }
  466. }
  467. f = f || this.focusEl;
  468. f.focus.defer(10, f);
  469. },
  470. <span id='Ext-Window-method-setAnimateTarget'> /**
  471. </span> * Sets the target element from which the window should animate while opening.
  472. * @param {String/Element} el The target element or id
  473. */
  474. setAnimateTarget : function(el){
  475. el = Ext.get(el);
  476. this.animateTarget = el;
  477. },
  478. <span id='Ext-Window-method-beforeShow'> // private
  479. </span> beforeShow : function(){
  480. delete this.el.lastXY;
  481. delete this.el.lastLT;
  482. if(this.x === undefined || this.y === undefined){
  483. var xy = this.el.getAlignToXY(this.container, 'c-c');
  484. var pos = this.el.translatePoints(xy[0], xy[1]);
  485. this.x = this.x === undefined? pos.left : this.x;
  486. this.y = this.y === undefined? pos.top : this.y;
  487. }
  488. this.el.setLeftTop(this.x, this.y);
  489. if(this.expandOnShow){
  490. this.expand(false);
  491. }
  492. if(this.modal){
  493. Ext.getBody().addClass('x-body-masked');
  494. this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
  495. this.mask.show();
  496. }
  497. },
  498. <span id='Ext-Window-method-show'> /**
  499. </span> * Shows the window, rendering it first if necessary, or activates it and brings it to front if hidden.
  500. * @param {String/Element} animateTarget (optional) The target element or id from which the window should
  501. * animate while opening (defaults to null with no animation)
  502. * @param {Function} callback (optional) A callback function to call after the window is displayed
  503. * @param {Object} scope (optional) The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the callback is executed. Defaults to this Window.
  504. * @return {Ext.Window} this
  505. */
  506. show : function(animateTarget, cb, scope){
  507. if(!this.rendered){
  508. this.render(Ext.getBody());
  509. }
  510. if(this.hidden === false){
  511. this.toFront();
  512. return this;
  513. }
  514. if(this.fireEvent('beforeshow', this) === false){
  515. return this;
  516. }
  517. if(cb){
  518. this.on('show', cb, scope, {single:true});
  519. }
  520. this.hidden = false;
  521. if(Ext.isDefined(animateTarget)){
  522. this.setAnimateTarget(animateTarget);
  523. }
  524. this.beforeShow();
  525. if(this.animateTarget){
  526. this.animShow();
  527. }else{
  528. this.afterShow();
  529. }
  530. return this;
  531. },
  532. <span id='Ext-Window-method-afterShow'> // private
  533. </span> afterShow : function(isAnim){
  534. if (this.isDestroyed){
  535. return false;
  536. }
  537. this.proxy.hide();
  538. this.el.setStyle('display', 'block');
  539. this.el.show();
  540. if(this.maximized){
  541. this.fitContainer();
  542. }
  543. if(Ext.isMac &amp;&amp; Ext.isGecko2){ // work around stupid FF 2.0/Mac scroll bar bug
  544. this.cascade(this.setAutoScroll);
  545. }
  546. if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
  547. Ext.EventManager.onWindowResize(this.onWindowResize, this);
  548. }
  549. this.doConstrain();
  550. this.doLayout();
  551. if(this.keyMap){
  552. this.keyMap.enable();
  553. }
  554. this.toFront();
  555. this.updateHandles();
  556. if(isAnim &amp;&amp; (Ext.isIE || Ext.isWebKit)){
  557. var sz = this.getSize();
  558. this.onResize(sz.width, sz.height);
  559. }
  560. this.onShow();
  561. this.fireEvent('show', this);
  562. },
  563. <span id='Ext-Window-method-animShow'> // private
  564. </span> animShow : function(){
  565. this.proxy.show();
  566. this.proxy.setBox(this.animateTarget.getBox());
  567. this.proxy.setOpacity(0);
  568. var b = this.getBox();
  569. this.el.setStyle('display', 'none');
  570. this.proxy.shift(Ext.apply(b, {
  571. callback: this.afterShow.createDelegate(this, [true], false),
  572. scope: this,
  573. easing: 'easeNone',
  574. duration: this.showAnimDuration,
  575. opacity: 0.5
  576. }));
  577. },
  578. <span id='Ext-Window-method-hide'> /**
  579. </span> * Hides the window, setting it to invisible and applying negative offsets.
  580. * @param {String/Element} animateTarget (optional) The target element or id to which the window should
  581. * animate while hiding (defaults to null with no animation)
  582. * @param {Function} callback (optional) A callback function to call after the window is hidden
  583. * @param {Object} scope (optional) The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the callback is executed. Defaults to this Window.
  584. * @return {Ext.Window} this
  585. */
  586. hide : function(animateTarget, cb, scope){
  587. if(this.hidden || this.fireEvent('beforehide', this) === false){
  588. return this;
  589. }
  590. if(cb){
  591. this.on('hide', cb, scope, {single:true});
  592. }
  593. this.hidden = true;
  594. if(animateTarget !== undefined){
  595. this.setAnimateTarget(animateTarget);
  596. }
  597. if(this.modal){
  598. this.mask.hide();
  599. Ext.getBody().removeClass('x-body-masked');
  600. }
  601. if(this.animateTarget){
  602. this.animHide();
  603. }else{
  604. this.el.hide();
  605. this.afterHide();
  606. }
  607. return this;
  608. },
  609. <span id='Ext-Window-method-afterHide'> // private
  610. </span> afterHide : function(){
  611. this.proxy.hide();
  612. if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
  613. Ext.EventManager.removeResizeListener(this.onWindowResize, this);
  614. }
  615. if(this.keyMap){
  616. this.keyMap.disable();
  617. }
  618. this.onHide();
  619. this.fireEvent('hide', this);
  620. },
  621. <span id='Ext-Window-method-animHide'> // private
  622. </span> animHide : function(){
  623. this.proxy.setOpacity(0.5);
  624. this.proxy.show();
  625. var tb = this.getBox(false);
  626. this.proxy.setBox(tb);
  627. this.el.hide();
  628. this.proxy.shift(Ext.apply(this.animateTarget.getBox(), {
  629. callback: this.afterHide,
  630. scope: this,
  631. duration: this.hideAnimDuration,
  632. easing: 'easeNone',
  633. opacity: 0
  634. }));
  635. },
  636. <span id='Ext-Window-method-onShow'> /**
  637. </span> * Method that is called immediately before the &lt;code&gt;show&lt;/code&gt; event is fired.
  638. * Defaults to &lt;code&gt;Ext.emptyFn&lt;/code&gt;.
  639. */
  640. onShow : Ext.emptyFn,
  641. <span id='Ext-Window-method-onHide'> /**
  642. </span> * Method that is called immediately before the &lt;code&gt;hide&lt;/code&gt; event is fired.
  643. * Defaults to &lt;code&gt;Ext.emptyFn&lt;/code&gt;.
  644. */
  645. onHide : Ext.emptyFn,
  646. <span id='Ext-Window-method-onWindowResize'> // private
  647. </span> onWindowResize : function(){
  648. if(this.maximized){
  649. this.fitContainer();
  650. }
  651. if(this.modal){
  652. this.mask.setSize('100%', '100%');
  653. var force = this.mask.dom.offsetHeight;
  654. this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
  655. }
  656. this.doConstrain();
  657. },
  658. <span id='Ext-Window-method-doConstrain'> // private
  659. </span> doConstrain : function(){
  660. if(this.constrain || this.constrainHeader){
  661. var offsets;
  662. if(this.constrain){
  663. offsets = {
  664. right:this.el.shadowOffset,
  665. left:this.el.shadowOffset,
  666. bottom:this.el.shadowOffset
  667. };
  668. }else {
  669. var s = this.getSize();
  670. offsets = {
  671. right:-(s.width - 100),
  672. bottom:-(s.height - 25 + this.el.getConstrainOffset())
  673. };
  674. }
  675. var xy = this.el.getConstrainToXY(this.container, true, offsets);
  676. if(xy){
  677. this.setPosition(xy[0], xy[1]);
  678. }
  679. }
  680. },
  681. <span id='Ext-Window-method-ghost'> // private - used for dragging
  682. </span> ghost : function(cls){
  683. var ghost = this.createGhost(cls);
  684. var box = this.getBox(true);
  685. ghost.setLeftTop(box.x, box.y);
  686. ghost.setWidth(box.width);
  687. this.el.hide();
  688. this.activeGhost = ghost;
  689. return ghost;
  690. },
  691. <span id='Ext-Window-method-unghost'> // private
  692. </span> unghost : function(show, matchPosition){
  693. if(!this.activeGhost) {
  694. return;
  695. }
  696. if(show !== false){
  697. this.el.show();
  698. this.focus.defer(10, this);
  699. if(Ext.isMac &amp;&amp; Ext.isGecko2){ // work around stupid FF 2.0/Mac scroll bar bug
  700. this.cascade(this.setAutoScroll);
  701. }
  702. }
  703. if(matchPosition !== false){
  704. this.setPosition(this.activeGhost.getLeft(true), this.activeGhost.getTop(true));
  705. }
  706. this.activeGhost.hide();
  707. this.activeGhost.remove();
  708. delete this.activeGhost;
  709. },
  710. <span id='Ext-Window-method-minimize'> /**
  711. </span> * Placeholder method for minimizing the window. By default, this method simply fires the {@link #minimize} event
  712. * since the behavior of minimizing a window is application-specific. To implement custom minimize behavior,
  713. * either the minimize event can be handled or this method can be overridden.
  714. * @return {Ext.Window} this
  715. */
  716. minimize : function(){
  717. this.fireEvent('minimize', this);
  718. return this;
  719. },
  720. <span id='Ext-Window-method-close'> /**
  721. </span> * &lt;p&gt;Closes the Window, removes it from the DOM, {@link Ext.Component#destroy destroy}s
  722. * the Window object and all its descendant Components. The {@link Ext.Panel#beforeclose beforeclose}
  723. * event is fired before the close happens and will cancel the close action if it returns false.&lt;p&gt;
  724. * &lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; This method is not affected by the {@link #closeAction} setting which
  725. * only affects the action triggered when clicking the {@link #closable 'close' tool in the header}.
  726. * To hide the Window without destroying it, call {@link #hide}.&lt;/p&gt;
  727. */
  728. close : function(){
  729. if(this.fireEvent('beforeclose', this) !== false){
  730. if(this.hidden){
  731. this.doClose();
  732. }else{
  733. this.hide(null, this.doClose, this);
  734. }
  735. }
  736. },
  737. <span id='Ext-Window-method-doClose'> // private
  738. </span> doClose : function(){
  739. this.fireEvent('close', this);
  740. this.destroy();
  741. },
  742. <span id='Ext-Window-method-maximize'> /**
  743. </span> * Fits the window within its current container and automatically replaces
  744. * the {@link #maximizable 'maximize' tool button} with the 'restore' tool button.
  745. * Also see {@link #toggleMaximize}.
  746. * @return {Ext.Window} this
  747. */
  748. maximize : function(){
  749. if(!this.maximized){
  750. this.expand(false);
  751. this.restoreSize = this.getSize();
  752. this.restorePos = this.getPosition(true);
  753. if (this.maximizable){
  754. this.tools.maximize.hide();
  755. this.tools.restore.show();
  756. }
  757. this.maximized = true;
  758. this.el.disableShadow();
  759. if(this.dd){
  760. this.dd.lock();
  761. }
  762. if(this.collapsible){
  763. this.tools.toggle.hide();
  764. }
  765. this.el.addClass('x-window-maximized');
  766. this.container.addClass('x-window-maximized-ct');
  767. this.setPosition(0, 0);
  768. this.fitContainer();
  769. this.fireEvent('maximize', this);
  770. }
  771. return this;
  772. },
  773. <span id='Ext-Window-method-restore'> /**
  774. </span> * Restores a {@link #maximizable maximized} window back to its original
  775. * size and position prior to being maximized and also replaces
  776. * the 'restore' tool button with the 'maximize' tool button.
  777. * Also see {@link #toggleMaximize}.
  778. * @return {Ext.Window} this
  779. */
  780. restore : function(){
  781. if(this.maximized){
  782. var t = this.tools;
  783. this.el.removeClass('x-window-maximized');
  784. if(t.restore){
  785. t.restore.hide();
  786. }
  787. if(t.maximize){
  788. t.maximize.show();
  789. }
  790. this.setPosition(this.restorePos[0], this.restorePos[1]);
  791. this.setSize(this.restoreSize.width, this.restoreSize.height);
  792. delete this.restorePos;
  793. delete this.restoreSize;
  794. this.maximized = false;
  795. this.el.enableShadow(true);
  796. if(this.dd){
  797. this.dd.unlock();
  798. }
  799. if(this.collapsible &amp;&amp; t.toggle){
  800. t.toggle.show();
  801. }
  802. this.container.removeClass('x-window-maximized-ct');
  803. this.doConstrain();
  804. this.fireEvent('restore', this);
  805. }
  806. return this;
  807. },
  808. <span id='Ext-Window-method-toggleMaximize'> /**
  809. </span> * A shortcut method for toggling between {@link #maximize} and {@link #restore} based on the current maximized
  810. * state of the window.
  811. * @return {Ext.Window} this
  812. */
  813. toggleMaximize : function(){
  814. return this[this.maximized ? 'restore' : 'maximize']();
  815. },
  816. <span id='Ext-Window-method-fitContainer'> // private
  817. </span> fitContainer : function(){
  818. var vs = this.container.getViewSize(false);
  819. this.setSize(vs.width, vs.height);
  820. },
  821. <span id='Ext-Window-method-setZIndex'> // private
  822. </span> // z-index is managed by the WindowManager and may be overwritten at any time
  823. setZIndex : function(index){
  824. if(this.modal){
  825. this.mask.setStyle('z-index', index);
  826. }
  827. this.el.setZIndex(++index);
  828. index += 5;
  829. if(this.resizer){
  830. this.resizer.proxy.setStyle('z-index', ++index);
  831. }
  832. this.lastZIndex = index;
  833. },
  834. <span id='Ext-Window-method-alignTo'> /**
  835. </span> * Aligns the window to the specified element
  836. * @param {Mixed} element The element to align to.
  837. * @param {String} position (optional, defaults to &quot;tl-bl?&quot;) The position to align to (see {@link Ext.Element#alignTo} for more details).
  838. * @param {Array} offsets (optional) Offset the positioning by [x, y]
  839. * @return {Ext.Window} this
  840. */
  841. alignTo : function(element, position, offsets){
  842. var xy = this.el.getAlignToXY(element, position, offsets);
  843. this.setPagePosition(xy[0], xy[1]);
  844. return this;
  845. },
  846. <span id='Ext-Window-method-anchorTo'> /**
  847. </span> * Anchors this window to another element and realigns it when the window is resized or scrolled.
  848. * @param {Mixed} element The element to align to.
  849. * @param {String} position The position to align to (see {@link Ext.Element#alignTo} for more details)
  850. * @param {Array} offsets (optional) Offset the positioning by [x, y]
  851. * @param {Boolean/Number} monitorScroll (optional) true to monitor body scroll and reposition. If this parameter
  852. * is a number, it is used as the buffer delay (defaults to 50ms).
  853. * @return {Ext.Window} this
  854. */
  855. anchorTo : function(el, alignment, offsets, monitorScroll){
  856. this.clearAnchor();
  857. this.anchorTarget = {
  858. el: el,
  859. alignment: alignment,
  860. offsets: offsets
  861. };
  862. Ext.EventManager.onWindowResize(this.doAnchor, this);
  863. var tm = typeof monitorScroll;
  864. if(tm != 'undefined'){
  865. Ext.EventManager.on(window, 'scroll', this.doAnchor, this,
  866. {buffer: tm == 'number' ? monitorScroll : 50});
  867. }
  868. return this.doAnchor();
  869. },
  870. <span id='Ext-Window-method-doAnchor'> /**
  871. </span> * Performs the anchor, using the saved anchorTarget property.
  872. * @return {Ext.Window} this
  873. * @private
  874. */
  875. doAnchor : function(){
  876. var o = this.anchorTarget;
  877. this.alignTo(o.el, o.alignment, o.offsets);
  878. return this;
  879. },
  880. <span id='Ext-Window-method-clearAnchor'> /**
  881. </span> * Removes any existing anchor from this window. See {@link #anchorTo}.
  882. * @return {Ext.Window} this
  883. */
  884. clearAnchor : function(){
  885. if(this.anchorTarget){
  886. Ext.EventManager.removeResizeListener(this.doAnchor, this);
  887. Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
  888. delete this.anchorTarget;
  889. }
  890. return this;
  891. },
  892. <span id='Ext-Window-method-toFront'> /**
  893. </span> * Brings this window to the front of any other visible windows
  894. * @param {Boolean} e (optional) Specify &lt;tt&gt;false&lt;/tt&gt; to prevent the window from being focused.
  895. * @return {Ext.Window} this
  896. */
  897. toFront : function(e){
  898. if(this.manager.bringToFront(this)){
  899. if(!e || !e.getTarget().focus){
  900. this.focus();
  901. }
  902. }
  903. return this;
  904. },
  905. <span id='Ext-Window-method-setActive'> /**
  906. </span> * Makes this the active window by showing its shadow, or deactivates it by hiding its shadow. This method also
  907. * fires the {@link #activate} or {@link #deactivate} event depending on which action occurred. This method is
  908. * called internally by {@link Ext.WindowMgr}.
  909. * @param {Boolean} active True to activate the window, false to deactivate it (defaults to false)
  910. */
  911. setActive : function(active){
  912. if(active){
  913. if(!this.maximized){
  914. this.el.enableShadow(true);
  915. }
  916. this.fireEvent('activate', this);
  917. }else{
  918. this.el.disableShadow();
  919. this.fireEvent('deactivate', this);
  920. }
  921. },
  922. <span id='Ext-Window-method-toBack'> /**
  923. </span> * Sends this window to the back of (lower z-index than) any other visible windows
  924. * @return {Ext.Window} this
  925. */
  926. toBack : function(){
  927. this.manager.sendToBack(this);
  928. return this;
  929. },
  930. <span id='Ext-Window-method-center'> /**
  931. </span> * Centers this window in the viewport
  932. * @return {Ext.Window} this
  933. */
  934. center : function(){
  935. var xy = this.el.getAlignToXY(this.container, 'c-c');
  936. this.setPagePosition(xy[0], xy[1]);
  937. return this;
  938. }
  939. <span id='Ext-Window-cfg-autoWidth'> /**
  940. </span> * @cfg {Boolean} autoWidth @hide
  941. **/
  942. });
  943. Ext.reg('window', Ext.Window);
  944. // private - custom Window DD implementation
  945. Ext.Window.DD = Ext.extend(Ext.dd.DD, {
  946. constructor : function(win){
  947. this.win = win;
  948. Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id);
  949. this.setHandleElId(win.header.id);
  950. this.scroll = false;
  951. },
  952. moveOnly:true,
  953. headerOffsets:[100, 25],
  954. startDrag : function(){
  955. var w = this.win;
  956. this.proxy = w.ghost(w.initialConfig.cls);
  957. if(w.constrain !== false){
  958. var so = w.el.shadowOffset;
  959. this.constrainTo(w.container, {right: so, left: so, bottom: so});
  960. }else if(w.constrainHeader !== false){
  961. var s = this.proxy.getSize();
  962. this.constrainTo(w.container, {right: -(s.width-this.headerOffsets[0]), bottom: -(s.height-this.headerOffsets[1])});
  963. }
  964. },
  965. b4Drag : Ext.emptyFn,
  966. onDrag : function(e){
  967. this.alignElWithMouse(this.proxy, e.getPageX(), e.getPageY());
  968. },
  969. endDrag : function(e){
  970. this.win.unghost();
  971. this.win.saveState();
  972. }
  973. });
  974. </pre>
  975. </body>
  976. </html>