The Coral utility belt.
Static Properties
-
Coral.commons.FOCUSABLE_ELEMENT_SELECTOR {String}
-
-
Coral.commons.TABBABLE_ELEMENT_SELECTOR {String}
-
Focusable elements are defined by https://www.w3.org/TR/html5/editing.html#focus-management.
Caution: the selector doesn't verify if elements are visible.
Tabbable elements are defined by https://www.w3.org/TR/html5/editing.html#sequential-focus-navigation-and-the-tabindex-attribute.
Caution: the selector doesn't verify if elements are visible.
Methods
-
Coral.commons.augment
-
- Parameters:
-
Name Type Optional Description dest Object No
The object to copy properties to source Object No
An object to copy properties from. Additional objects can be passed as subsequent arguments. handleCollision Coral.commons~handleCollision Yes
Called if the property being copied is already present on the destination. The return value will be used as the property value. - Returns:
-
The destination object,
dest
{Object}
-
Coral.commons.callAll
-
- Parameters:
-
Name Type Optional Default Description func function No
A function to call nth Number Yes
A zero-based index indicating the noth argument to return the value of. If the nth argument is not a function, null
will be returned. - Returns:
-
The aggregate function. {function}
-
Coral.commons.extend
-
- Parameters:
-
Name Type Description dest Object The object to copy properties to source Object An object to copy properties from. Additional objects can be passed as subsequent arguments. - Returns:
-
The destination object,
dest
{Object}
-
Coral.commons.getSubProperty
-
- Parameters:
-
Name Type Description root Object The root object on which the path should be traversed. path String The path of the sub-property to return. - Throws:
-
Will throw an error if the path is not present on the object.
- Returns:
-
The value of the provided property. {*}
-
Coral.commons.getUID
-
- Returns:
-
unique identifier. {String}
-
Coral.commons.mixin
-
- Parameters:
-
Name Type Description target Object The target prototype or instance on which to apply mixins. mixins Object|Coral~mixin|Array.<(Object|Coral~mixin)> A mixin or set of mixins to apply. options Object An object that will be passed to functional mixins as the second argument (options).
-
Coral.commons.nextFrame
-
- Parameters:
-
Name Type Description callback function The callback to execute.
-
Coral.commons.ready
-
- Parameters:
-
Name Type Description element HTMLElement The element that should be watched for ready events. callback Coral.commons~readyCallback The callback to call when all components are ready.
-
Coral.commons.setSubProperty
-
- Parameters:
-
Name Type Description root Object The root object on which the path should be traversed. path String The path at which the object should be assignment. obj String The object to assign at path. - Throws:
-
Will throw an error if the path is not present on the object.
-
Coral.commons.swapKeysAndValues
-
- Parameters:
-
Name Type Description obj Object The object to copy. - Returns:
-
An object with its keys as the values and values as the keys of the source object. {Object}
-
Coral.commons.transitionEnd
-
- Parameters:
-
Name Type Description element HTMLElement The DOM element that is affected by the CSS transition. callback Coral.commons~transitionEndCallback The callback to execute.
Copy the properties from the source object to the destination object, but calls the callback if the property is
already present on the destination object.
Call all of the provided functions, in order, returning the return value of the specified function.
Copy the properties from all provided objects into the first object.
Get the value of the property at the given nested path.
Get a unique ID.
Mix a set of mixins to a target object.
Execute the provided callback on the next animation frame.
Checks, if a Coral components and all nested components are ready, which means their
_initialize
and _render
methods have been called. If so, the provided callback function is executed
Assign an object given a nested path
Return a new object with the swapped keys and values of the provided object.
Execute the provided callback once a CSS transition has ended. This method listens for the next transitionEnd event
on the given DOM element. In case the provided element does not have a transition defined, the callback will be
called in the next macrotask to allow a normal application execution flow. It cannot be used to listen continuously
on transitionEnd events.
Type Definitions
-
instance.handleCollision
-
- Parameters:
-
Name Type Description oldValue * The value currently present on the destination object. newValue * The value on the destination object. prop * The property that collided. dest * The destination object. source * The source object. - Returns:
-
The value to use. If
undefined
, the old value will be used. {*}
-
instance.readyCallback
-
- Parameters:
-
Name Type Description element HTMLElement The element that is ready.
-
instance.transitionEndCallback
-
- Parameters:
-
Name Type Description event The event passed to the callback.
Name Type Description event.target HTMLElement The DOM element that was affected by the CSS transition. event.cssTransitionSupported Boolean Whether CSS transitions are supported by the browser. event.transitionStoppedByTimeout Boolean Whether the CSS transition has been ended by a timeout (should only happen as a fallback).
Called when a property already exists on the destination object.
Execute the callback once a component and sub-components are ready.
Execute the callback once a CSS transition has ended.