Methods
(static) blurAll(node)
Blurs (unfocuses) a specified DOM node and all relevant child nodes. This
function will recursively blur all <a>
, <button>
, <input>
,
<textarea>
and <select>
child nodes found.
- Parameters:
-
Name Type Description node
{Object} the HTML DOM node - Source:
- RapidContext.Util.js, line 82
(static) registerSizeConstraints(node, widthopt, heightopt)
Registers size constraints for the element width and/or height. The constraints may either be fixed numeric values or simple arithmetic (in a string). The formulas will be converted to CSS calc() expressions.
Legacy constraint functions are still supported and must take two arguments (parent width and height) and should return a number. The returned number is set as the new element width or height (in pixels). Any returned value will also be bounded by the parent element size to avoid calculation errors.
- Parameters:
-
Name Type Attributes Description node
{Object} the HTML DOM node width
{number|string|function} <optional>
the width constraint height
{number|string|function} <optional>
the height constraint - Deprecated:
- Use CSS width and height with calc() instead.
- Examples:
-
RapidContext.Util.registerSizeConstraints(node, "50%-20", "100%"); ==> Sets width to 50%-20 px and height to 100% of parent dimension
RapidContext.Util.resizeElements(node, otherNode); ==> Evaluates the size constraints for both nodes
- Source:
- RapidContext.Util.js, line 117
(static) resizeElements(…node)
Resizes one or more DOM nodes using their registered size constraints and their parent element sizes. The resize operation will only modify those elements that have constraints, but will perform a depth-first recursion over all element child nodes as well.
Partial constraints are accepted, in which case only the width or the height is modified. Aspect ratio constraints are applied after the width and height constraints. The result will always be bounded by the parent element width or height.
The recursive descent of this function can be limited by adding a
resizeContent
function to a DOM node. Such a function will be called to
handle all subnode resizing, making it possible to limit or omitting the
DOM tree traversal.
- Parameters:
-
Name Type Attributes Description node
{Node} <repeatable>
the HTML DOM nodes to resize - Deprecated:
- Use CSS width and height with calc() instead.
- Examples:
-
RapidContext.Util.resizeElements(node); ==> Evaluates the size constraints for a node and all child nodes
elem.resizeContent = () => {}; ==> Assigns a no-op child resize handler to elem
- Source:
- RapidContext.Util.js, line 171
(static) toTitleCase(str) → {string}
Converts a string to a title-cased string. All word boundaries are replaced with a single space and the subsequent character is capitalized.
All underscore ("_"), hyphen ("-") and lower-upper character pairs are recognized as word boundaries. Note that this function does not change the capitalization of other characters in the string.
- Parameters:
-
Name Type Description str
{string} the string to convert - Returns:
- {string} the converted string
- Examples:
-
RapidContext.Util.toTitleCase("a short heading") ==> "A Short Heading"
RapidContext.Util.toTitleCase("camelCase") ==> "Camel Case"
RapidContext.Util.toTitleCase("bounding-box") ==> "Bounding Box"
RapidContext.Util.toTitleCase("UPPER_CASE_VALUE") ==> "UPPER CASE VALUE"
- Source:
- RapidContext.Util.js, line 61