Class Index | File Index

Classes


Namespace metawidget.util

Utilities.
Defined in: metawidget-utils.js.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
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.
Namespace Detail
metawidget.util
Method Detail
<static> metawidget.util.appendPath(attributes, mw)
Appends the 'path' property from the given Metawidget to the 'name' property in the given attributes.
Parameters:
attributes
mw

<static> metawidget.util.appendPathWithName(path, attributes)
Returns the given path appended with the given name (e.g. 'foo' with 'bar' becomes 'foo.bar'). Supports nameIncludesSeparator. Also supports using bracket notation if the name contains illegal characters (e.g. 'foo['bar bar']')
Parameters:
path
attributes

<static> metawidget.util.appendToAttribute(separator, attributeName, toAppend, separator)
Sets the given 'toAppend' to the given widget's 'attributeName'. If the given widget already has a value for 'attributeName', appends a space and then adds 'toAppend'.
Parameters:
separator
separator to use (defaults to a space)
attributeName
toAppend
separator

<static> metawidget.util.camelCase(names)
Camel cases the given array of names (e.g. from ['foo','bar','baz'] to 'fooBarBaz'). The first name is decapitalized. Subsequent names are capitalized.

If names is not an array, first calls names.split( ' ' ).

Parameters:
names
Returns:
the camel cased name. Or an empty string if no name

<static> metawidget.util.capitalize(name)
Capitalize by uppercasing the first letter of the given String (e.g. from 'fooBarBaz' to 'FooBarBaz').

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

<static> metawidget.util.combineInspectionResults(existingInspectionResult, newInspectionResult)
Combines the given first inspection result with the given second inspection result.

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

<static> metawidget.util.createElement(mw, element)
Creates an element by calling ownerDocument rather than simply document. This stops us relying on a global document variable.
Parameters:
mw
element

<static> metawidget.util.createEvent(mw, name)
Creates an event by calling ownerDocument rather than simply document. This stops us relying on a global document variable.
Parameters:
mw
name

<static> metawidget.util.createTextNode(mw, text)
Creates a text node by calling ownerDocument rather than simply document. This stops us relying on a global document variable.
Parameters:
mw
text

<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. Thus 'FooBah' becomes 'fooBah' and 'X' becomes 'x', but 'URL' stays as 'URL'"
Parameters:
name

<static> metawidget.util.fillString(repeat, times)
Parameters:
repeat
times

<static> metawidget.util.getId(elementName, attributes, mw)
Gets a camelCased id based on the given attributes.name and the given mw.path.
Parameters:
elementName
attributes
mw

<static> metawidget.util.getLabelString(attributes, mw)
Returns a label for the given set of attributes.

The label is determined using the following algorithm:

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)

<static> metawidget.util.getLocalizedString(value, mw)
Localizes the given value.

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

<static> metawidget.util.getSortedInspectionResultProperties(inspectionResult)
Return an array of the given inspection result's properties, sorted by 'propertyOrder' (if any).

See: https://github.com/json-stylesheet/json-stylesheet/issues/1 https://github.com/json-schema/json-schema/issues/87

Parameters:
inspectionResult

<static> metawidget.util.hasAttribute(element, attribute)
Backward compatibility for IE.
Parameters:
element
attribute

<static> metawidget.util.hasChildElements(node)
Returns true if the given node has child elements. That is, their nodeType === 1. Ignores other sorts of child nodes, such as text nodes.
Parameters:
node

<static> metawidget.util.isSpanAllColumns(attributes)
Parameters:
attributes

<static> metawidget.util.isTrueOrTrueString(value)
Parameters:
value
Returns:
true if the value is boolean true or string 'true', but false for any other value (including other JavaScript 'truthy' values)

<static> metawidget.util.lookupEnumTitle(value, anEnum, enumTitles)
Parameters:
value
anEnum
enumTitles

<static> metawidget.util.niceIndexOf(array, item)
Finds the indexOf the given item in the given array.
Parameters:
array
item
Returns:
-1 if either array or item are undefined, otherwise indexOf

<static> metawidget.util.splitPath(path)
Splits the given path into its type and an array of names (e.g. 'foo.bar['baz']' into type 'foo' and names ['bar','baz']).
Parameters:
path
Returns:
an object with properties 'type' and 'names' (provided there is at least 1 name)

<static> metawidget.util.stripSection(attributes)
Strips the first section off the section attribute (if any).
Parameters:
attributes

<static> metawidget.util.traversePath(toInspect, names)
Traverses the given 'toInspect' along properties defined by the array of 'names'.
Parameters:
toInspect
object to traverse
names
array of propery names to traverse along

<static> metawidget.util.uncamelCase(name)
Uncamel case the given name (e.g. from 'fooBarBaz1' to 'Foo Bar Baz 1'). Ported from StringUtils.uncamelCase.
Parameters:
name

Documentation generated by JsDoc Toolkit 2.3.2 on Mon Dec 14 2015 20:12:11 GMT-0500 (EST)