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 // The following configs are set to provide the basic functionality of a window.
202 // Changing them would require additional code to handle correctly and should
203 // usually only be done in subclasses that can provide custom behavior. Changing them
204 // may have unexpected or undesirable results.
205 <div id="cfg-Ext.Window-elements"></div>/** @cfg {String} elements @hide */
206 elements : 'header,body',
207 <div id="cfg-Ext.Window-frame"></div>/** @cfg {Boolean} frame @hide */
209 <div id="cfg-Ext.Window-floating"></div>/** @cfg {Boolean} floating @hide */
213 initComponent : function(){
215 Ext.Window.superclass.initComponent.call(this);
217 <div id="event-Ext.Window-activate"></div>/**
219 * Fires after the window has been visually activated via {@link #setActive}.
220 * @param {Ext.Window} this
222 <div id="event-Ext.Window-deactivate"></div>/**
224 * Fires after the window has been visually deactivated via {@link #setActive}.
225 * @param {Ext.Window} this
227 <div id="event-Ext.Window-resize"></div>/**
229 * Fires after the window has been resized.
230 * @param {Ext.Window} this
231 * @param {Number} width The window's new width
232 * @param {Number} height The window's new height
235 <div id="event-Ext.Window-maximize"></div>/**
237 * Fires after the window has been maximized.
238 * @param {Ext.Window} this
241 <div id="event-Ext.Window-minimize"></div>/**
243 * Fires after the window has been minimized.
244 * @param {Ext.Window} this
247 <div id="event-Ext.Window-restore"></div>/**
249 * Fires after the window has been restored to its original size after being maximized.
250 * @param {Ext.Window} this
254 // for backwards compat, this should be removed at some point
255 if(Ext.isDefined(this.initHidden)){
256 this.hidden = this.initHidden;
258 if(this.hidden === false){
265 getState : function(){
266 return Ext.apply(Ext.Window.superclass.getState.call(this) || {}, this.getBox(true));
270 onRender : function(ct, position){
271 Ext.Window.superclass.onRender.call(this, ct, position);
274 this.el.addClass('x-window-plain');
277 // this element allows the Window to be focused for keyboard events
278 this.focusEl = this.el.createChild({
279 tag: 'a', href:'#', cls:'x-dlg-focus',
280 tabIndex:'-1', html: ' '});
281 this.focusEl.swallowEvent('click', true);
283 this.proxy = this.el.createProxy('x-window-proxy');
284 this.proxy.enableDisplayMode('block');
287 this.mask = this.container.createChild({cls:'ext-el-mask'}, this.el.dom);
288 this.mask.enableDisplayMode('block');
290 this.mon(this.mask, 'click', this.focus, this);
292 if(this.maximizable){
293 this.mon(this.header, 'dblclick', this.toggleMaximize, this);
298 initEvents : function(){
299 Ext.Window.superclass.initEvents.call(this);
300 if(this.animateTarget){
301 this.setAnimateTarget(this.animateTarget);
305 this.resizer = new Ext.Resizable(this.el, {
306 minWidth: this.minWidth,
307 minHeight:this.minHeight,
308 handles: this.resizeHandles || 'all',
310 resizeElement : this.resizerAction,
311 handleCls: 'x-window-handle'
313 this.resizer.window = this;
314 this.mon(this.resizer, 'beforeresize', this.beforeResize, this);
318 this.header.addClass('x-window-draggable');
320 this.mon(this.el, 'mousedown', this.toFront, this);
321 this.manager = this.manager || Ext.WindowMgr;
322 this.manager.register(this);
324 this.maximized = false;
328 var km = this.getKeyMap();
329 km.on(27, this.onEsc, this);
334 initDraggable : function(){
335 <div id="prop-Ext.Window-dd"></div>/**
336 * If this Window is configured {@link #draggable}, this property will contain
337 * an instance of {@link Ext.dd.DD} which handles dragging the Window's DOM Element.
341 this.dd = new Ext.Window.DD(this);
345 onEsc : function(k, e){
347 this[this.closeAction]();
351 beforeDestroy : function(){
355 Ext.EventManager.removeResizeListener(this.doAnchor, this);
356 Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
366 Ext.Window.superclass.beforeDestroy.call(this);
370 onDestroy : function(){
372 this.manager.unregister(this);
374 Ext.Window.superclass.onDestroy.call(this);
378 initTools : function(){
379 if(this.minimizable){
382 handler: this.minimize.createDelegate(this, [])
385 if(this.maximizable){
388 handler: this.maximize.createDelegate(this, [])
392 handler: this.restore.createDelegate(this, []),
399 handler: this[this.closeAction].createDelegate(this, [])
405 resizerAction : function(){
406 var box = this.proxy.getBox();
408 this.window.handleResize(box);
413 beforeResize : function(){
414 this.resizer.minHeight = Math.max(this.minHeight, this.getFrameHeight() + 40); // 40 is a magic minimum content size?
415 this.resizer.minWidth = Math.max(this.minWidth, this.getFrameWidth() + 40);
416 this.resizeBox = this.el.getBox();
420 updateHandles : function(){
421 if(Ext.isIE && this.resizer){
422 this.resizer.syncHandleHeight();
428 handleResize : function(box){
429 var rz = this.resizeBox;
430 if(rz.x != box.x || rz.y != box.y){
436 this.updateHandles();
441 <div id="method-Ext.Window-focus"></div>/**
442 * Focuses the window. If a defaultButton is set, it will receive focus, otherwise the
443 * window itself will receive focus.
446 var f = this.focusEl, db = this.defaultButton, t = typeof db;
447 if(Ext.isDefined(db)){
448 if(Ext.isNumber(db) && this.fbar){
449 f = this.fbar.items.get(db);
450 }else if(Ext.isString(db)){
456 f = f || this.focusEl;
457 f.focus.defer(10, f);
460 <div id="method-Ext.Window-setAnimateTarget"></div>/**
461 * Sets the target element from which the window should animate while opening.
462 * @param {String/Element} el The target element or id
464 setAnimateTarget : function(el){
466 this.animateTarget = el;
470 beforeShow : function(){
471 delete this.el.lastXY;
472 delete this.el.lastLT;
473 if(this.x === undefined || this.y === undefined){
474 var xy = this.el.getAlignToXY(this.container, 'c-c');
475 var pos = this.el.translatePoints(xy[0], xy[1]);
476 this.x = this.x === undefined? pos.left : this.x;
477 this.y = this.y === undefined? pos.top : this.y;
479 this.el.setLeftTop(this.x, this.y);
481 if(this.expandOnShow){
486 Ext.getBody().addClass('x-body-masked');
487 this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
492 <div id="method-Ext.Window-show"></div>/**
493 * Shows the window, rendering it first if necessary, or activates it and brings it to front if hidden.
494 * @param {String/Element} animateTarget (optional) The target element or id from which the window should
495 * animate while opening (defaults to null with no animation)
496 * @param {Function} callback (optional) A callback function to call after the window is displayed
497 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this Window.
498 * @return {Ext.Window} this
500 show : function(animateTarget, cb, scope){
502 this.render(Ext.getBody());
504 if(this.hidden === false){
508 if(this.fireEvent('beforeshow', this) === false){
512 this.on('show', cb, scope, {single:true});
515 if(Ext.isDefined(animateTarget)){
516 this.setAnimateTarget(animateTarget);
519 if(this.animateTarget){
528 afterShow : function(isAnim){
529 if (this.isDestroyed){
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});
896 <div id="method-Ext.Window-toFront"></div>/**
897 * Brings this window to the front of any other visible windows
898 * @param {Boolean} e (optional) Specify <tt>false</tt> to prevent the window from being focused.
899 * @return {Ext.Window} this
901 toFront : function(e){
902 if(this.manager.bringToFront(this)){
903 if(!e || !e.getTarget().focus){
910 <div id="method-Ext.Window-setActive"></div>/**
911 * Makes this the active window by showing its shadow, or deactivates it by hiding its shadow. This method also
912 * fires the {@link #activate} or {@link #deactivate} event depending on which action occurred. This method is
913 * called internally by {@link Ext.WindowMgr}.
914 * @param {Boolean} active True to activate the window, false to deactivate it (defaults to false)
916 setActive : function(active){
919 this.el.enableShadow(true);
921 this.fireEvent('activate', this);
923 this.el.disableShadow();
924 this.fireEvent('deactivate', this);
928 <div id="method-Ext.Window-toBack"></div>/**
929 * Sends this window to the back of (lower z-index than) any other visible windows
930 * @return {Ext.Window} this
933 this.manager.sendToBack(this);
937 <div id="method-Ext.Window-center"></div>/**
938 * Centers this window in the viewport
939 * @return {Ext.Window} this
942 var xy = this.el.getAlignToXY(this.container, 'c-c');
943 this.setPagePosition(xy[0], xy[1]);
947 <div id="cfg-Ext.Window-autoWidth"></div>/**
948 * @cfg {Boolean} autoWidth @hide
951 Ext.reg('window', Ext.Window);
953 // private - custom Window DD implementation
954 Ext.Window.DD = function(win){
956 Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id);
957 this.setHandleElId(win.header.id);
961 Ext.extend(Ext.Window.DD, Ext.dd.DD, {
963 headerOffsets:[100, 25],
964 startDrag : function(){
966 this.proxy = w.ghost();
967 if(w.constrain !== false){
968 var so = w.el.shadowOffset;
969 this.constrainTo(w.container, {right: so, left: so, bottom: so});
970 }else if(w.constrainHeader !== false){
971 var s = this.proxy.getSize();
972 this.constrainTo(w.container, {right: -(s.width-this.headerOffsets[0]), bottom: -(s.height-this.headerOffsets[1])});
975 b4Drag : Ext.emptyFn,
977 onDrag : function(e){
978 this.alignElWithMouse(this.proxy, e.getPageX(), e.getPageY());
981 endDrag : function(e){
983 this.win.saveState();