Built-In Namespace: String
Field Summary
Instance Methods
- camelize()
- capitalize()
- dasherize()
- decamelize()
- escapeCssIdForSelector()
- fmt()
- loc()
- locLayout(str, (optional), (optional))
- locMetric(str)
- locWithDefault(def)
- mult(value)
- trimLeft(str)
- trimRight(str)
- w()
Field Detail
trim StringRemoves any extra whitespace from the edges of the string. This method is also aliased as strip().
Defined in: string.js.
Instance Method Detail
Defined in: string.js.
- See:
- SC.String.camelize
Defined in: string.js.
- See:
- SC.String.capitalize
Defined in: string.js.
- See:
- SC.String.dasherize
Defined in: string.js.
- See:
- SC.String.decamelize
Defined in: string.js.
- See:
- SC.String.escapeCssIdForSelector
Defined in: string.js.
- See:
- SC.String.fmt
Defined in: string.js.
- See:
- SC.String.loc
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
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
Defined in: string.js.
- Parameters:
- str
- Returns:
- String
- the trimmed string
Defined in: string.js.
- Parameters:
- str
- Returns:
- String
- the trimmed string
Defined in: string.js.
- See:
- SC.String.w