-<html>
-<head>
- <title>The source code</title>
- <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
- <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
-</head>
-<body onload="prettyPrint();">
- <pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.0.3
- * Copyright(c) 2006-2009 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-<div id="cls-Ext.util.Format"></div>/**\r
+<html>\r
+<head>\r
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> \r
+ <title>The source code</title>\r
+ <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
+ <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
+</head>\r
+<body onload="prettyPrint();">\r
+ <pre class="prettyprint lang-js"><div id="cls-Ext.util.Format"></div>/**\r
* @class Ext.util.Format\r
* Reusable data formatting functions\r
* @singleton\r
*/\r
Ext.util.Format = function(){\r
- var trimRe = /^\s+|\s+$/g;\r
+ var trimRe = /^\s+|\s+$/g,\r
+ stripTagsRE = /<\/?[^>]+>/gi,\r
+ stripScriptsRe = /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig,\r
+ nl2brRe = /\r?\n/g;\r
+ \r
return {\r
<div id="method-Ext.util.Format-ellipsis"></div>/**\r
* Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length\r
ellipsis : function(value, len, word){\r
if(value && value.length > len){\r
if(word){\r
- var vs = value.substr(0, len - 2);\r
- var index = Math.max(vs.lastIndexOf(' '), vs.lastIndexOf('.'), vs.lastIndexOf('!'), vs.lastIndexOf('?'));\r
+ var vs = value.substr(0, len - 2),\r
+ index = Math.max(vs.lastIndexOf(' '), vs.lastIndexOf('.'), vs.lastIndexOf('!'), vs.lastIndexOf('?'));\r
if(index == -1 || index < (len - 15)){\r
return value.substr(0, len - 3) + "...";\r
}else{\r
v = (Math.round((v-0)*100))/100;\r
v = (v == Math.floor(v)) ? v + ".00" : ((v*10 == Math.floor(v*10)) ? v + "0" : v);\r
v = String(v);\r
- var ps = v.split('.');\r
- var whole = ps[0];\r
- var sub = ps[1] ? '.'+ ps[1] : '.00';\r
- var r = /(\d+)(\d{3})/;\r
+ var ps = v.split('.'),\r
+ whole = ps[0],\r
+ sub = ps[1] ? '.'+ ps[1] : '.00',\r
+ r = /(\d+)(\d{3})/;\r
while (r.test(whole)) {\r
whole = whole.replace(r, '$1' + ',' + '$2');\r
}\r
return Ext.util.Format.date(v, format);\r
};\r
},\r
-\r
- // private\r
- stripTagsRE : /<\/?[^>]+>/gi,\r
\r
<div id="method-Ext.util.Format-stripTags"></div>/**\r
* Strips all HTML tags\r
* @return {String} The stripped text\r
*/\r
stripTags : function(v){\r
- return !v ? v : String(v).replace(this.stripTagsRE, "");\r
+ return !v ? v : String(v).replace(stripTagsRE, "");\r
},\r
\r
- stripScriptsRe : /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig,\r
-\r
<div id="method-Ext.util.Format-stripScripts"></div>/**\r
* Strips all script tags\r
* @param {Mixed} value The text from which to strip script tags\r
* @return {String} The stripped text\r
*/\r
stripScripts : function(v){\r
- return !v ? v : String(v).replace(this.stripScriptsRe, "");\r
+ return !v ? v : String(v).replace(stripScriptsRe, "");\r
},\r
\r
<div id="method-Ext.util.Format-fileSize"></div>/**\r
* @return {String} The string with embedded <br/> tags in place of newlines.\r
*/\r
nl2br : function(v){\r
- return v === undefined || v === null ? '' : v.replace(/\n/g, '<br/>');\r
+ return Ext.isEmpty(v) ? '' : v.replace(nl2brRe, '<br/>');\r
}\r
}\r
-}();</pre>
-</body>
+}();\r
+</pre> \r
+</body>\r
</html>
\ No newline at end of file