3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
10 * <p>A specialized panel intended for use as an application window. Windows are floated, {@link #resizable}, and
11 * {@link #draggable} by default. Windows can be {@link #maximizable maximized} to fill the viewport,
12 * restored to their prior size, and can be {@link #minimize}d.</p>
13 * <p>Windows can also be linked to a {@link Ext.WindowGroup} or managed by the {@link Ext.WindowMgr} to provide
14 * grouping, activation, to front, to back and other application-specific behavior.</p>
15 * <p>By default, Windows will be rendered to document.body. To {@link #constrain} a Window to another element
16 * specify {@link Ext.Component#renderTo renderTo}.</p>
17 * <p><b>Note:</b> By default, the <code>{@link #closable close}</code> header tool <i>destroys</i> the Window resulting in
18 * destruction of any child Components. This makes the Window object, and all its descendants <b>unusable</b>. To enable
19 * re-use of a Window, use <b><code>{@link #closeAction closeAction: 'hide'}</code></b>.</p>
21 * @param {Object} config The config object
24 Ext.Window = Ext.extend(Ext.Panel, {
27 * The X position of the left edge of the window on initial showing. Defaults to centering the Window within
28 * the width of the Window's container {@link Ext.Element Element) (The Element that the Window is rendered to).
32 * The Y position of the top edge of the window on initial showing. Defaults to centering the Window within
33 * the height of the Window's container {@link Ext.Element Element) (The Element that the Window is rendered to).
36 * @cfg {Boolean} modal
37 * True to make the window modal and mask everything behind it when displayed, false to display it without
38 * restricting access to other UI elements (defaults to false).
41 * @cfg {String/Element} animateTarget
42 * Id or element from which the window should animate while opening (defaults to null with no animation).
45 * @cfg {String} resizeHandles
46 * A valid {@link Ext.Resizable} handles config string (defaults to 'all'). Only applies when resizable = true.
49 * @cfg {Ext.WindowGroup} manager
50 * A reference to the WindowGroup that should manage this window (defaults to {@link Ext.WindowMgr}).
53 * @cfg {String/Number/Component} defaultButton
54 * <p>Specifies a Component to receive focus when this Window is focussed.</p>
55 * <p>This may be one of:</p><div class="mdetail-params"><ul>
56 * <li>The index of a footer Button.</li>
57 * <li>The id of a Component.</li>
58 * <li>A Component.</li>
62 * @cfg {Function} onEsc
63 * Allows override of the built-in processing for the escape key. Default action
64 * is to close the Window (performing whatever action is specified in {@link #closeAction}.
65 * To prevent the Window closing when the escape key is pressed, specify this as
66 * Ext.emptyFn (See {@link Ext#emptyFn}).
69 * @cfg {Boolean} collapsed
70 * True to render the window collapsed, false to render it expanded (defaults to false). Note that if
71 * {@link #expandOnShow} is true (the default) it will override the <tt>collapsed</tt> config and the window
72 * will always be expanded when shown.
75 * @cfg {Boolean} maximized
76 * True to initially display the window in a maximized state. (Defaults to false).
80 * @cfg {String} baseCls
81 * The base CSS class to apply to this panel's element (defaults to 'x-window').
85 * @cfg {Boolean} resizable
86 * True to allow user resizing at each edge and corner of the window, false to disable resizing (defaults to true).
90 * @cfg {Boolean} draggable
91 * True to allow the window to be dragged by the header bar, false to disable dragging (defaults to true). Note
92 * that by default the window will be centered in the viewport, so if dragging is disabled the window may need
93 * to be positioned programmatically after render (e.g., myWindow.setPosition(100, 100);).
97 * @cfg {Boolean} closable
98 * <p>True to display the 'close' tool button and allow the user to close the window, false to
99 * hide the button and disallow closing the window (defaults to true).</p>
100 * <p>By default, when close is requested by either clicking the close button in the header
101 * or pressing ESC when the Window has focus, the {@link #close} method will be called. This
102 * will <i>{@link Ext.Component#destroy destroy}</i> the Window and its content meaning that
103 * it may not be reused.</p>
104 * <p>To make closing a Window <i>hide</i> the Window so that it may be reused, set
105 * {@link #closeAction} to 'hide'.
109 * @cfg {String} closeAction
110 * <p>The action to take when the close header tool is clicked:
111 * <div class="mdetail-params"><ul>
112 * <li><b><code>'{@link #close}'</code></b> : <b>Default</b><div class="sub-desc">
113 * {@link #close remove} the window from the DOM and {@link Ext.Component#destroy destroy}
114 * it and all descendant Components. The window will <b>not</b> be available to be
115 * redisplayed via the {@link #show} method.
117 * <li><b><code>'{@link #hide}'</code></b> : <div class="sub-desc">
118 * {@link #hide} the window by setting visibility to hidden and applying negative offsets.
119 * The window will be available to be redisplayed via the {@link #show} method.
122 * <p><b>Note:</b> This setting does not affect the {@link #close} method
123 * which will always {@link Ext.Component#destroy destroy} the window. To
124 * programatically <i>hide</i> a window, call {@link #hide}.</p>
126 closeAction : 'close',
128 * @cfg {Boolean} constrain
129 * True to constrain the window within its containing element, false to allow it to fall outside of its
130 * containing element. By default the window will be rendered to document.body. To render and constrain the
131 * window within another element specify {@link #renderTo}.
132 * (defaults to false). Optionally the header only can be constrained using {@link #constrainHeader}.
136 * @cfg {Boolean} constrainHeader
137 * True to constrain the window header within its containing element (allowing the window body to fall outside
138 * of its containing element) or false to allow the header to fall outside its containing element (defaults to
139 * false). Optionally the entire window can be constrained using {@link #constrain}.
141 constrainHeader : false,
143 * @cfg {Boolean} plain
144 * True to render the window body with a transparent background so that it will blend into the framing
145 * elements, false to add a lighter background color to visually highlight the body element and separate it
146 * more distinctly from the surrounding frame (defaults to false).
150 * @cfg {Boolean} minimizable
151 * True to display the 'minimize' tool button and allow the user to minimize the window, false to hide the button
152 * and disallow minimizing the window (defaults to false). Note that this button provides no implementation --
153 * the behavior of minimizing a window is implementation-specific, so the minimize event must be handled and a
154 * custom minimize behavior implemented for this option to be useful.
158 * @cfg {Boolean} maximizable
159 * True to display the 'maximize' tool button and allow the user to maximize the window, false to hide the button
160 * and disallow maximizing the window (defaults to false). Note that when a window is maximized, the tool button
161 * will automatically change to a 'restore' button with the appropriate behavior already built-in that will
162 * restore the window to its previous size.
166 * @cfg {Number} minHeight
167 * The minimum height in pixels allowed for this window (defaults to 100). Only applies when resizable = true.
171 * @cfg {Number} minWidth
172 * The minimum width in pixels allowed for this window (defaults to 200). Only applies when resizable = true.
176 * @cfg {Boolean} expandOnShow
177 * True to always expand the window when it is displayed, false to keep it in its current state (which may be
178 * {@link #collapsed}) when displayed (defaults to true).
183 * @cfg {Number} showAnimDuration The number of seconds that the window show animation takes if enabled.
186 showAnimDuration: 0.25,
189 * @cfg {Number} hideAnimDuration The number of seconds that the window hide animation takes if enabled.
192 hideAnimDuration: 0.25,
194 // inherited docs, same default
198 * @cfg {Boolean} initHidden
199 * True to hide the window until show() is explicitly called (defaults to true).
202 initHidden : undefined,
205 * @cfg {Boolean} hidden
206 * Render this component hidden (default is <tt>true</tt>). If <tt>true</tt>, the
207 * {@link #hide} method will be called internally.
211 // The following configs are set to provide the basic functionality of a window.
212 // Changing them would require additional code to handle correctly and should
213 // usually only be done in subclasses that can provide custom behavior. Changing them
214 // may have unexpected or undesirable results.
215 /** @cfg {String} elements @hide */
216 elements : 'header,body',
217 /** @cfg {Boolean} frame @hide */
219 /** @cfg {Boolean} floating @hide */
223 initComponent : function(){
225 Ext.Window.superclass.initComponent.call(this);
229 * Fires after the window has been visually activated via {@link #setActive}.
230 * @param {Ext.Window} this
234 * Fires after the window has been visually deactivated via {@link #setActive}.
235 * @param {Ext.Window} this
239 * Fires after the window has been resized.
240 * @param {Ext.Window} this
241 * @param {Number} width The window's new width
242 * @param {Number} height The window's new height
247 * Fires after the window has been maximized.
248 * @param {Ext.Window} this
253 * Fires after the window has been minimized.
254 * @param {Ext.Window} this
259 * Fires after the window has been restored to its original size after being maximized.
260 * @param {Ext.Window} this
264 // for backwards compat, this should be removed at some point
265 if(Ext.isDefined(this.initHidden)){
266 this.hidden = this.initHidden;
268 if(this.hidden === false){
275 getState : function(){
276 return Ext.apply(Ext.Window.superclass.getState.call(this) || {}, this.getBox(true));
280 onRender : function(ct, position){
281 Ext.Window.superclass.onRender.call(this, ct, position);
284 this.el.addClass('x-window-plain');
287 // this element allows the Window to be focused for keyboard events
288 this.focusEl = this.el.createChild({
289 tag: 'a', href:'#', cls:'x-dlg-focus',
290 tabIndex:'-1', html: ' '});
291 this.focusEl.swallowEvent('click', true);
293 this.proxy = this.el.createProxy('x-window-proxy');
294 this.proxy.enableDisplayMode('block');
297 this.mask = this.container.createChild({cls:'ext-el-mask'}, this.el.dom);
298 this.mask.enableDisplayMode('block');
300 this.mon(this.mask, 'click', this.focus, this);
302 if(this.maximizable){
303 this.mon(this.header, 'dblclick', this.toggleMaximize, this);
308 initEvents : function(){
309 Ext.Window.superclass.initEvents.call(this);
310 if(this.animateTarget){
311 this.setAnimateTarget(this.animateTarget);
315 this.resizer = new Ext.Resizable(this.el, {
316 minWidth: this.minWidth,
317 minHeight:this.minHeight,
318 handles: this.resizeHandles || 'all',
320 resizeElement : this.resizerAction,
321 handleCls: 'x-window-handle'
323 this.resizer.window = this;
324 this.mon(this.resizer, 'beforeresize', this.beforeResize, this);
328 this.header.addClass('x-window-draggable');
330 this.mon(this.el, 'mousedown', this.toFront, this);
331 this.manager = this.manager || Ext.WindowMgr;
332 this.manager.register(this);
334 this.maximized = false;
338 var km = this.getKeyMap();
339 km.on(27, this.onEsc, this);
344 initDraggable : function(){
346 * <p>If this Window is configured {@link #draggable}, this property will contain
347 * an instance of {@link Ext.dd.DD} which handles dragging the Window's DOM Element.</p>
348 * <p>This has implementations of <code>startDrag</code>, <code>onDrag</code> and <code>endDrag</code>
349 * which perform the dragging action. If extra logic is needed at these points, use
350 * {@link Function#createInterceptor createInterceptor} or {@link Function#createSequence createSequence} to
351 * augment the existing implementations.</p>
355 this.dd = new Ext.Window.DD(this);
359 onEsc : function(k, e){
361 this[this.closeAction]();
365 beforeDestroy : function(){
377 Ext.Window.superclass.beforeDestroy.call(this);
381 onDestroy : function(){
383 this.manager.unregister(this);
385 Ext.Window.superclass.onDestroy.call(this);
389 initTools : function(){
390 if(this.minimizable){
393 handler: this.minimize.createDelegate(this, [])
396 if(this.maximizable){
399 handler: this.maximize.createDelegate(this, [])
403 handler: this.restore.createDelegate(this, []),
410 handler: this[this.closeAction].createDelegate(this, [])
416 resizerAction : function(){
417 var box = this.proxy.getBox();
419 this.window.handleResize(box);
424 beforeResize : function(){
425 this.resizer.minHeight = Math.max(this.minHeight, this.getFrameHeight() + 40); // 40 is a magic minimum content size?
426 this.resizer.minWidth = Math.max(this.minWidth, this.getFrameWidth() + 40);
427 this.resizeBox = this.el.getBox();
431 updateHandles : function(){
432 if(Ext.isIE && this.resizer){
433 this.resizer.syncHandleHeight();
439 handleResize : function(box){
440 var rz = this.resizeBox;
441 if(rz.x != box.x || rz.y != box.y){
445 if (Ext.isIE6 && Ext.isStrict) {
450 this.updateHandles();
455 * Focuses the window. If a defaultButton is set, it will receive focus, otherwise the
456 * window itself will receive focus.
459 var f = this.focusEl,
460 db = this.defaultButton,
464 if(Ext.isDefined(db)){
465 if(Ext.isNumber(db) && this.fbar){
466 f = this.fbar.items.get(db);
467 }else if(Ext.isString(db)){
473 ct = Ext.getDom(this.container);
475 if (ct != document.body && !Ext.lib.Region.getRegion(ct).contains(Ext.lib.Region.getRegion(el.dom))){
480 f = f || this.focusEl;
481 f.focus.defer(10, f);
485 * Sets the target element from which the window should animate while opening.
486 * @param {String/Element} el The target element or id
488 setAnimateTarget : function(el){
490 this.animateTarget = el;
494 beforeShow : function(){
495 delete this.el.lastXY;
496 delete this.el.lastLT;
497 if(this.x === undefined || this.y === undefined){
498 var xy = this.el.getAlignToXY(this.container, 'c-c');
499 var pos = this.el.translatePoints(xy[0], xy[1]);
500 this.x = this.x === undefined? pos.left : this.x;
501 this.y = this.y === undefined? pos.top : this.y;
503 this.el.setLeftTop(this.x, this.y);
505 if(this.expandOnShow){
510 Ext.getBody().addClass('x-body-masked');
511 this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
517 * Shows the window, rendering it first if necessary, or activates it and brings it to front if hidden.
518 * @param {String/Element} animateTarget (optional) The target element or id from which the window should
519 * animate while opening (defaults to null with no animation)
520 * @param {Function} callback (optional) A callback function to call after the window is displayed
521 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this Window.
522 * @return {Ext.Window} this
524 show : function(animateTarget, cb, scope){
526 this.render(Ext.getBody());
528 if(this.hidden === false){
532 if(this.fireEvent('beforeshow', this) === false){
536 this.on('show', cb, scope, {single:true});
539 if(Ext.isDefined(animateTarget)){
540 this.setAnimateTarget(animateTarget);
543 if(this.animateTarget){
552 afterShow : function(isAnim){
553 if (this.isDestroyed){
557 this.el.setStyle('display', 'block');
562 if(Ext.isMac && Ext.isGecko2){ // work around stupid FF 2.0/Mac scroll bar bug
563 this.cascade(this.setAutoScroll);
566 if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
567 Ext.EventManager.onWindowResize(this.onWindowResize, this);
572 this.keyMap.enable();
575 this.updateHandles();
576 if(isAnim && (Ext.isIE || Ext.isWebKit)){
577 var sz = this.getSize();
578 this.onResize(sz.width, sz.height);
581 this.fireEvent('show', this);
585 animShow : function(){
587 this.proxy.setBox(this.animateTarget.getBox());
588 this.proxy.setOpacity(0);
589 var b = this.getBox();
590 this.el.setStyle('display', 'none');
591 this.proxy.shift(Ext.apply(b, {
592 callback: this.afterShow.createDelegate(this, [true], false),
595 duration: this.showAnimDuration,
601 * Hides the window, setting it to invisible and applying negative offsets.
602 * @param {String/Element} animateTarget (optional) The target element or id to which the window should
603 * animate while hiding (defaults to null with no animation)
604 * @param {Function} callback (optional) A callback function to call after the window is hidden
605 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this Window.
606 * @return {Ext.Window} this
608 hide : function(animateTarget, cb, scope){
609 if(this.hidden || this.fireEvent('beforehide', this) === false){
613 this.on('hide', cb, scope, {single:true});
616 if(animateTarget !== undefined){
617 this.setAnimateTarget(animateTarget);
621 Ext.getBody().removeClass('x-body-masked');
623 if(this.animateTarget){
633 afterHide : function(){
635 if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
636 Ext.EventManager.removeResizeListener(this.onWindowResize, this);
639 this.keyMap.disable();
642 this.fireEvent('hide', this);
646 animHide : function(){
647 this.proxy.setOpacity(0.5);
649 var tb = this.getBox(false);
650 this.proxy.setBox(tb);
652 this.proxy.shift(Ext.apply(this.animateTarget.getBox(), {
653 callback: this.afterHide,
655 duration: this.hideAnimDuration,
662 * Method that is called immediately before the <code>show</code> event is fired.
663 * Defaults to <code>Ext.emptyFn</code>.
665 onShow : Ext.emptyFn,
668 * Method that is called immediately before the <code>hide</code> event is fired.
669 * Defaults to <code>Ext.emptyFn</code>.
671 onHide : Ext.emptyFn,
674 onWindowResize : function(){
679 this.mask.setSize('100%', '100%');
680 var force = this.mask.dom.offsetHeight;
681 this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
687 doConstrain : function(){
688 if(this.constrain || this.constrainHeader){
692 right:this.el.shadowOffset,
693 left:this.el.shadowOffset,
694 bottom:this.el.shadowOffset
697 var s = this.getSize();
699 right:-(s.width - 100),
700 bottom:-(s.height - 25)
704 var xy = this.el.getConstrainToXY(this.container, true, offsets);
706 this.setPosition(xy[0], xy[1]);
711 // private - used for dragging
712 ghost : function(cls){
713 var ghost = this.createGhost(cls);
714 var box = this.getBox(true);
715 ghost.setLeftTop(box.x, box.y);
716 ghost.setWidth(box.width);
718 this.activeGhost = ghost;
723 unghost : function(show, matchPosition){
724 if(!this.activeGhost) {
729 this.focus.defer(10, this);
730 if(Ext.isMac && Ext.isGecko2){ // work around stupid FF 2.0/Mac scroll bar bug
731 this.cascade(this.setAutoScroll);
734 if(matchPosition !== false){
735 this.setPosition(this.activeGhost.getLeft(true), this.activeGhost.getTop(true));
737 this.activeGhost.hide();
738 this.activeGhost.remove();
739 delete this.activeGhost;
743 * Placeholder method for minimizing the window. By default, this method simply fires the {@link #minimize} event
744 * since the behavior of minimizing a window is application-specific. To implement custom minimize behavior,
745 * either the minimize event can be handled or this method can be overridden.
746 * @return {Ext.Window} this
748 minimize : function(){
749 this.fireEvent('minimize', this);
754 * <p>Closes the Window, removes it from the DOM, {@link Ext.Component#destroy destroy}s
755 * the Window object and all its descendant Components. The {@link Ext.Panel#beforeclose beforeclose}
756 * event is fired before the close happens and will cancel the close action if it returns false.<p>
757 * <p><b>Note:</b> This method is not affected by the {@link #closeAction} setting which
758 * only affects the action triggered when clicking the {@link #closable 'close' tool in the header}.
759 * To hide the Window without destroying it, call {@link #hide}.</p>
762 if(this.fireEvent('beforeclose', this) !== false){
766 this.hide(null, this.doClose, this);
772 doClose : function(){
773 this.fireEvent('close', this);
778 * Fits the window within its current container and automatically replaces
779 * the {@link #maximizable 'maximize' tool button} with the 'restore' tool button.
780 * Also see {@link #toggleMaximize}.
781 * @return {Ext.Window} this
783 maximize : function(){
786 this.restoreSize = this.getSize();
787 this.restorePos = this.getPosition(true);
788 if (this.maximizable){
789 this.tools.maximize.hide();
790 this.tools.restore.show();
792 this.maximized = true;
793 this.el.disableShadow();
798 if(this.collapsible){
799 this.tools.toggle.hide();
801 this.el.addClass('x-window-maximized');
802 this.container.addClass('x-window-maximized-ct');
804 this.setPosition(0, 0);
806 this.fireEvent('maximize', this);
812 * Restores a {@link #maximizable maximized} window back to its original
813 * size and position prior to being maximized and also replaces
814 * the 'restore' tool button with the 'maximize' tool button.
815 * Also see {@link #toggleMaximize}.
816 * @return {Ext.Window} this
818 restore : function(){
821 this.el.removeClass('x-window-maximized');
828 this.setPosition(this.restorePos[0], this.restorePos[1]);
829 this.setSize(this.restoreSize.width, this.restoreSize.height);
830 delete this.restorePos;
831 delete this.restoreSize;
832 this.maximized = false;
833 this.el.enableShadow(true);
838 if(this.collapsible && t.toggle){
841 this.container.removeClass('x-window-maximized-ct');
844 this.fireEvent('restore', this);
850 * A shortcut method for toggling between {@link #maximize} and {@link #restore} based on the current maximized
851 * state of the window.
852 * @return {Ext.Window} this
854 toggleMaximize : function(){
855 return this[this.maximized ? 'restore' : 'maximize']();
859 fitContainer : function(){
860 var vs = this.container.getViewSize(false);
861 this.setSize(vs.width, vs.height);
865 // z-index is managed by the WindowManager and may be overwritten at any time
866 setZIndex : function(index){
868 this.mask.setStyle('z-index', index);
870 this.el.setZIndex(++index);
874 this.resizer.proxy.setStyle('z-index', ++index);
877 this.lastZIndex = index;
881 * Aligns the window to the specified element
882 * @param {Mixed} element The element to align to.
883 * @param {String} position (optional, defaults to "tl-bl?") The position to align to (see {@link Ext.Element#alignTo} for more details).
884 * @param {Array} offsets (optional) Offset the positioning by [x, y]
885 * @return {Ext.Window} this
887 alignTo : function(element, position, offsets){
888 var xy = this.el.getAlignToXY(element, position, offsets);
889 this.setPagePosition(xy[0], xy[1]);
894 * Anchors this window to another element and realigns it when the window is resized or scrolled.
895 * @param {Mixed} element The element to align to.
896 * @param {String} position The position to align to (see {@link Ext.Element#alignTo} for more details)
897 * @param {Array} offsets (optional) Offset the positioning by [x, y]
898 * @param {Boolean/Number} monitorScroll (optional) true to monitor body scroll and reposition. If this parameter
899 * is a number, it is used as the buffer delay (defaults to 50ms).
900 * @return {Ext.Window} this
902 anchorTo : function(el, alignment, offsets, monitorScroll){
904 this.anchorTarget = {
906 alignment: alignment,
910 Ext.EventManager.onWindowResize(this.doAnchor, this);
911 var tm = typeof monitorScroll;
912 if(tm != 'undefined'){
913 Ext.EventManager.on(window, 'scroll', this.doAnchor, this,
914 {buffer: tm == 'number' ? monitorScroll : 50});
916 return this.doAnchor();
920 * Performs the anchor, using the saved anchorTarget property.
921 * @return {Ext.Window} this
924 doAnchor : function(){
925 var o = this.anchorTarget;
926 this.alignTo(o.el, o.alignment, o.offsets);
931 * Removes any existing anchor from this window. See {@link #anchorTo}.
932 * @return {Ext.Window} this
934 clearAnchor : function(){
935 if(this.anchorTarget){
936 Ext.EventManager.removeResizeListener(this.doAnchor, this);
937 Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
938 delete this.anchorTarget;
944 * Brings this window to the front of any other visible windows
945 * @param {Boolean} e (optional) Specify <tt>false</tt> to prevent the window from being focused.
946 * @return {Ext.Window} this
948 toFront : function(e){
949 if(this.manager.bringToFront(this)){
950 if(!e || !e.getTarget().focus){
958 * Makes this the active window by showing its shadow, or deactivates it by hiding its shadow. This method also
959 * fires the {@link #activate} or {@link #deactivate} event depending on which action occurred. This method is
960 * called internally by {@link Ext.WindowMgr}.
961 * @param {Boolean} active True to activate the window, false to deactivate it (defaults to false)
963 setActive : function(active){
966 this.el.enableShadow(true);
968 this.fireEvent('activate', this);
970 this.el.disableShadow();
971 this.fireEvent('deactivate', this);
976 * Sends this window to the back of (lower z-index than) any other visible windows
977 * @return {Ext.Window} this
980 this.manager.sendToBack(this);
985 * Centers this window in the viewport
986 * @return {Ext.Window} this
989 var xy = this.el.getAlignToXY(this.container, 'c-c');
990 this.setPagePosition(xy[0], xy[1]);
995 * @cfg {Boolean} autoWidth @hide
998 Ext.reg('window', Ext.Window);
1000 // private - custom Window DD implementation
1001 Ext.Window.DD = Ext.extend(Ext.dd.DD, {
1003 constructor : function(win){
1005 Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id);
1006 this.setHandleElId(win.header.id);
1007 this.scroll = false;
1011 headerOffsets:[100, 25],
1012 startDrag : function(){
1014 this.proxy = w.ghost(w.initialConfig.cls);
1015 if(w.constrain !== false){
1016 var so = w.el.shadowOffset;
1017 this.constrainTo(w.container, {right: so, left: so, bottom: so});
1018 }else if(w.constrainHeader !== false){
1019 var s = this.proxy.getSize();
1020 this.constrainTo(w.container, {right: -(s.width-this.headerOffsets[0]), bottom: -(s.height-this.headerOffsets[1])});
1023 b4Drag : Ext.emptyFn,
1025 onDrag : function(e){
1026 this.alignElWithMouse(this.proxy, e.getPageX(), e.getPageY());
1029 endDrag : function(e){
1031 this.win.saveState();