X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Roo%2FXComponent.js;h=06dc502eb2fb00214b7bd5259c5815b11edfe4e4;hb=0b69a11b1055a6d3a3fd0719bdd58b5a235de0e4;hp=3930de1b513bd0bf3ea3e5b0346aeaea9ae5fced;hpb=74507227122ed57ad72dbe511fb2e46aaa24d507;p=roojs1 diff --git a/Roo/XComponent.js b/Roo/XComponent.js index 3930de1b51..06dc502eb2 100644 --- a/Roo/XComponent.js +++ b/Roo/XComponent.js @@ -63,6 +63,12 @@ * Our builder application needs the ability to preview these sub compoennts. They will normally have parent=false set, * hence confusing the component builder as it thinks there are multiple top level elements. * + * String Over-ride & Translations + * + * Our builder application writes all the strings as _strings and _named_strings. This is to enable the translation of elements, + * and also the 'overlaying of string values - needed when different versions of the same application with different text content + * are needed. @see Roo.XComponent.overlayString + * * * * @extends Roo.util.Observable @@ -164,18 +170,48 @@ Roo.extend(Roo.XComponent, Roo.util.Observable, { el = el || false; var hp = this.parent ? 1 : 0; - Roo.log(this); + Roo.debug && Roo.log(this); + + var tree = this._tree ? this._tree() : this.tree(); + if (!el && typeof(this.parent) == 'string' && this.parent.substring(0,1) == '#') { // if parent is a '#.....' string, then let's use that.. var ename = this.parent.substr(1); this.parent = false; - Roo.log(ename); + Roo.debug && Roo.log(ename); switch (ename) { - case 'bootstrap-body' : - if (typeof(Roo.bootstrap.Body) != 'undefined') { + case 'bootstrap-body': + if (typeof(tree.el) != 'undefined' && tree.el == document.body) { + // this is the BorderLayout standard? + this.parent = { el : true }; + break; + } + if (["Nest", "Content", "Grid", "Tree"].indexOf(tree.xtype) > -1) { + // need to insert stuff... + this.parent = { + el : new Roo.bootstrap.layout.Border({ + el : document.body, + + center: { + titlebar: false, + autoScroll:false, + closeOnTab: true, + tabPosition: 'top', + //resizeTabs: true, + alwaysShowTabs: true, + hideTabs: false + //minTabWidth: 140 + } + }) + + }; + break; + } + + if (typeof(Roo.bootstrap.Body) != 'undefined' ) { this.parent = { el : new Roo.bootstrap.Body() }; - Roo.log("setting el to doc body"); + Roo.debug && Roo.log("setting el to doc body"); } else { throw "Container is bootstrap body, but Roo.bootstrap.Body is not defined"; @@ -186,23 +222,33 @@ Roo.extend(Roo.XComponent, Roo.util.Observable, { // fall through default: el = Roo.get(ename); + if (typeof(Roo.bootstrap) != 'undefined' && tree['|xns'] == 'Roo.bootstrap') { + this.parent = { el : true}; + } + break; } if (!el && !this.parent) { - Roo.log("Warning - element can not be found :#" + ename ); + Roo.debug && Roo.log("Warning - element can not be found :#" + ename ); return; } } - Roo.log("EL:");Roo.log(el); - Roo.log("this.parent.el:");Roo.log(this.parent.el); - var tree = this._tree ? this._tree() : this.tree(); + Roo.debug && Roo.log("EL:"); + Roo.debug && Roo.log(el); + Roo.debug && Roo.log("this.parent.el:"); + Roo.debug && Roo.log(this.parent.el); + // altertive root elements ??? - we need a better way to indicate these. - var is_alt = (typeof(Roo.bootstrap) != 'undefined' && tree.xns == Roo.bootstrap) || - (typeof(Roo.mailer) != 'undefined' && tree.xns == Roo.mailer) ; + var is_alt = Roo.XComponent.is_alt || + (typeof(tree.el) != 'undefined' && tree.el == document.body) || + (typeof(Roo.bootstrap) != 'undefined' && tree.xns == Roo.bootstrap) || + (typeof(Roo.mailer) != 'undefined' && tree.xns == Roo.mailer) ; + + if (!this.parent && is_alt) { //el = Roo.get(document.body); @@ -213,48 +259,73 @@ Roo.extend(Roo.XComponent, Roo.util.Observable, { if (!this.parent) { - Roo.log("no parent - creating one"); + Roo.debug && Roo.log("no parent - creating one"); el = el ? Roo.get(el) : false; - // it's a top level one.. - this.parent = { - el : new Roo.BorderLayout(el || document.body, { + if (typeof(Roo.BorderLayout) == 'undefined' ) { - center: { - titlebar: false, - autoScroll:false, - closeOnTab: true, - tabPosition: 'top', - //resizeTabs: true, - alwaysShowTabs: el && hp? false : true, - hideTabs: el || !hp ? true : false, - minTabWidth: 140 - } - }) + this.parent = { + el : new Roo.bootstrap.layout.Border({ + el: el || document.body, + + center: { + titlebar: false, + autoScroll:false, + closeOnTab: true, + tabPosition: 'top', + //resizeTabs: true, + alwaysShowTabs: false, + hideTabs: true, + minTabWidth: 140, + overflow: 'visible' + } + }) + }; + } else { + + // it's a top level one.. + this.parent = { + el : new Roo.BorderLayout(el || document.body, { + center: { + titlebar: false, + autoScroll:false, + closeOnTab: true, + tabPosition: 'top', + //resizeTabs: true, + alwaysShowTabs: el && hp? false : true, + hideTabs: el || !hp ? true : false, + minTabWidth: 140 + } + }) + }; } } - if (!this.parent.el) { - // probably an old style ctor, which has been disabled. - return; - - } + if (!this.parent.el) { + // probably an old style ctor, which has been disabled. + return; + + } // The 'tree' method is '_tree now' tree.region = tree.region || this.region; - + var is_body = false; if (this.parent.el === true) { // bootstrap... - body.. + if (el) { + tree.el = el; + } this.parent.el = Roo.factory(tree); + is_body = true; } - this.el = this.parent.el.addxtype(tree); + this.el = this.parent.el.addxtype(tree, undefined, is_body); this.fireEvent('built', this); this.panel = this.el; this.layout = this.panel.layout; - this.parentLayout = this.parent.layout || false; + this.parentLayout = this.parent.layout || false; } @@ -298,14 +369,21 @@ Roo.apply(Roo.XComponent, { elmodules : [], /** + * @property is_alt + * Is an alternative Root - normally used by bootstrap or other systems, + * where the top element in the tree can wrap 'body' + * @type {boolean} (default false) + */ + + is_alt : false, + /** * @property build_from_html * Build elements from html - used by bootstrap HTML stuff * - this is cleared after build is completed - * @type {boolean} true (default false) + * @type {boolean} (default false) */ build_from_html : false, - /** * Register components to be built later. * @@ -342,7 +420,7 @@ Roo.apply(Roo.XComponent, { break; default: - if (obj.disabled) { + if (obj.disabled || obj.region == '#disabled') { return; } break; @@ -406,7 +484,7 @@ Roo.apply(Roo.XComponent, { try { obj.parent = this.toObject(opar); } catch(e) { - Roo.log("parent:toObject failed: " + e.toString()); + Roo.debug && Roo.log("parent:toObject failed: " + e.toString()); return; } @@ -425,7 +503,7 @@ Roo.apply(Roo.XComponent, { return; } if (obj.parent.constructor != Roo.XComponent) { - Roo.log("Warning : Object Parent is not instance of XComponent:" + obj.name) + Roo.debug && Roo.log("Warning : Object Parent is not instance of XComponent:" + obj.name) } if (!obj.parent.modules) { obj.parent.modules = new Roo.util.MixedCollection(false, @@ -535,6 +613,7 @@ Roo.apply(Roo.XComponent, { msg: msg, width:450, progress:true, + buttons : false, closable:false, modal: false @@ -572,7 +651,7 @@ Roo.apply(Roo.XComponent, { " of " + total + (m.name ? (' - ' + m.name) : ''); Roo.debug && Roo.log(msg); - if (!this.hideProgress && Roo.MessageBox) { + if (!_this.hideProgress && Roo.MessageBox) { Roo.MessageBox.updateProgress( (total - mods.length)/total, msg ); } @@ -600,7 +679,32 @@ Roo.apply(Roo.XComponent, { }, - + /** + * Overlay a set of modified strings onto a component + * This is dependant on our builder exporting the strings and 'named strings' elements. + * + * @param {Object} element to overlay on - eg. Pman.Dialog.Login + * @param {Object} associative array of 'named' string and it's new value. + * + */ + overlayStrings : function( component, strings ) + { + if (typeof(component['_named_strings']) == 'undefined') { + throw "ERROR: component does not have _named_strings"; + } + for ( var k in strings ) { + var md = typeof(component['_named_strings'][k]) == 'undefined' ? false : component['_named_strings'][k]; + if (md !== false) { + component['_strings'][md] = strings[k]; + } else { + Roo.log('could not find named string: ' + k + ' in'); + Roo.log(component); + } + + } + + }, + /** * Event Object.