X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..6e39d509471fe9b4e2660e0d1631b350d0c66f40:/docs/source/Format.html
diff --git a/docs/source/Format.html b/docs/source/Format.html
index 412b2f74..2e15644d 100644
--- a/docs/source/Format.html
+++ b/docs/source/Format.html
@@ -1,5 +1,6 @@
+
The source code
@@ -11,7 +12,11 @@
* @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
@@ -23,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{
@@ -141,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');
}
@@ -181,9 +186,6 @@ Ext.util.Format = function(){
return Ext.util.Format.date(v, format);
};
},
-
- // private
- stripTagsRE : /<\/?[^>]+>/gi,
/**
* Strips all HTML tags
@@ -191,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, "");
},
/**
@@ -351,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