utils/dom
- utils/dom
- .dataAttributeToDatasetKey(dataAttribute) ⇒
string
- .getDatasetJson(element, key) ⇒
Object
- .getDatasetOptionalJson(element, key) ⇒
Object
|String
- .wasClickOutside()
- .setPositionClasses(parent, classes)
- .getElement(target, context) ⇒
HTMLElement
- .getElements(target, context) ⇒
Array
- .resolveClasses(input) ⇒
Array.<string>
- .addScrollbarProperty(options)
- .getScrollbarWidth([element], [container]) ⇒
number
- .dataAttributeToDatasetKey(dataAttribute) ⇒
utils/dom.dataAttributeToDatasetKey(dataAttribute) ⇒ string
Converts a data attribute name to its corresponding dataset property name.
Kind: static method of utils/dom
Returns: string
- - The dataset property name (e.g., "uluDialog").
Param | Type | Description |
---|---|---|
dataAttribute | string |
The data attribute name (e.g., "data-ulu-dialog"). |
utils/dom.getDatasetJson(element, key) ⇒ Object
Get an elements JSON dataset value
Kind: static method of utils/dom
Returns: Object
- Empty object or JSON object from dataset
Param | Type | Description |
---|---|---|
element | Node |
|
key | String |
key in dataset object for element |
utils/dom.getDatasetOptionalJson(element, key) ⇒ Object
| String
Get an elements JSON dataset value that could potentially just be a single string
- If JSON it will return the object else it will return the value directly
Kind: static method of utils/dom
Returns: Object
| String
- JSON object or current dataset value (string or empty string if no value)
Param | Type | Description |
---|---|---|
element | Node |
|
key | String |
key in dataset object for element |
utils/dom.wasClickOutside()
Check if a pointer event x/y was outside an elements bounding box
Kind: static method of utils/dom
utils/dom.setPositionClasses(parent, classes)
Sets up the positional classes that would come from the equal height module. Needs to be rerun by user when layout changes or new instances are added to the screen
- Used for gutter crops
- Used for rule placement
- Devs Remember that default classes should match sass defaults
Kind: static method of utils/dom
Param | Type | Description |
---|---|---|
parent | Node |
The grid parent <data-grid=""> |
classes | Object |
Override the default equal heights classes |
utils/dom.getElement(target, context) ⇒ HTMLElement
Resolve a target to Element
Kind: static method of utils/dom
Returns: HTMLElement
- The element or null if not found
Param | Type | Description |
---|---|---|
target | String | Node |
The selector or node/element |
context | Object |
[document] The context to query possible selectors from |
utils/dom.getElements(target, context) ⇒ Array
Resolve a target to Elements
Kind: static method of utils/dom
Returns: Array
- The elements or null if not found
Param | Type | Description |
---|---|---|
target | String | Node |
The selector or node/element |
context | Object |
[document] The context to query possible selectors from |
utils/dom.resolveClasses(input) ⇒ Array.<string>
Resolves a class input (string or array) into a consistent array of class names.
Kind: static method of utils/dom
Returns: Array.<string>
- An array of class names. Returns an empty array for invalid or falsy input.
Param | Type | Description |
---|---|---|
input | string | Array.<string> |
The class input, which can be a string, an array of strings, or any other value. |
Example
resolveClassArray("fas fa-check my-class"); // Returns ["fas", "fa-check", "my-class"]
resolveClassArray(["another-class", "yet-another-class"]); // Returns ["another-class", "yet-another-class"]
resolveClassArray("single-class"); // Returns ["single-class"]
utils/dom.addScrollbarProperty(options)
Sets a CSS custom property equal to the scrollbar width.
Kind: static method of utils/dom
Param | Type | Default | Description |
---|---|---|---|
options | object |
Configuration options. | |
[options.scrollableChild] | HTMLElement |
document.body |
An element that is a child of a scrollable container (used for width calculation). |
[options.container] | Window | HTMLElement |
window |
The container that can be scrolled (used for width calculation). |
[options.propertyElement] | HTMLElement |
document.documentElement |
The element to which the custom property will be added. Defaults to document.documentElement for :root access. |
[options.propName] | string |
""--ulu-scrollbar-width"" |
The name of the custom property to set. |
utils/dom.getScrollbarWidth([element], [container]) ⇒ number
Calculates the width of the scrollbar.
Kind: static method of utils/dom
Returns: number
- The width of the scrollbar in pixels.
Param | Type | Default | Description |
---|---|---|---|
[element] | HTMLElement |
document.body |
The element that is the child of a scrollable container |
[container] | Window | HTMLElement |
window |
The container that can be scrolled |