Namespace metawidget.util
Utilities.
Defined in: metawidget-utils.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
<static> |
metawidget.util.appendPath(attributes, mw)
Appends the 'path' property from the given Metawidget to the 'name'
property in the given attributes.
|
<static> |
metawidget.util.appendPathWithName(path, attributes)
Returns the given path appended with the given name (e.g.
|
<static> |
metawidget.util.appendToAttribute(separator, attributeName, toAppend, separator)
Sets the given 'toAppend' to the given widget's 'attributeName'.
|
<static> |
metawidget.util.camelCase(names)
Camel cases the given array of names (e.g.
|
<static> |
metawidget.util.capitalize(name)
Capitalize by uppercasing the first letter of the given String (e.g.
|
<static> |
metawidget.util.combineInspectionResults(existingInspectionResult, newInspectionResult)
Combines the given first inspection result with the given second
inspection result.
|
<static> |
metawidget.util.createElement(mw, element)
Creates an element by calling ownerDocument rather than simply
document.
|
<static> |
metawidget.util.createEvent(mw, name)
Creates an event by calling ownerDocument rather than simply
document.
|
<static> |
metawidget.util.createTextNode(mw, text)
Creates a text node by calling ownerDocument rather than
simply document.
|
<static> |
metawidget.util.decapitalize(name)
Following the rules defined in capitalize: "This normally
means converting the first character from upper case to lower case, but
in the (unusual) special case when there is more than one character and
both the first and second characters are upper case, we leave it alone.
|
<static> |
metawidget.util.fillString(repeat, times)
|
<static> |
metawidget.util.getId(elementName, attributes, mw)
Gets a camelCased id based on the given attributes.name and the given
mw.path.
|
<static> |
metawidget.util.getLabelString(attributes, mw)
Returns a label for the given set of attributes.
|
<static> |
metawidget.util.getLocalizedString(value, mw)
Localizes the given value.
|
<static> |
metawidget.util.getSortedInspectionResultProperties(inspectionResult)
Return an array of the given inspection result's properties, sorted by
'propertyOrder' (if any).
|
<static> |
metawidget.util.hasAttribute(element, attribute)
Backward compatibility for IE.
|
<static> |
metawidget.util.hasChildElements(node)
Returns true if the given node has child elements.
|
<static> |
metawidget.util.isSpanAllColumns(attributes)
|
<static> |
metawidget.util.isTrueOrTrueString(value)
|
<static> |
metawidget.util.lookupEnumTitle(value, anEnum, enumTitles)
|
<static> |
metawidget.util.niceIndexOf(array, item)
Finds the indexOf the given item in the given array.
|
<static> |
metawidget.util.splitPath(path)
Splits the given path into its type and an array of names (e.g.
|
<static> |
metawidget.util.stripSection(attributes)
Strips the first section off the section attribute (if any).
|
<static> |
metawidget.util.traversePath(toInspect, names)
Traverses the given 'toInspect' along properties defined by the array of
'names'.
|
<static> |
metawidget.util.uncamelCase(name)
Uncamel case the given name (e.g.
|
- Parameters:
- attributes
- mw
- Parameters:
- path
- attributes
- Parameters:
- separator
- separator to use (defaults to a space)
- attributeName
- toAppend
- separator
If names is not an array, first calls names.split( ' ' ).
- Parameters:
- names
- Returns:
- the camel cased name. Or an empty string if no name
The rules for capitalizing are not clearly, but we try to make capitalize the inverse of decapitalize (this includes the 'second character' clause). For example, in Eclipse if you define a property 'aB123' and then 'generate getters' Eclipse will generate a method called 'getaB123' not 'getAB123'. See: https://community.jboss.org/thread/203202?start=0&tstart=0
- Parameters:
- name
Inspection results are expected to be JSON Schema (v3) objects. They are combined based on their property name. If no elements match, new properties are appended.
- Parameters:
- existingInspectionResult
- newInspectionResult
- Parameters:
- mw
- element
- Parameters:
- mw
- name
- Parameters:
- mw
- text
- Parameters:
- name
- Parameters:
- repeat
- times
- Parameters:
- elementName
- attributes
- mw
The label is determined using the following algorithm:
- if attributes.title exists...
- if the given mw has a property l10n, then attributes.title is camel-cased and used as a lookup into mw.i10n[camelCasedTitle]. This means developers can initially build their UIs without worrying about localization, then turn it on later
- if no such lookup exists (or mw.l10n does not exist), return attributes.title
- if attributes.title does not exist...
- if the given mw has a property l10n, then attributes.name is used as a lookup into mw.i10n[attributes.name]
- if no such lookup exists (or mw.l10n does not exist), return attributes.name
- Parameters:
- attributes
- mw
- Returns:
- the label string. Empty string if no such name. Null if name has been forced to blank (i.e. should be hidden)
First, camelCases the given value to create a key. Then looks this key up in mw.l10n. If it exists, returns the value associated with that key. Otherwise, returns the original value.
Clients can either initialize a property called l10n on the Metawidget, or replace this whole method with their own localization approach. In the latter case, mw.path may also prove useful.
- Parameters:
- value
- mw
See: https://github.com/json-stylesheet/json-stylesheet/issues/1 https://github.com/json-schema/json-schema/issues/87
- Parameters:
- inspectionResult
- Parameters:
- element
- attribute
- Parameters:
- node
- Parameters:
- attributes
- Parameters:
- value
- Returns:
- true if the value is boolean true or string 'true', but false for any other value (including other JavaScript 'truthy' values)
- Parameters:
- value
- anEnum
- enumTitles
- Parameters:
- array
- item
- Returns:
- -1 if either array or item are undefined, otherwise indexOf
- Parameters:
- path
- Returns:
- an object with properties 'type' and 'names' (provided there is at least 1 name)
- Parameters:
- attributes
- Parameters:
- toInspect
- object to traverse
- names
- array of propery names to traverse along
- Parameters:
- name