Class JSComponent
Defined in: toolkit.js.
Constructor Attributes | Constructor Name and Description |
---|---|
JSComponent(preferences, template, useElementAsRootHTMLElement)
The root class for additional UI components.
|
Method Attributes | Method Name and Description |
---|---|
attachChildComponent(name, component)
Attaches the given component to a child DOM element, becoming a child component.
|
|
buildHtmlFromTemplate(templateHtml)
Substitutes all the place holders in the given html with localized labels.
|
|
dispose()
Releases any resource or listener associated with this component, when it's disposed.
|
|
findElement(query)
Returns the element that matches the given query selector within this component.
|
|
findElements(query)
Returns the elements that match the given query selector within this component.
|
|
getElement(name)
Returns the named element that corresponds to the given name within this component.
|
|
Returns the HTML element used to view this component.
|
|
getLocalizedLabelText(resourceClass, propertyKey, resourceParameters)
Returns the localized text defined for the given
>resourceClass + propertyKey . |
|
Returns the user preferences used to localize this component.
|
|
<static> |
JSComponent.isElementContained(element, candidateParent)
Returns true if element is or is child of candidateParent, false otherwise.
|
registerEventListener(elements, eventName, listener)
Registers the given listener on given elements(s) and removes them when this component is disposed.
|
|
registerPropertyChangeListener(object, propertyName, listener)
Registers the given property change listener on object and removes it when this component is disposed.
|
|
<static> |
JSComponent.substituteWithLocale(preferences, html)
Substitutes all the place holders in the html with localized labels.
|
Class Detail
JSComponent(preferences, template, useElementAsRootHTMLElement)
The root class for additional UI components.
Author: Renaud Pawlak, Emmanuel Puybaret.
Author: Renaud Pawlak, Emmanuel Puybaret.
- Parameters:
- {UserPreferences} preferences
- the current user preferences
- {string|HTMLElement} template
- template element (view HTML will be this element's innerHTML) or HTML string (if null or undefined, then the component creates an empty div for the root node)
- {boolean} useElementAsRootHTMLElement Optional
Method Detail
attachChildComponent(name, component)
Attaches the given component to a child DOM element, becoming a child component.
- Parameters:
- {string} name
- the component's name, which matches child DOM element name (as defined in JSComponent#getElement)
- {JSComponent} component
- child component instance
buildHtmlFromTemplate(templateHtml)
Substitutes all the place holders in the given html with localized labels.
- Parameters:
- {string} templateHtml
dispose()
Releases any resource or listener associated with this component, when it's disposed.
Override to perform custom clean.
Don't forget to call super method: JSComponent.prototype.dispose()
findElement(query)
Returns the element that matches the given query selector within this component.
- Parameters:
- {string} query
- css selector to be applied on children elements
findElements(query)
Returns the elements that match the given query selector within this component.
- Parameters:
- {string} query
- css selector to be applied on children elements
getElement(name)
Returns the named element that corresponds to the given name within this component.
A named element shall define the "name" attribute (for instance an input), or
a "data-name" attribute if the name attribute is not supported.
- Parameters:
- name
{HTMLElement}
getHTMLElement()
Returns the HTML element used to view this component.
- Returns:
- {HTMLElement}
{string}
getLocalizedLabelText(resourceClass, propertyKey, resourceParameters)
Returns the localized text defined for the given
>resourceClass
+ propertyKey
.
- Parameters:
- {Object} resourceClass
- {string} propertyKey
- {Array} resourceParameters
- Returns:
- {string}
{UserPreferences}
getUserPreferences()
Returns the user preferences used to localize this component.
- Returns:
- {UserPreferences}
<static>
{boolean}
JSComponent.isElementContained(element, candidateParent)
Returns true if element is or is child of candidateParent, false otherwise.
- Parameters:
- {HTMLElement} element
- {HTMLElement} candidateParent
- Returns:
- {boolean}
registerEventListener(elements, eventName, listener)
Registers the given listener on given elements(s) and removes them when this component is disposed.
- Parameters:
- {(HTMLElement[]|HTMLElement)} elements
- {string} eventName
- {function} listener
registerPropertyChangeListener(object, propertyName, listener)
Registers the given property change listener on object and removes it when this component is disposed.
- Parameters:
- {Object} object
- {string} propertyName
- {function} listener
<static>
JSComponent.substituteWithLocale(preferences, html)
Substitutes all the place holders in the html with localized labels.
- Parameters:
- {UserPreferences} preferences
- the current user preferences
- {string} html