X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775..10a866c12701c0a0afd0ac85dcdcf32a421514ac:/docs/source/Format.html?ds=sidebyside diff --git a/docs/source/Format.html b/docs/source/Format.html index ea9dedf5..2e15644d 100644 --- a/docs/source/Format.html +++ b/docs/source/Format.html @@ -1,23 +1,22 @@ - - - The source code - - - - -
/*!
- * Ext JS Library 3.0.3
- * Copyright(c) 2006-2009 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-
/** + + + + The source code + + + + +
/** * @class Ext.util.Format * Reusable data formatting functions * @singleton */ Ext.util.Format = function(){ - var trimRe = /^\s+|\s+$/g; + var trimRe = /^\s+|\s+$/g, + stripTagsRE = /<\/?[^>]+>/gi, + stripScriptsRe = /(?:)((\n|\r|.)*?)(?:<\/script>)/ig, + nl2brRe = /\r?\n/g; + return {
/** * Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length @@ -29,8 +28,8 @@ Ext.util.Format = function(){ ellipsis : function(value, len, word){ if(value && value.length > len){ if(word){ - var vs = value.substr(0, len - 2); - var index = Math.max(vs.lastIndexOf(' '), vs.lastIndexOf('.'), vs.lastIndexOf('!'), vs.lastIndexOf('?')); + var vs = value.substr(0, len - 2), + index = Math.max(vs.lastIndexOf(' '), vs.lastIndexOf('.'), vs.lastIndexOf('!'), vs.lastIndexOf('?')); if(index == -1 || index < (len - 15)){ return value.substr(0, len - 3) + "..."; }else{ @@ -147,10 +146,10 @@ Ext.util.Format = function(){ v = (Math.round((v-0)*100))/100; v = (v == Math.floor(v)) ? v + ".00" : ((v*10 == Math.floor(v*10)) ? v + "0" : v); v = String(v); - var ps = v.split('.'); - var whole = ps[0]; - var sub = ps[1] ? '.'+ ps[1] : '.00'; - var r = /(\d+)(\d{3})/; + var ps = v.split('.'), + whole = ps[0], + sub = ps[1] ? '.'+ ps[1] : '.00', + r = /(\d+)(\d{3})/; while (r.test(whole)) { whole = whole.replace(r, '$1' + ',' + '$2'); } @@ -187,9 +186,6 @@ Ext.util.Format = function(){ return Ext.util.Format.date(v, format); }; }, - - // private - stripTagsRE : /<\/?[^>]+>/gi,
/** * Strips all HTML tags @@ -197,18 +193,16 @@ Ext.util.Format = function(){ * @return {String} The stripped text */ stripTags : function(v){ - return !v ? v : String(v).replace(this.stripTagsRE, ""); + return !v ? v : String(v).replace(stripTagsRE, ""); }, - stripScriptsRe : /(?:)((\n|\r|.)*?)(?:<\/script>)/ig, -
/** * Strips all script tags * @param {Mixed} value The text from which to strip script tags * @return {String} The stripped text */ stripScripts : function(v){ - return !v ? v : String(v).replace(this.stripScriptsRe, ""); + return !v ? v : String(v).replace(stripScriptsRe, ""); },
/** @@ -357,9 +351,10 @@ Ext.util.Format = function(){ * @return {String} The string with embedded <br/> tags in place of newlines. */ nl2br : function(v){ - return v === undefined || v === null ? '' : v.replace(/\n/g, '
'); + return Ext.isEmpty(v) ? '' : v.replace(nl2brRe, '
'); } } -}();
- +}(); +
+ \ No newline at end of file