roojs-core.js
authorAlan Knowles <alan@roojs.com>
Wed, 16 Apr 2014 10:15:14 +0000 (18:15 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 16 Apr 2014 10:15:14 +0000 (18:15 +0800)
roojs-core-debug.js

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

index 25ca51d..9638d7e 100644 (file)
@@ -13326,7 +13326,7 @@ Roo.util.JSON = new (function(){
      */
     this.encode = function(o)
     {
-        // should this be extended to fully wrap stringify..
+        // should this be extended to fully wrap ..
         
         if(typeof o == "undefined" || o === null){
             return "null";
@@ -13379,7 +13379,7 @@ Roo.util.JSON = new (function(){
  * Shorthand for {@link Roo.util.JSON#encode}
  * @member Roo encode 
  * @method */
-Roo.encode = typeof(JSON) != 'undefined' && JSON.stringify ? JSON.stringify : Roo.util.JSON.encode;
+Roo.encode = typeof(JSON) != 'undefined' && JSON. ? JSON. : Roo.util.JSON.encode;
 /** 
  * Shorthand for {@link Roo.util.JSON#decode}
  * @member Roo decode 
@@ -15864,10 +15864,20 @@ Roo.extend(Roo.XComponent, Roo.util.Observable, {
                 return;
             }
         }
+        var tree = this._tree ? this._tree() : this.tree();
+
         
+        if (!this.parent && typeof(Roo.bootstrap) != 'undefined' && tree.xns == Roo.bootstrap) {
+            //el = Roo.get(document.body);
+            this.parent = { el : true };
+        }
+            
+            
         
         if (!this.parent) {
             
+            Roo.log("no parent - creating one");
+            
             el = el ? Roo.get(el) : false;     
             
             // it's a top level one..
@@ -15895,7 +15905,6 @@ Roo.extend(Roo.XComponent, Roo.util.Observable, {
                }
                // The 'tree' method is  '_tree now' 
             
-        var tree = this._tree ? this._tree() : this.tree();
         tree.region = tree.region || this.region;
         
         if (this.parent.el === true) {
index 0660738..0437b2f 100644 (file)
@@ -256,7 +256,7 @@ c=b.charCodeAt();return "\\u00"+Math.floor(c/16).toString(16)+(c%16).toString(16
 a.push(v===null?"null":Roo.util.JSON.encode(v));b=true;}}
 a.push("]");return a.join("");};var E=function(o){return '"'+o.getFullYear()+"-"+B(o.getMonth()+1)+"-"+B(o.getDate())+"T"+B(o.getHours())+":"+B(o.getMinutes())+":"+B(o.getSeconds())+'"';};this.encode=function(o){if(typeof o=="undefined"||o===null){return "null";}else if(o instanceof Array){return D(o);}else if(o instanceof Date){return E(o);}else if(typeof o=="string"){return C(o);}else if(typeof o=="number"){return isFinite(o)?String(o):"null";}else if(typeof o=="boolean"){return String(o);}else {var a=["{"],b,i,v;for(i in o){if(!A||o.hasOwnProperty(i)){v=o[i];switch(typeof v){case "undefined":case "function":case "unknown":break;default:if(b){a.push(',');}
 a.push(this.encode(i),":",v===null?"null":this.encode(v));b=true;}}}
-a.push("}");return a.join("");}};this.decode=function(json){return eval("("+json+')');};})();Roo.encode=typeof(JSON)!='undefined'&&JSON.stringify?JSON.stringify:Roo.util.JSON.encode;Roo.decode=typeof(JSON)!='undefined'&&JSON.parse?JSON.parse:Roo.util.JSON.decode;
+a.push("}");return a.join("");}};this.decode=function(json){return eval("("+json+')');};})();Roo.encode=typeof(JSON)!='undefined'&&JSON.?JSON.:Roo.util.JSON.encode;Roo.decode=typeof(JSON)!='undefined'&&JSON.parse?JSON.parse:Roo.util.JSON.decode;
 //Roo/util/Format.js
 Roo.util.Format=function(){var A=/^\s+|\s+$/g;return {ellipsis:function(B,C){if(B&&B.length>C){return B.substr(0,C-3)+"...";}return B;},undef:function(B){return typeof B!="undefined"?B:"";},htmlEncode:function(B){return !B?B:String(B).replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/"/g,"&quot;");},htmlDecode:function(B){return !B?B:String(B).replace(/&amp;/g,"&").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&quot;/g,'"');},trim:function(B){return String(B).replace(A,"");},substr:function(B,C,D){return String(B).substr(C,D);},lowercase:function(B){return String(B).toLowerCase();},uppercase:function(B){return String(B).toUpperCase();},capitalize:function(B){return !B?B:B.charAt(0).toUpperCase()+B.substr(1).toLowerCase();},call:function(value,fn){if(arguments.length>2){var B=Array.prototype.slice.call(arguments,2);B.unshift(value);return eval(fn).apply(window,B);}else {return eval(fn).call(window,value);}},toFixed:function(v,n){if(!n){return Math.round(v-0);}var B=Math.pow(10,n+1);v=(Math.round((v-0)*B))/B;var z=(''+B).substring(2);if(v==Math.floor(v)){return Math.floor(v)+'.'+z;}var ps=String(v).split('.');var fd=(ps[1]+z);var r=fd.substring(0,n);var rm=fd.substring(n);if(rm<5){return ps[0]+'.'+r;}
 r*=1;r++;if(String(r).length!=n){ps[0]*=1;ps[0]++;r=String(r).substring(1);}return ps[0]+'.'+r;},usMoney:function(v){return '$'+Roo.util.Format.number(v);},number:function(v,B){B=typeof(B)=='undefined'?2:B;var C=Math.pow(10,B);var D=String(C).substring(1);v=(Math.round((v-0)*C))/C;v=String(v);var ps=v.split('.');var E=ps[0];var r=/(\d+)(\d{3})/;while(r.test(E)){E=E.replace(r,'$1'+','+'$2');}var F=ps[1]?(B?('.'+ps[1]+D.substring(ps[1].length)):''):(B?('.'+D):'');return E+F;},date:function(v,B){if(!v){return "";}if(!(v instanceof Date)){v=new Date(Date.parse(v));}return v.dateFormat(B||Roo.util.Format.defaults.date);},dateRenderer:function(B){return function(v){return Roo.util.Format.date(v,B);};},stripTagsRE:/<\/?[^>]+>/gi,stripTags:function(v){return !v?v:String(v).replace(this.stripTagsRE,"");}};}();Roo.util.Format.defaults={date:'d/M/Y'};
@@ -321,7 +321,8 @@ this.onPosition(ax,ay);this.fireEvent('move',this,ax,ay);}return this;},setPageP
 //Roo/XComponent.js
 Roo.XComponent=function(A){Roo.apply(this,A);this.addEvents({'built':true});this.region=this.region||'center';Roo.XComponent.register(this);this.modules=false;this.el=false;}
 Roo.extend(Roo.XComponent,Roo.util.Observable,{el:false,panel:false,layout:false,disabled:false,parent:false,order:false,name:false,region:'center',items:false,_tree:false,render:function(el){el=el||false;var hp=this.parent?1:0;if(!el&&typeof(this.parent)=='string'&&this.parent.substring(0,1)=='#'){var A=this.parent.substr(1)
-this.parent=(this.parent=='#bootstrap')?{el:true}:false;el=Roo.get(A);if(!el&&!this.parent){Roo.log("Warning - element can not be found :#"+A);return;}}if(!this.parent){el=el?Roo.get(el):false;this.parent={el:new Roo.BorderLayout(el||document.body,{center:{titlebar:false,autoScroll:false,closeOnTab:true,tabPosition:'top',alwaysShowTabs:el&&hp?false:true,hideTabs:el||!hp?true:false,minTabWidth:140}})}}if(!this.parent.el){return;}var B=this._tree?this._tree():this.tree();B.region=B.region||this.region;if(this.parent.el===true){this.parent.el=Roo.factory(B);}
+this.parent=(this.parent=='#bootstrap')?{el:true}:false;el=Roo.get(A);if(!el&&!this.parent){Roo.log("Warning - element can not be found :#"+A);return;}}var B=this._tree?this._tree():this.tree();if(!this.parent&&typeof(Roo.bootstrap)!='undefined'&&B.xns==Roo.bootstrap){this.parent={el:true};}if(!this.parent){Roo.log("no parent - creating one");el=el?Roo.get(el):false;this.parent={el:new Roo.BorderLayout(el||document.body,{center:{titlebar:false,autoScroll:false,closeOnTab:true,tabPosition:'top',alwaysShowTabs:el&&hp?false:true,hideTabs:el||!hp?true:false,minTabWidth:140}})}}if(!this.parent.el){return;}
+B.region=B.region||this.region;if(this.parent.el===true){this.parent.el=Roo.factory(B);}
 this.el=this.parent.el.addxtype(B);this.fireEvent('built',this);this.panel=this.el;this.layout=this.panel.layout;this.parentLayout=this.parent.layout||false;}});Roo.apply(Roo.XComponent,{hideProgress:false,buildCompleted:false,topModule:false,modules:[],elmodules:[],build_from_html:false,register:function(A){Roo.XComponent.event.fireEvent('register',A);switch(typeof(A.disabled)){case 'undefined':break;case 'function':if(A.disabled()){return;}break;default:if(A.disabled){return;}break;}
 this.modules.push(A);},toObject:function(str){if(!str||typeof(str)=='object'){return str;}if(str.substring(0,1)=='#'){return str;}var ar=str.split('.');var rt,o;rt=ar.shift();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;}
 Roo.each(ar,function(e){if(typeof(o[e])=='undefined'){throw "Module not found : "+str;}