X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6746dc89c47ed01b165cc1152533605f97eb8e8d..HEAD:/src/core/src/util/Format.js diff --git a/src/core/src/util/Format.js b/src/core/src/util/Format.js index 1b0ff797..ec242a6d 100644 --- a/src/core/src/util/Format.js +++ b/src/core/src/util/Format.js @@ -15,7 +15,7 @@ If you are unsure which license is appropriate for your use, please contact the /** * @class Ext.util.Format -This class is a centralized place for formatting functions inside the library. It includes +This class is a centralized place for formatting functions. It includes functions to format various different types of data, such as text, dates and numeric values. __Localization__ @@ -30,7 +30,7 @@ Options include: 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 +There are two helper functions that return a new function that can be used in conjunction with grid renderers: columns: [{ @@ -40,7 +40,7 @@ grid renderers: dataIndex: 'time', renderer: Ext.util.Format.numberRenderer('0.000') }] - + Functions that only take a single argument can also be passed directly: columns: [{ dataIndex: 'cost', @@ -49,7 +49,7 @@ Functions that only take a single argument can also be passed directly: dataIndex: 'productCode', renderer: Ext.util.Format.uppercase }] - + __Using with XTemplates__ XTemplates can also directly use Ext.util.Format functions: @@ -79,50 +79,45 @@ XTemplates can also directly use Ext.util.Format functions: Ext.apply(UtilFormat, { /** - * @type String - * @property thousandSeparator + * @property {String} thousandSeparator *

The character that the {@link #number} function uses as a thousand separator.

- *

This defaults to ,, but may be overridden in a locale file.

+ *

This may be overridden in a locale file.

*/ thousandSeparator: ',', /** - * @type String - * @property decimalSeparator + * @property {String} decimalSeparator *

The character that the {@link #number} function uses as a decimal point.

- *

This defaults to ., but may be overridden in a locale file.

+ *

This may be overridden in a locale file.

*/ decimalSeparator: '.', /** - * @type Number - * @property currencyPrecision + * @property {Number} currencyPrecision *

The number of decimal places that the {@link #currency} function displays.

- *

This defaults to 2, but may be overridden in a locale file.

+ *

This may be overridden in a locale file.

*/ currencyPrecision: 2, /** - * @type String - * @property currencySign + * @property {String} currencySign *

The currency sign that the {@link #currency} function displays.

- *

This defaults to $, but may be overridden in a locale file.

+ *

This may be overridden in a locale file.

*/ currencySign: '$', /** - * @type Boolean - * @property currencyAtEnd + * @property {Boolean} currencyAtEnd *

This may be set to true to make the {@link #currency} function * append the currency sign to the formatted value.

- *

This defaults to false, but may be overridden in a locale file.

+ *

This may be overridden in a locale file.

*/ currencyAtEnd: false, /** * Checks a reference and converts it to empty string if it is undefined - * @param {Mixed} value Reference to check - * @return {Mixed} Empty string if converted, otherwise the original value + * @param {Object} value Reference to check + * @return {Object} Empty string if converted, otherwise the original value */ undef : function(value) { return value !== undefined ? value : ""; @@ -130,7 +125,7 @@ XTemplates can also directly use Ext.util.Format functions: /** * Checks a reference and converts it to the default value if it's empty - * @param {Mixed} value Reference to check + * @param {Object} value Reference to check * @param {String} defaultValue The value to insert of it's undefined (defaults to "") * @return {String} */ @@ -198,7 +193,7 @@ XTemplates can also directly use Ext.util.Format functions: for (; i < decimals; i++) { format += '0'; } - v = UtilFormat.number(v, format); + v = UtilFormat.number(v, format); if ((end || UtilFormat.currencyAtEnd) === true) { return Ext.String.format("{0}{1}{2}", negativeSign, v, currencySign || UtilFormat.currencySign); } else { @@ -236,7 +231,7 @@ XTemplates can also directly use Ext.util.Format functions: /** * Strips all HTML tags - * @param {Mixed} value The text from which to strip tags + * @param {Object} value The text from which to strip tags * @return {String} The stripped text */ stripTags : function(v) { @@ -245,7 +240,7 @@ XTemplates can also directly use Ext.util.Format functions: /** * Strips all script tags - * @param {Mixed} value The text from which to strip script tags + * @param {Object} value The text from which to strip script tags * @return {String} The stripped text */ stripScripts : function(v) { @@ -307,7 +302,7 @@ XTemplates can also directly use Ext.util.Format functions: *

The presence of a thousand separator character in the format string specifies that * the locale-specific thousand separator (if any) is inserted separating thousand groups.

*

By default, "," is expected as the thousand separator, and "." is expected as the decimal separator.

- *

New to Ext4

+ *

New to Ext JS 4

*

Locale-specific characters are always used in the formatted output when inserting * thousand and decimal separators.

*

The format string must specify separator characters according to US/UK conventions ("," as the @@ -408,7 +403,7 @@ XTemplates can also directly use Ext.util.Format functions: fnum = psplit[0] + dec + psplit[1]; } } - + if (neg) { /* * Edge case. If we have a very small negative number it will get rounded to 0, @@ -454,54 +449,58 @@ XTemplates can also directly use Ext.util.Format functions: }, /** - * Capitalize the given string. See {@link Ext.String#capitalize}. + * Alias for {@link Ext.String#capitalize}. * @method + * @alias Ext.String#capitalize */ 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}. + * Alias for {@link Ext.String#ellipsis}. * @method + * @alias Ext.String#ellipsis */ ellipsis: Ext.String.ellipsis, /** - * Formats to a string. See {@link Ext.String#format} + * Alias for {@link Ext.String#format}. * @method + * @alias Ext.String#format */ format: Ext.String.format, /** - * Convert certain characters (&, <, >, and ') from their HTML character equivalents. - * See {@link Ext.String#htmlDecode}. + * Alias for {@link Ext.String#htmlDecode}. * @method + * @alias Ext.String#htmlDecode */ htmlDecode: Ext.String.htmlDecode, /** - * Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages. - * See {@link Ext.String#htmlEncode}. + * Alias for {@link Ext.String#htmlEncode}. * @method + * @alias Ext.String#htmlEncode */ htmlEncode: Ext.String.htmlEncode, /** - * Adds left padding to a string. See {@link Ext.String#leftPad} + * Alias for {@link Ext.String#leftPad}. * @method + * @alias Ext.String#leftPad */ leftPad: Ext.String.leftPad, /** - * Trims any whitespace from either side of a string. See {@link Ext.String#trim}. + * Alias for {@link Ext.String#trim}. * @method + * @alias Ext.String#trim */ trim : Ext.String.trim, /** * Parses a number or string representing margin sizes into an object. Supports CSS-style margin declarations * (e.g. 10, "10", "10 10", "10 10 10" and "10 10 10 10" are all valid options and would return the same result) - * @param {Number|String} v The encoded margins + * @param {Number/String} v The encoded margins * @return {Object} An object with margin sizes for top, right, bottom and left */ parseBox : function(box) {