X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/2e847cf21b8ab9d15fa167b315ca5b2fa92638fc..0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6:/src/widgets/Window.js diff --git a/src/widgets/Window.js b/src/widgets/Window.js index e4d967e8..208cd731 100644 --- a/src/widgets/Window.js +++ b/src/widgets/Window.js @@ -1,8 +1,8 @@ /*! - * Ext JS Library 3.1.1 - * Copyright(c) 2006-2010 Ext JS, LLC - * licensing@extjs.com - * http://www.extjs.com/license + * Ext JS Library 3.3.1 + * Copyright(c) 2006-2010 Sencha Inc. + * licensing@sencha.com + * http://www.sencha.com/license */ /** * @class Ext.Window @@ -178,6 +178,18 @@ Ext.Window = Ext.extend(Ext.Panel, { * {@link #collapsed}) when displayed (defaults to true). */ expandOnShow : true, + + /** + * @cfg {Number} showAnimDuration The number of seconds that the window show animation takes if enabled. + * Defaults to 0.25 + */ + showAnimDuration: 0.25, + + /** + * @cfg {Number} hideAnimDuration The number of seconds that the window hide animation takes if enabled. + * Defaults to 0.25 + */ + hideAnimDuration: 0.25, // inherited docs, same default collapsible : false, @@ -331,8 +343,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 */ @@ -347,12 +363,9 @@ Ext.Window = Ext.extend(Ext.Panel, { // 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, @@ -429,11 +442,13 @@ Ext.Window = Ext.extend(Ext.Panel, { this.updateBox(box); }else{ this.setSize(box); + if (Ext.isIE6 && Ext.isStrict) { + this.doLayout(); + } } this.focus(); this.updateHandles(); this.saveState(); - this.doLayout(); }, /** @@ -441,7 +456,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); @@ -450,6 +469,13 @@ Ext.Window = Ext.extend(Ext.Panel, { }else{ f = db; } + el = f.getEl(); + ct = Ext.getDom(this.container); + if (el && ct) { + if (ct != document.body && !Ext.lib.Region.getRegion(ct).contains(Ext.lib.Region.getRegion(el.dom))){ + return; + } + } } f = f || this.focusEl; f.focus.defer(10, f); @@ -566,7 +592,7 @@ Ext.Window = Ext.extend(Ext.Panel, { callback: this.afterShow.createDelegate(this, [true], false), scope: this, easing: 'easeNone', - duration: 0.25, + duration: this.showAnimDuration, opacity: 0.5 })); }, @@ -626,7 +652,7 @@ Ext.Window = Ext.extend(Ext.Panel, { this.proxy.shift(Ext.apply(this.animateTarget.getBox(), { callback: this.afterHide, scope: this, - duration: 0.25, + duration: this.hideAnimDuration, easing: 'easeNone', opacity: 0 })); @@ -700,7 +726,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,21 +900,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); + 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; + }, - var tm = typeof monitorScroll; - if(tm != 'undefined'){ - Ext.EventManager.on(window, 'scroll', this.doAnchor, this, - {buffer: tm == 'number' ? monitorScroll : 50}); - } - 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; }, /** @@ -949,19 +998,20 @@ Ext.Window = Ext.extend(Ext.Panel, { Ext.reg('window', Ext.Window); // private - custom Window DD implementation -Ext.Window.DD = function(win){ - this.win = win; - Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id); - this.setHandleElId(win.header.id); - this.scroll = false; -}; - -Ext.extend(Ext.Window.DD, Ext.dd.DD, { +Ext.Window.DD = Ext.extend(Ext.dd.DD, { + + constructor : function(win){ + this.win = win; + Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id); + this.setHandleElId(win.header.id); + this.scroll = false; + }, + moveOnly:true, headerOffsets:[100, 25], startDrag : function(){ var w = this.win; - this.proxy = w.ghost(); + this.proxy = w.ghost(w.initialConfig.cls); if(w.constrain !== false){ var so = w.el.shadowOffset; this.constrainTo(w.container, {right: so, left: so, bottom: so});