3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.2.1
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
15 <div id="cls-Ext.Window"></div>/**
18 * <p>A specialized panel intended for use as an application window. Windows are floated, {@link #resizable}, and
19 * {@link #draggable} by default. Windows can be {@link #maximizable maximized} to fill the viewport,
20 * restored to their prior size, and can be {@link #minimize}d.</p>
21 * <p>Windows can also be linked to a {@link Ext.WindowGroup} or managed by the {@link Ext.WindowMgr} to provide
22 * grouping, activation, to front, to back and other application-specific behavior.</p>
23 * <p>By default, Windows will be rendered to document.body. To {@link #constrain} a Window to another element
24 * specify {@link Ext.Component#renderTo renderTo}.</p>
25 * <p><b>Note:</b> By default, the <code>{@link #closable close}</code> header tool <i>destroys</i> the Window resulting in
26 * destruction of any child Components. This makes the Window object, and all its descendants <b>unusable</b>. To enable
27 * re-use of a Window, use <b><code>{@link #closeAction closeAction: 'hide'}</code></b>.</p>
29 * @param {Object} config The config object
32 Ext.Window = Ext.extend(Ext.Panel, {
33 <div id="cfg-Ext.Window-x"></div>/**
35 * The X position of the left edge of the window on initial showing. Defaults to centering the Window within
36 * the width of the Window's container {@link Ext.Element Element) (The Element that the Window is rendered to).
38 <div id="cfg-Ext.Window-y"></div>/**
40 * The Y position of the top edge of the window on initial showing. Defaults to centering the Window within
41 * the height of the Window's container {@link Ext.Element Element) (The Element that the Window is rendered to).
43 <div id="cfg-Ext.Window-modal"></div>/**
44 * @cfg {Boolean} modal
45 * True to make the window modal and mask everything behind it when displayed, false to display it without
46 * restricting access to other UI elements (defaults to false).
48 <div id="cfg-Ext.Window-animateTarget"></div>/**
49 * @cfg {String/Element} animateTarget
50 * Id or element from which the window should animate while opening (defaults to null with no animation).
52 <div id="cfg-Ext.Window-resizeHandles"></div>/**
53 * @cfg {String} resizeHandles
54 * A valid {@link Ext.Resizable} handles config string (defaults to 'all'). Only applies when resizable = true.
56 <div id="cfg-Ext.Window-manager"></div>/**
57 * @cfg {Ext.WindowGroup} manager
58 * A reference to the WindowGroup that should manage this window (defaults to {@link Ext.WindowMgr}).
60 <div id="cfg-Ext.Window-defaultButton"></div>/**
61 * @cfg {String/Number/Component} defaultButton
62 * <p>Specifies a Component to receive focus when this Window is focussed.</p>
63 * <p>This may be one of:</p><div class="mdetail-params"><ul>
64 * <li>The index of a footer Button.</li>
65 * <li>The id of a Component.</li>
66 * <li>A Component.</li>
69 <div id="cfg-Ext.Window-onEsc"></div>/**
70 * @cfg {Function} onEsc
71 * Allows override of the built-in processing for the escape key. Default action
72 * is to close the Window (performing whatever action is specified in {@link #closeAction}.
73 * To prevent the Window closing when the escape key is pressed, specify this as
74 * Ext.emptyFn (See {@link Ext#emptyFn}).
76 <div id="cfg-Ext.Window-collapsed"></div>/**
77 * @cfg {Boolean} collapsed
78 * True to render the window collapsed, false to render it expanded (defaults to false). Note that if
79 * {@link #expandOnShow} is true (the default) it will override the <tt>collapsed</tt> config and the window
80 * will always be expanded when shown.
82 <div id="cfg-Ext.Window-maximized"></div>/**
83 * @cfg {Boolean} maximized
84 * True to initially display the window in a maximized state. (Defaults to false).
87 <div id="cfg-Ext.Window-baseCls"></div>/**
88 * @cfg {String} baseCls
89 * The base CSS class to apply to this panel's element (defaults to 'x-window').
92 <div id="cfg-Ext.Window-resizable"></div>/**
93 * @cfg {Boolean} resizable
94 * True to allow user resizing at each edge and corner of the window, false to disable resizing (defaults to true).
97 <div id="cfg-Ext.Window-draggable"></div>/**
98 * @cfg {Boolean} draggable
99 * True to allow the window to be dragged by the header bar, false to disable dragging (defaults to true). Note
100 * that by default the window will be centered in the viewport, so if dragging is disabled the window may need
101 * to be positioned programmatically after render (e.g., myWindow.setPosition(100, 100);).
104 <div id="cfg-Ext.Window-closable"></div>/**
105 * @cfg {Boolean} closable
106 * <p>True to display the 'close' tool button and allow the user to close the window, false to
107 * hide the button and disallow closing the window (defaults to true).</p>
108 * <p>By default, when close is requested by either clicking the close button in the header
109 * or pressing ESC when the Window has focus, the {@link #close} method will be called. This
110 * will <i>{@link Ext.Component#destroy destroy}</i> the Window and its content meaning that
111 * it may not be reused.</p>
112 * <p>To make closing a Window <i>hide</i> the Window so that it may be reused, set
113 * {@link #closeAction} to 'hide'.
116 <div id="cfg-Ext.Window-closeAction"></div>/**
117 * @cfg {String} closeAction
118 * <p>The action to take when the close header tool is clicked:
119 * <div class="mdetail-params"><ul>
120 * <li><b><code>'{@link #close}'</code></b> : <b>Default</b><div class="sub-desc">
121 * {@link #close remove} the window from the DOM and {@link Ext.Component#destroy destroy}
122 * it and all descendant Components. The window will <b>not</b> be available to be
123 * redisplayed via the {@link #show} method.
125 * <li><b><code>'{@link #hide}'</code></b> : <div class="sub-desc">
126 * {@link #hide} the window by setting visibility to hidden and applying negative offsets.
127 * The window will be available to be redisplayed via the {@link #show} method.
130 * <p><b>Note:</b> This setting does not affect the {@link #close} method
131 * which will always {@link Ext.Component#destroy destroy} the window. To
132 * programatically <i>hide</i> a window, call {@link #hide}.</p>
134 closeAction : 'close',
135 <div id="cfg-Ext.Window-constrain"></div>/**
136 * @cfg {Boolean} constrain
137 * True to constrain the window within its containing element, false to allow it to fall outside of its
138 * containing element. By default the window will be rendered to document.body. To render and constrain the
139 * window within another element specify {@link #renderTo}.
140 * (defaults to false). Optionally the header only can be constrained using {@link #constrainHeader}.
143 <div id="cfg-Ext.Window-constrainHeader"></div>/**
144 * @cfg {Boolean} constrainHeader
145 * True to constrain the window header within its containing element (allowing the window body to fall outside
146 * of its containing element) or false to allow the header to fall outside its containing element (defaults to
147 * false). Optionally the entire window can be constrained using {@link #constrain}.
149 constrainHeader : false,
150 <div id="cfg-Ext.Window-plain"></div>/**
151 * @cfg {Boolean} plain
152 * True to render the window body with a transparent background so that it will blend into the framing
153 * elements, false to add a lighter background color to visually highlight the body element and separate it
154 * more distinctly from the surrounding frame (defaults to false).
157 <div id="cfg-Ext.Window-minimizable"></div>/**
158 * @cfg {Boolean} minimizable
159 * True to display the 'minimize' tool button and allow the user to minimize the window, false to hide the button
160 * and disallow minimizing the window (defaults to false). Note that this button provides no implementation --
161 * the behavior of minimizing a window is implementation-specific, so the minimize event must be handled and a
162 * custom minimize behavior implemented for this option to be useful.
165 <div id="cfg-Ext.Window-maximizable"></div>/**
166 * @cfg {Boolean} maximizable
167 * True to display the 'maximize' tool button and allow the user to maximize the window, false to hide the button
168 * and disallow maximizing the window (defaults to false). Note that when a window is maximized, the tool button
169 * will automatically change to a 'restore' button with the appropriate behavior already built-in that will
170 * restore the window to its previous size.
173 <div id="cfg-Ext.Window-minHeight"></div>/**
174 * @cfg {Number} minHeight
175 * The minimum height in pixels allowed for this window (defaults to 100). Only applies when resizable = true.
178 <div id="cfg-Ext.Window-minWidth"></div>/**
179 * @cfg {Number} minWidth
180 * The minimum width in pixels allowed for this window (defaults to 200). Only applies when resizable = true.
183 <div id="cfg-Ext.Window-expandOnShow"></div>/**
184 * @cfg {Boolean} expandOnShow
185 * True to always expand the window when it is displayed, false to keep it in its current state (which may be
186 * {@link #collapsed}) when displayed (defaults to true).
190 // inherited docs, same default
193 <div id="cfg-Ext.Window-initHidden"></div>/**
194 * @cfg {Boolean} initHidden
195 * True to hide the window until show() is explicitly called (defaults to true).
198 initHidden : undefined,
200 <div id="cfg-Ext.Window-hidden"></div>/**
201 * @cfg {Boolean} hidden
202 * Render this component hidden (default is <tt>true</tt>). If <tt>true</tt>, the
203 * {@link #hide} method will be called internally.
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,
317 handleCls: 'x-window-handle'
319 this.resizer.window = this;
320 this.mon(this.resizer, 'beforeresize', this.beforeResize, this);
324 this.header.addClass('x-window-draggable');
326 this.mon(this.el, 'mousedown', this.toFront, this);
327 this.manager = this.manager || Ext.WindowMgr;
328 this.manager.register(this);
330 this.maximized = false;
334 var km = this.getKeyMap();
335 km.on(27, this.onEsc, this);
340 initDraggable : function(){
341 <div id="prop-Ext.Window-dd"></div>/**
342 * <p>If this Window is configured {@link #draggable}, this property will contain
343 * an instance of {@link Ext.dd.DD} which handles dragging the Window's DOM Element.</p>
344 * <p>This has implementations of <code>startDrag</code>, <code>onDrag</code> and <code>endDrag</code>
345 * which perform the dragging action. If extra logic is needed at these points, use
346 * {@link Function#createInterceptor createInterceptor} or {@link Function#createSequence createSequence} to
347 * augment the existing implementations.</p>
351 this.dd = new Ext.Window.DD(this);
355 onEsc : function(k, e){
357 this[this.closeAction]();
361 beforeDestroy : function(){
373 Ext.Window.superclass.beforeDestroy.call(this);
377 onDestroy : function(){
379 this.manager.unregister(this);
381 Ext.Window.superclass.onDestroy.call(this);
385 initTools : function(){
386 if(this.minimizable){
389 handler: this.minimize.createDelegate(this, [])
392 if(this.maximizable){
395 handler: this.maximize.createDelegate(this, [])
399 handler: this.restore.createDelegate(this, []),
406 handler: this[this.closeAction].createDelegate(this, [])
412 resizerAction : function(){
413 var box = this.proxy.getBox();
415 this.window.handleResize(box);
420 beforeResize : function(){
421 this.resizer.minHeight = Math.max(this.minHeight, this.getFrameHeight() + 40); // 40 is a magic minimum content size?
422 this.resizer.minWidth = Math.max(this.minWidth, this.getFrameWidth() + 40);
423 this.resizeBox = this.el.getBox();
427 updateHandles : function(){
428 if(Ext.isIE && this.resizer){
429 this.resizer.syncHandleHeight();
435 handleResize : function(box){
436 var rz = this.resizeBox;
437 if(rz.x != box.x || rz.y != box.y){
441 if (Ext.isIE6 && Ext.isStrict) {
446 this.updateHandles();
450 <div id="method-Ext.Window-focus"></div>/**
451 * Focuses the window. If a defaultButton is set, it will receive focus, otherwise the
452 * window itself will receive focus.
455 var f = this.focusEl,
456 db = this.defaultButton,
460 if(Ext.isDefined(db)){
461 if(Ext.isNumber(db) && this.fbar){
462 f = this.fbar.items.get(db);
463 }else if(Ext.isString(db)){
469 ct = Ext.getDom(this.container);
471 if (!Ext.lib.Region.getRegion(ct).contains(Ext.lib.Region.getRegion(el.dom))){
476 f = f || this.focusEl;
477 f.focus.defer(10, f);
480 <div id="method-Ext.Window-setAnimateTarget"></div>/**
481 * Sets the target element from which the window should animate while opening.
482 * @param {String/Element} el The target element or id
484 setAnimateTarget : function(el){
486 this.animateTarget = el;
490 beforeShow : function(){
491 delete this.el.lastXY;
492 delete this.el.lastLT;
493 if(this.x === undefined || this.y === undefined){
494 var xy = this.el.getAlignToXY(this.container, 'c-c');
495 var pos = this.el.translatePoints(xy[0], xy[1]);
496 this.x = this.x === undefined? pos.left : this.x;
497 this.y = this.y === undefined? pos.top : this.y;
499 this.el.setLeftTop(this.x, this.y);
501 if(this.expandOnShow){
506 Ext.getBody().addClass('x-body-masked');
507 this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
512 <div id="method-Ext.Window-show"></div>/**
513 * Shows the window, rendering it first if necessary, or activates it and brings it to front if hidden.
514 * @param {String/Element} animateTarget (optional) The target element or id from which the window should
515 * animate while opening (defaults to null with no animation)
516 * @param {Function} callback (optional) A callback function to call after the window is displayed
517 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this Window.
518 * @return {Ext.Window} this
520 show : function(animateTarget, cb, scope){
522 this.render(Ext.getBody());
524 if(this.hidden === false){
528 if(this.fireEvent('beforeshow', this) === false){
532 this.on('show', cb, scope, {single:true});
535 if(Ext.isDefined(animateTarget)){
536 this.setAnimateTarget(animateTarget);
539 if(this.animateTarget){
548 afterShow : function(isAnim){
549 if (this.isDestroyed){
553 this.el.setStyle('display', 'block');
558 if(Ext.isMac && Ext.isGecko2){ // work around stupid FF 2.0/Mac scroll bar bug
559 this.cascade(this.setAutoScroll);
562 if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
563 Ext.EventManager.onWindowResize(this.onWindowResize, this);
568 this.keyMap.enable();
571 this.updateHandles();
572 if(isAnim && (Ext.isIE || Ext.isWebKit)){
573 var sz = this.getSize();
574 this.onResize(sz.width, sz.height);
577 this.fireEvent('show', this);
581 animShow : function(){
583 this.proxy.setBox(this.animateTarget.getBox());
584 this.proxy.setOpacity(0);
585 var b = this.getBox();
586 this.el.setStyle('display', 'none');
587 this.proxy.shift(Ext.apply(b, {
588 callback: this.afterShow.createDelegate(this, [true], false),
596 <div id="method-Ext.Window-hide"></div>/**
597 * Hides the window, setting it to invisible and applying negative offsets.
598 * @param {String/Element} animateTarget (optional) The target element or id to which the window should
599 * animate while hiding (defaults to null with no animation)
600 * @param {Function} callback (optional) A callback function to call after the window is hidden
601 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this Window.
602 * @return {Ext.Window} this
604 hide : function(animateTarget, cb, scope){
605 if(this.hidden || this.fireEvent('beforehide', this) === false){
609 this.on('hide', cb, scope, {single:true});
612 if(animateTarget !== undefined){
613 this.setAnimateTarget(animateTarget);
617 Ext.getBody().removeClass('x-body-masked');
619 if(this.animateTarget){
629 afterHide : function(){
631 if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
632 Ext.EventManager.removeResizeListener(this.onWindowResize, this);
635 this.keyMap.disable();
638 this.fireEvent('hide', this);
642 animHide : function(){
643 this.proxy.setOpacity(0.5);
645 var tb = this.getBox(false);
646 this.proxy.setBox(tb);
648 this.proxy.shift(Ext.apply(this.animateTarget.getBox(), {
649 callback: this.afterHide,
657 <div id="prop-Ext.Window-onShow"></div>/**
658 * Method that is called immediately before the <code>show</code> event is fired.
659 * Defaults to <code>Ext.emptyFn</code>.
661 onShow : Ext.emptyFn,
663 <div id="prop-Ext.Window-onHide"></div>/**
664 * Method that is called immediately before the <code>hide</code> event is fired.
665 * Defaults to <code>Ext.emptyFn</code>.
667 onHide : Ext.emptyFn,
670 onWindowResize : function(){
675 this.mask.setSize('100%', '100%');
676 var force = this.mask.dom.offsetHeight;
677 this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
683 doConstrain : function(){
684 if(this.constrain || this.constrainHeader){
688 right:this.el.shadowOffset,
689 left:this.el.shadowOffset,
690 bottom:this.el.shadowOffset
693 var s = this.getSize();
695 right:-(s.width - 100),
696 bottom:-(s.height - 25)
700 var xy = this.el.getConstrainToXY(this.container, true, offsets);
702 this.setPosition(xy[0], xy[1]);
707 // private - used for dragging
708 ghost : function(cls){
709 var ghost = this.createGhost(cls);
710 var box = this.getBox(true);
711 ghost.setLeftTop(box.x, box.y);
712 ghost.setWidth(box.width);
714 this.activeGhost = ghost;
719 unghost : function(show, matchPosition){
720 if(!this.activeGhost) {
725 this.focus.defer(10, this);
726 if(Ext.isMac && Ext.isGecko2){ // work around stupid FF 2.0/Mac scroll bar bug
727 this.cascade(this.setAutoScroll);
730 if(matchPosition !== false){
731 this.setPosition(this.activeGhost.getLeft(true), this.activeGhost.getTop(true));
733 this.activeGhost.hide();
734 this.activeGhost.remove();
735 delete this.activeGhost;
738 <div id="method-Ext.Window-minimize"></div>/**
739 * Placeholder method for minimizing the window. By default, this method simply fires the {@link #minimize} event
740 * since the behavior of minimizing a window is application-specific. To implement custom minimize behavior,
741 * either the minimize event can be handled or this method can be overridden.
742 * @return {Ext.Window} this
744 minimize : function(){
745 this.fireEvent('minimize', this);
749 <div id="method-Ext.Window-close"></div>/**
750 * <p>Closes the Window, removes it from the DOM, {@link Ext.Component#destroy destroy}s
751 * the Window object and all its descendant Components. The {@link Ext.Panel#beforeclose beforeclose}
752 * event is fired before the close happens and will cancel the close action if it returns false.<p>
753 * <p><b>Note:</b> This method is not affected by the {@link #closeAction} setting which
754 * only affects the action triggered when clicking the {@link #closable 'close' tool in the header}.
755 * To hide the Window without destroying it, call {@link #hide}.</p>
758 if(this.fireEvent('beforeclose', this) !== false){
762 this.hide(null, this.doClose, this);
768 doClose : function(){
769 this.fireEvent('close', this);
773 <div id="method-Ext.Window-maximize"></div>/**
774 * Fits the window within its current container and automatically replaces
775 * the {@link #maximizable 'maximize' tool button} with the 'restore' tool button.
776 * Also see {@link #toggleMaximize}.
777 * @return {Ext.Window} this
779 maximize : function(){
782 this.restoreSize = this.getSize();
783 this.restorePos = this.getPosition(true);
784 if (this.maximizable){
785 this.tools.maximize.hide();
786 this.tools.restore.show();
788 this.maximized = true;
789 this.el.disableShadow();
794 if(this.collapsible){
795 this.tools.toggle.hide();
797 this.el.addClass('x-window-maximized');
798 this.container.addClass('x-window-maximized-ct');
800 this.setPosition(0, 0);
802 this.fireEvent('maximize', this);
807 <div id="method-Ext.Window-restore"></div>/**
808 * Restores a {@link #maximizable maximized} window back to its original
809 * size and position prior to being maximized and also replaces
810 * the 'restore' tool button with the 'maximize' tool button.
811 * Also see {@link #toggleMaximize}.
812 * @return {Ext.Window} this
814 restore : function(){
817 this.el.removeClass('x-window-maximized');
824 this.setPosition(this.restorePos[0], this.restorePos[1]);
825 this.setSize(this.restoreSize.width, this.restoreSize.height);
826 delete this.restorePos;
827 delete this.restoreSize;
828 this.maximized = false;
829 this.el.enableShadow(true);
834 if(this.collapsible && t.toggle){
837 this.container.removeClass('x-window-maximized-ct');
840 this.fireEvent('restore', this);
845 <div id="method-Ext.Window-toggleMaximize"></div>/**
846 * A shortcut method for toggling between {@link #maximize} and {@link #restore} based on the current maximized
847 * state of the window.
848 * @return {Ext.Window} this
850 toggleMaximize : function(){
851 return this[this.maximized ? 'restore' : 'maximize']();
855 fitContainer : function(){
856 var vs = this.container.getViewSize(false);
857 this.setSize(vs.width, vs.height);
861 // z-index is managed by the WindowManager and may be overwritten at any time
862 setZIndex : function(index){
864 this.mask.setStyle('z-index', index);
866 this.el.setZIndex(++index);
870 this.resizer.proxy.setStyle('z-index', ++index);
873 this.lastZIndex = index;
876 <div id="method-Ext.Window-alignTo"></div>/**
877 * Aligns the window to the specified element
878 * @param {Mixed} element The element to align to.
879 * @param {String} position (optional, defaults to "tl-bl?") The position to align to (see {@link Ext.Element#alignTo} for more details).
880 * @param {Array} offsets (optional) Offset the positioning by [x, y]
881 * @return {Ext.Window} this
883 alignTo : function(element, position, offsets){
884 var xy = this.el.getAlignToXY(element, position, offsets);
885 this.setPagePosition(xy[0], xy[1]);
889 <div id="method-Ext.Window-anchorTo"></div>/**
890 * Anchors this window to another element and realigns it when the window is resized or scrolled.
891 * @param {Mixed} element The element to align to.
892 * @param {String} position The position to align to (see {@link Ext.Element#alignTo} for more details)
893 * @param {Array} offsets (optional) Offset the positioning by [x, y]
894 * @param {Boolean/Number} monitorScroll (optional) true to monitor body scroll and reposition. If this parameter
895 * is a number, it is used as the buffer delay (defaults to 50ms).
896 * @return {Ext.Window} this
898 anchorTo : function(el, alignment, offsets, monitorScroll){
900 this.anchorTarget = {
902 alignment: alignment,
906 Ext.EventManager.onWindowResize(this.doAnchor, this);
907 var tm = typeof monitorScroll;
908 if(tm != 'undefined'){
909 Ext.EventManager.on(window, 'scroll', this.doAnchor, this,
910 {buffer: tm == 'number' ? monitorScroll : 50});
912 return this.doAnchor();
916 * Performs the anchor, using the saved anchorTarget property.
917 * @return {Ext.Window} this
920 doAnchor : function(){
921 var o = this.anchorTarget;
922 this.alignTo(o.el, o.alignment, o.offsets);
926 <div id="method-Ext.Window-clearAnchor"></div>/**
927 * Removes any existing anchor from this window. See {@link #anchorTo}.
928 * @return {Ext.Window} this
930 clearAnchor : function(){
931 if(this.anchorTarget){
932 Ext.EventManager.removeResizeListener(this.doAnchor, this);
933 Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
934 delete this.anchorTarget;
939 <div id="method-Ext.Window-toFront"></div>/**
940 * Brings this window to the front of any other visible windows
941 * @param {Boolean} e (optional) Specify <tt>false</tt> to prevent the window from being focused.
942 * @return {Ext.Window} this
944 toFront : function(e){
945 if(this.manager.bringToFront(this)){
946 if(!e || !e.getTarget().focus){
953 <div id="method-Ext.Window-setActive"></div>/**
954 * Makes this the active window by showing its shadow, or deactivates it by hiding its shadow. This method also
955 * fires the {@link #activate} or {@link #deactivate} event depending on which action occurred. This method is
956 * called internally by {@link Ext.WindowMgr}.
957 * @param {Boolean} active True to activate the window, false to deactivate it (defaults to false)
959 setActive : function(active){
962 this.el.enableShadow(true);
964 this.fireEvent('activate', this);
966 this.el.disableShadow();
967 this.fireEvent('deactivate', this);
971 <div id="method-Ext.Window-toBack"></div>/**
972 * Sends this window to the back of (lower z-index than) any other visible windows
973 * @return {Ext.Window} this
976 this.manager.sendToBack(this);
980 <div id="method-Ext.Window-center"></div>/**
981 * Centers this window in the viewport
982 * @return {Ext.Window} this
985 var xy = this.el.getAlignToXY(this.container, 'c-c');
986 this.setPagePosition(xy[0], xy[1]);
990 <div id="cfg-Ext.Window-autoWidth"></div>/**
991 * @cfg {Boolean} autoWidth @hide
994 Ext.reg('window', Ext.Window);
996 // private - custom Window DD implementation
997 Ext.Window.DD = function(win){
999 Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id);
1000 this.setHandleElId(win.header.id);
1001 this.scroll = false;
1004 Ext.extend(Ext.Window.DD, Ext.dd.DD, {
1006 headerOffsets:[100, 25],
1007 startDrag : function(){
1009 this.proxy = w.ghost();
1010 if(w.constrain !== false){
1011 var so = w.el.shadowOffset;
1012 this.constrainTo(w.container, {right: so, left: so, bottom: so});
1013 }else if(w.constrainHeader !== false){
1014 var s = this.proxy.getSize();
1015 this.constrainTo(w.container, {right: -(s.width-this.headerOffsets[0]), bottom: -(s.height-this.headerOffsets[1])});
1018 b4Drag : Ext.emptyFn,
1020 onDrag : function(e){
1021 this.alignElWithMouse(this.proxy, e.getPageX(), e.getPageY());
1024 endDrag : function(e){
1026 this.win.saveState();