sync
authorAlan Knowles <alan@roojs.com>
Thu, 10 May 2018 07:26:42 +0000 (15:26 +0800)
committerAlan Knowles <alan@roojs.com>
Thu, 10 May 2018 07:26:42 +0000 (15:26 +0800)
roojs-all.js
roojs-debug.js

index eb8cc77..f89d55a 100644 (file)
@@ -27,7 +27,8 @@ E=E.concat(B);}else if(typeof C=="number"){E=Array.prototype.slice.call(argument
 }var C=this;return function(){A.target=this;A.method=C;if(A.apply(B||this||window,arguments)===false){return;}return C.apply(this||window,arguments);};}});
 // String.js
 Roo.applyIf(String,{escape:function(A){return A.replace(/('|\\)/g,"\\$1");},leftPad:function(A,B,ch){var C=new String(A);if(ch===null||ch===undefined||ch===''){ch=" ";}while(C.length<B){C=ch+C;}return C;},format:function(A){var B=Array.prototype.slice.call(arguments,1);
-return A.replace(/\{(\d+)\}/g,function(m,i){return Roo.util.Format.htmlEncode(B[i]);});}});String.prototype.toggle=function(A,B){return this==A?B:A;};
+return A.replace(/\{(\d+)\}/g,function(m,i){return Roo.util.Format.htmlEncode(B[i]);});}.});String.prototype.toggle=function(A,B){return this==A?B:A;};String.prototype.unicodeClean=function(){return this.replace(/[\s\S]/g,function(A){if(A.charCodeAt()<256){return A;
+}try{encodeURIComponent(A);}catch(e){return '';}return A;});};
 // Number.js
 Roo.applyIf(Number.prototype,{constrain:function(A,B){return Math.min(Math.max(this,A),B);}});
 // Array.js
@@ -672,8 +673,9 @@ m.modules.each(D);}else{Roo.debug&&Roo.log("build Order: no child modules");}if(
 }return C;},build:function(A){if(typeof(A)!='undefined'){Roo.apply(this,A);}this.preBuild();var B=this.buildOrder();if(!B.length){throw "NO modules!!!";}var C="Building Interface...";if(!this.hideProgress&&Roo.MessageBox){Roo.MessageBox.show({title:'loading'}
 );Roo.MessageBox.show({title:"Please wait...",msg:C,width:450,progress:true,closable:false,modal:false});}var D=B.length;var E=this;var F=function(){if(!B.length){Roo.debug&&Roo.log('hide?');if(!this.hideProgress&&Roo.MessageBox){Roo.MessageBox.hide();}Roo.XComponent.build_from_html=false;
 Roo.XComponent.event.fireEvent('buildcomplete',E.topModule);return false;}var m=B.shift();Roo.debug&&Roo.log(m);if(typeof(m)=='function'){m.call(this);return F.defer(10,E);}C="Building Interface "+(D-B.length)+" of "+D+(m.name?(' - '+m.name):'');Roo.debug&&Roo.log(C);
-if(!E.hideProgress&&Roo.MessageBox){Roo.MessageBox.updateProgress((D-B.length)/D,C);}var G=(typeof(m.disabled)=='function')?m.disabled.call(m.module.disabled):m.disabled;if(G){return F();}m.render();return F.defer(10,E);};F.defer(1,E);},event:false,on:false}
-);Roo.XComponent.event=new Roo.util.Observable({events:{'register':true,'beforebuild':true,'buildcomplete':true}});Roo.XComponent.on=Roo.XComponent.event.on.createDelegate(Roo.XComponent.event);
+if(!E.hideProgress&&Roo.MessageBox){Roo.MessageBox.updateProgress((D-B.length)/D,C);}var G=(typeof(m.disabled)=='function')?m.disabled.call(m.module.disabled):m.disabled;if(G){return F();}m.render();return F.defer(10,E);};F.defer(1,E);},overlayStrings:function(A,B){if(typeof(A['_named_strings'])==undefined){throw "ERROR: component does not have _named_strings";
+}for(var k in B){var md=typeof(A['_named_strings'][k])=='undefined'?false:A['_named_strings'][k];if(md!==false){A['_strings'][md]=B[k];}else{Roo.log('could not find named string: '+k+' in');Roo.log(A);}}},event:false,on:false});Roo.XComponent.event=new Roo.util.Observable({events:{'register':true,'beforebuild':true,'buildcomplete':true}
+});Roo.XComponent.on=Roo.XComponent.event.on.createDelegate(Roo.XComponent.event);
 // Roo/Markdown.js
 Roo.Markdown={};Roo.Markdown.toHtml=function(A){var c=new Roo.Markdown.marked.setOptions({renderer:new Roo.Markdown.marked.Renderer(),gfm:true,tables:true,breaks:false,pedantic:false,sanitize:false,smartLists:true,smartypants:false});A=A.replace(/\\\n/g,' ');
 return Roo.Markdown.marked(A);};(function(){var A={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:noop,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:noop,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:noop,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/}
index 646c052..cbfc6e3 100644 (file)
@@ -884,7 +884,9 @@ var s = String.format('<div class="{0}">{1}</div>', cls, text);
         return format.replace(/\{(\d+)\}/g, function(m, i){
             return Roo.util.Format.htmlEncode(args[i]);
         });
-    }
+    }.
+  
+    
 });
 
 /**
@@ -906,7 +908,31 @@ sort = (sort == 'ASC' ? 'DESC' : 'ASC');
  
 String.prototype.toggle = function(value, other){
     return this == value ? other : value;
-};/*
+};
+
+
+/**
+  * Remove invalid unicode characters from a string 
+  *
+  * @return {String} The clean string
+  */
+String.prototype.unicodeClean = function () {
+    return this.replace(/[\s\S]/g,
+        function(character) {
+            if (character.charCodeAt()< 256) {
+              return character;
+           }
+           try {
+                encodeURIComponent(character);
+           } catch(e) { 
+              return '';
+           }
+           return character;
+        }
+    );
+};
+  
+/*
  * Based on:
  * Ext JS Library 1.1.1
  * Copyright(c) 2006-2007, Ext JS, LLC.
@@ -15974,6 +16000,12 @@ Roo.extend(Roo.BoxComponent, Roo.Component, {
  * 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
@@ -16583,7 +16615,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.