X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Roo%2FContentPanel.js;h=29f2a68cebd74bc7752fcd495cc91a819e25bb9d;hb=61bc45258e16a779856dd2ad0862630b489e4583;hp=ed3ebce4625e756640f8d2b60271e53c2b7e5bac;hpb=e52202569ddda709e0f5eef7aead4d8b7b3029b9;p=roojs1 diff --git a/Roo/ContentPanel.js b/Roo/ContentPanel.js index ed3ebce462..29f2a68ceb 100644 --- a/Roo/ContentPanel.js +++ b/Roo/ContentPanel.js @@ -26,7 +26,7 @@ * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors) * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value - * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.) + * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.) * @constructor * Create a new ContentPanel. @@ -74,18 +74,33 @@ Roo.ContentPanel = function(el, config, content){ } if (this.toolbar && !this.toolbar.el && this.toolbar.xtype) { - this.wrapEl = this.el.wrap(); - this.toolbar = new Roo.Toolbar(this.el.insertSibling(false, 'before'), [] , this.toolbar); - + this.wrapEl = this.el.wrap(); + this.toolbar.container = this.el.insertSibling(false, 'before'); + this.toolbar = new Roo.Toolbar(this.toolbar); } + // xtype created footer. - not sure if will work as we normally have to render first.. + if (this.footer && !this.footer.el && this.footer.xtype) { + if (!this.wrapEl) { + this.wrapEl = this.el.wrap(); + } + this.footer.container = this.wrapEl.createChild(); + + this.footer = Roo.factory(this.footer, Roo); + + } if(this.resizeEl){ this.resizeEl = Roo.get(this.resizeEl, true); }else{ this.resizeEl = this.el; } + // handle view.xtype + + + + this.addEvents({ /** * @event activate @@ -107,8 +122,21 @@ Roo.ContentPanel = function(el, config, content){ * @param {Number} width The width after any component adjustments * @param {Number} height The height after any component adjustments */ - "resize" : true + "resize" : true, + + /** + * @event render + * Fires when this tab is created + * @param {Roo.ContentPanel} this + */ + "render" : true + + }); + + + + if(this.autoScroll){ this.resizeEl.setStyle("overflow", "auto"); } else { @@ -129,6 +157,15 @@ Roo.ContentPanel = function(el, config, content){ Roo.ContentPanel.superclass.constructor.call(this); + + if (this.view && typeof(this.view.xtype) != 'undefined') { + this.view.el = this.el.appendChild(document.createElement("div")); + this.view = Roo.factory(this.view); + this.view.render && this.view.render(false, ''); + } + + + this.fireEvent('render', this); }; Roo.extend(Roo.ContentPanel, Roo.util.Observable, { @@ -255,7 +292,9 @@ panel.load({ return this.wrapEl || this.el; }, - adjustForComponents : function(width, height){ + adjustForComponents : function(width, height) + { + //Roo.log('adjustForComponents '); if(this.resizeEl != this.el){ width -= this.el.getFrameWidth('lr'); height -= this.el.getFrameWidth('tb'); @@ -265,6 +304,15 @@ panel.load({ height -= te.getHeight(); te.setWidth(width); } + if(this.footer){ + var te = this.footer.getEl(); + //Roo.log("footer:" + te.getHeight()); + + height -= te.getHeight(); + te.setWidth(width); + } + + if(this.adjustments){ width += this.adjustments[0]; height += this.adjustments[1]; @@ -373,26 +421,36 @@ layout.addxtype({ addxtype : function(cfg) { // add form.. if (cfg.xtype.match(/^Form$/)) { - var el = this.el.createChild(); + + var el; + //if (this.footer) { + // el = this.footer.container.insertSibling(false, 'before'); + //} else { + el = this.el.createChild(); + //} this.form = new Roo.form.Form(cfg); - if ( this.form.allItems.length) this.form.render(el.dom); + if ( this.form.allItems.length) { + this.form.render(el.dom); + } return this.form; } // should only have one of theses.. - if (['View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) { - // views.. + if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) { + // views.. should not be just added - used named prop 'view'' + cfg.el = this.el.appendChild(document.createElement("div")); // factory? - var ret = new Roo[cfg.xtype](cfg); - ret.render && ret.render(false, ''); // render blank.. + + var ret = new Roo.factory(cfg); + + ret.render && ret.render(false, ''); // render blank.. this.view = ret; return ret; } return false; - } }); @@ -699,12 +757,14 @@ Roo.TreePanel = function(config){ //console.log('render tree'); this.tree.render(); }); - - this.on('resize', function (cp, w, h) { - this.tree.innerCt.setWidth(w); - this.tree.innerCt.setHeight(h); - this.tree.innerCt.setStyle('overflow-y', 'auto'); - }); + // this should not be needed.. - it's actually the 'el' that resizes? + // actuall it breaks the containerScroll - dragging nodes auto scroll at top + + //this.on('resize', function (cp, w, h) { + // this.tree.innerCt.setWidth(w); + // this.tree.innerCt.setHeight(h); + // //this.tree.innerCt.setStyle('overflow-y', 'auto'); + //});