utils/system
Core classes and mechanisms that define how UI components are created and managed within the library
- utils/system
- .ComponentInitializer
- new exports.ComponentInitializer(options)
- .init(config)
- .setupElements(config)
- .getAttribute(key) ⇒
String
- .attributeSelector(key)
- .attributeSelectorInitial() ⇒
String
- .queryAllInitial(context, withData, context) ⇒
Array.<{element: HTMLElement, data: object, initialize: function()}>
- .initializeElement(element)
- .getData() ⇒
*
- .log()
- .warn()
- .logError()
- .ComponentInstance
- .ComponentInitializer
utils/system.ComponentInitializer
Class serves as a utility for UI modules, handling the selection of elements and the initialization of corresponding component instances, ensuring consistent setup within the module
Kind: static class of utils/system
- .ComponentInitializer
- new exports.ComponentInitializer(options)
- .init(config)
- .setupElements(config)
- .getAttribute(key) ⇒
String
- .attributeSelector(key)
- .attributeSelectorInitial() ⇒
String
- .queryAllInitial(context, withData, context) ⇒
Array.<{element: HTMLElement, data: object, initialize: function()}>
- .initializeElement(element)
- .getData() ⇒
*
- .log()
- .warn()
- .logError()
new exports.ComponentInitializer(options)
Create a new instance of ComponentInitializer
Param | Type | Description |
---|---|---|
options | Object |
Options for configuring the component initializer. |
options.type | String |
Type of component (used for logs). |
options.baseAttribute | String |
Prefix and base attribute name (used for base attribute and further element attribute names). |
componentInitializer.init(config)
Initializes the component based on the provided configuration.
Kind: instance method of ComponentInitializer
Param | Type | Description |
---|---|---|
config | Object |
The initialization configuration. |
config.setup | function |
The setup function to call for each element. |
config.key | String |
[null] The optional key to use with attribute selector. |
config.withData | Boolean |
[null] Whether to retrieve element data. |
config.events | Array |
[null] Ulu events that should call setup when dispatched (ie. pageModified, pageResized) |
config.onPageResized | Boolean |
[null] Whether to bind event listener for page resize end |
config.context | HTMLElement |
[document] The context to query within. |
componentInitializer.setupElements(config)
Processes the elements based on the provided configuration.
Kind: instance method of ComponentInitializer
Param | Type | Description |
---|---|---|
config | object |
The initialization configuration. |
config.setup | function |
The setup function to call for each element. |
config.key | string |
The optional key to use with attribute selector. |
config.withData | boolean |
[false] Whether to retrieve element data. |
config.onPageModified | boolean |
[true] Whether to bind event listener for page modifications. |
config.context | HTMLElement |
[document] The context to query within. |
componentInitializer.getAttribute(key) ⇒ String
Get an attribute name
Kind: instance method of ComponentInitializer
Returns: String
- String like data-ulu-dialog or data-ulu-dialog-element
Param | Type | Description |
---|---|---|
key | String |
Optional key, if no key will return baseAttribute if key will return key added to base |
componentInitializer.attributeSelector(key)
Create an attribute selector
Kind: instance method of ComponentInitializer
Param | Type | Description |
---|---|---|
key | String |
Optional key (see getAttribute) |
componentInitializer.attributeSelectorInitial() ⇒ String
Create an attribute selector for initial
Kind: instance method of ComponentInitializer
componentInitializer.queryAllInitial(context, withData, context) ⇒ Array.<{element: HTMLElement, data: object, initialize: function()}>
Queries all main elements of a component that have not been initialized and extracts their data attributes.
Kind: instance method of ComponentInitializer
Returns: Array.<{element: HTMLElement, data: object, initialize: function()}>
- An array of objects containing the elements, their data, and convenience function initialize() which when called will set the init attribute on the element
Param | Type | Description |
---|---|---|
context | HTMLElement |
The context to query within. |
withData | Boolean |
Include dataset from element (as optional JSON) |
context | Node |
Element to query elements from |
componentInitializer.initializeElement(element)
Sets the init attribute on an element, marking it as initialized.
Kind: instance method of ComponentInitializer
Param | Type | Description |
---|---|---|
element | HTMLElement |
The element to initialize. |
componentInitializer.getData() ⇒ *
Get an elements dataset value as JSON or other value
Kind: instance method of ComponentInitializer
Returns: *
- The value of the dataset, if JSON will return object else will return string value or undefined
componentInitializer.log()
Will output namespaced console logs for the given initializer
Kind: instance method of ComponentInitializer
componentInitializer.warn()
Will output namespaced console warnings for the given initializer
Kind: instance method of ComponentInitializer
componentInitializer.logError()
Will output namespaced console error for the given initializer
Kind: instance method of ComponentInitializer
utils/system.ComponentInstance
Class serves as a base for representing individual occurrences of a UI component, providing a consistent structure for each
Kind: static class of utils/system