X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6e39d509471fe9b4e2660e0d1631b350d0c66f40..b37ceabb82336ee82757cd32efe353cfab8ec267:/src/widgets/Window.js diff --git a/src/widgets/Window.js b/src/widgets/Window.js index fc52b5c0..b1c1c9ed 100644 --- a/src/widgets/Window.js +++ b/src/widgets/Window.js @@ -1,6 +1,6 @@ /*! - * Ext JS Library 3.1.0 - * Copyright(c) 2006-2009 Ext JS, LLC + * Ext JS Library 3.2.2 + * Copyright(c) 2006-2010 Ext JS, Inc. * licensing@extjs.com * http://www.extjs.com/license */ @@ -196,12 +196,6 @@ Ext.Window = Ext.extend(Ext.Panel, { */ hidden : true, - /** - * @cfg {Boolean} monitorResize @hide - * This is automatically managed based on the value of constrain and constrainToHeader - */ - monitorResize : true, - // The following configs are set to provide the basic functionality of a window. // Changing them would require additional code to handle correctly and should // usually only be done in subclasses that can provide custom behavior. Changing them @@ -311,7 +305,8 @@ Ext.Window = Ext.extend(Ext.Panel, { minHeight:this.minHeight, handles: this.resizeHandles || 'all', pinned: true, - resizeElement : this.resizerAction + resizeElement : this.resizerAction, + handleCls: 'x-window-handle' }); this.resizer.window = this; this.mon(this.resizer, 'beforeresize', this.beforeResize, this); @@ -336,8 +331,12 @@ Ext.Window = Ext.extend(Ext.Panel, { initDraggable : function(){ /** - * If this Window is configured {@link #draggable}, this property will contain - * an instance of {@link Ext.dd.DD} which handles dragging the Window's DOM Element. + *

If this Window is configured {@link #draggable}, this property will contain + * an instance of {@link Ext.dd.DD} which handles dragging the Window's DOM Element.

+ *

This has implementations of startDrag, onDrag and endDrag + * which perform the dragging action. If extra logic is needed at these points, use + * {@link Function#createInterceptor createInterceptor} or {@link Function#createSequence createSequence} to + * augment the existing implementations.

* @type Ext.dd.DD * @property dd */ @@ -345,18 +344,16 @@ Ext.Window = Ext.extend(Ext.Panel, { }, // private - onEsc : function(){ + onEsc : function(k, e){ + e.stopEvent(); this[this.closeAction](); }, // private beforeDestroy : function(){ - if (this.rendered){ + if(this.rendered){ this.hide(); - if(this.doAnchor){ - Ext.EventManager.removeResizeListener(this.doAnchor, this); - Ext.EventManager.un(window, 'scroll', this.doAnchor, this); - } + this.clearAnchor(); Ext.destroy( this.focusEl, this.resizer, @@ -433,6 +430,9 @@ Ext.Window = Ext.extend(Ext.Panel, { this.updateBox(box); }else{ this.setSize(box); + if (Ext.isIE6 && Ext.isStrict) { + this.doLayout(); + } } this.focus(); this.updateHandles(); @@ -444,7 +444,11 @@ Ext.Window = Ext.extend(Ext.Panel, { * window itself will receive focus. */ focus : function(){ - var f = this.focusEl, db = this.defaultButton, t = typeof db; + var f = this.focusEl, + db = this.defaultButton, + t = typeof db, + el, + ct; if(Ext.isDefined(db)){ if(Ext.isNumber(db) && this.fbar){ f = this.fbar.items.get(db); @@ -453,6 +457,13 @@ Ext.Window = Ext.extend(Ext.Panel, { }else{ f = db; } + el = f.getEl(); + ct = Ext.getDom(this.container); + if (el && ct) { + if (!Ext.lib.Region.getRegion(ct).contains(Ext.lib.Region.getRegion(el.dom))){ + return; + } + } } f = f || this.focusEl; f.focus.defer(10, f); @@ -527,6 +538,9 @@ Ext.Window = Ext.extend(Ext.Panel, { // private afterShow : function(isAnim){ + if (this.isDestroyed){ + return false; + } this.proxy.hide(); this.el.setStyle('display', 'block'); this.el.show(); @@ -700,7 +714,7 @@ Ext.Window = Ext.extend(Ext.Panel, { } if(show !== false){ this.el.show(); - this.focus(); + this.focus.defer(10, this); if(Ext.isMac && Ext.isGecko2){ // work around stupid FF 2.0/Mac scroll bar bug this.cascade(this.setAutoScroll); } @@ -874,22 +888,44 @@ Ext.Window = Ext.extend(Ext.Panel, { * @return {Ext.Window} this */ anchorTo : function(el, alignment, offsets, monitorScroll){ - if(this.doAnchor){ - Ext.EventManager.removeResizeListener(this.doAnchor, this); - Ext.EventManager.un(window, 'scroll', this.doAnchor, this); - } - this.doAnchor = function(){ - this.alignTo(el, alignment, offsets); - }; - Ext.EventManager.onWindowResize(this.doAnchor, this); - - var tm = typeof monitorScroll; - if(tm != 'undefined'){ - Ext.EventManager.on(window, 'scroll', this.doAnchor, this, - {buffer: tm == 'number' ? monitorScroll : 50}); - } - this.doAnchor(); - return this; + this.clearAnchor(); + this.anchorTarget = { + el: el, + alignment: alignment, + offsets: offsets + }; + + Ext.EventManager.onWindowResize(this.doAnchor, this); + var tm = typeof monitorScroll; + if(tm != 'undefined'){ + Ext.EventManager.on(window, 'scroll', this.doAnchor, this, + {buffer: tm == 'number' ? monitorScroll : 50}); + } + return this.doAnchor(); + }, + + /** + * Performs the anchor, using the saved anchorTarget property. + * @return {Ext.Window} this + * @private + */ + doAnchor : function(){ + var o = this.anchorTarget; + this.alignTo(o.el, o.alignment, o.offsets); + return this; + }, + + /** + * Removes any existing anchor from this window. See {@link #anchorTo}. + * @return {Ext.Window} this + */ + clearAnchor : function(){ + if(this.anchorTarget){ + Ext.EventManager.removeResizeListener(this.doAnchor, this); + Ext.EventManager.un(window, 'scroll', this.doAnchor, this); + delete this.anchorTarget; + } + return this; }, /**