3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js"><div id="cls-Ext.Window"></div>/**
11 * <p>A specialized panel intended for use as an application window. Windows are floated, {@link #resizable}, and
12 * {@link #draggable} by default. Windows can be {@link #maximizable maximized} to fill the viewport,
13 * restored to their prior size, and can be {@link #minimize}d.</p>
14 * <p>Windows can also be linked to a {@link Ext.WindowGroup} or managed by the {@link Ext.WindowMgr} to provide
15 * grouping, activation, to front, to back and other application-specific behavior.</p>
16 * <p>By default, Windows will be rendered to document.body. To {@link #constrain} a Window to another element
17 * specify {@link Ext.Component#renderTo renderTo}.</p>
18 * <p><b>Note:</b> By default, the <code>{@link #closable close}</code> header tool <i>destroys</i> the Window resulting in
19 * destruction of any child Components. This makes the Window object, and all its descendants <b>unusable</b>. To enable
20 * re-use of a Window, use <b><code>{@link #closeAction closeAction: 'hide'}</code></b>.</p>
22 * @param {Object} config The config object
25 Ext.Window = Ext.extend(Ext.Panel, {
26 <div id="cfg-Ext.Window-x"></div>/**
28 * The X position of the left edge of the window on initial showing. Defaults to centering the Window within
29 * the width of the Window's container {@link Ext.Element Element) (The Element that the Window is rendered to).
31 <div id="cfg-Ext.Window-y"></div>/**
33 * The Y position of the top edge of the window on initial showing. Defaults to centering the Window within
34 * the height of the Window's container {@link Ext.Element Element) (The Element that the Window is rendered to).
36 <div id="cfg-Ext.Window-modal"></div>/**
37 * @cfg {Boolean} modal
38 * True to make the window modal and mask everything behind it when displayed, false to display it without
39 * restricting access to other UI elements (defaults to false).
41 <div id="cfg-Ext.Window-animateTarget"></div>/**
42 * @cfg {String/Element} animateTarget
43 * Id or element from which the window should animate while opening (defaults to null with no animation).
45 <div id="cfg-Ext.Window-resizeHandles"></div>/**
46 * @cfg {String} resizeHandles
47 * A valid {@link Ext.Resizable} handles config string (defaults to 'all'). Only applies when resizable = true.
49 <div id="cfg-Ext.Window-manager"></div>/**
50 * @cfg {Ext.WindowGroup} manager
51 * A reference to the WindowGroup that should manage this window (defaults to {@link Ext.WindowMgr}).
53 <div id="cfg-Ext.Window-defaultButton"></div>/**
54 * @cfg {String/Number/Button} defaultButton
55 * The id / index of a button or a button instance to focus when this window received the focus.
57 <div id="cfg-Ext.Window-onEsc"></div>/**
58 * @cfg {Function} onEsc
59 * Allows override of the built-in processing for the escape key. Default action
60 * is to close the Window (performing whatever action is specified in {@link #closeAction}.
61 * To prevent the Window closing when the escape key is pressed, specify this as
62 * Ext.emptyFn (See {@link Ext#emptyFn}).
64 <div id="cfg-Ext.Window-collapsed"></div>/**
65 * @cfg {Boolean} collapsed
66 * True to render the window collapsed, false to render it expanded (defaults to false). Note that if
67 * {@link #expandOnShow} is true (the default) it will override the <tt>collapsed</tt> config and the window
68 * will always be expanded when shown.
70 <div id="cfg-Ext.Window-maximized"></div>/**
71 * @cfg {Boolean} maximized
72 * True to initially display the window in a maximized state. (Defaults to false).
75 <div id="cfg-Ext.Window-baseCls"></div>/**
76 * @cfg {String} baseCls
77 * The base CSS class to apply to this panel's element (defaults to 'x-window').
80 <div id="cfg-Ext.Window-resizable"></div>/**
81 * @cfg {Boolean} resizable
82 * True to allow user resizing at each edge and corner of the window, false to disable resizing (defaults to true).
85 <div id="cfg-Ext.Window-draggable"></div>/**
86 * @cfg {Boolean} draggable
87 * True to allow the window to be dragged by the header bar, false to disable dragging (defaults to true). Note
88 * that by default the window will be centered in the viewport, so if dragging is disabled the window may need
89 * to be positioned programmatically after render (e.g., myWindow.setPosition(100, 100);).
92 <div id="cfg-Ext.Window-closable"></div>/**
93 * @cfg {Boolean} closable
94 * <p>True to display the 'close' tool button and allow the user to close the window, false to
95 * hide the button and disallow closing the window (defaults to true).</p>
96 * <p>By default, when close is requested by either clicking the close button in the header
97 * or pressing ESC when the Window has focus, the {@link #close} method will be called. This
98 * will <i>{@link Ext.Component#destroy destroy}</i> the Window and its content meaning that
99 * it may not be reused.</p>
100 * <p>To make closing a Window <i>hide</i> the Window so that it may be reused, set
101 * {@link #closeAction} to 'hide'.
104 <div id="cfg-Ext.Window-closeAction"></div>/**
105 * @cfg {String} closeAction
106 * <p>The action to take when the close header tool is clicked:
107 * <div class="mdetail-params"><ul>
108 * <li><b><code>'{@link #close}'</code></b> : <b>Default</b><div class="sub-desc">
109 * {@link #close remove} the window from the DOM and {@link Ext.Component#destroy destroy}
110 * it and all descendant Components. The window will <b>not</b> be available to be
111 * redisplayed via the {@link #show} method.
113 * <li><b><code>'{@link #hide}'</code></b> : <div class="sub-desc">
114 * {@link #hide} the window by setting visibility to hidden and applying negative offsets.
115 * The window will be available to be redisplayed via the {@link #show} method.
118 * <p><b>Note:</b> This setting does not affect the {@link #close} method
119 * which will always {@link Ext.Component#destroy destroy} the window. To
120 * programatically <i>hide</i> a window, call {@link #hide}.</p>
122 closeAction : 'close',
123 <div id="cfg-Ext.Window-constrain"></div>/**
124 * @cfg {Boolean} constrain
125 * True to constrain the window within its containing element, false to allow it to fall outside of its
126 * containing element. By default the window will be rendered to document.body. To render and constrain the
127 * window within another element specify {@link #renderTo}.
128 * (defaults to false). Optionally the header only can be constrained using {@link #constrainHeader}.
131 <div id="cfg-Ext.Window-constrainHeader"></div>/**
132 * @cfg {Boolean} constrainHeader
133 * True to constrain the window header within its containing element (allowing the window body to fall outside
134 * of its containing element) or false to allow the header to fall outside its containing element (defaults to
135 * false). Optionally the entire window can be constrained using {@link #constrain}.
137 constrainHeader : false,
138 <div id="cfg-Ext.Window-plain"></div>/**
139 * @cfg {Boolean} plain
140 * True to render the window body with a transparent background so that it will blend into the framing
141 * elements, false to add a lighter background color to visually highlight the body element and separate it
142 * more distinctly from the surrounding frame (defaults to false).
145 <div id="cfg-Ext.Window-minimizable"></div>/**
146 * @cfg {Boolean} minimizable
147 * True to display the 'minimize' tool button and allow the user to minimize the window, false to hide the button
148 * and disallow minimizing the window (defaults to false). Note that this button provides no implementation --
149 * the behavior of minimizing a window is implementation-specific, so the minimize event must be handled and a
150 * custom minimize behavior implemented for this option to be useful.
153 <div id="cfg-Ext.Window-maximizable"></div>/**
154 * @cfg {Boolean} maximizable
155 * True to display the 'maximize' tool button and allow the user to maximize the window, false to hide the button
156 * and disallow maximizing the window (defaults to false). Note that when a window is maximized, the tool button
157 * will automatically change to a 'restore' button with the appropriate behavior already built-in that will
158 * restore the window to its previous size.
161 <div id="cfg-Ext.Window-minHeight"></div>/**
162 * @cfg {Number} minHeight
163 * The minimum height in pixels allowed for this window (defaults to 100). Only applies when resizable = true.
166 <div id="cfg-Ext.Window-minWidth"></div>/**
167 * @cfg {Number} minWidth
168 * The minimum width in pixels allowed for this window (defaults to 200). Only applies when resizable = true.
171 <div id="cfg-Ext.Window-expandOnShow"></div>/**
172 * @cfg {Boolean} expandOnShow
173 * True to always expand the window when it is displayed, false to keep it in its current state (which may be
174 * {@link #collapsed}) when displayed (defaults to true).
178 // inherited docs, same default
181 <div id="cfg-Ext.Window-initHidden"></div>/**
182 * @cfg {Boolean} initHidden
183 * True to hide the window until show() is explicitly called (defaults to true).
186 <div id="cfg-Ext.Window-monitorResize"></div>/**
187 * @cfg {Boolean} monitorResize @hide
188 * This is automatically managed based on the value of constrain and constrainToHeader
190 monitorResize : true,
192 // The following configs are set to provide the basic functionality of a window.
193 // Changing them would require additional code to handle correctly and should
194 // usually only be done in subclasses that can provide custom behavior. Changing them
195 // may have unexpected or undesirable results.
196 <div id="cfg-Ext.Window-elements"></div>/** @cfg {String} elements @hide */
197 elements : 'header,body',
198 <div id="cfg-Ext.Window-frame"></div>/** @cfg {Boolean} frame @hide */
200 <div id="cfg-Ext.Window-floating"></div>/** @cfg {Boolean} floating @hide */
204 initComponent : function(){
205 Ext.Window.superclass.initComponent.call(this);
207 <div id="event-Ext.Window-activate"></div>/**
209 * Fires after the window has been visually activated via {@link setActive}.
210 * @param {Ext.Window} this
212 <div id="event-Ext.Window-deactivate"></div>/**
214 * Fires after the window has been visually deactivated via {@link setActive}.
215 * @param {Ext.Window} this
217 <div id="event-Ext.Window-resize"></div>/**
219 * Fires after the window has been resized.
220 * @param {Ext.Window} this
221 * @param {Number} width The window's new width
222 * @param {Number} height The window's new height
225 <div id="event-Ext.Window-maximize"></div>/**
227 * Fires after the window has been maximized.
228 * @param {Ext.Window} this
231 <div id="event-Ext.Window-minimize"></div>/**
233 * Fires after the window has been minimized.
234 * @param {Ext.Window} this
237 <div id="event-Ext.Window-restore"></div>/**
239 * Fires after the window has been restored to its original size after being maximized.
240 * @param {Ext.Window} this
244 if(this.initHidden === false){
252 getState : function(){
253 return Ext.apply(Ext.Window.superclass.getState.call(this) || {}, this.getBox(true));
257 onRender : function(ct, position){
258 Ext.Window.superclass.onRender.call(this, ct, position);
261 this.el.addClass('x-window-plain');
264 // this element allows the Window to be focused for keyboard events
265 this.focusEl = this.el.createChild({
266 tag: 'a', href:'#', cls:'x-dlg-focus',
267 tabIndex:'-1', html: ' '});
268 this.focusEl.swallowEvent('click', true);
270 this.proxy = this.el.createProxy('x-window-proxy');
271 this.proxy.enableDisplayMode('block');
274 this.mask = this.container.createChild({cls:'ext-el-mask'}, this.el.dom);
275 this.mask.enableDisplayMode('block');
277 this.mon(this.mask, 'click', this.focus, this);
283 initEvents : function(){
284 Ext.Window.superclass.initEvents.call(this);
285 if(this.animateTarget){
286 this.setAnimateTarget(this.animateTarget);
290 this.resizer = new Ext.Resizable(this.el, {
291 minWidth: this.minWidth,
292 minHeight:this.minHeight,
293 handles: this.resizeHandles || 'all',
295 resizeElement : this.resizerAction
297 this.resizer.window = this;
298 this.mon(this.resizer, 'beforeresize', this.beforeResize, this);
302 this.header.addClass('x-window-draggable');
304 this.mon(this.el, 'mousedown', this.toFront, this);
305 this.manager = this.manager || Ext.WindowMgr;
306 this.manager.register(this);
308 this.maximized = false;
312 var km = this.getKeyMap();
313 km.on(27, this.onEsc, this);
318 initDraggable : function(){
319 <div id="prop-Ext.Window-dd"></div>/**
320 * If this Window is configured {@link #draggable}, this property will contain
321 * an instance of {@link Ext.dd.DD} which handles dragging the Window's DOM Element.
325 this.dd = new Ext.Window.DD(this);
330 this[this.closeAction]();
334 beforeDestroy : function(){
338 Ext.EventManager.removeResizeListener(this.doAnchor, this);
339 Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
349 Ext.Window.superclass.beforeDestroy.call(this);
353 onDestroy : function(){
355 this.manager.unregister(this);
357 Ext.Window.superclass.onDestroy.call(this);
361 initTools : function(){
362 if(this.minimizable){
365 handler: this.minimize.createDelegate(this, [])
368 if(this.maximizable){
371 handler: this.maximize.createDelegate(this, [])
375 handler: this.restore.createDelegate(this, []),
378 this.mon(this.header, 'dblclick', this.toggleMaximize, this);
383 handler: this[this.closeAction].createDelegate(this, [])
389 resizerAction : function(){
390 var box = this.proxy.getBox();
392 this.window.handleResize(box);
397 beforeResize : function(){
398 this.resizer.minHeight = Math.max(this.minHeight, this.getFrameHeight() + 40); // 40 is a magic minimum content size?
399 this.resizer.minWidth = Math.max(this.minWidth, this.getFrameWidth() + 40);
400 this.resizeBox = this.el.getBox();
404 updateHandles : function(){
405 if(Ext.isIE && this.resizer){
406 this.resizer.syncHandleHeight();
412 handleResize : function(box){
413 var rz = this.resizeBox;
414 if(rz.x != box.x || rz.y != box.y){
420 this.updateHandles();
423 this.fireEvent('resize', this, box.width, box.height);
426 <div id="method-Ext.Window-focus"></div>/**
427 * Focuses the window. If a defaultButton is set, it will receive focus, otherwise the
428 * window itself will receive focus.
431 var f = this.focusEl, db = this.defaultButton, t = typeof db;
432 if(t != 'undefined'){
433 if(t == 'number' && this.fbar){
434 f = this.fbar.items.get(db);
435 }else if(t == 'string'){
441 f = f || this.focusEl;
442 f.focus.defer(10, f);
445 <div id="method-Ext.Window-setAnimateTarget"></div>/**
446 * Sets the target element from which the window should animate while opening.
447 * @param {String/Element} el The target element or id
449 setAnimateTarget : function(el){
451 this.animateTarget = el;
455 beforeShow : function(){
456 delete this.el.lastXY;
457 delete this.el.lastLT;
458 if(this.x === undefined || this.y === undefined){
459 var xy = this.el.getAlignToXY(this.container, 'c-c');
460 var pos = this.el.translatePoints(xy[0], xy[1]);
461 this.x = this.x === undefined? pos.left : this.x;
462 this.y = this.y === undefined? pos.top : this.y;
464 this.el.setLeftTop(this.x, this.y);
466 if(this.expandOnShow){
471 Ext.getBody().addClass('x-body-masked');
472 this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
477 <div id="method-Ext.Window-show"></div>/**
478 * Shows the window, rendering it first if necessary, or activates it and brings it to front if hidden.
479 * @param {String/Element} animateTarget (optional) The target element or id from which the window should
480 * animate while opening (defaults to null with no animation)
481 * @param {Function} callback (optional) A callback function to call after the window is displayed
482 * @param {Object} scope (optional) The scope in which to execute the callback
483 * @return {Ext.Window} this
485 show : function(animateTarget, cb, scope){
487 this.render(Ext.getBody());
489 if(this.hidden === false){
493 if(this.fireEvent('beforeshow', this) === false){
497 this.on('show', cb, scope, {single:true});
500 if(animateTarget !== undefined){
501 this.setAnimateTarget(animateTarget);
504 if(this.animateTarget){
513 afterShow : function(isAnim){
515 this.el.setStyle('display', 'block');
520 if(Ext.isMac && Ext.isGecko){ // work around stupid FF 2.0/Mac scroll bar bug
521 this.cascade(this.setAutoScroll);
524 if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
525 Ext.EventManager.onWindowResize(this.onWindowResize, this);
530 this.keyMap.enable();
533 this.updateHandles();
534 if(isAnim && (Ext.isIE || Ext.isWebKit)){
535 var sz = this.getSize();
536 this.onResize(sz.width, sz.height);
538 this.fireEvent('show', this);
542 animShow : function(){
544 this.proxy.setBox(this.animateTarget.getBox());
545 this.proxy.setOpacity(0);
546 var b = this.getBox(false);
547 b.callback = this.afterShow.createDelegate(this, [true], false);
550 b.easing = 'easeNone';
553 this.el.setStyle('display', 'none');
557 <div id="method-Ext.Window-hide"></div>/**
558 * Hides the window, setting it to invisible and applying negative offsets.
559 * @param {String/Element} animateTarget (optional) The target element or id to which the window should
560 * animate while hiding (defaults to null with no animation)
561 * @param {Function} callback (optional) A callback function to call after the window is hidden
562 * @param {Object} scope (optional) The scope in which to execute the callback
563 * @return {Ext.Window} this
565 hide : function(animateTarget, cb, scope){
566 if(this.hidden || this.fireEvent('beforehide', this) === false){
570 this.on('hide', cb, scope, {single:true});
573 if(animateTarget !== undefined){
574 this.setAnimateTarget(animateTarget);
578 Ext.getBody().removeClass('x-body-masked');
580 if(this.animateTarget){
590 afterHide : function(){
592 if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
593 Ext.EventManager.removeResizeListener(this.onWindowResize, this);
596 this.keyMap.disable();
598 this.fireEvent('hide', this);
602 animHide : function(){
603 this.proxy.setOpacity(0.5);
605 var tb = this.getBox(false);
606 this.proxy.setBox(tb);
608 var b = this.animateTarget.getBox();
609 b.callback = this.afterHide;
612 b.easing = 'easeNone';
619 onWindowResize : function(){
624 this.mask.setSize('100%', '100%');
625 var force = this.mask.dom.offsetHeight;
626 this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
632 doConstrain : function(){
633 if(this.constrain || this.constrainHeader){
637 right:this.el.shadowOffset,
638 left:this.el.shadowOffset,
639 bottom:this.el.shadowOffset
642 var s = this.getSize();
644 right:-(s.width - 100),
645 bottom:-(s.height - 25)
649 var xy = this.el.getConstrainToXY(this.container, true, offsets);
651 this.setPosition(xy[0], xy[1]);
656 // private - used for dragging
657 ghost : function(cls){
658 var ghost = this.createGhost(cls);
659 var box = this.getBox(true);
660 ghost.setLeftTop(box.x, box.y);
661 ghost.setWidth(box.width);
663 this.activeGhost = ghost;
668 unghost : function(show, matchPosition){
669 if(!this.activeGhost) {
675 if(Ext.isMac && Ext.isGecko){ // work around stupid FF 2.0/Mac scroll bar bug
676 this.cascade(this.setAutoScroll);
679 if(matchPosition !== false){
680 this.setPosition(this.activeGhost.getLeft(true), this.activeGhost.getTop(true));
682 this.activeGhost.hide();
683 this.activeGhost.remove();
684 delete this.activeGhost;
687 <div id="method-Ext.Window-minimize"></div>/**
688 * Placeholder method for minimizing the window. By default, this method simply fires the {@link #minimize} event
689 * since the behavior of minimizing a window is application-specific. To implement custom minimize behavior,
690 * either the minimize event can be handled or this method can be overridden.
691 * @return {Ext.Window} this
693 minimize : function(){
694 this.fireEvent('minimize', this);
698 <div id="method-Ext.Window-close"></div>/**
699 * <p>Closes the Window, removes it from the DOM, {@link Ext.Component#destroy destroy}s
700 * the Window object and all its descendant Components. The {@link Ext.Panel#beforeclose beforeclose}
701 * event is fired before the close happens and will cancel the close action if it returns false.<p>
702 * <p><b>Note:</b> This method is not affected by the {@link #closeAction} setting which
703 * only affects the action triggered when clicking the {@link #closable 'close' tool in the header}.
704 * To hide the Window without destroying it, call {@link #hide}.</p>
707 if(this.fireEvent('beforeclose', this) !== false){
708 this.hide(null, function(){
709 this.fireEvent('close', this);
715 <div id="method-Ext.Window-maximize"></div>/**
716 * Fits the window within its current container and automatically replaces
717 * the {@link #maximizable 'maximize' tool button} with the 'restore' tool button.
718 * Also see {@link #toggleMaximize}.
719 * @return {Ext.Window} this
721 maximize : function(){
724 this.restoreSize = this.getSize();
725 this.restorePos = this.getPosition(true);
726 if (this.maximizable){
727 this.tools.maximize.hide();
728 this.tools.restore.show();
730 this.maximized = true;
731 this.el.disableShadow();
736 if(this.collapsible){
737 this.tools.toggle.hide();
739 this.el.addClass('x-window-maximized');
740 this.container.addClass('x-window-maximized-ct');
742 this.setPosition(0, 0);
744 this.fireEvent('maximize', this);
749 <div id="method-Ext.Window-restore"></div>/**
750 * Restores a {@link #maximizable maximized} window back to its original
751 * size and position prior to being maximized and also replaces
752 * the 'restore' tool button with the 'maximize' tool button.
753 * Also see {@link #toggleMaximize}.
754 * @return {Ext.Window} this
756 restore : function(){
758 this.el.removeClass('x-window-maximized');
759 this.tools.restore.hide();
760 this.tools.maximize.show();
761 this.setPosition(this.restorePos[0], this.restorePos[1]);
762 this.setSize(this.restoreSize.width, this.restoreSize.height);
763 delete this.restorePos;
764 delete this.restoreSize;
765 this.maximized = false;
766 this.el.enableShadow(true);
771 if(this.collapsible){
772 this.tools.toggle.show();
774 this.container.removeClass('x-window-maximized-ct');
777 this.fireEvent('restore', this);
782 <div id="method-Ext.Window-toggleMaximize"></div>/**
783 * A shortcut method for toggling between {@link #maximize} and {@link #restore} based on the current maximized
784 * state of the window.
785 * @return {Ext.Window} this
787 toggleMaximize : function(){
788 return this[this.maximized ? 'restore' : 'maximize']();
792 fitContainer : function(){
793 var vs = this.container.getViewSize();
794 this.setSize(vs.width, vs.height);
798 // z-index is managed by the WindowManager and may be overwritten at any time
799 setZIndex : function(index){
801 this.mask.setStyle('z-index', index);
803 this.el.setZIndex(++index);
807 this.resizer.proxy.setStyle('z-index', ++index);
810 this.lastZIndex = index;
813 <div id="method-Ext.Window-alignTo"></div>/**
814 * Aligns the window to the specified element
815 * @param {Mixed} element The element to align to.
816 * @param {String} position The position to align to (see {@link Ext.Element#alignTo} for more details).
817 * @param {Array} offsets (optional) Offset the positioning by [x, y]
818 * @return {Ext.Window} this
820 alignTo : function(element, position, offsets){
821 var xy = this.el.getAlignToXY(element, position, offsets);
822 this.setPagePosition(xy[0], xy[1]);
826 <div id="method-Ext.Window-anchorTo"></div>/**
827 * Anchors this window to another element and realigns it when the window is resized or scrolled.
828 * @param {Mixed} element The element to align to.
829 * @param {String} position The position to align to (see {@link Ext.Element#alignTo} for more details)
830 * @param {Array} offsets (optional) Offset the positioning by [x, y]
831 * @param {Boolean/Number} monitorScroll (optional) true to monitor body scroll and reposition. If this parameter
832 * is a number, it is used as the buffer delay (defaults to 50ms).
833 * @return {Ext.Window} this
835 anchorTo : function(el, alignment, offsets, monitorScroll){
837 Ext.EventManager.removeResizeListener(this.doAnchor, this);
838 Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
840 this.doAnchor = function(){
841 this.alignTo(el, alignment, offsets);
843 Ext.EventManager.onWindowResize(this.doAnchor, this);
845 var tm = typeof monitorScroll;
846 if(tm != 'undefined'){
847 Ext.EventManager.on(window, 'scroll', this.doAnchor, this,
848 {buffer: tm == 'number' ? monitorScroll : 50});
854 <div id="method-Ext.Window-toFront"></div>/**
855 * Brings this window to the front of any other visible windows
856 * @param {Boolean} e (optional) Specify <tt>false</tt> to prevent the window from being focused.
857 * @return {Ext.Window} this
859 toFront : function(e){
860 if(this.manager.bringToFront(this)){
861 if(!e || !e.getTarget().focus){
868 <div id="method-Ext.Window-setActive"></div>/**
869 * Makes this the active window by showing its shadow, or deactivates it by hiding its shadow. This method also
870 * fires the {@link #activate} or {@link #deactivate} event depending on which action occurred.
871 * @param {Boolean} active True to activate the window, false to deactivate it (defaults to false)
873 setActive : function(active){
876 this.el.enableShadow(true);
878 this.fireEvent('activate', this);
880 this.el.disableShadow();
881 this.fireEvent('deactivate', this);
885 <div id="method-Ext.Window-toBack"></div>/**
886 * Sends this window to the back of (lower z-index than) any other visible windows
887 * @return {Ext.Window} this
890 this.manager.sendToBack(this);
894 <div id="method-Ext.Window-center"></div>/**
895 * Centers this window in the viewport
896 * @return {Ext.Window} this
899 var xy = this.el.getAlignToXY(this.container, 'c-c');
900 this.setPagePosition(xy[0], xy[1]);
904 <div id="cfg-Ext.Window-autoWidth"></div>/**
905 * @cfg {Boolean} autoWidth @hide
908 Ext.reg('window', Ext.Window);
910 // private - custom Window DD implementation
911 Ext.Window.DD = function(win){
913 Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id);
914 this.setHandleElId(win.header.id);
918 Ext.extend(Ext.Window.DD, Ext.dd.DD, {
920 headerOffsets:[100, 25],
921 startDrag : function(){
923 this.proxy = w.ghost();
924 if(w.constrain !== false){
925 var so = w.el.shadowOffset;
926 this.constrainTo(w.container, {right: so, left: so, bottom: so});
927 }else if(w.constrainHeader !== false){
928 var s = this.proxy.getSize();
929 this.constrainTo(w.container, {right: -(s.width-this.headerOffsets[0]), bottom: -(s.height-this.headerOffsets[1])});
932 b4Drag : Ext.emptyFn,
934 onDrag : function(e){
935 this.alignElWithMouse(this.proxy, e.getPageX(), e.getPageY());
938 endDrag : function(e){
940 this.win.saveState();