3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js"><div id="cls-Ext.Window"></div>/**
12 * <p>A specialized panel intended for use as an application window. Windows are floated, {@link #resizable}, and
13 * {@link #draggable} by default. Windows can be {@link #maximizable maximized} to fill the viewport,
14 * restored to their prior size, and can be {@link #minimize}d.</p>
15 * <p>Windows can also be linked to a {@link Ext.WindowGroup} or managed by the {@link Ext.WindowMgr} to provide
16 * grouping, activation, to front, to back and other application-specific behavior.</p>
17 * <p>By default, Windows will be rendered to document.body. To {@link #constrain} a Window to another element
18 * specify {@link Ext.Component#renderTo renderTo}.</p>
19 * <p><b>Note:</b> By default, the <code>{@link #closable close}</code> header tool <i>destroys</i> the Window resulting in
20 * destruction of any child Components. This makes the Window object, and all its descendants <b>unusable</b>. To enable
21 * re-use of a Window, use <b><code>{@link #closeAction closeAction: 'hide'}</code></b>.</p>
23 * @param {Object} config The config object
26 Ext.Window = Ext.extend(Ext.Panel, {
27 <div id="cfg-Ext.Window-x"></div>/**
29 * The X position of the left edge of the window on initial showing. Defaults to centering the Window within
30 * the width of the Window's container {@link Ext.Element Element) (The Element that the Window is rendered to).
32 <div id="cfg-Ext.Window-y"></div>/**
34 * The Y position of the top edge of the window on initial showing. Defaults to centering the Window within
35 * the height of the Window's container {@link Ext.Element Element) (The Element that the Window is rendered to).
37 <div id="cfg-Ext.Window-modal"></div>/**
38 * @cfg {Boolean} modal
39 * True to make the window modal and mask everything behind it when displayed, false to display it without
40 * restricting access to other UI elements (defaults to false).
42 <div id="cfg-Ext.Window-animateTarget"></div>/**
43 * @cfg {String/Element} animateTarget
44 * Id or element from which the window should animate while opening (defaults to null with no animation).
46 <div id="cfg-Ext.Window-resizeHandles"></div>/**
47 * @cfg {String} resizeHandles
48 * A valid {@link Ext.Resizable} handles config string (defaults to 'all'). Only applies when resizable = true.
50 <div id="cfg-Ext.Window-manager"></div>/**
51 * @cfg {Ext.WindowGroup} manager
52 * A reference to the WindowGroup that should manage this window (defaults to {@link Ext.WindowMgr}).
54 <div id="cfg-Ext.Window-defaultButton"></div>/**
55 * @cfg {String/Number/Component} defaultButton
56 * <p>Specifies a Component to receive focus when this Window is focussed.</p>
57 * <p>This may be one of:</p><div class="mdetail-params"><ul>
58 * <li>The index of a footer Button.</li>
59 * <li>The id of a Component.</li>
60 * <li>A Component.</li>
63 <div id="cfg-Ext.Window-onEsc"></div>/**
64 * @cfg {Function} onEsc
65 * Allows override of the built-in processing for the escape key. Default action
66 * is to close the Window (performing whatever action is specified in {@link #closeAction}.
67 * To prevent the Window closing when the escape key is pressed, specify this as
68 * Ext.emptyFn (See {@link Ext#emptyFn}).
70 <div id="cfg-Ext.Window-collapsed"></div>/**
71 * @cfg {Boolean} collapsed
72 * True to render the window collapsed, false to render it expanded (defaults to false). Note that if
73 * {@link #expandOnShow} is true (the default) it will override the <tt>collapsed</tt> config and the window
74 * will always be expanded when shown.
76 <div id="cfg-Ext.Window-maximized"></div>/**
77 * @cfg {Boolean} maximized
78 * True to initially display the window in a maximized state. (Defaults to false).
81 <div id="cfg-Ext.Window-baseCls"></div>/**
82 * @cfg {String} baseCls
83 * The base CSS class to apply to this panel's element (defaults to 'x-window').
86 <div id="cfg-Ext.Window-resizable"></div>/**
87 * @cfg {Boolean} resizable
88 * True to allow user resizing at each edge and corner of the window, false to disable resizing (defaults to true).
91 <div id="cfg-Ext.Window-draggable"></div>/**
92 * @cfg {Boolean} draggable
93 * True to allow the window to be dragged by the header bar, false to disable dragging (defaults to true). Note
94 * that by default the window will be centered in the viewport, so if dragging is disabled the window may need
95 * to be positioned programmatically after render (e.g., myWindow.setPosition(100, 100);).
98 <div id="cfg-Ext.Window-closable"></div>/**
99 * @cfg {Boolean} closable
100 * <p>True to display the 'close' tool button and allow the user to close the window, false to
101 * hide the button and disallow closing the window (defaults to true).</p>
102 * <p>By default, when close is requested by either clicking the close button in the header
103 * or pressing ESC when the Window has focus, the {@link #close} method will be called. This
104 * will <i>{@link Ext.Component#destroy destroy}</i> the Window and its content meaning that
105 * it may not be reused.</p>
106 * <p>To make closing a Window <i>hide</i> the Window so that it may be reused, set
107 * {@link #closeAction} to 'hide'.
110 <div id="cfg-Ext.Window-closeAction"></div>/**
111 * @cfg {String} closeAction
112 * <p>The action to take when the close header tool is clicked:
113 * <div class="mdetail-params"><ul>
114 * <li><b><code>'{@link #close}'</code></b> : <b>Default</b><div class="sub-desc">
115 * {@link #close remove} the window from the DOM and {@link Ext.Component#destroy destroy}
116 * it and all descendant Components. The window will <b>not</b> be available to be
117 * redisplayed via the {@link #show} method.
119 * <li><b><code>'{@link #hide}'</code></b> : <div class="sub-desc">
120 * {@link #hide} the window by setting visibility to hidden and applying negative offsets.
121 * The window will be available to be redisplayed via the {@link #show} method.
124 * <p><b>Note:</b> This setting does not affect the {@link #close} method
125 * which will always {@link Ext.Component#destroy destroy} the window. To
126 * programatically <i>hide</i> a window, call {@link #hide}.</p>
128 closeAction : 'close',
129 <div id="cfg-Ext.Window-constrain"></div>/**
130 * @cfg {Boolean} constrain
131 * True to constrain the window within its containing element, false to allow it to fall outside of its
132 * containing element. By default the window will be rendered to document.body. To render and constrain the
133 * window within another element specify {@link #renderTo}.
134 * (defaults to false). Optionally the header only can be constrained using {@link #constrainHeader}.
137 <div id="cfg-Ext.Window-constrainHeader"></div>/**
138 * @cfg {Boolean} constrainHeader
139 * True to constrain the window header within its containing element (allowing the window body to fall outside
140 * of its containing element) or false to allow the header to fall outside its containing element (defaults to
141 * false). Optionally the entire window can be constrained using {@link #constrain}.
143 constrainHeader : false,
144 <div id="cfg-Ext.Window-plain"></div>/**
145 * @cfg {Boolean} plain
146 * True to render the window body with a transparent background so that it will blend into the framing
147 * elements, false to add a lighter background color to visually highlight the body element and separate it
148 * more distinctly from the surrounding frame (defaults to false).
151 <div id="cfg-Ext.Window-minimizable"></div>/**
152 * @cfg {Boolean} minimizable
153 * True to display the 'minimize' tool button and allow the user to minimize the window, false to hide the button
154 * and disallow minimizing the window (defaults to false). Note that this button provides no implementation --
155 * the behavior of minimizing a window is implementation-specific, so the minimize event must be handled and a
156 * custom minimize behavior implemented for this option to be useful.
159 <div id="cfg-Ext.Window-maximizable"></div>/**
160 * @cfg {Boolean} maximizable
161 * True to display the 'maximize' tool button and allow the user to maximize the window, false to hide the button
162 * and disallow maximizing the window (defaults to false). Note that when a window is maximized, the tool button
163 * will automatically change to a 'restore' button with the appropriate behavior already built-in that will
164 * restore the window to its previous size.
167 <div id="cfg-Ext.Window-minHeight"></div>/**
168 * @cfg {Number} minHeight
169 * The minimum height in pixels allowed for this window (defaults to 100). Only applies when resizable = true.
172 <div id="cfg-Ext.Window-minWidth"></div>/**
173 * @cfg {Number} minWidth
174 * The minimum width in pixels allowed for this window (defaults to 200). Only applies when resizable = true.
177 <div id="cfg-Ext.Window-expandOnShow"></div>/**
178 * @cfg {Boolean} expandOnShow
179 * True to always expand the window when it is displayed, false to keep it in its current state (which may be
180 * {@link #collapsed}) when displayed (defaults to true).
184 // inherited docs, same default
187 <div id="cfg-Ext.Window-initHidden"></div>/**
188 * @cfg {Boolean} initHidden
189 * True to hide the window until show() is explicitly called (defaults to true).
192 initHidden : undefined,
194 <div id="cfg-Ext.Window-hidden"></div>/**
195 * @cfg {Boolean} hidden
196 * Render this component hidden (default is <tt>true</tt>). If <tt>true</tt>, the
197 * {@link #hide} method will be called internally.
201 <div id="cfg-Ext.Window-monitorResize"></div>/**
202 * @cfg {Boolean} monitorResize @hide
203 * This is automatically managed based on the value of constrain and constrainToHeader
205 monitorResize : true,
207 // The following configs are set to provide the basic functionality of a window.
208 // Changing them would require additional code to handle correctly and should
209 // usually only be done in subclasses that can provide custom behavior. Changing them
210 // may have unexpected or undesirable results.
211 <div id="cfg-Ext.Window-elements"></div>/** @cfg {String} elements @hide */
212 elements : 'header,body',
213 <div id="cfg-Ext.Window-frame"></div>/** @cfg {Boolean} frame @hide */
215 <div id="cfg-Ext.Window-floating"></div>/** @cfg {Boolean} floating @hide */
219 initComponent : function(){
221 Ext.Window.superclass.initComponent.call(this);
223 <div id="event-Ext.Window-activate"></div>/**
225 * Fires after the window has been visually activated via {@link #setActive}.
226 * @param {Ext.Window} this
228 <div id="event-Ext.Window-deactivate"></div>/**
230 * Fires after the window has been visually deactivated via {@link #setActive}.
231 * @param {Ext.Window} this
233 <div id="event-Ext.Window-resize"></div>/**
235 * Fires after the window has been resized.
236 * @param {Ext.Window} this
237 * @param {Number} width The window's new width
238 * @param {Number} height The window's new height
241 <div id="event-Ext.Window-maximize"></div>/**
243 * Fires after the window has been maximized.
244 * @param {Ext.Window} this
247 <div id="event-Ext.Window-minimize"></div>/**
249 * Fires after the window has been minimized.
250 * @param {Ext.Window} this
253 <div id="event-Ext.Window-restore"></div>/**
255 * Fires after the window has been restored to its original size after being maximized.
256 * @param {Ext.Window} this
260 // for backwards compat, this should be removed at some point
261 if(Ext.isDefined(this.initHidden)){
262 this.hidden = this.initHidden;
264 if(this.hidden === false){
271 getState : function(){
272 return Ext.apply(Ext.Window.superclass.getState.call(this) || {}, this.getBox(true));
276 onRender : function(ct, position){
277 Ext.Window.superclass.onRender.call(this, ct, position);
280 this.el.addClass('x-window-plain');
283 // this element allows the Window to be focused for keyboard events
284 this.focusEl = this.el.createChild({
285 tag: 'a', href:'#', cls:'x-dlg-focus',
286 tabIndex:'-1', html: ' '});
287 this.focusEl.swallowEvent('click', true);
289 this.proxy = this.el.createProxy('x-window-proxy');
290 this.proxy.enableDisplayMode('block');
293 this.mask = this.container.createChild({cls:'ext-el-mask'}, this.el.dom);
294 this.mask.enableDisplayMode('block');
296 this.mon(this.mask, 'click', this.focus, this);
298 if(this.maximizable){
299 this.mon(this.header, 'dblclick', this.toggleMaximize, this);
304 initEvents : function(){
305 Ext.Window.superclass.initEvents.call(this);
306 if(this.animateTarget){
307 this.setAnimateTarget(this.animateTarget);
311 this.resizer = new Ext.Resizable(this.el, {
312 minWidth: this.minWidth,
313 minHeight:this.minHeight,
314 handles: this.resizeHandles || 'all',
316 resizeElement : this.resizerAction
318 this.resizer.window = this;
319 this.mon(this.resizer, 'beforeresize', this.beforeResize, this);
323 this.header.addClass('x-window-draggable');
325 this.mon(this.el, 'mousedown', this.toFront, this);
326 this.manager = this.manager || Ext.WindowMgr;
327 this.manager.register(this);
329 this.maximized = false;
333 var km = this.getKeyMap();
334 km.on(27, this.onEsc, this);
339 initDraggable : function(){
340 <div id="prop-Ext.Window-dd"></div>/**
341 * If this Window is configured {@link #draggable}, this property will contain
342 * an instance of {@link Ext.dd.DD} which handles dragging the Window's DOM Element.
346 this.dd = new Ext.Window.DD(this);
351 this[this.closeAction]();
355 beforeDestroy : function(){
359 Ext.EventManager.removeResizeListener(this.doAnchor, this);
360 Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
370 Ext.Window.superclass.beforeDestroy.call(this);
374 onDestroy : function(){
376 this.manager.unregister(this);
378 Ext.Window.superclass.onDestroy.call(this);
382 initTools : function(){
383 if(this.minimizable){
386 handler: this.minimize.createDelegate(this, [])
389 if(this.maximizable){
392 handler: this.maximize.createDelegate(this, [])
396 handler: this.restore.createDelegate(this, []),
403 handler: this[this.closeAction].createDelegate(this, [])
409 resizerAction : function(){
410 var box = this.proxy.getBox();
412 this.window.handleResize(box);
417 beforeResize : function(){
418 this.resizer.minHeight = Math.max(this.minHeight, this.getFrameHeight() + 40); // 40 is a magic minimum content size?
419 this.resizer.minWidth = Math.max(this.minWidth, this.getFrameWidth() + 40);
420 this.resizeBox = this.el.getBox();
424 updateHandles : function(){
425 if(Ext.isIE && this.resizer){
426 this.resizer.syncHandleHeight();
432 handleResize : function(box){
433 var rz = this.resizeBox;
434 if(rz.x != box.x || rz.y != box.y){
440 this.updateHandles();
444 <div id="method-Ext.Window-focus"></div>/**
445 * Focuses the window. If a defaultButton is set, it will receive focus, otherwise the
446 * window itself will receive focus.
449 var f = this.focusEl, db = this.defaultButton, t = typeof db;
450 if(Ext.isDefined(db)){
451 if(Ext.isNumber(db) && this.fbar){
452 f = this.fbar.items.get(db);
453 }else if(Ext.isString(db)){
459 f = f || this.focusEl;
460 f.focus.defer(10, f);
463 <div id="method-Ext.Window-setAnimateTarget"></div>/**
464 * Sets the target element from which the window should animate while opening.
465 * @param {String/Element} el The target element or id
467 setAnimateTarget : function(el){
469 this.animateTarget = el;
473 beforeShow : function(){
474 delete this.el.lastXY;
475 delete this.el.lastLT;
476 if(this.x === undefined || this.y === undefined){
477 var xy = this.el.getAlignToXY(this.container, 'c-c');
478 var pos = this.el.translatePoints(xy[0], xy[1]);
479 this.x = this.x === undefined? pos.left : this.x;
480 this.y = this.y === undefined? pos.top : this.y;
482 this.el.setLeftTop(this.x, this.y);
484 if(this.expandOnShow){
489 Ext.getBody().addClass('x-body-masked');
490 this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
495 <div id="method-Ext.Window-show"></div>/**
496 * Shows the window, rendering it first if necessary, or activates it and brings it to front if hidden.
497 * @param {String/Element} animateTarget (optional) The target element or id from which the window should
498 * animate while opening (defaults to null with no animation)
499 * @param {Function} callback (optional) A callback function to call after the window is displayed
500 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this Window.
501 * @return {Ext.Window} this
503 show : function(animateTarget, cb, scope){
505 this.render(Ext.getBody());
507 if(this.hidden === false){
511 if(this.fireEvent('beforeshow', this) === false){
515 this.on('show', cb, scope, {single:true});
518 if(Ext.isDefined(animateTarget)){
519 this.setAnimateTarget(animateTarget);
522 if(this.animateTarget){
531 afterShow : function(isAnim){
533 this.el.setStyle('display', 'block');
538 if(Ext.isMac && Ext.isGecko2){ // work around stupid FF 2.0/Mac scroll bar bug
539 this.cascade(this.setAutoScroll);
542 if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
543 Ext.EventManager.onWindowResize(this.onWindowResize, this);
548 this.keyMap.enable();
551 this.updateHandles();
552 if(isAnim && (Ext.isIE || Ext.isWebKit)){
553 var sz = this.getSize();
554 this.onResize(sz.width, sz.height);
557 this.fireEvent('show', this);
561 animShow : function(){
563 this.proxy.setBox(this.animateTarget.getBox());
564 this.proxy.setOpacity(0);
565 var b = this.getBox();
566 this.el.setStyle('display', 'none');
567 this.proxy.shift(Ext.apply(b, {
568 callback: this.afterShow.createDelegate(this, [true], false),
576 <div id="method-Ext.Window-hide"></div>/**
577 * Hides the window, setting it to invisible and applying negative offsets.
578 * @param {String/Element} animateTarget (optional) The target element or id to which the window should
579 * animate while hiding (defaults to null with no animation)
580 * @param {Function} callback (optional) A callback function to call after the window is hidden
581 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this Window.
582 * @return {Ext.Window} this
584 hide : function(animateTarget, cb, scope){
585 if(this.hidden || this.fireEvent('beforehide', this) === false){
589 this.on('hide', cb, scope, {single:true});
592 if(animateTarget !== undefined){
593 this.setAnimateTarget(animateTarget);
597 Ext.getBody().removeClass('x-body-masked');
599 if(this.animateTarget){
609 afterHide : function(){
611 if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
612 Ext.EventManager.removeResizeListener(this.onWindowResize, this);
615 this.keyMap.disable();
618 this.fireEvent('hide', this);
622 animHide : function(){
623 this.proxy.setOpacity(0.5);
625 var tb = this.getBox(false);
626 this.proxy.setBox(tb);
628 this.proxy.shift(Ext.apply(this.animateTarget.getBox(), {
629 callback: this.afterHide,
637 <div id="prop-Ext.Window-onShow"></div>/**
638 * Method that is called immediately before the <code>show</code> event is fired.
639 * Defaults to <code>Ext.emptyFn</code>.
641 onShow : Ext.emptyFn,
643 <div id="prop-Ext.Window-onHide"></div>/**
644 * Method that is called immediately before the <code>hide</code> event is fired.
645 * Defaults to <code>Ext.emptyFn</code>.
647 onHide : Ext.emptyFn,
650 onWindowResize : function(){
655 this.mask.setSize('100%', '100%');
656 var force = this.mask.dom.offsetHeight;
657 this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
663 doConstrain : function(){
664 if(this.constrain || this.constrainHeader){
668 right:this.el.shadowOffset,
669 left:this.el.shadowOffset,
670 bottom:this.el.shadowOffset
673 var s = this.getSize();
675 right:-(s.width - 100),
676 bottom:-(s.height - 25)
680 var xy = this.el.getConstrainToXY(this.container, true, offsets);
682 this.setPosition(xy[0], xy[1]);
687 // private - used for dragging
688 ghost : function(cls){
689 var ghost = this.createGhost(cls);
690 var box = this.getBox(true);
691 ghost.setLeftTop(box.x, box.y);
692 ghost.setWidth(box.width);
694 this.activeGhost = ghost;
699 unghost : function(show, matchPosition){
700 if(!this.activeGhost) {
706 if(Ext.isMac && Ext.isGecko2){ // work around stupid FF 2.0/Mac scroll bar bug
707 this.cascade(this.setAutoScroll);
710 if(matchPosition !== false){
711 this.setPosition(this.activeGhost.getLeft(true), this.activeGhost.getTop(true));
713 this.activeGhost.hide();
714 this.activeGhost.remove();
715 delete this.activeGhost;
718 <div id="method-Ext.Window-minimize"></div>/**
719 * Placeholder method for minimizing the window. By default, this method simply fires the {@link #minimize} event
720 * since the behavior of minimizing a window is application-specific. To implement custom minimize behavior,
721 * either the minimize event can be handled or this method can be overridden.
722 * @return {Ext.Window} this
724 minimize : function(){
725 this.fireEvent('minimize', this);
729 <div id="method-Ext.Window-close"></div>/**
730 * <p>Closes the Window, removes it from the DOM, {@link Ext.Component#destroy destroy}s
731 * the Window object and all its descendant Components. The {@link Ext.Panel#beforeclose beforeclose}
732 * event is fired before the close happens and will cancel the close action if it returns false.<p>
733 * <p><b>Note:</b> This method is not affected by the {@link #closeAction} setting which
734 * only affects the action triggered when clicking the {@link #closable 'close' tool in the header}.
735 * To hide the Window without destroying it, call {@link #hide}.</p>
738 if(this.fireEvent('beforeclose', this) !== false){
742 this.hide(null, this.doClose, this);
748 doClose : function(){
749 this.fireEvent('close', this);
753 <div id="method-Ext.Window-maximize"></div>/**
754 * Fits the window within its current container and automatically replaces
755 * the {@link #maximizable 'maximize' tool button} with the 'restore' tool button.
756 * Also see {@link #toggleMaximize}.
757 * @return {Ext.Window} this
759 maximize : function(){
762 this.restoreSize = this.getSize();
763 this.restorePos = this.getPosition(true);
764 if (this.maximizable){
765 this.tools.maximize.hide();
766 this.tools.restore.show();
768 this.maximized = true;
769 this.el.disableShadow();
774 if(this.collapsible){
775 this.tools.toggle.hide();
777 this.el.addClass('x-window-maximized');
778 this.container.addClass('x-window-maximized-ct');
780 this.setPosition(0, 0);
782 this.fireEvent('maximize', this);
787 <div id="method-Ext.Window-restore"></div>/**
788 * Restores a {@link #maximizable maximized} window back to its original
789 * size and position prior to being maximized and also replaces
790 * the 'restore' tool button with the 'maximize' tool button.
791 * Also see {@link #toggleMaximize}.
792 * @return {Ext.Window} this
794 restore : function(){
797 this.el.removeClass('x-window-maximized');
804 this.setPosition(this.restorePos[0], this.restorePos[1]);
805 this.setSize(this.restoreSize.width, this.restoreSize.height);
806 delete this.restorePos;
807 delete this.restoreSize;
808 this.maximized = false;
809 this.el.enableShadow(true);
814 if(this.collapsible && t.toggle){
817 this.container.removeClass('x-window-maximized-ct');
820 this.fireEvent('restore', this);
825 <div id="method-Ext.Window-toggleMaximize"></div>/**
826 * A shortcut method for toggling between {@link #maximize} and {@link #restore} based on the current maximized
827 * state of the window.
828 * @return {Ext.Window} this
830 toggleMaximize : function(){
831 return this[this.maximized ? 'restore' : 'maximize']();
835 fitContainer : function(){
836 var vs = this.container.getViewSize(false);
837 this.setSize(vs.width, vs.height);
841 // z-index is managed by the WindowManager and may be overwritten at any time
842 setZIndex : function(index){
844 this.mask.setStyle('z-index', index);
846 this.el.setZIndex(++index);
850 this.resizer.proxy.setStyle('z-index', ++index);
853 this.lastZIndex = index;
856 <div id="method-Ext.Window-alignTo"></div>/**
857 * Aligns the window to the specified element
858 * @param {Mixed} element The element to align to.
859 * @param {String} position (optional, defaults to "tl-bl?") The position to align to (see {@link Ext.Element#alignTo} for more details).
860 * @param {Array} offsets (optional) Offset the positioning by [x, y]
861 * @return {Ext.Window} this
863 alignTo : function(element, position, offsets){
864 var xy = this.el.getAlignToXY(element, position, offsets);
865 this.setPagePosition(xy[0], xy[1]);
869 <div id="method-Ext.Window-anchorTo"></div>/**
870 * Anchors this window to another element and realigns it when the window is resized or scrolled.
871 * @param {Mixed} element The element to align to.
872 * @param {String} position The position to align to (see {@link Ext.Element#alignTo} for more details)
873 * @param {Array} offsets (optional) Offset the positioning by [x, y]
874 * @param {Boolean/Number} monitorScroll (optional) true to monitor body scroll and reposition. If this parameter
875 * is a number, it is used as the buffer delay (defaults to 50ms).
876 * @return {Ext.Window} this
878 anchorTo : function(el, alignment, offsets, monitorScroll){
880 Ext.EventManager.removeResizeListener(this.doAnchor, this);
881 Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
883 this.doAnchor = function(){
884 this.alignTo(el, alignment, offsets);
886 Ext.EventManager.onWindowResize(this.doAnchor, this);
888 var tm = typeof monitorScroll;
889 if(tm != 'undefined'){
890 Ext.EventManager.on(window, 'scroll', this.doAnchor, this,
891 {buffer: tm == 'number' ? monitorScroll : 50});
897 <div id="method-Ext.Window-toFront"></div>/**
898 * Brings this window to the front of any other visible windows
899 * @param {Boolean} e (optional) Specify <tt>false</tt> to prevent the window from being focused.
900 * @return {Ext.Window} this
902 toFront : function(e){
903 if(this.manager.bringToFront(this)){
904 if(!e || !e.getTarget().focus){
911 <div id="method-Ext.Window-setActive"></div>/**
912 * Makes this the active window by showing its shadow, or deactivates it by hiding its shadow. This method also
913 * fires the {@link #activate} or {@link #deactivate} event depending on which action occurred. This method is
914 * called internally by {@link Ext.WindowMgr}.
915 * @param {Boolean} active True to activate the window, false to deactivate it (defaults to false)
917 setActive : function(active){
920 this.el.enableShadow(true);
922 this.fireEvent('activate', this);
924 this.el.disableShadow();
925 this.fireEvent('deactivate', this);
929 <div id="method-Ext.Window-toBack"></div>/**
930 * Sends this window to the back of (lower z-index than) any other visible windows
931 * @return {Ext.Window} this
934 this.manager.sendToBack(this);
938 <div id="method-Ext.Window-center"></div>/**
939 * Centers this window in the viewport
940 * @return {Ext.Window} this
943 var xy = this.el.getAlignToXY(this.container, 'c-c');
944 this.setPagePosition(xy[0], xy[1]);
948 <div id="cfg-Ext.Window-autoWidth"></div>/**
949 * @cfg {Boolean} autoWidth @hide
952 Ext.reg('window', Ext.Window);
954 // private - custom Window DD implementation
955 Ext.Window.DD = function(win){
957 Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id);
958 this.setHandleElId(win.header.id);
962 Ext.extend(Ext.Window.DD, Ext.dd.DD, {
964 headerOffsets:[100, 25],
965 startDrag : function(){
967 this.proxy = w.ghost();
968 if(w.constrain !== false){
969 var so = w.el.shadowOffset;
970 this.constrainTo(w.container, {right: so, left: so, bottom: so});
971 }else if(w.constrainHeader !== false){
972 var s = this.proxy.getSize();
973 this.constrainTo(w.container, {right: -(s.width-this.headerOffsets[0]), bottom: -(s.height-this.headerOffsets[1])});
976 b4Drag : Ext.emptyFn,
978 onDrag : function(e){
979 this.alignElWithMouse(this.proxy, e.getPageX(), e.getPageY());
982 endDrag : function(e){
984 this.win.saveState();