Built-In Namespace: String

Field Summary

Instance Methods

Field Detail

trim String

Removes any extra whitespace from the edges of the string. This method is also aliased as strip().


Defined in: string.js.

Instance Method Detail

camelize()

Defined in: string.js.
See:
SC.String.camelize
capitalize()

Defined in: string.js.
See:
SC.String.capitalize
dasherize()

Defined in: string.js.
See:
SC.String.dasherize
decamelize()

Defined in: string.js.
See:
SC.String.decamelize
escapeCssIdForSelector()

Defined in: string.js.
See:
SC.String.escapeCssIdForSelector
fmt()

Defined in: string.js.
See:
SC.String.fmt
loc()

Defined in: string.js.
See:
SC.String.loc
locLayout(str, (optional), (optional))

Creates and returns a new hash suitable for use as an SC.View’s 'layout' hash. This hash will be created by looking for localized metrics following a pattern based on the “base key” you specify.

For example, if you specify "Button.Confirm", the following metrics will be used if they are defined:

Button.Confirm.left Button.Confirm.top Button.Confirm.right Button.Confirm.bottom Button.Confirm.width Button.Confirm.height Button.Confirm.midWidth Button.Confirm.minHeight Button.Confirm.centerX Button.Confirm.centerY

Additionally, you can optionally specify a hash which will be merged on top of the returned hash. For example, if you wish to allow a button’s width to be configurable per-locale, but always wish for it to be centered vertically and horizontally, you can call:

locLayout("Button.Confirm", {centerX:0, centerY:0})

…so that you can combine both localized and non-localized elements in the returned hash. (An exception will be thrown if there is a locale-specific key that matches a key specific in this hash.)

For example, if your locale defines:

Button.Confirm.left Button.Confirm.top Button.Confirm.right Button.Confirm.bottom

…then these two code snippets will produce the same result:

layout: { left: "Button.Confirm.left".locMetric(), top: "Button.Confirm.top".locMetric(), right: "Button.Confirm.right".locMetric(), bottom: "Button.Confirm.bottom".locMetric() }

layout: "Button.Confirm".locLayout()

The former is slightly more efficient because it doesn’t have to iterate through the possible localized layout keys, but in virtually all situations you will likely wish to use the latter.


Defined in: string.js.
Parameters:
str
{String} key
(optional) str
additionalHash
(optional) String
additionalHash
Returns:
Number
the localized metric
locMetric(str)

Returns the localized metric value for the specified key. A metric is a single value intended to be used in your interface’s layout, such as "Button.Confirm.Width" = 100.

If you would like to return a set of metrics for use in a layout hash, you may prefer to use the locLayout() method instead.


Defined in: string.js.
Parameters:
str
{String} key
Returns:
Number
the localized metric
locWithDefault(def)

Defined in: string.js.
Parameters:
def
See:
SC.String.locWithDefault
mult(value)

Defined in: string.js.
Parameters:
value
See:
SC.String.mult
trimLeft(str)
Removes any extra whitespace from the left edge of the string.
Defined in: string.js.
Parameters:
str
Returns:
String
the trimmed string
trimRight(str)
Removes any extra whitespace from the right edge of the string.
Defined in: string.js.
Parameters:
str
Returns:
String
the trimmed string
w()

Defined in: string.js.
See:
SC.String.w
Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 08 2015 10:02:21 GMT-0600 (CST)