+/*
+
+This file is part of Ext JS 4
+
+Copyright (c) 2011 Sencha Inc
+
+Contact: http://www.sencha.com/contact
+
+GNU General Public License Usage
+This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
+
+If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
+
+*/
/**
* @class Ext.util.Format
- currenyPrecision
- currencySign
- currencyAtEnd
-This class also uses the default date format defined here: {@link Ext.date#defaultFormat}.
+This class also uses the default date format defined here: {@link Ext.Date#defaultFormat}.
__Using with renderers__
There are two helper functions that return a new function that can be used in conjunction with
* var tpl = new Ext.Template('{value} * 10 = {value:math("* 10")}');
* </code></pre>
* @return {Function} A function that operates on the passed value.
+ * @method
*/
math : function(){
var fns = {};
* @param {String} format The way you would like to format this text.
* @return {String} The formatted number.
*/
- number:
- function(v, formatString) {
+ number: function(v, formatString) {
if (!formatString) {
return v;
}
fnum = psplit[0] + dec + psplit[1];
}
}
+
+ if (neg) {
+ /*
+ * Edge case. If we have a very small negative number it will get rounded to 0,
+ * however the initial check at the top will still report as negative. Replace
+ * everything but 1-9 and check if the string is empty to determine a 0 value.
+ */
+ neg = fnum.replace(/[^1-9]/g, '') !== '';
+ }
return (neg ? '-' : '') + formatString.replace(/[\d,?\.?]+/, fnum);
},
/**
* Capitalize the given string. See {@link Ext.String#capitalize}.
+ * @method
*/
capitalize: Ext.String.capitalize,
/**
* Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length.
* See {@link Ext.String#ellipsis}.
+ * @method
*/
ellipsis: Ext.String.ellipsis,
/**
* Formats to a string. See {@link Ext.String#format}
+ * @method
*/
format: Ext.String.format,
/**
* Convert certain characters (&, <, >, and ') from their HTML character equivalents.
- * See {@link Ext.string#htmlDecode}.
+ * See {@link Ext.String#htmlDecode}.
+ * @method
*/
htmlDecode: Ext.String.htmlDecode,
/**
* Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages.
* See {@link Ext.String#htmlEncode}.
+ * @method
*/
htmlEncode: Ext.String.htmlEncode,
/**
* Adds left padding to a string. See {@link Ext.String#leftPad}
+ * @method
*/
leftPad: Ext.String.leftPad,
/**
* Trims any whitespace from either side of a string. See {@link Ext.String#trim}.
+ * @method
*/
trim : Ext.String.trim,
}
});
})();
+