roojs-core.js
authorAlan Knowles <alan@akbkhome.com>
Sun, 18 Nov 2012 10:38:22 +0000 (18:38 +0800)
committerAlan Knowles <alan@akbkhome.com>
Sun, 18 Nov 2012 10:38:22 +0000 (18:38 +0800)
roojs-core-debug.js

roojs-core-debug.js
roojs-core.js

index 004733b..345838f 100644 (file)
@@ -12249,8 +12249,9 @@ Roo.extend(Roo.DomTemplate, Roo.Template, {
         var s = this.html;
         
         // covert the html into DOM...
-        
-        var div = document.createElement('div');
+        var doc = document.implementation.createHTMLDocument("");
+        //doc.documentElement.innerHTML = htmlBody
+        var div = doc.documentElement;
         div.innerHTML =   this.html  ;
         
         this.tpls = [];
@@ -12522,7 +12523,7 @@ Roo.extend(Roo.DomTemplate, Roo.Template, {
         
         try { 
             if(t.ifCall && !t.ifCall.call(this, values, parent)){
-                Roo.log('if call on ' + t.value + ' return false');
+                Roo.debug && Roo.log('if call on ' + t.value + ' return false');
                 return '';
             }
         } catch(e) {
index c8523bd..5cf275a 100644 (file)
@@ -224,11 +224,11 @@ this.update(this.defaultUrl,null,A,true);},startAutoRefresh:function(A,B,C,D,E){
 this.autoRefreshProcId=setInterval(this.update.createDelegate(this,[B||this.defaultUrl,C,D,true]),A*1000);},stopAutoRefresh:function(){if(this.autoRefreshProcId){clearInterval(this.autoRefreshProcId);delete this.autoRefreshProcId;}},isAutoRefreshing:function(){return this.autoRefreshProcId?true:false;},showLoading:function(){if(this.showLoadIndicator){this.el.update(this.indicatorText);}},prepareUrl:function(A){if(this.disableCaching){var B="_dc="+(new Date().getTime());if(A.indexOf("?")!==-1){A+="&"+B;}else {A+="?"+B;}}return A;},processSuccess:function(A){this.transaction=null;if(A.argument.form&&A.argument.reset){try{A.argument.form.reset();}catch(e){}}if(this.loadScripts){this.renderer.render(this.el,A,this,this.updateComplete.createDelegate(this,[A]));}else {this.renderer.render(this.el,A,this);this.updateComplete(A);}},updateComplete:function(A){this.fireEvent("update",this.el,A);if(typeof A.argument.callback=="function"){A.argument.callback(this.el,true,A);}},processFailure:function(A){this.transaction=null;this.fireEvent("failure",this.el,A);if(typeof A.argument.callback=="function"){A.argument.callback(this.el,false,A);}},setRenderer:function(A){this.renderer=A;},getRenderer:function(){return this.renderer;},setDefaultUrl:function(A){this.defaultUrl=A;},abort:function(){if(this.transaction){Roo.Ajax.abort(this.transaction);}},isUpdating:function(){if(this.transaction){return Roo.Ajax.isLoading(this.transaction);}return false;}});Roo.UpdateManager.defaults={timeout:30,loadScripts:false,sslBlankUrl:(Roo.SSL_SECURE_URL||"javascript:false"),disableCaching:false,showLoadIndicator:true,indicatorText:'<div class="loading-indicator">Loading...</div>'};Roo.UpdateManager.updateElement=function(el,A,B,C){var um=Roo.get(el,true).getUpdateManager();Roo.apply(um,C);um.update(A,B,C?C.callback:null);};Roo.UpdateManager.update=Roo.UpdateManager.updateElement;Roo.UpdateManager.BasicRenderer=function(){};Roo.UpdateManager.BasicRenderer.prototype={render:function(el,A,B,C){el.update(A.responseText,B.loadScripts,C);}};
 //Roo/DomTemplate.js
 Roo.DomTemplate=function(){Roo.DomTemplate.superclass.constructor.apply(this,arguments);if(this.html){this.compile();}};Roo.extend(Roo.DomTemplate,Roo.Template,{id:0,inPre:false,tpls:false,re:/(\{|\%7B)([\w-\.]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?(\}|\%7D)/g,iterChild:function(A,B){var C=this.inPre;if(A.tagName=='PRE'){this.inPre=true;}for(var i=0;i<A.childNodes.length;i++){B.call(this,A.childNodes[i]);}
-this.inPre=C;},compile:function(){var s=this.html;var A=document.createElement('div');A.innerHTML=this.html;this.tpls=[];var _t=this;this.iterChild(A,function(n){_t.compileNode(n,true);});var B=this.tpls;var C={uid:'master',id:this.id++,attr:false,value:false,body:A.innerHTML,forCall:false,execCall:false,dom:A,isTop:true};B.unshift(C);this.tpls=[];Roo.each(B,function(tp){this.compileTpl(tp);this.tpls[tp.id]=tp;},this);this.master=B[0];return this;},compileNode:function(A,B){if(A.nodeType!=1){if(A.nodeType==3&&!this.inPre){A.nodeValue=A.nodeValue.replace(/\s+/g,' ');}return;}var C={uid:false,id:false,attr:false,value:false,body:'',forCall:false,execCall:false,dom:false,isTop:B};switch(true){case (A.hasAttribute('roo-for')):C.attr='for';break;case (A.hasAttribute('roo-if')):C.attr='if';break;case (A.hasAttribute('roo-name')):C.attr='name';break;case (A.hasAttribute('roo-exec')):C.attr='exec';break;}if(!C.attr){this.iterChild(A,this.compileNode);return;}
+this.inPre=C;},compile:function(){var s=this.html;var A=document.implementation.createHTMLDocument("");var B=A.documentElement;B.innerHTML=this.html;this.tpls=[];var _t=this;this.iterChild(B,function(n){_t.compileNode(n,true);});var C=this.tpls;var D={uid:'master',id:this.id++,attr:false,value:false,body:B.innerHTML,forCall:false,execCall:false,dom:B,isTop:true};C.unshift(D);this.tpls=[];Roo.each(C,function(tp){this.compileTpl(tp);this.tpls[tp.id]=tp;},this);this.master=C[0];return this;},compileNode:function(A,B){if(A.nodeType!=1){if(A.nodeType==3&&!this.inPre){A.nodeValue=A.nodeValue.replace(/\s+/g,' ');}return;}var C={uid:false,id:false,attr:false,value:false,body:'',forCall:false,execCall:false,dom:false,isTop:B};switch(true){case (A.hasAttribute('roo-for')):C.attr='for';break;case (A.hasAttribute('roo-if')):C.attr='if';break;case (A.hasAttribute('roo-name')):C.attr='name';break;case (A.hasAttribute('roo-exec')):C.attr='exec';break;}if(!C.attr){this.iterChild(A,this.compileNode);return;}
 C.uid=this.id++;C.value=A.getAttribute('roo-'+C.attr);A.removeAttribute('roo-'+C.attr);if(C.attr!='name'){var D=document.createTextNode('{domtpl'+C.uid+'}');A.parentNode.replaceChild(D,A);}else {var D=document.createElement('span');D.className='roo-tpl-'+C.value;A.parentNode.replaceChild(D,A);}
 this.iterChild(A,this.compileNode);var E=document.createElement('div');E.appendChild(A);C.dom=A;C.body=E.innerHTML;C.id=C.uid;switch(C.attr){case 'for':switch(C.value){case '.':C.forCall=new Function('values','parent','with(values){ return values; }');break;case '..':C.forCall=new Function('values','parent','with(values){ return parent; }');break;default:C.forCall=new Function('values','parent','with(values){ return '+C.value+'; }');}break;case 'exec':C.execCall=new Function('values','parent','with(values){ '+(Roo.util.Format.htmlDecode(C.value))+'; }');break;case 'if':C.ifCall=new Function('values','parent','with(values){ return '+(Roo.util.Format.htmlDecode(C.value))+'; }');break;case 'name':C.id=C.value;break;}
 this.tpls.push(C);},compileTpl:function(tpl){var fm=Roo.util.Format;var useF=this.disableFormats!==true;var A=Roo.isGecko?"+\n":",\n";var undef=function(C){Roo.debug&&Roo.log("Property not found :"+C);return '';};var fn=function(m,C,D,E,F){F=F?F.replace(/\\'/g,"'"):F;if(typeof(E)=='undefined'){E='htmlEncode';}if(E=='raw'){E=false;}if(D.substr(0,6)=='domtpl'){return "'"+A+'this.applySubTemplate('+D.substr(6)+', values, parent)'+A+"'";}var G=[];var H='';Roo.each(D.split('.'),function(st){H+=(H.length?'.':'')+st;G.push("(typeof("+H+") == 'undefined')");});var I='(('+G.join(" || ")+") ? undef('"+D+"') : ";if(E&&useF){F=F?','+F:"";if(E.substr(0,5)!="this."){E="fm."+E+'(';}else {E='this.call("'+E.substr(5)+'", ';F=", values";}return "'"+A+I+E+D+F+"))"+A+"'";}if(F.length){return "'"+A+I+D+'('+F+"))"+A+"'";}return "'"+A+I+D+")"+A+"'";};var B;if(Roo.isGecko){B="tpl.compiled = function(values, parent){  with(values) { return '"+tpl.body.replace(/(\r\n|\n)/g,'\\n').replace(/'/g,"\\'").replace(this.re,fn)+"';};};";}else {B=["tpl.compiled = function(values, parent){  with (values) { return ['"];B.push(tpl.body.replace(/(\r\n|\n)/g,'\\n').replace(/'/g,"\\'").replace(this.re,fn));B.push("'].join('');};};");B=B.join('');}
-Roo.debug&&Roo.log(B.replace(/\\n/,'\n'));eval(B);return this;},applySubTemplate:function(id,A,B){var t=this.tpls[id];try{if(t.ifCall&&!t.ifCall.call(this,A,B)){Roo.log('if call on '+t.value+' return false');return '';}}catch(e){Roo.log('Xtemplate.applySubTemplate('+id+'): Exception thrown on roo-if="'+t.value+'" - '+e.toString());Roo.log(values);return '';}try{if(t.execCall&&t.execCall.call(this,A,B)){return '';}}catch(e){Roo.log('Xtemplate.applySubTemplate('+id+'): Exception thrown on roo-for="'+t.value+'" - '+e.toString());Roo.log(values);return '';}try{var vs=t.forCall?t.forCall.call(this,A,B):A;B=t.target?A:B;if(t.forCall&&vs instanceof Array){var C=[];for(var i=0,D=vs.length;i<D;i++){try{C[C.length]=t.compiled.call(this,vs[i],B);}catch(e){Roo.log('Xtemplate.applySubTemplate('+id+'): Exception thrown on body="'+t.value+'" - '+e.toString());Roo.log(e.body);Roo.log(vs[i]);}}return C.join('');}}catch(e){Roo.log('Xtemplate.applySubTemplate('+id+'): Exception thrown on roo-for="'+t.value+'" - '+e.toString());Roo.log(values);return '';}try{return t.compiled.call(this,vs,B);}catch(e){Roo.log('Xtemplate.applySubTemplate('+id+'): Exception thrown on body="'+t.value+'" - '+e.toString());Roo.log(e.body);Roo.log(values);return '';}},applyTemplate:function(A){return this.master.compiled.call(this,A,{});},apply:function(){return this.applyTemplate.apply(this,arguments);}});Roo.DomTemplate.from=function(el){el=Roo.getDom(el);return new Roo.Domtemplate(el.value||el.innerHTML);};
+Roo.debug&&Roo.log(B.replace(/\\n/,'\n'));eval(B);return this;},applySubTemplate:function(id,A,B){var t=this.tpls[id];try{if(t.ifCall&&!t.ifCall.call(this,A,B)){Roo.debug&&Roo.log('if call on '+t.value+' return false');return '';}}catch(e){Roo.log('Xtemplate.applySubTemplate('+id+'): Exception thrown on roo-if="'+t.value+'" - '+e.toString());Roo.log(values);return '';}try{if(t.execCall&&t.execCall.call(this,A,B)){return '';}}catch(e){Roo.log('Xtemplate.applySubTemplate('+id+'): Exception thrown on roo-for="'+t.value+'" - '+e.toString());Roo.log(values);return '';}try{var vs=t.forCall?t.forCall.call(this,A,B):A;B=t.target?A:B;if(t.forCall&&vs instanceof Array){var C=[];for(var i=0,D=vs.length;i<D;i++){try{C[C.length]=t.compiled.call(this,vs[i],B);}catch(e){Roo.log('Xtemplate.applySubTemplate('+id+'): Exception thrown on body="'+t.value+'" - '+e.toString());Roo.log(e.body);Roo.log(vs[i]);}}return C.join('');}}catch(e){Roo.log('Xtemplate.applySubTemplate('+id+'): Exception thrown on roo-for="'+t.value+'" - '+e.toString());Roo.log(values);return '';}try{return t.compiled.call(this,vs,B);}catch(e){Roo.log('Xtemplate.applySubTemplate('+id+'): Exception thrown on body="'+t.value+'" - '+e.toString());Roo.log(e.body);Roo.log(values);return '';}},applyTemplate:function(A){return this.master.compiled.call(this,A,{});},apply:function(){return this.applyTemplate.apply(this,arguments);}});Roo.DomTemplate.from=function(el){el=Roo.getDom(el);return new Roo.Domtemplate(el.value||el.innerHTML);};
 //Roo/util/DelayedTask.js
 Roo.util.DelayedTask=function(fn,A,B){var id=null,d,t;var C=function(){var D=new Date().getTime();if(D-t>=d){clearInterval(id);id=null;fn.apply(A,B||[]);}};this.delay=function(D,E,F,G){if(id&&D!=d){this.cancel();}
 d=D;t=new Date().getTime();fn=E||fn;A=F||A;B=G||B;if(!id){id=setInterval(C,d);}};this.cancel=function(){if(id){clearInterval(id);id=null;}};};