From 763e77d7d5c3346589f6590b7388d5a571bbc74d Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Thu, 4 Aug 2011 04:39:54 +0000 Subject: [PATCH] XComponent - tweaking failure conditions. --- Roo/XComponent.js | 14 ++++++++++++-- roojs-all.js | 6 +++--- roojs-debug.js | 16 ++++++++++++++-- roojs-ui-debug.js | 16 ++++++++++++++-- roojs-ui.js | 6 +++--- 5 files changed, 46 insertions(+), 12 deletions(-) diff --git a/Roo/XComponent.js b/Roo/XComponent.js index 060df507b4..37b7bdae82 100644 --- a/Roo/XComponent.js +++ b/Roo/XComponent.js @@ -256,7 +256,12 @@ Roo.apply(Roo.XComponent, { var rt, o; rt = ar.shift(); /** eval:var:o */ - eval('if (typeof ' + rt + ' == "undefined"){ o = false;} o = ' + rt + ';'); + try { + eval('if (typeof ' + rt + ' == "undefined"){ o = false;} o = ' + rt + ';'); + } catch (e) { + throw "Module not found : " + str; + } + if (o === false) { throw "Module not found : " + str; } @@ -282,7 +287,12 @@ Roo.apply(Roo.XComponent, { Roo.each(this.modules , function (obj) { var opar = obj.parent; - obj.parent = this.toObject(opar); + try { + obj.parent = this.toObject(opar); + } catch(e) { + Roo.log(e.toString()); + return; + } if (!obj.parent) { this.topModule = obj; diff --git a/roojs-all.js b/roojs-all.js index ac07c51f44..361cb2ab5a 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -958,9 +958,9 @@ D.push({id:id,target:G,exec:F,test:fn,body:m[1]||''});s=s.replace(m[0],'{xtpl'+i this.master=D[D.length-1];this.tpls=D;};Roo.extend(Roo.XTemplate,Roo.Template,{re:/\{([\w-\.]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,applySubTemplate:function(id,A,B){var t=this.tpls[id];if(t.test&&!t.test.call(this,A,B)){return '';}if(t.exec&&t.exec.call(this,A,B)){return '';}var vs=t.target?t.target.call(this,A,B):A;B=t.target?A:B;if(t.target&&vs instanceof Array){var C=[];for(var i=0,D=vs.length;iString(b).toUpperCase()?1:-1;};if((!this.topModule||!this.topModule.modules)&&!this.elmodules.length){throw "No top level modules to build";}var C=this.topModule?[this.topModule]:[];Roo.each(this.elmodules,function(e){C.push(e)});var D=function(m){C.push(m);if(m.modules){m.modules.keySort('ASC',B);m.modules.each(D);}if(m.finalize){m.finalize.name=m.name+" (clean up) ";C.push(m.finalize);}};if(this.topModule){this.topModule.modules.keySort('ASC',B);this.topModule.modules.each(D);}return C;},build:function(){this.preBuild();var A=this.buildOrder();if(!A.length){throw "NO modules!!!";} Roo.MessageBox.show({title:'loading'});Roo.MessageBox.show({title:"Please wait...",msg:"Building Interface...",width:450,progress:true,closable:false,modal:false});var B=A.length;var C=this;var D=function(){if(!A.length){Roo.debug&&Roo.log('hide?');Roo.MessageBox.hide();if(C.topModule){C.topModule.fireEvent('buildcomplete',C.topModule);}return false;}var m=A.shift();Roo.debug&&Roo.log(m);if(typeof(m)=='function'){m.call(this);return D.defer(10,C);}Roo.MessageBox.updateProgress((B-A.length)/B,"Building Interface "+(B-A.length)+" of "+B+(m.name?(' - '+m.name):''));var E=(typeof(m.disabled)=='function')?m.disabled.call(m.module.disabled):m.disabled;if(E){return D();} m.render();return D.defer(10,C);} diff --git a/roojs-debug.js b/roojs-debug.js index b8ee0efc59..c9e0eed314 100644 --- a/roojs-debug.js +++ b/roojs-debug.js @@ -23671,6 +23671,8 @@ Roo.View = function(config, depreciated_tpl, depreciated_config){ * Fires on every row to render, to allow you to change the data. * @param {Roo.View} this * @param {Object} data to be rendered (change this) + * @param {Number} row being rendered + * @param {Roo.data.Record} record being rendered. */ "preparedata" : true }); @@ -51572,7 +51574,12 @@ Roo.apply(Roo.XComponent, { var rt, o; rt = ar.shift(); /** eval:var:o */ - eval('if (typeof ' + rt + ' == "undefined"){ o = false;} o = ' + rt + ';'); + try { + eval('if (typeof ' + rt + ' == "undefined"){ o = false;} o = ' + rt + ';'); + } catch (e) { + throw "Module not found : " + str; + } + if (o === false) { throw "Module not found : " + str; } @@ -51598,7 +51605,12 @@ Roo.apply(Roo.XComponent, { Roo.each(this.modules , function (obj) { var opar = obj.parent; - obj.parent = this.toObject(opar); + try { + obj.parent = this.toObject(opar); + } catch(e) { + Roo.log(e.toString()); + return; + } if (!obj.parent) { this.topModule = obj; diff --git a/roojs-ui-debug.js b/roojs-ui-debug.js index 4b05276b3e..bcba846501 100644 --- a/roojs-ui-debug.js +++ b/roojs-ui-debug.js @@ -9211,6 +9211,8 @@ Roo.View = function(config, depreciated_tpl, depreciated_config){ * Fires on every row to render, to allow you to change the data. * @param {Roo.View} this * @param {Object} data to be rendered (change this) + * @param {Number} row being rendered + * @param {Roo.data.Record} record being rendered. */ "preparedata" : true }); @@ -37112,7 +37114,12 @@ Roo.apply(Roo.XComponent, { var rt, o; rt = ar.shift(); /** eval:var:o */ - eval('if (typeof ' + rt + ' == "undefined"){ o = false;} o = ' + rt + ';'); + try { + eval('if (typeof ' + rt + ' == "undefined"){ o = false;} o = ' + rt + ';'); + } catch (e) { + throw "Module not found : " + str; + } + if (o === false) { throw "Module not found : " + str; } @@ -37138,7 +37145,12 @@ Roo.apply(Roo.XComponent, { Roo.each(this.modules , function (obj) { var opar = obj.parent; - obj.parent = this.toObject(opar); + try { + obj.parent = this.toObject(opar); + } catch(e) { + Roo.log(e.toString()); + return; + } if (!obj.parent) { this.topModule = obj; diff --git a/roojs-ui.js b/roojs-ui.js index 2e4d769883..4917e52c7b 100644 --- a/roojs-ui.js +++ b/roojs-ui.js @@ -714,9 +714,9 @@ D.push({id:id,target:G,exec:F,test:fn,body:m[1]||''});s=s.replace(m[0],'{xtpl'+i this.master=D[D.length-1];this.tpls=D;};Roo.extend(Roo.XTemplate,Roo.Template,{re:/\{([\w-\.]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,applySubTemplate:function(id,A,B){var t=this.tpls[id];if(t.test&&!t.test.call(this,A,B)){return '';}if(t.exec&&t.exec.call(this,A,B)){return '';}var vs=t.target?t.target.call(this,A,B):A;B=t.target?A:B;if(t.target&&vs instanceof Array){var C=[];for(var i=0,D=vs.length;iString(b).toUpperCase()?1:-1;};if((!this.topModule||!this.topModule.modules)&&!this.elmodules.length){throw "No top level modules to build";}var C=this.topModule?[this.topModule]:[];Roo.each(this.elmodules,function(e){C.push(e)});var D=function(m){C.push(m);if(m.modules){m.modules.keySort('ASC',B);m.modules.each(D);}if(m.finalize){m.finalize.name=m.name+" (clean up) ";C.push(m.finalize);}};if(this.topModule){this.topModule.modules.keySort('ASC',B);this.topModule.modules.each(D);}return C;},build:function(){this.preBuild();var A=this.buildOrder();if(!A.length){throw "NO modules!!!";} Roo.MessageBox.show({title:'loading'});Roo.MessageBox.show({title:"Please wait...",msg:"Building Interface...",width:450,progress:true,closable:false,modal:false});var B=A.length;var C=this;var D=function(){if(!A.length){Roo.debug&&Roo.log('hide?');Roo.MessageBox.hide();if(C.topModule){C.topModule.fireEvent('buildcomplete',C.topModule);}return false;}var m=A.shift();Roo.debug&&Roo.log(m);if(typeof(m)=='function'){m.call(this);return D.defer(10,C);}Roo.MessageBox.updateProgress((B-A.length)/B,"Building Interface "+(B-A.length)+" of "+B+(m.name?(' - '+m.name):''));var E=(typeof(m.disabled)=='function')?m.disabled.call(m.module.disabled):m.disabled;if(E){return D();} m.render();return D.defer(10,C);} -- 2.39.2