From: Alan Knowles Date: Sat, 7 Apr 2012 03:50:15 +0000 (+0800) Subject: roojs-core.js X-Git-Url: http://git.roojs.org/?a=commitdiff_plain;h=3c5cc827d384af8501bcd190d640c82003a7aa44;p=roojs1 roojs-core.js roojs-core-debug.js roojs-ui.js roojs-ui-debug.js roojs-all.js roojs-debug.js --- diff --git a/roojs-all.js b/roojs-all.js index f4ebdf0da6..492d22001e 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -1140,7 +1140,7 @@ this.store.loadRecords({records:A},{},true);},onUpdate:function(ds,A,B){if(B==Ro Roo.LoadMask=function(el,A){this.el=Roo.get(el);Roo.apply(this,A);if(this.store){this.store.on('beforeload',this.onBeforeLoad,this);this.store.on('load',this.onLoad,this);this.store.on('loadexception',this.onLoadException,this);this.removeMask=false;}else {var um=this.el.getUpdateManager();um.showLoadIndicator=false;um.on('beforeupdate',this.onBeforeLoad,this);um.on('update',this.onLoad,this);um.on('failure',this.onLoad,this);this.removeMask=true;}};Roo.LoadMask.prototype={msg:'Loading...',msgCls:'x-mask-loading',disabled:false,disable:function(){this.disabled=true;},enable:function(){this.disabled=false;},onLoadException:function(){if(this.store&&typeof(this.store.reader.jsonData.errorMsg)!='undefined'){Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);} this.el.unmask(this.removeMask);},onLoad:function(){this.el.unmask(this.removeMask);},onBeforeLoad:function(){if(!this.disabled){this.el.mask(this.msg,this.msgCls);}},destroy:function(){if(this.store){this.store.un('beforeload',this.onBeforeLoad,this);this.store.un('load',this.onLoad,this);this.store.un('loadexception',this.onLoadException,this);}else {var um=this.el.getUpdateManager();um.un('beforeupdate',this.onBeforeLoad,this);um.un('update',this.onLoad,this);um.un('failure',this.onLoad,this);}}}; //Roo/XTemplate.js -Roo.XTemplate=function(){Roo.XTemplate.superclass.constructor.apply(this,arguments);if(this.html){this.preCompile();}};Roo.extend(Roo.XTemplate,Roo.Template,{re:/\{([\w-\.]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,compile:function(){var s=this.html;s=['',s,''].join('');var re=/]*>((?:(?=([^<]+))\2|<(?!tpl\b[^>]*>))*?)<\/tpl>/;var A=/^]*?for="(.*?)"/;var B=/^]*?if="(.*?)"/;var C=/^]*?exec="(.*?)"/;var m,id=0;var D=[];while(true==!!(m=s.match(re))){var m2=m[0].match(A);var m3=m[0].match(B);var m4=m[0].match(C);var E=null,fn=null,F=null;var G=m2&&m2[1]?m2[1]:'';if(m3){E=m3&&m3[1]?m3[1]:null;if(E){fn=new Function('values','parent','with(values){ return '+(Roo.util.Format.htmlDecode(E))+'; }');}}if(m4){E=m4&&m4[1]?m4[1]:null;if(E){F=new Function('values','parent','with(values){ '+(Roo.util.Format.htmlDecode(E))+'; }');}}if(G){switch(G){case '.':G=new Function('values','parent','with(values){ return values; }');break;case '..':G=new Function('values','parent','with(values){ return parent; }');break;default:G=new Function('values','parent','with(values){ return '+G+'; }');}} +Roo.XTemplate=function(){Roo.XTemplate.superclass.constructor.apply(this,arguments);if(this.html){this.compile();}};Roo.extend(Roo.XTemplate,Roo.Template,{re:/\{([\w-\.]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,compile:function(){var s=this.html;s=['',s,''].join('');var re=/]*>((?:(?=([^<]+))\2|<(?!tpl\b[^>]*>))*?)<\/tpl>/,A=/^]*?for="(.*?)"/,B=/^]*?if="(.*?)"/,C=/^]*?exec="(.*?)"/,m,id=0,D=[];while(true==!!(m=s.match(re))){var m2=m[0].match(A),m3=m[0].match(B),m4=m[0].match(C),E=null,fn=null,F=null,G=m2&&m2[1]?m2[1]:'';if(m3){E=m3&&m3[1]?m3[1]:null;if(E){fn=new Function('values','parent','with(values){ return '+(Roo.util.Format.htmlDecode(E))+'; }');}}if(m4){E=m4&&m4[1]?m4[1]:null;if(E){F=new Function('values','parent','with(values){ '+(Roo.util.Format.htmlDecode(E))+'; }');}}if(G){switch(G){case '.':G=new Function('values','parent','with(values){ return values; }');break;case '..':G=new Function('values','parent','with(values){ return parent; }');break;default:G=new Function('values','parent','with(values){ return '+G+'; }');}} D.push({id:id,target:G,exec:F,test:fn,body:m[1]||''});s=s.replace(m[0],'{xtpl'+id+'}');++id;}for(var i=D.length-1;i>=0;--i){this.compileTpl(D[i]);} this.master=D[D.length-1];this.tpls=D;return this;},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;i */ -Roo.XTemplate = function(){ + + +/** + * @class Roo.XTemplate + * @extends Roo.Template + * Provides a template that can have nested templates for loops or conditionals. The syntax is: +

+var t = new Roo.MasterTemplate(
+	'<select name="{name}">',
+		'<tpl for="options"><option value="{value:trim}">{text:ellipsis(10)}</option></tpl>',
+	'</select>'
+);
+ 
+// then append, applying the master template values
+ 
+ * + * Supported features: + * + * Tags: + * {a_variable} - output encoded. + * {a_variable.format:("Y-m-d")} - call a method on the variable + * {a_variable:raw} - unencoded output + * {a_variable:toFixed(1,2)} - Roo.util.Format."toFixed" + * {a_variable:this.method_on_template(...)} - call a method on the template object. + * + * Tpl: + * + * + * + * + * - just iterate the property.. + * - iterates witht the parent (probably the template) + * + * + */ +Roo.XTemplate = function() +{ Roo.XTemplate.superclass.constructor.apply(this, arguments); if (this.html) { - this.preCompile(); + this.compile(); } }; @@ -52350,53 +52386,54 @@ Roo.extend(Roo.XTemplate, Roo.Template, { s = ['', s, ''].join(''); - var re = /]*>((?:(?=([^<]+))\2|<(?!tpl\b[^>]*>))*?)<\/tpl>/; - - var nameRe = /^]*?for="(.*?)"/; - var ifRe = /^]*?if="(.*?)"/; - var execRe = /^]*?exec="(.*?)"/; - var m, id = 0; - var tpls = []; + var re = /]*>((?:(?=([^<]+))\2|<(?!tpl\b[^>]*>))*?)<\/tpl>/, + nameRe = /^]*?for="(.*?)"/, + ifRe = /^]*?if="(.*?)"/, + execRe = /^]*?exec="(.*?)"/, + m, + id = 0, + tpls = []; while(true == !!(m = s.match(re))){ - var m2 = m[0].match(nameRe); - var m3 = m[0].match(ifRe); - var m4 = m[0].match(execRe); - var exp = null, - fn = null, - exec = null; - var name = m2 && m2[1] ? m2[1] : ''; - if(m3){ + var m2 = m[0].match(nameRe), + m3 = m[0].match(ifRe), + m4 = m[0].match(execRe), + exp = null, + fn = null, + exec = null, + name = m2 && m2[1] ? m2[1] : ''; + + if (m3) { // if - puts fn into test.. exp = m3 && m3[1] ? m3[1] : null; if(exp){ fn = new Function('values', 'parent', 'with(values){ return '+(Roo.util.Format.htmlDecode(exp))+'; }'); } - } - if(m4){ + } + if (m4) { // exec - calls a function... returns empty if true is returned. - exp = m4 && m4[1] ? m4[1] : null; - if(exp){ + exp = m4 && m4[1] ? m4[1] : null; + if(exp){ exec = new Function('values', 'parent', 'with(values){ '+(Roo.util.Format.htmlDecode(exp))+'; }'); - } - } - if(name){ + } + } + if (name) { // for = - switch(name){ - case '.': name = new Function('values', 'parent', 'with(values){ return values; }'); break; - case '..': name = new Function('values', 'parent', 'with(values){ return parent; }'); break; - default: name = new Function('values', 'parent', 'with(values){ return '+name+'; }'); - } - } - tpls.push({ - id: id, + switch(name){ + case '.': name = new Function('values', 'parent', 'with(values){ return values; }'); break; + case '..': name = new Function('values', 'parent', 'with(values){ return parent; }'); break; + default: name = new Function('values', 'parent', 'with(values){ return '+name+'; }'); + } + } + tpls.push({ + id: id, target: name, - exec: exec, - test: fn, - body: m[1]||'' + exec: exec, + test: fn, + body: m[1] || '' }); - s = s.replace(m[0], '{xtpl'+ id + '}'); - ++id; + s = s.replace(m[0], '{xtpl'+ id + '}'); + ++id; } for(var i = tpls.length-1; i >= 0; --i){ this.compileTpl(tpls[i]); diff --git a/roojs-ui-debug.js b/roojs-ui-debug.js index 80d41c2c02..49979908b9 100644 --- a/roojs-ui-debug.js +++ b/roojs-ui-debug.js @@ -37820,10 +37820,46 @@ Roo.LoadMask.prototype = { * Fork - LGPL *