Namespace idx.util
Provides Javascript utility methods in addition to those provided by Dojo.
Defined in: <idx\util.js>.
Constructor Summary
Constructor Attributes | Constructor Name and Description |
---|---|
Field Summary
Field Attributes | Field Name and Description |
---|---|
<static> |
idx.util.isAIR
Equivalent to "dojo.isAIR" in Dojo 1.6 and dojo/has("air") in Dojo 1.7+
|
<static> |
idx.util.isBrowser
Equivalent to "dojo.isBrowser" in Dojo 1.6 and dojo/has("host-browser") in Dojo 1.7+
|
<static> |
idx.util.isChrome
Equivalent to "dojo.isChrome" in Dojo 1.6 and dojo/has("chrome") in Dojo 1.7+
|
<static> |
idx.util.isFF
Equivalent to "dojo.isFF" in Dojo 1.6 and dojo/has("ff") in Dojo 1.7+
|
<static> |
idx.util.isIE
Equivalent to "dojo.isIE" in Dojo 1.6 and dojo/has("ie") in Dojo 1.7+
|
<static> |
idx.util.isKhtml
Equivalent to "dojo.isKhtml" in Dojo 1.6 and dojo/has("khtml") in Dojo 1.7+
|
<static> |
idx.util.isMozilla
Equivalent to "dojo.isMozilla" in Dojo 1.6 and dojo/has("mozilla") in Dojo 1.7+
|
<static> |
idx.util.isOpera
Equivalent to "dojo.isOpera" in Dojo 1.6 and dojo/has("opera") in Dojo 1.7+
|
<static> |
idx.util.isQuirks
Equivalent to "dojo.isQuirks" in Dojo 1.6 and dojo/has("quirks") in Dojo 1.7+
|
<static> |
idx.util.isSafari
Equivalent to "dojo.isSafari" in Dojo 1.6 and dojo/has("safari") in Dojo 1.7+
|
<static> |
idx.util.isWebkit
Equivalent to "dojo.isWebkit" in Dojo 1.6 and dojo/has("webkit") in Dojo 1.7+
|
Method Summary
Method Attributes | Method Name and Description |
---|---|
<static> |
idx.util.debugObject(obj)
Generates a diagnostic string describing the specified object.
|
<static> |
idx.util.fitToHeight(parent, child)
Sizes a parent to fit the child node as if the child node's positioning was
NOT absolute.
|
<static> |
idx.util.fitToSize(parent, child)
Sizes a parent to fit the child node as if the child node's positioning was
NOT absolute.
|
<static> |
idx.util.fitToWidth(parent, child)
Sizes a parent to fit the child node as if the child node's positioning was
NOT absolute.
|
<static> |
idx.util.fromJson(json, optReviver)
Generates a diagnostic string describing the specified object.
|
<static> |
idx.util.getChildWidget(parent, last, widgetType)
Determines the widget that is the first or last child of the specified widget
or node that is a widget (optionally of a specified type).
|
<static> |
idx.util.getCSSOptions(className, parentNode, guide)
Creates a temporary div as a child of the optional parent (otherwise the body node),
applies the specified CSS class to the div and extracts the query-string from the
background image of the created div to determine the CSS options.
|
<static> |
idx.util.getFormWidget(formFieldName, parent)
Determines the widget (derived from dijit.form._FormWidget) that is a child of the
specified node or widget (usually a dijit.form.Form) that has the specified form
field name.
|
<static> |
idx.util.getOffsetPosition(node, root)
Returns the pixel offset from top-left for a given node relative to a "root" node.
|
<static> |
idx.util.getParentWidget(child, widgetType)
Determines the widget that is the parent of the specified widget or node.
|
<static> |
idx.util.getSiblingWidget(target, previous, widgetType)
Determines the widget that is the first next or previous sibling of the
specified widget or node that is a widget (optionally of a specific type).
|
<static> |
idx.util.getStaticSize(node)
Determines the dimensions of the specified node if it were to use static positioning.
|
<static> |
idx.util.getVersion(full)
Returns the IDX toolkit version string from the "version.txt" file embedded in the toolkit.
|
<static> |
idx.util.includeValidCSSWidth(value)
Attempts to determine if the value includes a valid CSS width
|
<static> |
idx.util.isNodeOrElement(obj)
Attempts to determine if the specified object is a DOM node.
|
<static> |
idx.util.isPercentage(value)
Attempts to determine if the value is a percentage
|
<static> |
idx.util.mixin(target, source, guide)
Provides a restricted version of dojo.lang.mixin.
|
<static> |
idx.util.mixinCSSDefaults(target, className, parentNode)
Obtains the "CSS Options" using idx.util.getCSSOptions via the specified CSS class name
and optional parent node using the specified target object as the "guide" and mixing the
CSS options directly into the target object via idx.util.mixin.
|
<static> |
idx.util.normalizedLength(len, fontSizeOrNode)
Converts non-percentage CSS widths from various units to pixels.
|
<static> |
idx.util.nullify(target, ctorArgs, props)
Accepts a target object, an object that represents arguments passed
to construct the target object (usually via mixin).
|
<static> |
idx.util.recursiveMixin(first, second, options)
Recursively mixes in the second specified object into the first, optionally using
the specifed options.
|
<static> |
idx.util.reposition(node, position)
Determines the dimensions of the specified node if it were to use static positioning.
|
<static> |
idx.util.typeOfObject(value)
Provides a type for the specified object based on the locally-scoped
"val2type" function from "dojo/parser" module.
|
Field Detail
<static> idx.util.isAIR
Equivalent to "dojo.isAIR" in Dojo 1.6 and dojo/has("air") in Dojo 1.7+
- Deprecated:
- Use dojo/has("air") instead.
<static> idx.util.isBrowser
Equivalent to "dojo.isBrowser" in Dojo 1.6 and dojo/has("host-browser") in Dojo 1.7+
- Deprecated:
- Use dojo/has("host-browser") instead.
<static> idx.util.isChrome
Equivalent to "dojo.isChrome" in Dojo 1.6 and dojo/has("chrome") in Dojo 1.7+
- Deprecated:
- Use dojo/has("chrome") instead.
<static> idx.util.isFF
Equivalent to "dojo.isFF" in Dojo 1.6 and dojo/has("ff") in Dojo 1.7+
- Deprecated:
- Use dojo/has("ff") instead.
<static> idx.util.isIE
Equivalent to "dojo.isIE" in Dojo 1.6 and dojo/has("ie") in Dojo 1.7+
- Deprecated:
- Use dojo/has("ie") instead.
<static> idx.util.isKhtml
Equivalent to "dojo.isKhtml" in Dojo 1.6 and dojo/has("khtml") in Dojo 1.7+
- Deprecated:
- Use dojo/has("khtml") instead.
<static> idx.util.isMozilla
Equivalent to "dojo.isMozilla" in Dojo 1.6 and dojo/has("mozilla") in Dojo 1.7+
- Deprecated:
- Use dojo/has("mozilla") instead.
<static> idx.util.isOpera
Equivalent to "dojo.isOpera" in Dojo 1.6 and dojo/has("opera") in Dojo 1.7+
- Deprecated:
- Use dojo/has("opera") instead.
<static> idx.util.isQuirks
Equivalent to "dojo.isQuirks" in Dojo 1.6 and dojo/has("quirks") in Dojo 1.7+
- Deprecated:
- Use dojo/has("quirks") instead.
<static> idx.util.isSafari
Equivalent to "dojo.isSafari" in Dojo 1.6 and dojo/has("safari") in Dojo 1.7+
- Deprecated:
- Use dojo/has("safari") instead.
<static> idx.util.isWebkit
Equivalent to "dojo.isWebkit" in Dojo 1.6 and dojo/has("webkit") in Dojo 1.7+
- Deprecated:
- Use dojo/has("webkit") instead.
Method Detail
<static> idx.util.debugObject(obj)
Generates a diagnostic string describing the specified object.
- Parameters:
- {Object} obj
- The object to debug
- Returns:
- The debug string for the object.
<static> idx.util.fitToHeight(parent, child)
Sizes a parent to fit the child node as if the child node's positioning was
NOT absolute. Absolutely positioned elements due not "reserve" space, so
this method will temporarily position the element as "static", then determine
the result size of the parent, set the parent's height explicitly, and then
return the child to the default previously set positioning. This is especially
handy in that it allows the parent to define padding which will be respected.
- Parameters:
- {Node} parent
- The parent node -- no checking is done to ensure this node is actually a parent of the specified child.
- {Node} child
- The child node -- no checking is done to ensure this node is actually a child of the specified parent.
<static> idx.util.fitToSize(parent, child)
Sizes a parent to fit the child node as if the child node's positioning was
NOT absolute. Absolutely positioned elements due not "reserve" space, so this
method will temporarily position the element as "static", then determine the
result size of the parent, set the parent's size explicitly, and then return the
child to the default previously set positioning. This is especially handy in
that it allows the parent to define padding which will be respected.
- Parameters:
- {Node} parent
- The parent node -- no checking is done to ensure this node is actually a parent of the specified child.
- {Node} child
- The child node -- no checking is done to ensure this node is actually a child of the specified parent.
<static> idx.util.fitToWidth(parent, child)
Sizes a parent to fit the child node as if the child node's positioning was
NOT absolute. Absolutely positioned elements due not "reserve" space, so this
method will temporarily position the element as "static", then determine the
result size of the parent, set the parent's width explicitly, and then return the
child to the default previously set positioning. This is especially handy in that
it allows the parent to define padding which will be respected.
- Parameters:
- {Node} parent
- The parent node -- no checking is done to ensure this node is actually a parent of the specified child.
- {Node} child
- The child node -- no checking is done to ensure this node is actually a child of the specified parent.
<static> {Object|Array} idx.util.fromJson(json, optReviver)
Generates a diagnostic string describing the specified object. Parses a string
of well-formed JSON text without exposing the application to cross-site request
forgery attacks. Use this in place of dojo.fromJson(). The code is copied from
IBM Dojo Toolkit 1.7.x implementation of dojox.secure.fromJson module which lacks
support for AMD as of Dojo 1.7 & Dojo 1.8 RC1.
Parses a string of well-formed JSON text. If the input is not well-formed, then behavior
is undefined, but it is deterministic and is guaranteed not to modify any object other
than its return value.
This does not use `eval` so is less likely to have obscure security bugs than json2.js.
It is optimized for speed, so is much faster than json_parse.js.
This library should be used whenever security is a concern (when JSON may
come from an untrusted source), speed is a concern, and erroring on malformed
JSON is *not* a concern.
json2.js is very fast, but potentially insecure since it calls `eval` to
parse JSON data, so an attacker might be able to supply strange JS that
looks like JSON, but that executes arbitrary javascript.
- Parameters:
- {String} json
- JSON text per RFC 4627
- {Function (this:Object|string|*)} optReviver
- Optional function that reworks JSON objects post-parse per Chapter 15.12 of EcmaScript3.1. If supplied, the function is called with a string key, and a value. The value is the property of 'this'. The reviver should return the value to use in its place. So if dates were serialized as {@code { "type": "Date", "time": 1234 }}, then a reviver might look like {@code function (key, value) { if (value && typeof value === 'object' && 'Date' === value.type) { return new Date(value.time); } else { return value; } }}. If the reviver returns {@code undefined} then the property named by key will be deleted from its container. {@code this} is bound to the object containing the specified property.
- Returns:
- {Object|Array} representing the parsed object.
<static> {Widget} idx.util.getChildWidget(parent, last, widgetType)
Determines the widget that is the first or last child of the specified widget
or node that is a widget (optionally of a specified type). This is determined
by obtaining the widget for the specified parent, obtaining the children widgets
and returning either the first or last that is optionally of a specified type.
This method may return null if no widget child exists.
- Parameters:
- {Node|Widget} parent
- The node or dijit._WidgetBase for which the child is being requested.
- {Boolean} last
- Optional parameter for indicating which child. Specify true if the last child is desired and false if the first child. If omitted then false is the default.
- {Type} widgetType
- The optional type of widget for the child. If specified, this method ignores any child that is not of the specified type.
- Returns:
- {Widget} The child widget or null if no widget matching the criteria is found.
<static> {Object} idx.util.getCSSOptions(className, parentNode, guide)
Creates a temporary div as a child of the optional parent (otherwise the body node),
applies the specified CSS class to the div and extracts the query-string from the
background image of the created div to determine the CSS options. The parameters in
query string are converted to specific object types according to the optionally specified
"guide" object which is checked for attributes with names in common with the provided
parameters (see idx.util.mixin). This conversion is done in much the same way Dojo 1.6
parser converted string attribute values to the proper type for the created widget's attributes.
- Parameters:
- {String} className
- The CSS class name to use for getting the options.
- {Node} parentNode
- The optional (but recommended) parent node parameter for the scope in which to create the temporary node.
- {Object} guide
- The optional guide to help in converting the CSS options to objects.
- Returns:
- {Object} The Object containing the CSS options with the attribute types matching the specified guide where applicable.
<static> idx.util.getFormWidget(formFieldName, parent)
Determines the widget (derived from dijit.form._FormWidget) that is a child of the
specified node or widget (usually a dijit.form.Form) that has the specified form
field name. If the found form field is found to be an instance of dijit.form._FormWidget
then it is returned, otherwise null is returned.
- Parameters:
- {String} formFieldName
- The name of the form field widget that is being requested.
- {Node|Widget} parent
- Optional root node or root widget under which to look for the form widgets. If not specified then the entire document body is searched.
- Returns:
- The form field widget with the specified name or null if not found.
<static> {Object} idx.util.getOffsetPosition(node, root)
Returns the pixel offset from top-left for a given node relative to a "root" node.
- Parameters:
- {Node} node
- The node for which the offset is desired.
- {Node} root
- The optional ancestor node of the first specified node. If not specified then the Window body tag is used.
- Returns:
- {Object} The returned value has two fields: "l" and "t" representing "left offset" and "top offset", respectively. Results are undefined if the "root" node is not an ancestor of the first specified node.
<static> {Widget} idx.util.getParentWidget(child, widgetType)
Determines the widget that is the parent of the specified widget or node. This
is determined by obtaining the parent node for the specified node or "widget.domNode"
and then calling dijit.getEnclosingWidget(). This method may return null if no widget
parent exists.
- Parameters:
- {Node|Widget} child
- The node or dijit._WidgetBase child for which the parent is being requested.
- {Type} widgetType
- The optional type of widget for the parent. The method recursively looks for the first ancestor of this type until found or we run out of ancestors.
- Returns:
- {Widget} The parent or ancestor widget.
<static> {Widget} idx.util.getSiblingWidget(target, previous, widgetType)
Determines the widget that is the first next or previous sibling of the
specified widget or node that is a widget (optionally of a specific type). This
is determined by obtaining the parent node for the specified node or "widget.domNode",
finding the first next or previous sibling node that is the domNode for a widget, and
if not moving on to the next. This method may return null if no widget sibling exists.
- Parameters:
- {Node|Widget} target
- The node or dijit._WidgetBase for which the sibling is being requested.
- {Boolean} previous
- Optional parameter for indicating which sibling. Specify true if the previous sibling is desired and false if the next sibling. If omitted then false is the default.
- {Type} widgetType
- The optional type of widget for the sibling. If specified, this method ignores any sibling that is not of the specified type.
- Returns:
- {Widget} The sibling widget or null if no widget matching the criteria is found..
<static> idx.util.getStaticSize(node)
Determines the dimensions of the specified node if it were to use static positioning.
- Parameters:
- {Node} node
- The node to work with.
<static> idx.util.getVersion(full)
Returns the IDX toolkit version string from the "version.txt" file embedded in the toolkit.
- Parameters:
- {Boolean} full
- A boolean value indicating if the full version or partial version is desired.
<static> idx.util.includeValidCSSWidth(value)
Attempts to determine if the value includes a valid CSS width
- Parameters:
- value
- to be check
- Returns:
- return ture if the value includes a valid CSS width
<static> idx.util.isNodeOrElement(obj)
Attempts to determine if the specified object is a DOM node. This is needed since IE does
not recognize the "Node" type, and only IE-8 recognizes the "Element" type.
- Parameters:
- {Object|Node|Element} obj
- The object to check.
- Returns:
- The result is true if the specified object is a node or element, otherwise false.
<static> idx.util.isPercentage(value)
Attempts to determine if the value is a percentage
- Parameters:
- value
- to be check
- Returns:
- return true if value is a percentage
<static> idx.util.mixin(target, source, guide)
Provides a restricted version of dojo.lang.mixin. This function Mixes the attributes of the
specified "source" into the specified "target" but only if the specified target object (or
optionally specified "guide" object) already has the attribute from the source object. Further,
the type of each attribute that is mixed in is interpretted to match the type of the same
attribute in the target (or rather the "guide" object if provided). If no guide is specified,
then the target object is used as a guide. If a guide is specified the the target object simply
becomes the landing zone for the mixed-in attributes.
- Parameters:
- {Object} target
- The target object to mix the attributes into.
- {Object} source
- The source object to pull the attributes from.
- {Object} guide
- The optional object whose attributes and types of those attributes will be used as a guide for converting the source attributes to the target attribute.
- Returns:
- The specified target object is returned.
<static> {Object} idx.util.mixinCSSDefaults(target, className, parentNode)
Obtains the "CSS Options" using idx.util.getCSSOptions via the specified CSS class name
and optional parent node using the specified target object as the "guide" and mixing the
CSS options directly into the target object via idx.util.mixin. Any CSS options not
matching an attribute of the target object are ignored.
- Parameters:
- {Object} target
- The target object to mix the CSS defaults into.
- {String} className
- The CSS class name passed to idx.util.getCSSOptions.
- {Node} parentNode
- The optional (but recommended) parent node passed to idx.util.getCSSOptions.
- Returns:
- {Object} The Object containing the CSS options with the attribute types matching the specified guide where applicable.
<static> idx.util.normalizedLength(len, fontSizeOrNode)
Converts non-percentage CSS widths from various units to pixels.
- Parameters:
- len
- The CSS length with optional units.
- fontSizeOrNode
- The optional font size or node for which the font size is computed (defaults to "12pt").
- Returns:
- The length/width in pixels.
<static> idx.util.nullify(target, ctorArgs, props)
Accepts a target object, an object that represents arguments passed
to construct the target object (usually via mixin). and an
and an array of property names for which the value should be null if
not otherwise specified. For each of the specified properties, if
the construction arguments does not specify a value for that property,
then the same property is set to null on the target object. If a
property name is found not to exist in the target object then it is
ignored.
- Parameters:
- {Object} target
- Usually the object being constructed.
- {Object} ctorArgs
- The objects that would specify attributes on the target.
- {Object} props
- The array of property names for properties to be set to null if none of the objects in the argsArray specify them.
<static> idx.util.recursiveMixin(first, second, options)
Recursively mixes in the second specified object into the first, optionally using
the specifed options. Recursion occurs when the attribute is contained in both
the first and second object and is of type "object" in both cases. Recursion can
be made optional via the "options" parameter by specifying the name of a "controlField"
and "controlValue". In such cases the first object is checked for the presence of the
"controlField" and if it exists and the value is equal to the specified "controlValue"
then recusion occurs, otherwise it does not. When recursion does not occur an an object
value from the second object is copied it may optionally be cloned by setting "options.clone"
to true.
- Parameters:
- {Object} first
- The object the attributes will be mixed into
- {Object} second
- The object that holds the attributes to mixin
- {Objet} options
- (includes "clone", "controlField" and "controlValue"). If "clone" is specified then attributes whose values are of type object in the second object are cloned before being set in the first object. The "controlField" and "controlValue" options are used to determine if an object in the first object should be recursively mixed in. If "controlField" is provided, but not "controlValue" then "controlValue" is defaulted to true.
<static> idx.util.reposition(node, position)
Determines the dimensions of the specified node if it were to use static positioning.
- Parameters:
- {Node} node
- The node to work with.
- {String} position
- The CSS position to use.
<static> {String} idx.util.typeOfObject(value)
Provides a type for the specified object based on the locally-scoped
"val2type" function from "dojo/parser" module.
- Parameters:
- {Any} value
- The value for which the type is desired.
- Returns:
- {String} Possible return values include: "string", "undefined", "number", "boolean", "function", "array", "date", "url" and "object".