X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775..6e39d509471fe9b4e2660e0d1631b350d0c66f40:/src/widgets/layout/ContainerLayout.js diff --git a/src/widgets/layout/ContainerLayout.js b/src/widgets/layout/ContainerLayout.js index 70b01f78..92d547fe 100644 --- a/src/widgets/layout/ContainerLayout.js +++ b/src/widgets/layout/ContainerLayout.js @@ -1,5 +1,5 @@ /*! - * Ext JS Library 3.0.3 + * Ext JS Library 3.1.0 * Copyright(c) 2006-2009 Ext JS, LLC * licensing@extjs.com * http://www.extjs.com/license @@ -15,11 +15,7 @@ *

This class is intended to be extended or created via the {@link Ext.Container#layout layout} * configuration property. See {@link Ext.Container#layout} for additional details.

*/ -Ext.layout.ContainerLayout = function(config){ - Ext.apply(this, config); -}; - -Ext.layout.ContainerLayout.prototype = { +Ext.layout.ContainerLayout = Ext.extend(Object, { /** * @cfg {String} extraCls *

An optional extra CSS class that will be added to the container. This can be useful for adding @@ -59,11 +55,19 @@ Ext.layout.ContainerLayout.prototype = { // private activeItem : null, + constructor : function(config){ + Ext.apply(this, config); + }, + // private layout : function(){ var target = this.container.getLayoutTarget(); + if(!(this.hasLayout || Ext.isEmpty(this.targetCls))){ + target.addClass(this.targetCls) + } this.onLayout(this.container, target); this.container.fireEvent('afterlayout', this.container, this); + this.hasLayout = true; }, // private @@ -73,7 +77,7 @@ Ext.layout.ContainerLayout.prototype = { // private isValidParent : function(c, target){ - return target && c.getDomPositionEl().dom.parentNode == (target.dom || target); + return target && c.getPositionEl().dom.parentNode == (target.dom || target); }, // private @@ -96,26 +100,27 @@ Ext.layout.ContainerLayout.prototype = { if(Ext.isNumber(position)){ position = target.dom.childNodes[position]; } - target.dom.insertBefore(c.getDomPositionEl().dom, position || null); + target.dom.insertBefore(c.getPositionEl().dom, position || null); c.container = target; this.configureItem(c, position); } }, - + // private configureItem: function(c, position){ if(this.extraCls){ var t = c.getPositionEl ? c.getPositionEl() : c; t.addClass(this.extraCls); } - if (this.renderHidden && c != this.activeItem) { - c.hide(); - } + // If we are forcing a layout, do so *before* we hide so elements have height/width if(c.doLayout && this.forceLayout){ c.doLayout(false, true); } + if (this.renderHidden && c != this.activeItem) { + c.hide(); + } }, - + onRemove: function(c){ if(this.activeItem == c){ delete this.activeItem; @@ -129,14 +134,19 @@ Ext.layout.ContainerLayout.prototype = { // private onResize: function(){ var ct = this.container, - b; - - if(ct.collapsed){ + b = ct.bufferResize; + + if (ct.collapsed){ return; } - if(b = ct.bufferResize){ - // Only allow if we should buffer the layout - if(ct.shouldBufferLayout()){ + + // Not having an ownerCt negates the buffering: floating and top level + // Containers (Viewport, Window, ToolTip, Menu) need to lay out ASAP. + if (b && ct.ownerCt) { + // If we do NOT already have a layout pending from an ancestor, schedule one. + // If there is a layout pending, we do nothing here. + // buffering to be deprecated soon + if (!ct.hasLayoutPending()){ if(!this.resizeTask){ this.resizeTask = new Ext.util.DelayedTask(this.runLayout, this); this.resizeBuffer = Ext.isNumber(b) ? b : 50; @@ -145,10 +155,10 @@ Ext.layout.ContainerLayout.prototype = { this.resizeTask.delay(this.resizeBuffer); } }else{ - ct.doLayout(); + ct.doLayout(false, this.forceLayout); } }, - + // private runLayout: function(){ var ct = this.container; @@ -158,6 +168,8 @@ Ext.layout.ContainerLayout.prototype = { // private setContainer : function(ct){ + // No longer use events to handle resize. Instead this will be handled through a direct function call. + /* if(this.monitorResize && ct != this.container){ var old = this.container; if(old){ @@ -167,6 +179,7 @@ Ext.layout.ContainerLayout.prototype = { ct.on(ct.resizeEvent, this.onResize, this); } } + */ this.container = ct; }, @@ -217,12 +230,19 @@ Ext.layout.ContainerLayout.prototype = { t.disableFormats = true; return t.compile(); })(), - + /* * Destroys this layout. This is a template method that is empty by default, but should be implemented * by subclasses that require explicit destruction to purge event handlers or remove DOM nodes. * @protected */ - destroy : Ext.emptyFn -}; -Ext.Container.LAYOUTS['auto'] = Ext.layout.ContainerLayout; \ No newline at end of file + destroy : function(){ + if(!Ext.isEmpty(this.targetCls)){ + var target = this.container.getLayoutTarget(); + if(target){ + target.removeClass(this.targetCls); + } + } + } +}); +Ext.Container.LAYOUTS['auto'] = Ext.layout.ContainerLayout;