3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
14 <div id="cls-Ext.Window"></div>/**
17 * <p>A specialized panel intended for use as an application window. Windows are floated, {@link #resizable}, and
18 * {@link #draggable} by default. Windows can be {@link #maximizable maximized} to fill the viewport,
19 * restored to their prior size, and can be {@link #minimize}d.</p>
20 * <p>Windows can also be linked to a {@link Ext.WindowGroup} or managed by the {@link Ext.WindowMgr} to provide
21 * grouping, activation, to front, to back and other application-specific behavior.</p>
22 * <p>By default, Windows will be rendered to document.body. To {@link #constrain} a Window to another element
23 * specify {@link Ext.Component#renderTo renderTo}.</p>
24 * <p><b>Note:</b> By default, the <code>{@link #closable close}</code> header tool <i>destroys</i> the Window resulting in
25 * destruction of any child Components. This makes the Window object, and all its descendants <b>unusable</b>. To enable
26 * re-use of a Window, use <b><code>{@link #closeAction closeAction: 'hide'}</code></b>.</p>
28 * @param {Object} config The config object
31 Ext.Window = Ext.extend(Ext.Panel, {
32 <div id="cfg-Ext.Window-x"></div>/**
34 * The X position of the left edge of the window on initial showing. Defaults to centering the Window within
35 * the width of the Window's container {@link Ext.Element Element) (The Element that the Window is rendered to).
37 <div id="cfg-Ext.Window-y"></div>/**
39 * The Y position of the top edge of the window on initial showing. Defaults to centering the Window within
40 * the height of the Window's container {@link Ext.Element Element) (The Element that the Window is rendered to).
42 <div id="cfg-Ext.Window-modal"></div>/**
43 * @cfg {Boolean} modal
44 * True to make the window modal and mask everything behind it when displayed, false to display it without
45 * restricting access to other UI elements (defaults to false).
47 <div id="cfg-Ext.Window-animateTarget"></div>/**
48 * @cfg {String/Element} animateTarget
49 * Id or element from which the window should animate while opening (defaults to null with no animation).
51 <div id="cfg-Ext.Window-resizeHandles"></div>/**
52 * @cfg {String} resizeHandles
53 * A valid {@link Ext.Resizable} handles config string (defaults to 'all'). Only applies when resizable = true.
55 <div id="cfg-Ext.Window-manager"></div>/**
56 * @cfg {Ext.WindowGroup} manager
57 * A reference to the WindowGroup that should manage this window (defaults to {@link Ext.WindowMgr}).
59 <div id="cfg-Ext.Window-defaultButton"></div>/**
60 * @cfg {String/Number/Button} defaultButton
61 * The id / index of a button or a button instance to focus when this window received the focus.
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();
445 <div id="method-Ext.Window-focus"></div>/**
446 * Focuses the window. If a defaultButton is set, it will receive focus, otherwise the
447 * window itself will receive focus.
450 var f = this.focusEl, db = this.defaultButton, t = typeof db;
451 if(Ext.isDefined(db)){
452 if(Ext.isNumber(db) && this.fbar){
453 f = this.fbar.items.get(db);
454 }else if(Ext.isString(db)){
460 f = f || this.focusEl;
461 f.focus.defer(10, f);
464 <div id="method-Ext.Window-setAnimateTarget"></div>/**
465 * Sets the target element from which the window should animate while opening.
466 * @param {String/Element} el The target element or id
468 setAnimateTarget : function(el){
470 this.animateTarget = el;
474 beforeShow : function(){
475 delete this.el.lastXY;
476 delete this.el.lastLT;
477 if(this.x === undefined || this.y === undefined){
478 var xy = this.el.getAlignToXY(this.container, 'c-c');
479 var pos = this.el.translatePoints(xy[0], xy[1]);
480 this.x = this.x === undefined? pos.left : this.x;
481 this.y = this.y === undefined? pos.top : this.y;
483 this.el.setLeftTop(this.x, this.y);
485 if(this.expandOnShow){
490 Ext.getBody().addClass('x-body-masked');
491 this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
496 <div id="method-Ext.Window-show"></div>/**
497 * Shows the window, rendering it first if necessary, or activates it and brings it to front if hidden.
498 * @param {String/Element} animateTarget (optional) The target element or id from which the window should
499 * animate while opening (defaults to null with no animation)
500 * @param {Function} callback (optional) A callback function to call after the window is displayed
501 * @param {Object} scope (optional) The scope in which to execute the callback
502 * @return {Ext.Window} this
504 show : function(animateTarget, cb, scope){
506 this.render(Ext.getBody());
508 if(this.hidden === false){
512 if(this.fireEvent('beforeshow', this) === false){
516 this.on('show', cb, scope, {single:true});
519 if(Ext.isDefined(animateTarget)){
520 this.setAnimateTarget(animateTarget);
523 if(this.animateTarget){
532 afterShow : function(isAnim){
534 this.el.setStyle('display', 'block');
539 if(Ext.isMac && Ext.isGecko){ // work around stupid FF 2.0/Mac scroll bar bug
540 this.cascade(this.setAutoScroll);
543 if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
544 Ext.EventManager.onWindowResize(this.onWindowResize, this);
549 this.keyMap.enable();
552 this.updateHandles();
553 if(isAnim && (Ext.isIE || Ext.isWebKit)){
554 var sz = this.getSize();
555 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 in which to execute the callback
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();
617 this.fireEvent('hide', this);
621 animHide : function(){
622 this.proxy.setOpacity(0.5);
624 var tb = this.getBox(false);
625 this.proxy.setBox(tb);
627 this.proxy.shift(Ext.apply(this.animateTarget.getBox(), {
628 callback: this.afterHide,
637 onWindowResize : function(){
642 this.mask.setSize('100%', '100%');
643 var force = this.mask.dom.offsetHeight;
644 this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
650 doConstrain : function(){
651 if(this.constrain || this.constrainHeader){
655 right:this.el.shadowOffset,
656 left:this.el.shadowOffset,
657 bottom:this.el.shadowOffset
660 var s = this.getSize();
662 right:-(s.width - 100),
663 bottom:-(s.height - 25)
667 var xy = this.el.getConstrainToXY(this.container, true, offsets);
669 this.setPosition(xy[0], xy[1]);
674 // private - used for dragging
675 ghost : function(cls){
676 var ghost = this.createGhost(cls);
677 var box = this.getBox(true);
678 ghost.setLeftTop(box.x, box.y);
679 ghost.setWidth(box.width);
681 this.activeGhost = ghost;
686 unghost : function(show, matchPosition){
687 if(!this.activeGhost) {
693 if(Ext.isMac && Ext.isGecko){ // work around stupid FF 2.0/Mac scroll bar bug
694 this.cascade(this.setAutoScroll);
697 if(matchPosition !== false){
698 this.setPosition(this.activeGhost.getLeft(true), this.activeGhost.getTop(true));
700 this.activeGhost.hide();
701 this.activeGhost.remove();
702 delete this.activeGhost;
705 <div id="method-Ext.Window-minimize"></div>/**
706 * Placeholder method for minimizing the window. By default, this method simply fires the {@link #minimize} event
707 * since the behavior of minimizing a window is application-specific. To implement custom minimize behavior,
708 * either the minimize event can be handled or this method can be overridden.
709 * @return {Ext.Window} this
711 minimize : function(){
712 this.fireEvent('minimize', this);
716 <div id="method-Ext.Window-close"></div>/**
717 * <p>Closes the Window, removes it from the DOM, {@link Ext.Component#destroy destroy}s
718 * the Window object and all its descendant Components. The {@link Ext.Panel#beforeclose beforeclose}
719 * event is fired before the close happens and will cancel the close action if it returns false.<p>
720 * <p><b>Note:</b> This method is not affected by the {@link #closeAction} setting which
721 * only affects the action triggered when clicking the {@link #closable 'close' tool in the header}.
722 * To hide the Window without destroying it, call {@link #hide}.</p>
725 if(this.fireEvent('beforeclose', this) !== false){
729 this.hide(null, this.doClose, this);
735 doClose : function(){
736 this.fireEvent('close', this);
740 <div id="method-Ext.Window-maximize"></div>/**
741 * Fits the window within its current container and automatically replaces
742 * the {@link #maximizable 'maximize' tool button} with the 'restore' tool button.
743 * Also see {@link #toggleMaximize}.
744 * @return {Ext.Window} this
746 maximize : function(){
749 this.restoreSize = this.getSize();
750 this.restorePos = this.getPosition(true);
751 if (this.maximizable){
752 this.tools.maximize.hide();
753 this.tools.restore.show();
755 this.maximized = true;
756 this.el.disableShadow();
761 if(this.collapsible){
762 this.tools.toggle.hide();
764 this.el.addClass('x-window-maximized');
765 this.container.addClass('x-window-maximized-ct');
767 this.setPosition(0, 0);
769 this.fireEvent('maximize', this);
774 <div id="method-Ext.Window-restore"></div>/**
775 * Restores a {@link #maximizable maximized} window back to its original
776 * size and position prior to being maximized and also replaces
777 * the 'restore' tool button with the 'maximize' tool button.
778 * Also see {@link #toggleMaximize}.
779 * @return {Ext.Window} this
781 restore : function(){
783 this.el.removeClass('x-window-maximized');
784 this.tools.restore.hide();
785 this.tools.maximize.show();
786 this.setPosition(this.restorePos[0], this.restorePos[1]);
787 this.setSize(this.restoreSize.width, this.restoreSize.height);
788 delete this.restorePos;
789 delete this.restoreSize;
790 this.maximized = false;
791 this.el.enableShadow(true);
796 if(this.collapsible){
797 this.tools.toggle.show();
799 this.container.removeClass('x-window-maximized-ct');
802 this.fireEvent('restore', this);
807 <div id="method-Ext.Window-toggleMaximize"></div>/**
808 * A shortcut method for toggling between {@link #maximize} and {@link #restore} based on the current maximized
809 * state of the window.
810 * @return {Ext.Window} this
812 toggleMaximize : function(){
813 return this[this.maximized ? 'restore' : 'maximize']();
817 fitContainer : function(){
818 var vs = this.container.getViewSize();
819 this.setSize(vs.width, vs.height);
823 // z-index is managed by the WindowManager and may be overwritten at any time
824 setZIndex : function(index){
826 this.mask.setStyle('z-index', index);
828 this.el.setZIndex(++index);
832 this.resizer.proxy.setStyle('z-index', ++index);
835 this.lastZIndex = index;
838 <div id="method-Ext.Window-alignTo"></div>/**
839 * Aligns the window to the specified element
840 * @param {Mixed} element The element to align to.
841 * @param {String} position The position to align to (see {@link Ext.Element#alignTo} for more details).
842 * @param {Array} offsets (optional) Offset the positioning by [x, y]
843 * @return {Ext.Window} this
845 alignTo : function(element, position, offsets){
846 var xy = this.el.getAlignToXY(element, position, offsets);
847 this.setPagePosition(xy[0], xy[1]);
851 <div id="method-Ext.Window-anchorTo"></div>/**
852 * Anchors this window to another element and realigns it when the window is resized or scrolled.
853 * @param {Mixed} element The element to align to.
854 * @param {String} position The position to align to (see {@link Ext.Element#alignTo} for more details)
855 * @param {Array} offsets (optional) Offset the positioning by [x, y]
856 * @param {Boolean/Number} monitorScroll (optional) true to monitor body scroll and reposition. If this parameter
857 * is a number, it is used as the buffer delay (defaults to 50ms).
858 * @return {Ext.Window} this
860 anchorTo : function(el, alignment, offsets, monitorScroll){
862 Ext.EventManager.removeResizeListener(this.doAnchor, this);
863 Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
865 this.doAnchor = function(){
866 this.alignTo(el, alignment, offsets);
868 Ext.EventManager.onWindowResize(this.doAnchor, this);
870 var tm = typeof monitorScroll;
871 if(tm != 'undefined'){
872 Ext.EventManager.on(window, 'scroll', this.doAnchor, this,
873 {buffer: tm == 'number' ? monitorScroll : 50});
879 <div id="method-Ext.Window-toFront"></div>/**
880 * Brings this window to the front of any other visible windows
881 * @param {Boolean} e (optional) Specify <tt>false</tt> to prevent the window from being focused.
882 * @return {Ext.Window} this
884 toFront : function(e){
885 if(this.manager.bringToFront(this)){
886 if(!e || !e.getTarget().focus){
893 <div id="method-Ext.Window-setActive"></div>/**
894 * Makes this the active window by showing its shadow, or deactivates it by hiding its shadow. This method also
895 * fires the {@link #activate} or {@link #deactivate} event depending on which action occurred. This method is
896 * called internally by {@link Ext.WindowMgr}.
897 * @param {Boolean} active True to activate the window, false to deactivate it (defaults to false)
899 setActive : function(active){
902 this.el.enableShadow(true);
904 this.fireEvent('activate', this);
906 this.el.disableShadow();
907 this.fireEvent('deactivate', this);
911 <div id="method-Ext.Window-toBack"></div>/**
912 * Sends this window to the back of (lower z-index than) any other visible windows
913 * @return {Ext.Window} this
916 this.manager.sendToBack(this);
920 <div id="method-Ext.Window-center"></div>/**
921 * Centers this window in the viewport
922 * @return {Ext.Window} this
925 var xy = this.el.getAlignToXY(this.container, 'c-c');
926 this.setPagePosition(xy[0], xy[1]);
930 <div id="cfg-Ext.Window-autoWidth"></div>/**
931 * @cfg {Boolean} autoWidth @hide
934 Ext.reg('window', Ext.Window);
936 // private - custom Window DD implementation
937 Ext.Window.DD = function(win){
939 Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id);
940 this.setHandleElId(win.header.id);
944 Ext.extend(Ext.Window.DD, Ext.dd.DD, {
946 headerOffsets:[100, 25],
947 startDrag : function(){
949 this.proxy = w.ghost();
950 if(w.constrain !== false){
951 var so = w.el.shadowOffset;
952 this.constrainTo(w.container, {right: so, left: so, bottom: so});
953 }else if(w.constrainHeader !== false){
954 var s = this.proxy.getSize();
955 this.constrainTo(w.container, {right: -(s.width-this.headerOffsets[0]), bottom: -(s.height-this.headerOffsets[1])});
958 b4Drag : Ext.emptyFn,
960 onDrag : function(e){
961 this.alignElWithMouse(this.proxy, e.getPageX(), e.getPageY());
964 endDrag : function(e){
966 this.win.saveState();