"Fossies" - the Fresh Open Source Software Archive

Member "WebGUI/www/extras/yui/docs/YAHOO.util.Number.html" (18 Nov 2014, 36398 Bytes) of archive /linux/www/webgui-7.10.29-stable.tar.gz:

	API: datasource  YAHOO.util.Number   (YUI Library)



Yahoo! UI Library

DataSource Utility  2.9.0

Yahoo! UI Library > datasource > YAHOO.util.Number

static Class YAHOO.util.Number

The static Number class provides helper functions to deal with data of type Number.


Number.format.defaults - static {Object}

Default values for Number.format behavior. Override properties of this object if you want every call to Number.format in your system to use specific presets.

Available keys include:

  • format
  • negativeFormat
  • decimalSeparator
  • decimalPlaces
  • thousandsSeparator
  • prefix/suffix or any other token you want to use in the format templates



String format ( nData , oConfig )
Takes a native JavaScript Number and formats to a string for display.
nData <Number> Number.
oConfig <Object} (Optional) Optional configuration values:
String used as a template for formatting positive numbers. {placeholders} in the string are applied from the values in this config object. {number} is used to indicate where the numeric portion of the output goes. For example "{prefix}{number} per item" might yield "$5.25 per item". The only required {placeholder} is {number}.
Like format, but applied to negative numbers. If set to null, defaults from the configured format, prefixed with -. This is separate from format to support formats like "($12,345.67)".
prefix {String} (deprecated, use format/negativeFormat)
String prepended before each number, like a currency designator "$"
decimalPlaces {Number}
Number of decimal places to round.
decimalSeparator {String}
Decimal separator
thousandsSeparator {String}
Thousands separator
suffix {String> (deprecated, use format/negativeFormat)
String appended after each number, like " items" (note the space)
Returns: String
Formatted number for display. Note, the following values return as "": null, undefined, NaN, "".


static String Number.format._applyFormat ( tmpl , num , data )
Apply any special formatting to the "d,ddd.dd" string. Takes either the cfg.format or cfg.negativeFormat template and replaces any {placeholders} with either the number or a value from a so-named property of the config object.
tmpl <String> the cfg.format or cfg.numberFormat template string
num <String> the number with separators and decimalPlaces applied
data <Object} the config object, used here to populate {placeholder> s
Returns: String
the number with any decorators added

Copyright © 2011 Yahoo! Inc. All rights reserved.