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.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.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 <div id="cfg-Ext.Window-showAnimDuration"></div>/**
191 * @cfg {Number} showAnimDuration The number of seconds that the window show animation takes if enabled.
194 showAnimDuration: 0.25,
196 <div id="cfg-Ext.Window-hideAnimDuration"></div>/**
197 * @cfg {Number} hideAnimDuration The number of seconds that the window hide animation takes if enabled.
200 hideAnimDuration: 0.25,
202 // inherited docs, same default
205 <div id="cfg-Ext.Window-initHidden"></div>/**
206 * @cfg {Boolean} initHidden
207 * True to hide the window until show() is explicitly called (defaults to true).
210 initHidden : undefined,
212 <div id="cfg-Ext.Window-hidden"></div>/**
213 * @cfg {Boolean} hidden
214 * Render this component hidden (default is <tt>true</tt>). If <tt>true</tt>, the
215 * {@link #hide} method will be called internally.
219 // The following configs are set to provide the basic functionality of a window.
220 // Changing them would require additional code to handle correctly and should
221 // usually only be done in subclasses that can provide custom behavior. Changing them
222 // may have unexpected or undesirable results.
223 <div id="cfg-Ext.Window-elements"></div>/** @cfg {String} elements @hide */
224 elements : 'header,body',
225 <div id="cfg-Ext.Window-frame"></div>/** @cfg {Boolean} frame @hide */
227 <div id="cfg-Ext.Window-floating"></div>/** @cfg {Boolean} floating @hide */
231 initComponent : function(){
233 Ext.Window.superclass.initComponent.call(this);
235 <div id="event-Ext.Window-activate"></div>/**
237 * Fires after the window has been visually activated via {@link #setActive}.
238 * @param {Ext.Window} this
240 <div id="event-Ext.Window-deactivate"></div>/**
242 * Fires after the window has been visually deactivated via {@link #setActive}.
243 * @param {Ext.Window} this
245 <div id="event-Ext.Window-resize"></div>/**
247 * Fires after the window has been resized.
248 * @param {Ext.Window} this
249 * @param {Number} width The window's new width
250 * @param {Number} height The window's new height
253 <div id="event-Ext.Window-maximize"></div>/**
255 * Fires after the window has been maximized.
256 * @param {Ext.Window} this
259 <div id="event-Ext.Window-minimize"></div>/**
261 * Fires after the window has been minimized.
262 * @param {Ext.Window} this
265 <div id="event-Ext.Window-restore"></div>/**
267 * Fires after the window has been restored to its original size after being maximized.
268 * @param {Ext.Window} this
272 // for backwards compat, this should be removed at some point
273 if(Ext.isDefined(this.initHidden)){
274 this.hidden = this.initHidden;
276 if(this.hidden === false){
283 getState : function(){
284 return Ext.apply(Ext.Window.superclass.getState.call(this) || {}, this.getBox(true));
288 onRender : function(ct, position){
289 Ext.Window.superclass.onRender.call(this, ct, position);
292 this.el.addClass('x-window-plain');
295 // this element allows the Window to be focused for keyboard events
296 this.focusEl = this.el.createChild({
297 tag: 'a', href:'#', cls:'x-dlg-focus',
298 tabIndex:'-1', html: ' '});
299 this.focusEl.swallowEvent('click', true);
301 this.proxy = this.el.createProxy('x-window-proxy');
302 this.proxy.enableDisplayMode('block');
305 this.mask = this.container.createChild({cls:'ext-el-mask'}, this.el.dom);
306 this.mask.enableDisplayMode('block');
308 this.mon(this.mask, 'click', this.focus, this);
310 if(this.maximizable){
311 this.mon(this.header, 'dblclick', this.toggleMaximize, this);
316 initEvents : function(){
317 Ext.Window.superclass.initEvents.call(this);
318 if(this.animateTarget){
319 this.setAnimateTarget(this.animateTarget);
323 this.resizer = new Ext.Resizable(this.el, {
324 minWidth: this.minWidth,
325 minHeight:this.minHeight,
326 handles: this.resizeHandles || 'all',
328 resizeElement : this.resizerAction,
329 handleCls: 'x-window-handle'
331 this.resizer.window = this;
332 this.mon(this.resizer, 'beforeresize', this.beforeResize, this);
336 this.header.addClass('x-window-draggable');
338 this.mon(this.el, 'mousedown', this.toFront, this);
339 this.manager = this.manager || Ext.WindowMgr;
340 this.manager.register(this);
342 this.maximized = false;
346 var km = this.getKeyMap();
347 km.on(27, this.onEsc, this);
352 initDraggable : function(){
353 <div id="prop-Ext.Window-dd"></div>/**
354 * <p>If this Window is configured {@link #draggable}, this property will contain
355 * an instance of {@link Ext.dd.DD} which handles dragging the Window's DOM Element.</p>
356 * <p>This has implementations of <code>startDrag</code>, <code>onDrag</code> and <code>endDrag</code>
357 * which perform the dragging action. If extra logic is needed at these points, use
358 * {@link Function#createInterceptor createInterceptor} or {@link Function#createSequence createSequence} to
359 * augment the existing implementations.</p>
363 this.dd = new Ext.Window.DD(this);
367 onEsc : function(k, e){
369 this[this.closeAction]();
373 beforeDestroy : function(){
385 Ext.Window.superclass.beforeDestroy.call(this);
389 onDestroy : function(){
391 this.manager.unregister(this);
393 Ext.Window.superclass.onDestroy.call(this);
397 initTools : function(){
398 if(this.minimizable){
401 handler: this.minimize.createDelegate(this, [])
404 if(this.maximizable){
407 handler: this.maximize.createDelegate(this, [])
411 handler: this.restore.createDelegate(this, []),
418 handler: this[this.closeAction].createDelegate(this, [])
424 resizerAction : function(){
425 var box = this.proxy.getBox();
427 this.window.handleResize(box);
432 beforeResize : function(){
433 this.resizer.minHeight = Math.max(this.minHeight, this.getFrameHeight() + 40); // 40 is a magic minimum content size?
434 this.resizer.minWidth = Math.max(this.minWidth, this.getFrameWidth() + 40);
435 this.resizeBox = this.el.getBox();
439 updateHandles : function(){
440 if(Ext.isIE && this.resizer){
441 this.resizer.syncHandleHeight();
447 handleResize : function(box){
448 var rz = this.resizeBox;
449 if(rz.x != box.x || rz.y != box.y){
453 if (Ext.isIE6 && Ext.isStrict) {
458 this.updateHandles();
462 <div id="method-Ext.Window-focus"></div>/**
463 * Focuses the window. If a defaultButton is set, it will receive focus, otherwise the
464 * window itself will receive focus.
467 var f = this.focusEl,
468 db = this.defaultButton,
472 if(Ext.isDefined(db)){
473 if(Ext.isNumber(db) && this.fbar){
474 f = this.fbar.items.get(db);
475 }else if(Ext.isString(db)){
481 ct = Ext.getDom(this.container);
483 if (ct != document.body && !Ext.lib.Region.getRegion(ct).contains(Ext.lib.Region.getRegion(el.dom))){
488 f = f || this.focusEl;
489 f.focus.defer(10, f);
492 <div id="method-Ext.Window-setAnimateTarget"></div>/**
493 * Sets the target element from which the window should animate while opening.
494 * @param {String/Element} el The target element or id
496 setAnimateTarget : function(el){
498 this.animateTarget = el;
502 beforeShow : function(){
503 delete this.el.lastXY;
504 delete this.el.lastLT;
505 if(this.x === undefined || this.y === undefined){
506 var xy = this.el.getAlignToXY(this.container, 'c-c');
507 var pos = this.el.translatePoints(xy[0], xy[1]);
508 this.x = this.x === undefined? pos.left : this.x;
509 this.y = this.y === undefined? pos.top : this.y;
511 this.el.setLeftTop(this.x, this.y);
513 if(this.expandOnShow){
518 Ext.getBody().addClass('x-body-masked');
519 this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
524 <div id="method-Ext.Window-show"></div>/**
525 * Shows the window, rendering it first if necessary, or activates it and brings it to front if hidden.
526 * @param {String/Element} animateTarget (optional) The target element or id from which the window should
527 * animate while opening (defaults to null with no animation)
528 * @param {Function} callback (optional) A callback function to call after the window is displayed
529 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this Window.
530 * @return {Ext.Window} this
532 show : function(animateTarget, cb, scope){
534 this.render(Ext.getBody());
536 if(this.hidden === false){
540 if(this.fireEvent('beforeshow', this) === false){
544 this.on('show', cb, scope, {single:true});
547 if(Ext.isDefined(animateTarget)){
548 this.setAnimateTarget(animateTarget);
551 if(this.animateTarget){
560 afterShow : function(isAnim){
561 if (this.isDestroyed){
565 this.el.setStyle('display', 'block');
570 if(Ext.isMac && Ext.isGecko2){ // work around stupid FF 2.0/Mac scroll bar bug
571 this.cascade(this.setAutoScroll);
574 if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
575 Ext.EventManager.onWindowResize(this.onWindowResize, this);
580 this.keyMap.enable();
583 this.updateHandles();
584 if(isAnim && (Ext.isIE || Ext.isWebKit)){
585 var sz = this.getSize();
586 this.onResize(sz.width, sz.height);
589 this.fireEvent('show', this);
593 animShow : function(){
595 this.proxy.setBox(this.animateTarget.getBox());
596 this.proxy.setOpacity(0);
597 var b = this.getBox();
598 this.el.setStyle('display', 'none');
599 this.proxy.shift(Ext.apply(b, {
600 callback: this.afterShow.createDelegate(this, [true], false),
603 duration: this.showAnimDuration,
608 <div id="method-Ext.Window-hide"></div>/**
609 * Hides the window, setting it to invisible and applying negative offsets.
610 * @param {String/Element} animateTarget (optional) The target element or id to which the window should
611 * animate while hiding (defaults to null with no animation)
612 * @param {Function} callback (optional) A callback function to call after the window is hidden
613 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this Window.
614 * @return {Ext.Window} this
616 hide : function(animateTarget, cb, scope){
617 if(this.hidden || this.fireEvent('beforehide', this) === false){
621 this.on('hide', cb, scope, {single:true});
624 if(animateTarget !== undefined){
625 this.setAnimateTarget(animateTarget);
629 Ext.getBody().removeClass('x-body-masked');
631 if(this.animateTarget){
641 afterHide : function(){
643 if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
644 Ext.EventManager.removeResizeListener(this.onWindowResize, this);
647 this.keyMap.disable();
650 this.fireEvent('hide', this);
654 animHide : function(){
655 this.proxy.setOpacity(0.5);
657 var tb = this.getBox(false);
658 this.proxy.setBox(tb);
660 this.proxy.shift(Ext.apply(this.animateTarget.getBox(), {
661 callback: this.afterHide,
663 duration: this.hideAnimDuration,
669 <div id="prop-Ext.Window-onShow"></div>/**
670 * Method that is called immediately before the <code>show</code> event is fired.
671 * Defaults to <code>Ext.emptyFn</code>.
673 onShow : Ext.emptyFn,
675 <div id="prop-Ext.Window-onHide"></div>/**
676 * Method that is called immediately before the <code>hide</code> event is fired.
677 * Defaults to <code>Ext.emptyFn</code>.
679 onHide : Ext.emptyFn,
682 onWindowResize : function(){
687 this.mask.setSize('100%', '100%');
688 var force = this.mask.dom.offsetHeight;
689 this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
695 doConstrain : function(){
696 if(this.constrain || this.constrainHeader){
700 right:this.el.shadowOffset,
701 left:this.el.shadowOffset,
702 bottom:this.el.shadowOffset
705 var s = this.getSize();
707 right:-(s.width - 100),
708 bottom:-(s.height - 25)
712 var xy = this.el.getConstrainToXY(this.container, true, offsets);
714 this.setPosition(xy[0], xy[1]);
719 // private - used for dragging
720 ghost : function(cls){
721 var ghost = this.createGhost(cls);
722 var box = this.getBox(true);
723 ghost.setLeftTop(box.x, box.y);
724 ghost.setWidth(box.width);
726 this.activeGhost = ghost;
731 unghost : function(show, matchPosition){
732 if(!this.activeGhost) {
737 this.focus.defer(10, this);
738 if(Ext.isMac && Ext.isGecko2){ // work around stupid FF 2.0/Mac scroll bar bug
739 this.cascade(this.setAutoScroll);
742 if(matchPosition !== false){
743 this.setPosition(this.activeGhost.getLeft(true), this.activeGhost.getTop(true));
745 this.activeGhost.hide();
746 this.activeGhost.remove();
747 delete this.activeGhost;
750 <div id="method-Ext.Window-minimize"></div>/**
751 * Placeholder method for minimizing the window. By default, this method simply fires the {@link #minimize} event
752 * since the behavior of minimizing a window is application-specific. To implement custom minimize behavior,
753 * either the minimize event can be handled or this method can be overridden.
754 * @return {Ext.Window} this
756 minimize : function(){
757 this.fireEvent('minimize', this);
761 <div id="method-Ext.Window-close"></div>/**
762 * <p>Closes the Window, removes it from the DOM, {@link Ext.Component#destroy destroy}s
763 * the Window object and all its descendant Components. The {@link Ext.Panel#beforeclose beforeclose}
764 * event is fired before the close happens and will cancel the close action if it returns false.<p>
765 * <p><b>Note:</b> This method is not affected by the {@link #closeAction} setting which
766 * only affects the action triggered when clicking the {@link #closable 'close' tool in the header}.
767 * To hide the Window without destroying it, call {@link #hide}.</p>
770 if(this.fireEvent('beforeclose', this) !== false){
774 this.hide(null, this.doClose, this);
780 doClose : function(){
781 this.fireEvent('close', this);
785 <div id="method-Ext.Window-maximize"></div>/**
786 * Fits the window within its current container and automatically replaces
787 * the {@link #maximizable 'maximize' tool button} with the 'restore' tool button.
788 * Also see {@link #toggleMaximize}.
789 * @return {Ext.Window} this
791 maximize : function(){
794 this.restoreSize = this.getSize();
795 this.restorePos = this.getPosition(true);
796 if (this.maximizable){
797 this.tools.maximize.hide();
798 this.tools.restore.show();
800 this.maximized = true;
801 this.el.disableShadow();
806 if(this.collapsible){
807 this.tools.toggle.hide();
809 this.el.addClass('x-window-maximized');
810 this.container.addClass('x-window-maximized-ct');
812 this.setPosition(0, 0);
814 this.fireEvent('maximize', this);
819 <div id="method-Ext.Window-restore"></div>/**
820 * Restores a {@link #maximizable maximized} window back to its original
821 * size and position prior to being maximized and also replaces
822 * the 'restore' tool button with the 'maximize' tool button.
823 * Also see {@link #toggleMaximize}.
824 * @return {Ext.Window} this
826 restore : function(){
829 this.el.removeClass('x-window-maximized');
836 this.setPosition(this.restorePos[0], this.restorePos[1]);
837 this.setSize(this.restoreSize.width, this.restoreSize.height);
838 delete this.restorePos;
839 delete this.restoreSize;
840 this.maximized = false;
841 this.el.enableShadow(true);
846 if(this.collapsible && t.toggle){
849 this.container.removeClass('x-window-maximized-ct');
852 this.fireEvent('restore', this);
857 <div id="method-Ext.Window-toggleMaximize"></div>/**
858 * A shortcut method for toggling between {@link #maximize} and {@link #restore} based on the current maximized
859 * state of the window.
860 * @return {Ext.Window} this
862 toggleMaximize : function(){
863 return this[this.maximized ? 'restore' : 'maximize']();
867 fitContainer : function(){
868 var vs = this.container.getViewSize(false);
869 this.setSize(vs.width, vs.height);
873 // z-index is managed by the WindowManager and may be overwritten at any time
874 setZIndex : function(index){
876 this.mask.setStyle('z-index', index);
878 this.el.setZIndex(++index);
882 this.resizer.proxy.setStyle('z-index', ++index);
885 this.lastZIndex = index;
888 <div id="method-Ext.Window-alignTo"></div>/**
889 * Aligns the window to the specified element
890 * @param {Mixed} element The element to align to.
891 * @param {String} position (optional, defaults to "tl-bl?") The position to align to (see {@link Ext.Element#alignTo} for more details).
892 * @param {Array} offsets (optional) Offset the positioning by [x, y]
893 * @return {Ext.Window} this
895 alignTo : function(element, position, offsets){
896 var xy = this.el.getAlignToXY(element, position, offsets);
897 this.setPagePosition(xy[0], xy[1]);
901 <div id="method-Ext.Window-anchorTo"></div>/**
902 * Anchors this window to another element and realigns it when the window is resized or scrolled.
903 * @param {Mixed} element The element to align to.
904 * @param {String} position The position to align to (see {@link Ext.Element#alignTo} for more details)
905 * @param {Array} offsets (optional) Offset the positioning by [x, y]
906 * @param {Boolean/Number} monitorScroll (optional) true to monitor body scroll and reposition. If this parameter
907 * is a number, it is used as the buffer delay (defaults to 50ms).
908 * @return {Ext.Window} this
910 anchorTo : function(el, alignment, offsets, monitorScroll){
912 this.anchorTarget = {
914 alignment: alignment,
918 Ext.EventManager.onWindowResize(this.doAnchor, this);
919 var tm = typeof monitorScroll;
920 if(tm != 'undefined'){
921 Ext.EventManager.on(window, 'scroll', this.doAnchor, this,
922 {buffer: tm == 'number' ? monitorScroll : 50});
924 return this.doAnchor();
928 * Performs the anchor, using the saved anchorTarget property.
929 * @return {Ext.Window} this
932 doAnchor : function(){
933 var o = this.anchorTarget;
934 this.alignTo(o.el, o.alignment, o.offsets);
938 <div id="method-Ext.Window-clearAnchor"></div>/**
939 * Removes any existing anchor from this window. See {@link #anchorTo}.
940 * @return {Ext.Window} this
942 clearAnchor : function(){
943 if(this.anchorTarget){
944 Ext.EventManager.removeResizeListener(this.doAnchor, this);
945 Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
946 delete this.anchorTarget;
951 <div id="method-Ext.Window-toFront"></div>/**
952 * Brings this window to the front of any other visible windows
953 * @param {Boolean} e (optional) Specify <tt>false</tt> to prevent the window from being focused.
954 * @return {Ext.Window} this
956 toFront : function(e){
957 if(this.manager.bringToFront(this)){
958 if(!e || !e.getTarget().focus){
965 <div id="method-Ext.Window-setActive"></div>/**
966 * Makes this the active window by showing its shadow, or deactivates it by hiding its shadow. This method also
967 * fires the {@link #activate} or {@link #deactivate} event depending on which action occurred. This method is
968 * called internally by {@link Ext.WindowMgr}.
969 * @param {Boolean} active True to activate the window, false to deactivate it (defaults to false)
971 setActive : function(active){
974 this.el.enableShadow(true);
976 this.fireEvent('activate', this);
978 this.el.disableShadow();
979 this.fireEvent('deactivate', this);
983 <div id="method-Ext.Window-toBack"></div>/**
984 * Sends this window to the back of (lower z-index than) any other visible windows
985 * @return {Ext.Window} this
988 this.manager.sendToBack(this);
992 <div id="method-Ext.Window-center"></div>/**
993 * Centers this window in the viewport
994 * @return {Ext.Window} this
997 var xy = this.el.getAlignToXY(this.container, 'c-c');
998 this.setPagePosition(xy[0], xy[1]);
1002 <div id="cfg-Ext.Window-autoWidth"></div>/**
1003 * @cfg {Boolean} autoWidth @hide
1006 Ext.reg('window', Ext.Window);
1008 // private - custom Window DD implementation
1009 Ext.Window.DD = Ext.extend(Ext.dd.DD, {
1011 constructor : function(win){
1013 Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id);
1014 this.setHandleElId(win.header.id);
1015 this.scroll = false;
1019 headerOffsets:[100, 25],
1020 startDrag : function(){
1022 this.proxy = w.ghost(w.initialConfig.cls);
1023 if(w.constrain !== false){
1024 var so = w.el.shadowOffset;
1025 this.constrainTo(w.container, {right: so, left: so, bottom: so});
1026 }else if(w.constrainHeader !== false){
1027 var s = this.proxy.getSize();
1028 this.constrainTo(w.container, {right: -(s.width-this.headerOffsets[0]), bottom: -(s.height-this.headerOffsets[1])});
1031 b4Drag : Ext.emptyFn,
1033 onDrag : function(e){
1034 this.alignElWithMouse(this.proxy, e.getPageX(), e.getPageY());
1037 endDrag : function(e){
1039 this.win.saveState();