Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / source / widgets / Window.js
diff --git a/source/widgets/Window.js b/source/widgets/Window.js
deleted file mode 100644 (file)
index 17cf87f..0000000
+++ /dev/null
@@ -1,904 +0,0 @@
-/*\r
- * Ext JS Library 2.2.1\r
- * Copyright(c) 2006-2009, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
-\r
-/**\r
- * @class Ext.Window\r
- * @extends Ext.Panel\r
- * A specialized panel intended for use as an application window.  Windows are floated and draggable by default, and\r
- * also provide specific behavior like the ability to maximize and restore (with an event for minimizing, since the\r
- * minimize behavior is application-specific).  Windows can also be linked to a {@link Ext.WindowGroup} or managed\r
- * by the {@link Ext.WindowMgr} to provide grouping, activation, to front/back and other application-specific behavior.\r
- * @constructor\r
- * @param {Object} config The config object\r
- */\r
-Ext.Window = Ext.extend(Ext.Panel, {\r
-    /**\r
-     * @cfg {Number} x\r
-     * The X position of the left edge of the Window on initial showing. Defaults to centering the Window within\r
-     * the width of the Window's container {@link Ext.Element Element) (The Element that the Window is rendered to).\r
-     */\r
-    /**\r
-     * @cfg {Number} y\r
-     * The Y position of the top edge of the Window on initial showing. Defaults to centering the Window within\r
-     * the height of the Window's container {@link Ext.Element Element) (The Element that the Window is rendered to).\r
-     */\r
-    /**\r
-     * @cfg {Boolean} modal\r
-     * True to make the window modal and mask everything behind it when displayed, false to display it without\r
-     * restricting access to other UI elements (defaults to false).\r
-     */\r
-    /**\r
-     * @cfg {String/Element} animateTarget\r
-     * Id or element from which the window should animate while opening (defaults to null with no animation).\r
-     */\r
-    /**\r
-     * @cfg {String} resizeHandles\r
-     * A valid {@link Ext.Resizable} handles config string (defaults to 'all').  Only applies when resizable = true.\r
-     */\r
-    /**\r
-     * @cfg {Ext.WindowGroup} manager\r
-     * A reference to the WindowGroup that should manage this window (defaults to {@link Ext.WindowMgr}).\r
-     */\r
-    /**\r
-    * @cfg {String/Number/Button} defaultButton\r
-    * The id / index of a button or a button instance to focus when this window received the focus.\r
-    */\r
-    /**\r
-    * @cfg {Function} onEsc\r
-    * Allows override of the built-in processing for the escape key. Default action\r
-    * is to close the Window (performing whatever action is specified in {@link #closeAction}.\r
-    * To prevent the Window closing when the escape key is pressed, specify this as\r
-    * Ext.emptyFn (See {@link Ext#emptyFn}).\r
-    */\r
-    /**\r
-     * @cfg {Boolean} collapsed\r
-     * True to render the window collapsed, false to render it expanded (defaults to false). Note that if \r
-     * {@link #expandOnShow} is true (the default) it will override the <tt>collapsed</tt> config and the window \r
-     * will always be expanded when shown.\r
-     */\r
-    /**\r
-     * @cfg {Boolean} maximized\r
-     * True to initially display the window in a maximized state. (Defaults to false).\r
-     */\r
-    \r
-    /**\r
-    * @cfg {String} baseCls\r
-    * The base CSS class to apply to this panel's element (defaults to 'x-window').\r
-    */\r
-    baseCls : 'x-window',\r
-    /**\r
-     * @cfg {Boolean} resizable\r
-     * True to allow user resizing at each edge and corner of the window, false to disable resizing (defaults to true).\r
-     */\r
-    resizable:true,\r
-    /**\r
-     * @cfg {Boolean} draggable\r
-     * True to allow the window to be dragged by the header bar, false to disable dragging (defaults to true).  Note\r
-     * that by default the window will be centered in the viewport, so if dragging is disabled the window may need\r
-     * to be positioned programmatically after render (e.g., myWindow.setPosition(100, 100);).\r
-     */\r
-    draggable:true,\r
-    /**\r
-     * @cfg {Boolean} closable\r
-     * <p>True to display the 'close' tool button and allow the user to close the window, false to\r
-     * hide the button and disallow closing the window (default to true).</p>\r
-     * <p>By default, when close is requested by either clicking the close button in the header\r
-     * or pressing ESC when the Window has focus, the {@link #close} method will be called. This\r
-     * will <i>destroy</i> the Window and its content meaning that it may not be reused.</p>\r
-     * <p>To make closing a Window <i>hide</i> the Window so that it may be reused, set\r
-     * {@link #closeAction} to 'hide'.\r
-     */\r
-    closable : true,\r
-    /**\r
-     * @cfg {Boolean} constrain\r
-     * True to constrain the window to the viewport, false to allow it to fall outside of the viewport\r
-     * (defaults to false).  Optionally the header only can be constrained using {@link #constrainHeader}.\r
-     */\r
-    constrain:false,\r
-    /**\r
-     * @cfg {Boolean} constrainHeader\r
-     * True to constrain the window header to the viewport, allowing the window body to fall outside of the viewport,\r
-     * false to allow the header to fall outside the viewport (defaults to false).  Optionally the entire window\r
-     * can be constrained using {@link #constrain}.\r
-     */\r
-    constrainHeader:false,\r
-    /**\r
-     * @cfg {Boolean} plain\r
-     * True to render the window body with a transparent background so that it will blend into the framing\r
-     * elements, false to add a lighter background color to visually highlight the body element and separate it\r
-     * more distinctly from the surrounding frame (defaults to false).\r
-     */\r
-    plain:false,\r
-    /**\r
-     * @cfg {Boolean} minimizable\r
-     * True to display the 'minimize' tool button and allow the user to minimize the window, false to hide the button\r
-     * and disallow minimizing the window (defaults to false).  Note that this button provides no implementation --\r
-     * the behavior of minimizing a window is implementation-specific, so the minimize event must be handled and a\r
-     * custom minimize behavior implemented for this option to be useful.\r
-     */\r
-    minimizable : false,\r
-    /**\r
-     * @cfg {Boolean} maximizable\r
-     * True to display the 'maximize' tool button and allow the user to maximize the window, false to hide the button\r
-     * and disallow maximizing the window (defaults to false).  Note that when a window is maximized, the tool button\r
-     * will automatically change to a 'restore' button with the appropriate behavior already built-in that will\r
-     * restore the window to its previous size.\r
-     */\r
-    maximizable : false,\r
-    /**\r
-     * @cfg {Number} minHeight\r
-     * The minimum height in pixels allowed for this window (defaults to 100).  Only applies when resizable = true.\r
-     */\r
-    minHeight: 100,\r
-    /**\r
-     * @cfg {Number} minWidth\r
-     * The minimum width in pixels allowed for this window (defaults to 200).  Only applies when resizable = true.\r
-     */\r
-    minWidth: 200,\r
-    /**\r
-     * @cfg {Boolean} expandOnShow\r
-     * True to always expand the window when it is displayed, false to keep it in its current state (which may be\r
-     * {@link #collapsed}) when displayed (defaults to true).\r
-     */\r
-    expandOnShow: true,\r
-    /**\r
-     * @cfg {String} closeAction\r
-     * The action to take when the close button is clicked.  The default action is 'close' which will actually remove\r
-     * the window from the DOM and destroy it.  The other valid option is 'hide' which will simply hide the window\r
-     * by setting visibility to hidden and applying negative offsets, keeping the window available to be redisplayed\r
-     * via the {@link #show} method.\r
-     */\r
-    closeAction: 'close',\r
-    /**\r
-     * @cfg {String} elements\r
-     * A comma-delimited list of panel elements to initialize when the window is rendered.  Normally, this list will be\r
-     * generated automatically based on the items added to the window at config time, but sometimes it might be useful to\r
-     * make sure a structural element is rendered even if not specified at config time (for example, you may want\r
-     * to add a button or toolbar dynamically after the window has been rendered).  Adding those elements to this\r
-     * list will allocate the required placeholders in the window when it is rendered.  Valid values are<ul>\r
-     * <li><b>header</b> (required)</li>\r
-     * <li><b>tbar</b> (top bar)</li>\r
-     * <li><b>body</b> (required)</li>\r
-     * <li><b>bbar</b> (bottom bar)</li>\r
-     * <li><b>footer</b><li>\r
-     * </ul>\r
-     * Defaults to 'header,body'.\r
-     */\r
-    elements: 'header,body',\r
-\r
-    // inherited docs, same default\r
-    collapsible:false,\r
-\r
-    // private\r
-    initHidden : true,\r
-    /**\r
-    * @cfg {Boolean} monitorResize @hide\r
-    * This is automatically managed based on the value of constrain and constrainToHeader\r
-    */\r
-    monitorResize : true,\r
-    /** @cfg {Boolean} frame @hide */\r
-    frame:true,\r
-    /** @cfg {Boolean} floating @hide */\r
-    floating:true,\r
-\r
-    // private\r
-    initComponent : function(){\r
-        Ext.Window.superclass.initComponent.call(this);\r
-        this.addEvents(\r
-            /**\r
-             * @event activate\r
-             * Fires after the window has been visually activated via {@link setActive}.\r
-             * @param {Ext.Window} this\r
-             */\r
-            /**\r
-             * @event deactivate\r
-             * Fires after the window has been visually deactivated via {@link setActive}.\r
-             * @param {Ext.Window} this\r
-             */\r
-            /**\r
-             * @event resize\r
-             * Fires after the window has been resized.\r
-             * @param {Ext.Window} this\r
-             * @param {Number} width The window's new width\r
-             * @param {Number} height The window's new height\r
-             */\r
-            'resize',\r
-            /**\r
-             * @event maximize\r
-             * Fires after the window has been maximized.\r
-             * @param {Ext.Window} this\r
-             */\r
-            'maximize',\r
-            /**\r
-             * @event minimize\r
-             * Fires after the window has been minimized.\r
-             * @param {Ext.Window} this\r
-             */\r
-            'minimize',\r
-            /**\r
-             * @event restore\r
-             * Fires after the window has been restored to its original size after being maximized.\r
-             * @param {Ext.Window} this\r
-             */\r
-            'restore'\r
-        );\r
-    },\r
-\r
-    // private\r
-    getState : function(){\r
-        return Ext.apply(Ext.Window.superclass.getState.call(this) || {}, this.getBox());\r
-    },\r
-\r
-    // private\r
-    onRender : function(ct, position){\r
-        Ext.Window.superclass.onRender.call(this, ct, position);\r
-\r
-        if(this.plain){\r
-            this.el.addClass('x-window-plain');\r
-        }\r
-\r
-        // this element allows the Window to be focused for keyboard events\r
-        this.focusEl = this.el.createChild({\r
-                    tag: "a", href:"#", cls:"x-dlg-focus",\r
-                    tabIndex:"-1", html: "&#160;"});\r
-        this.focusEl.swallowEvent('click', true);\r
-\r
-        this.proxy = this.el.createProxy("x-window-proxy");\r
-        this.proxy.enableDisplayMode('block');\r
-\r
-        if(this.modal){\r
-            this.mask = this.container.createChild({cls:"ext-el-mask"}, this.el.dom);\r
-            this.mask.enableDisplayMode("block");\r
-            this.mask.hide();\r
-            this.mask.on('click', this.focus, this);\r
-        }\r
-    },\r
-\r
-    // private\r
-    initEvents : function(){\r
-        Ext.Window.superclass.initEvents.call(this);\r
-        if(this.animateTarget){\r
-            this.setAnimateTarget(this.animateTarget);\r
-        }\r
-\r
-        if(this.resizable){\r
-            this.resizer = new Ext.Resizable(this.el, {\r
-                minWidth: this.minWidth,\r
-                minHeight:this.minHeight,\r
-                handles: this.resizeHandles || "all",\r
-                pinned: true,\r
-                resizeElement : this.resizerAction\r
-            });\r
-            this.resizer.window = this;\r
-            this.resizer.on("beforeresize", this.beforeResize, this);\r
-        }\r
-\r
-        if(this.draggable){\r
-            this.header.addClass("x-window-draggable");\r
-        }\r
-        this.initTools();\r
-\r
-        this.el.on("mousedown", this.toFront, this);\r
-        this.manager = this.manager || Ext.WindowMgr;\r
-        this.manager.register(this);\r
-        this.hidden = true;\r
-        if(this.maximized){\r
-            this.maximized = false;\r
-            this.maximize();\r
-        }\r
-        if(this.closable){\r
-            var km = this.getKeyMap();\r
-            km.on(27, this.onEsc, this);\r
-            km.disable();\r
-        }\r
-    },\r
-\r
-    initDraggable : function(){\r
-        /**\r
-         * If this Window is configured {@link #draggable}, this property will contain\r
-         * an instance of {@link Ext.dd.DD} which handles dragging the Window's DOM Element.\r
-         * @type Ext.dd.DD\r
-         * @property dd\r
-         */\r
-        this.dd = new Ext.Window.DD(this);\r
-    },\r
-\r
-   // private\r
-    onEsc : function(){\r
-        this[this.closeAction]();\r
-    },\r
-\r
-    // private\r
-    beforeDestroy : function(){\r
-        this.hide();\r
-        if(this.doAnchor){\r
-            Ext.EventManager.removeResizeListener(this.doAnchor, this);\r
-            Ext.EventManager.un(window, 'scroll', this.doAnchor, this);\r
-        }\r
-        Ext.destroy(\r
-            this.focusEl,\r
-            this.resizer,\r
-            this.dd,\r
-            this.proxy,\r
-            this.mask\r
-        );\r
-        Ext.Window.superclass.beforeDestroy.call(this);\r
-    },\r
-\r
-    // private\r
-    onDestroy : function(){\r
-        if(this.manager){\r
-            this.manager.unregister(this);\r
-        }\r
-        Ext.Window.superclass.onDestroy.call(this);\r
-    },\r
-\r
-    // private\r
-    initTools : function(){\r
-        if(this.minimizable){\r
-            this.addTool({\r
-                id: 'minimize',\r
-                handler: this.minimize.createDelegate(this, [])\r
-            });\r
-        }\r
-        if(this.maximizable){\r
-            this.addTool({\r
-                id: 'maximize',\r
-                handler: this.maximize.createDelegate(this, [])\r
-            });\r
-            this.addTool({\r
-                id: 'restore',\r
-                handler: this.restore.createDelegate(this, []),\r
-                hidden:true\r
-            });\r
-            this.header.on('dblclick', this.toggleMaximize, this);\r
-        }\r
-        if(this.closable){\r
-            this.addTool({\r
-                id: 'close',\r
-                handler: this[this.closeAction].createDelegate(this, [])\r
-            });\r
-        }\r
-    },\r
-\r
-    // private\r
-    resizerAction : function(){\r
-        var box = this.proxy.getBox();\r
-        this.proxy.hide();\r
-        this.window.handleResize(box);\r
-        return box;\r
-    },\r
-\r
-    // private\r
-    beforeResize : function(){\r
-        this.resizer.minHeight = Math.max(this.minHeight, this.getFrameHeight() + 40); // 40 is a magic minimum content size?\r
-        this.resizer.minWidth = Math.max(this.minWidth, this.getFrameWidth() + 40);\r
-        this.resizeBox = this.el.getBox();\r
-    },\r
-\r
-    // private\r
-    updateHandles : function(){\r
-        if(Ext.isIE && this.resizer){\r
-            this.resizer.syncHandleHeight();\r
-            this.el.repaint();\r
-        }\r
-    },\r
-\r
-    // private\r
-    handleResize : function(box){\r
-        var rz = this.resizeBox;\r
-        if(rz.x != box.x || rz.y != box.y){\r
-            this.updateBox(box);\r
-        }else{\r
-            this.setSize(box);\r
-        }\r
-        this.focus();\r
-        this.updateHandles();\r
-        this.saveState();\r
-        if(this.layout){\r
-            this.doLayout();\r
-        }\r
-        this.fireEvent("resize", this, box.width, box.height);\r
-    },\r
-\r
-    /**\r
-     * Focuses the window.  If a defaultButton is set, it will receive focus, otherwise the\r
-     * window itself will receive focus.\r
-     */\r
-    focus : function(){\r
-        var f = this.focusEl, db = this.defaultButton, t = typeof db;\r
-        if(t != 'undefined'){\r
-            if(t == 'number'){\r
-                f = this.buttons[db];\r
-            }else if(t == 'string'){\r
-                f = Ext.getCmp(db);\r
-            }else{\r
-                f = db;\r
-            }\r
-        }\r
-        f.focus.defer(10, f);\r
-    },\r
-\r
-    /**\r
-     * Sets the target element from which the window should animate while opening.\r
-     * @param {String/Element} el The target element or id\r
-     */\r
-    setAnimateTarget : function(el){\r
-        el = Ext.get(el);\r
-        this.animateTarget = el;\r
-    },\r
-\r
-    // private\r
-    beforeShow : function(){\r
-        delete this.el.lastXY;\r
-        delete this.el.lastLT;\r
-        if(this.x === undefined || this.y === undefined){\r
-            var xy = this.el.getAlignToXY(this.container, 'c-c');\r
-            var pos = this.el.translatePoints(xy[0], xy[1]);\r
-            this.x = this.x === undefined? pos.left : this.x;\r
-            this.y = this.y === undefined? pos.top : this.y;\r
-        }\r
-        this.el.setLeftTop(this.x, this.y);\r
-\r
-        if(this.expandOnShow){\r
-            this.expand(false);\r
-        }\r
-\r
-        if(this.modal){\r
-            Ext.getBody().addClass("x-body-masked");\r
-            this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));\r
-            this.mask.show();\r
-        }\r
-    },\r
-\r
-    /**\r
-     * Shows the window, rendering it first if necessary, or activates it and brings it to front if hidden.\r
-     * @param {String/Element} animateTarget (optional) The target element or id from which the window should\r
-     * animate while opening (defaults to undefined with no animation)\r
-     * @param {Function} callback (optional) A callback function to call after the window is displayed\r
-     * @param {Object} scope (optional) The scope in which to execute the callback\r
-     */\r
-    show : function(animateTarget, cb, scope){\r
-        if(!this.rendered){\r
-            this.render(Ext.getBody());\r
-        }\r
-        if(this.hidden === false){\r
-            this.toFront();\r
-            return;\r
-        }\r
-        if(this.fireEvent("beforeshow", this) === false){\r
-            return;\r
-        }\r
-        if(cb){\r
-            this.on('show', cb, scope, {single:true});\r
-        }\r
-        this.hidden = false;\r
-        if(animateTarget !== undefined){\r
-            this.setAnimateTarget(animateTarget);\r
-        }\r
-        this.beforeShow();\r
-        if(this.animateTarget){\r
-            this.animShow();\r
-        }else{\r
-            this.afterShow();\r
-        }\r
-    },\r
-\r
-    // private\r
-    afterShow : function(){\r
-        this.proxy.hide();\r
-        this.el.setStyle('display', 'block');\r
-        this.el.show();\r
-        if(this.maximized){\r
-            this.fitContainer();\r
-        }\r
-        if(Ext.isMac && Ext.isGecko){ // work around stupid FF 2.0/Mac scroll bar bug\r
-               this.cascade(this.setAutoScroll);\r
-        }\r
-\r
-        if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){\r
-            Ext.EventManager.onWindowResize(this.onWindowResize, this);\r
-        }\r
-        this.doConstrain();\r
-        if(this.layout){\r
-            this.doLayout();\r
-        }\r
-        if(this.keyMap){\r
-            this.keyMap.enable();\r
-        }\r
-        this.toFront();\r
-        this.updateHandles();\r
-        this.fireEvent("show", this);\r
-    },\r
-\r
-    // private\r
-    animShow : function(){\r
-        this.proxy.show();\r
-        this.proxy.setBox(this.animateTarget.getBox());\r
-        this.proxy.setOpacity(0);\r
-        var b = this.getBox(false);\r
-        b.callback = this.afterShow;\r
-        b.scope = this;\r
-        b.duration = .25;\r
-        b.easing = 'easeNone';\r
-        b.opacity = .5;\r
-        b.block = true;\r
-        this.el.setStyle('display', 'none');\r
-        this.proxy.shift(b);\r
-    },\r
-\r
-    /**\r
-     * Hides the window, setting it to invisible and applying negative offsets.\r
-     * @param {String/Element} animateTarget (optional) The target element or id to which the window should\r
-     * animate while hiding (defaults to null with no animation)\r
-     * @param {Function} callback (optional) A callback function to call after the window is hidden\r
-     * @param {Object} scope (optional) The scope in which to execute the callback\r
-     */\r
-    hide : function(animateTarget, cb, scope){\r
-        if(this.activeGhost){ // drag active?\r
-            this.hide.defer(100, this, [animateTarget, cb, scope]);\r
-            return;\r
-        }\r
-        if(this.hidden || this.fireEvent("beforehide", this) === false){\r
-            return;\r
-        }\r
-        if(cb){\r
-            this.on('hide', cb, scope, {single:true});\r
-        }\r
-        this.hidden = true;\r
-        if(animateTarget !== undefined){\r
-            this.setAnimateTarget(animateTarget);\r
-        }\r
-        if(this.animateTarget){\r
-            this.animHide();\r
-        }else{\r
-            this.el.hide();\r
-            this.afterHide();\r
-        }\r
-    },\r
-\r
-    // private\r
-    afterHide : function(){\r
-        this.proxy.hide();\r
-        if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){\r
-            Ext.EventManager.removeResizeListener(this.onWindowResize, this);\r
-        }\r
-        if(this.modal){\r
-            this.mask.hide();\r
-            Ext.getBody().removeClass("x-body-masked");\r
-        }\r
-        if(this.keyMap){\r
-            this.keyMap.disable();\r
-        }\r
-        this.fireEvent("hide", this);\r
-    },\r
-\r
-    // private\r
-    animHide : function(){\r
-        this.proxy.setOpacity(.5);\r
-        this.proxy.show();\r
-        var tb = this.getBox(false);\r
-        this.proxy.setBox(tb);\r
-        this.el.hide();\r
-        var b = this.animateTarget.getBox();\r
-        b.callback = this.afterHide;\r
-        b.scope = this;\r
-        b.duration = .25;\r
-        b.easing = 'easeNone';\r
-        b.block = true;\r
-        b.opacity = 0;\r
-        this.proxy.shift(b);\r
-    },\r
-\r
-    // private\r
-    onWindowResize : function(){\r
-        if(this.maximized){\r
-            this.fitContainer();\r
-        }\r
-        if(this.modal){\r
-            this.mask.setSize('100%', '100%');\r
-            var force = this.mask.dom.offsetHeight;\r
-            this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));\r
-        }\r
-        this.doConstrain();\r
-    },\r
-\r
-    // private\r
-    doConstrain : function(){\r
-        if(this.constrain || this.constrainHeader){\r
-            var offsets;\r
-            if(this.constrain){\r
-                offsets = {\r
-                    right:this.el.shadowOffset,\r
-                    left:this.el.shadowOffset,\r
-                    bottom:this.el.shadowOffset\r
-                };\r
-            }else {\r
-                var s = this.getSize();\r
-                offsets = {\r
-                    right:-(s.width - 100),\r
-                    bottom:-(s.height - 25)\r
-                };\r
-            }\r
-\r
-            var xy = this.el.getConstrainToXY(this.container, true, offsets);\r
-            if(xy){\r
-                this.setPosition(xy[0], xy[1]);\r
-            }\r
-        }\r
-    },\r
-\r
-    // private - used for dragging\r
-    ghost : function(cls){\r
-        var ghost = this.createGhost(cls);\r
-        var box = this.getBox(true);\r
-        ghost.setLeftTop(box.x, box.y);\r
-        ghost.setWidth(box.width);\r
-        this.el.hide();\r
-        this.activeGhost = ghost;\r
-        return ghost;\r
-    },\r
-\r
-    // private\r
-    unghost : function(show, matchPosition){\r
-        if(show !== false){\r
-            this.el.show();\r
-            this.focus();\r
-               if(Ext.isMac && Ext.isGecko){ // work around stupid FF 2.0/Mac scroll bar bug\r
-                       this.cascade(this.setAutoScroll);\r
-               }\r
-        }\r
-        if(matchPosition !== false){\r
-            this.setPosition(this.activeGhost.getLeft(true), this.activeGhost.getTop(true));\r
-        }\r
-        this.activeGhost.hide();\r
-        this.activeGhost.remove();\r
-        delete this.activeGhost;\r
-    },\r
-\r
-    /**\r
-     * Placeholder method for minimizing the window.  By default, this method simply fires the {@link #minimize} event\r
-     * since the behavior of minimizing a window is application-specific.  To implement custom minimize behavior,\r
-     * either the minimize event can be handled or this method can be overridden.\r
-     */\r
-    minimize : function(){\r
-        this.fireEvent('minimize', this);\r
-    },\r
-\r
-    /**\r
-     * Closes the window, removes it from the DOM and destroys the window object.  The beforeclose event is fired\r
-     * before the close happens and will cancel the close action if it returns false.\r
-     */\r
-    close : function(){\r
-        if(this.fireEvent("beforeclose", this) !== false){\r
-            this.hide(null, function(){\r
-                this.fireEvent('close', this);\r
-                this.destroy();\r
-            }, this);\r
-        }\r
-    },\r
-\r
-    /**\r
-     * Fits the window within its current container and automatically replaces the 'maximize' tool button with\r
-     * the 'restore' tool button.\r
-     */\r
-    maximize : function(){\r
-        if(!this.maximized){\r
-            this.expand(false);\r
-            this.restoreSize = this.getSize();\r
-            this.restorePos = this.getPosition(true);\r
-            if (this.maximizable){\r
-                this.tools.maximize.hide();\r
-                this.tools.restore.show();\r
-            }\r
-            this.maximized = true;\r
-            this.el.disableShadow();\r
-\r
-            if(this.dd){\r
-                this.dd.lock();\r
-            }\r
-            if(this.collapsible){\r
-                this.tools.toggle.hide();\r
-            }\r
-            this.el.addClass('x-window-maximized');\r
-            this.container.addClass('x-window-maximized-ct');\r
-\r
-            this.setPosition(0, 0);\r
-            this.fitContainer();\r
-            this.fireEvent('maximize', this);\r
-        }\r
-    },\r
-\r
-    /**\r
-     * Restores a maximized window back to its original size and position prior to being maximized and also replaces\r
-     * the 'restore' tool button with the 'maximize' tool button.\r
-     */\r
-    restore : function(){\r
-        if(this.maximized){\r
-            this.el.removeClass('x-window-maximized');\r
-            this.tools.restore.hide();\r
-            this.tools.maximize.show();\r
-            this.setPosition(this.restorePos[0], this.restorePos[1]);\r
-            this.setSize(this.restoreSize.width, this.restoreSize.height);\r
-            delete this.restorePos;\r
-            delete this.restoreSize;\r
-            this.maximized = false;\r
-            this.el.enableShadow(true);\r
-\r
-            if(this.dd){\r
-                this.dd.unlock();\r
-            }\r
-            if(this.collapsible){\r
-                this.tools.toggle.show();\r
-            }\r
-            this.container.removeClass('x-window-maximized-ct');\r
-\r
-            this.doConstrain();\r
-            this.fireEvent('restore', this);\r
-        }\r
-    },\r
-\r
-    /**\r
-     * A shortcut method for toggling between {@link #maximize} and {@link #restore} based on the current maximized\r
-     * state of the window.\r
-     */\r
-    toggleMaximize : function(){\r
-        this[this.maximized ? 'restore' : 'maximize']();\r
-    },\r
-\r
-    // private\r
-    fitContainer : function(){\r
-        var vs = this.container.getViewSize();\r
-        this.setSize(vs.width, vs.height);\r
-    },\r
-\r
-    // private\r
-    // z-index is managed by the WindowManager and may be overwritten at any time\r
-    setZIndex : function(index){\r
-        if(this.modal){\r
-            this.mask.setStyle("z-index", index);\r
-        }\r
-        this.el.setZIndex(++index);\r
-        index += 5;\r
-\r
-        if(this.resizer){\r
-            this.resizer.proxy.setStyle("z-index", ++index);\r
-        }\r
-\r
-        this.lastZIndex = index;\r
-    },\r
-\r
-    /**\r
-     * Aligns the window to the specified element\r
-     * @param {Mixed} element The element to align to.\r
-     * @param {String} position The position to align to (see {@link Ext.Element#alignTo} for more details).\r
-     * @param {Array} offsets (optional) Offset the positioning by [x, y]\r
-     * @return {Ext.Window} this\r
-     */\r
-    alignTo : function(element, position, offsets){\r
-        var xy = this.el.getAlignToXY(element, position, offsets);\r
-        this.setPagePosition(xy[0], xy[1]);\r
-        return this;\r
-    },\r
-\r
-    /**\r
-     * Anchors this window to another element and realigns it when the window is resized or scrolled.\r
-     * @param {Mixed} element The element to align to.\r
-     * @param {String} position The position to align to (see {@link Ext.Element#alignTo} for more details)\r
-     * @param {Array} offsets (optional) Offset the positioning by [x, y]\r
-     * @param {Boolean/Number} monitorScroll (optional) true to monitor body scroll and reposition. If this parameter\r
-     * is a number, it is used as the buffer delay (defaults to 50ms).\r
-     * @return {Ext.Window} this\r
-     */\r
-    anchorTo : function(el, alignment, offsets, monitorScroll){\r
-      if(this.doAnchor){\r
-          Ext.EventManager.removeResizeListener(this.doAnchor, this);\r
-          Ext.EventManager.un(window, 'scroll', this.doAnchor, this);\r
-      }\r
-      this.doAnchor = function(){\r
-          this.alignTo(el, alignment, offsets);\r
-      };\r
-      Ext.EventManager.onWindowResize(this.doAnchor, this);\r
-      \r
-      var tm = typeof monitorScroll;\r
-      if(tm != 'undefined'){\r
-          Ext.EventManager.on(window, 'scroll', this.doAnchor, this,\r
-              {buffer: tm == 'number' ? monitorScroll : 50});\r
-      }\r
-      this.doAnchor();\r
-      return this;\r
-    },\r
-\r
-    /**\r
-     * Brings this window to the front of any other visible windows\r
-     * @return {Ext.Window} this\r
-     */\r
-    toFront : function(e){\r
-        if(this.manager.bringToFront(this)){\r
-            if(!e || !e.getTarget().focus){\r
-                this.focus();\r
-            }\r
-        }\r
-        return this;\r
-    },\r
-\r
-    /**\r
-     * Makes this the active window by showing its shadow, or deactivates it by hiding its shadow.  This method also\r
-     * fires the {@link #activate} or {@link #deactivate} event depending on which action occurred.\r
-     * @param {Boolean} active True to activate the window, false to deactivate it (defaults to false)\r
-     */\r
-    setActive : function(active){\r
-        if(active){\r
-            if(!this.maximized){\r
-                this.el.enableShadow(true);\r
-            }\r
-            this.fireEvent('activate', this);\r
-        }else{\r
-            this.el.disableShadow();\r
-            this.fireEvent('deactivate', this);\r
-        }\r
-    },\r
-\r
-    /**\r
-     * Sends this window to the back of (lower z-index than) any other visible windows\r
-     * @return {Ext.Window} this\r
-     */\r
-    toBack : function(){\r
-        this.manager.sendToBack(this);\r
-        return this;\r
-    },\r
-\r
-    /**\r
-     * Centers this window in the viewport\r
-     * @return {Ext.Window} this\r
-     */\r
-    center : function(){\r
-        var xy = this.el.getAlignToXY(this.container, 'c-c');\r
-        this.setPagePosition(xy[0], xy[1]);\r
-        return this;\r
-    }\r
-\r
-    /**\r
-     * @cfg {Boolean} autoWidth @hide\r
-     **/\r
-});\r
-Ext.reg('window', Ext.Window);\r
-\r
-// private - custom Window DD implementation\r
-Ext.Window.DD = function(win){\r
-    this.win = win;\r
-    Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id);\r
-    this.setHandleElId(win.header.id);\r
-    this.scroll = false;\r
-};\r
-\r
-Ext.extend(Ext.Window.DD, Ext.dd.DD, {\r
-    moveOnly:true,\r
-    headerOffsets:[100, 25],\r
-    startDrag : function(){\r
-        var w = this.win;\r
-        this.proxy = w.ghost();\r
-        if(w.constrain !== false){\r
-            var so = w.el.shadowOffset;\r
-            this.constrainTo(w.container, {right: so, left: so, bottom: so});\r
-        }else if(w.constrainHeader !== false){\r
-            var s = this.proxy.getSize();\r
-            this.constrainTo(w.container, {right: -(s.width-this.headerOffsets[0]), bottom: -(s.height-this.headerOffsets[1])});\r
-        }\r
-    },\r
-    b4Drag : Ext.emptyFn,\r
-\r
-    onDrag : function(e){\r
-        this.alignElWithMouse(this.proxy, e.getPageX(), e.getPageY());\r
-    },\r
-\r
-    endDrag : function(e){\r
-        this.win.unghost();\r
-        this.win.saveState();\r
-    }\r
-});\r