From 43e5e267a93fd3379694976db7091af84654cee9 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Thu, 10 May 2018 15:26:42 +0800 Subject: [PATCH] sync --- roojs-all.js | 8 ++++--- roojs-debug.js | 63 +++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/roojs-all.js b/roojs-all.js index eb8cc77b38..f89d55ae2f 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -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[^\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:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:noop,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/} diff --git a/roojs-debug.js b/roojs-debug.js index 646c052867..cbfc6e33c3 100644 --- a/roojs-debug.js +++ b/roojs-debug.js @@ -884,7 +884,9 @@ var s = String.format('
{1}
', 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. -- 2.39.2