Element
Direct Subclass:
Indirect Subclass:
The root component for all elements within the Form.io renderer.
Constructor Summary
| Public Constructor | ||
| public |
|
|
Member Summary
| Public Members | ||
| public |
defaultMask: * |
|
| public |
An array of event handlers so that the destry command can deregister them. |
|
| public |
events: EventEmitter An instance of the EventEmitter class to handle the emitting and registration of events. |
|
| public |
i18next: * |
|
| public |
The ID of this component. |
|
| public |
inputMasks: *[] |
|
| public |
options: {} The options for this component. |
|
Method Summary
| Public Methods | ||
| public |
addClass(element: *, className: *) Adds a class to a DOM element. |
|
| public |
addEventListener(obj: *, type: *, func: *, persistent: *) Wrapper method to add an event listener to an HTML element. |
|
| public |
appendChild(child: *) Append different types of children. |
|
| public |
appendTo(element: *, container: *) Append an HTML DOM element to a container. |
|
| public |
Adds an object of attributes onto an element. |
|
| public |
Alias for document.createElement. |
|
| public |
destroy() Removes all event listeners attached to this component. |
|
| public |
Emit a new event. |
|
| public |
empty(element: HTMLElement) Empty's an HTML DOM element. |
|
| public |
evalContext(additional: *): * Create an evaluation context for all script executions and interpolations. |
|
| public |
evaluate(func: *, args: *, ret: *, tokenize: *): * Performs an evaluation using the evaluation context of this component. |
|
| public |
hasClass(element: *, className: *): * Determines if an element has a class. |
|
| public |
hook(): * Allow for options to hook into the functionality of this renderer. |
|
| public |
interpolate(string: *, data: *): XML | string | * | void Performs an interpolation using the evaluation context of this component. |
|
| public |
maskPlaceholder(mask: HTMLElement): string Creates a new input mask placeholder. |
|
| public |
off(event: *) Removes all listeners for a certain event. |
|
| public |
Register for a new event within this component. |
|
| public |
prependTo(element: HTMLElement, container: HTMLElement) Prepend an HTML DOM element to a container. |
|
| public |
removeChildFrom(element: HTMLElement, container: HTMLElement) Removes an HTML DOM element from its bounding container. |
|
| public |
removeClass(element: *, className: *) Remove a class from a DOM element. |
|
| public |
removeEventListener(obj: *, type: *) Remove an event listener from the object. |
|
| public |
|
|
| public |
setInputMask(input: HTMLElement, inputMask: String, placeholder: Boolean) Sets the input mask for an input. |
|
| public |
Translate a text using the i18n system. |
|
| public |
text(text: *): Text Alias to create a text node. |
|
Public Constructors
public constructor() source
Public Members
public defaultMask: * source
public eventHandlers: Array source
An array of event handlers so that the destry command can deregister them.
public events: EventEmitter source
An instance of the EventEmitter class to handle the emitting and registration of events.
public i18next: * source
public id: string source
The ID of this component. This value is auto-generated when the component is created, but can also be provided from the component.id value passed into the constructor.
public inputMasks: *[] source
Public Methods
public addClass(element: *, className: *) source
Adds a class to a DOM element.
Params:
| Name | Type | Attribute | Description |
| element | * | The element to add a class to. |
|
| className | * | The name of the class to add. |
public addEventListener(obj: *, type: *, func: *, persistent: *) source
Wrapper method to add an event listener to an HTML element.
Params:
| Name | Type | Attribute | Description |
| obj | * | The DOM element to add the event to. |
|
| type | * | The event name to add. |
|
| func | * | The callback function to be executed when the listener is triggered. |
|
| persistent | * | If this listener should persist beyond "destroy" commands. |
public appendChild(child: *) source
Append different types of children.
Params:
| Name | Type | Attribute | Description |
| child | * |
public appendTo(element: *, container: *) source
Append an HTML DOM element to a container.
Params:
| Name | Type | Attribute | Description |
| element | * | ||
| container | * |
public attr(element: HtmlElement, attr: Object) source
Adds an object of attributes onto an element.
Params:
| Name | Type | Attribute | Description |
| element | HtmlElement | The element to add the attributes to. |
|
| attr | Object | The attributes to add to the input element. |
public ce(type: string, attr: Object, children: Various): HTMLElement source
Alias for document.createElement.
Return:
| HTMLElement | The created element. |
public empty(element: HTMLElement) source
Empty's an HTML DOM element.
Params:
| Name | Type | Attribute | Description |
| element | HTMLElement | The element you wish to empty. |
public evalContext(additional: *): * source
Create an evaluation context for all script executions and interpolations.
Params:
| Name | Type | Attribute | Description |
| additional | * |
Return:
| * |
public evaluate(func: *, args: *, ret: *, tokenize: *): * source
Performs an evaluation using the evaluation context of this component.
Params:
| Name | Type | Attribute | Description |
| func | * | ||
| args | * | ||
| ret | * | ||
| tokenize | * |
Return:
| * |
public hasClass(element: *, className: *): * source
Determines if an element has a class.
Taken from jQuery https://j11y.io/jquery/#v=1.5.0&fn=jQuery.fn.hasClass
Params:
| Name | Type | Attribute | Description |
| element | * | ||
| className | * |
Return:
| * |
public hook(): * source
Allow for options to hook into the functionality of this renderer.
Return:
| * |
public interpolate(string: *, data: *): XML | string | * | void source
Performs an interpolation using the evaluation context of this component.
Params:
| Name | Type | Attribute | Description |
| string | * | ||
| data | * |
public maskPlaceholder(mask: HTMLElement): string source
Creates a new input mask placeholder.
Params:
| Name | Type | Attribute | Description |
| mask | HTMLElement | The input mask. |
public off(event: *) source
Removes all listeners for a certain event.
Params:
| Name | Type | Attribute | Description |
| event | * |
public on(event: string, cb: function): * source
Register for a new event within this component.
Return:
| * |
Example:
let component = new BaseComponent({
type: 'textfield',
label: 'First Name',
key: 'firstName'
});
component.on('componentChange', (changed) => {
console.log('this element is changed.');
});
public prependTo(element: HTMLElement, container: HTMLElement) source
Prepend an HTML DOM element to a container.
Params:
| Name | Type | Attribute | Description |
| element | HTMLElement | The DOM element to prepend. |
|
| container | HTMLElement | The DOM element that is the container of the element getting prepended. |
public removeChildFrom(element: HTMLElement, container: HTMLElement) source
Removes an HTML DOM element from its bounding container.
Params:
| Name | Type | Attribute | Description |
| element | HTMLElement | The element to remove. |
|
| container | HTMLElement | The DOM element that is the container of the element to remove. |
public removeClass(element: *, className: *) source
Remove a class from a DOM element.
Params:
| Name | Type | Attribute | Description |
| element | * | The DOM element to remove the class from. |
|
| className | * | The name of the class that is to be removed. |
public removeEventListener(obj: *, type: *) source
Remove an event listener from the object.
Params:
| Name | Type | Attribute | Description |
| obj | * | ||
| type | * |
public removeEventListeners() source
public setInputMask(input: HTMLElement, inputMask: String, placeholder: Boolean) source
Sets the input mask for an input.
public text(text: *): Text source
Alias to create a text node.
Params:
| Name | Type | Attribute | Description |
| text | * |
Return:
| Text |
