ele
Method Summary
Public Methods | ||
public |
asButton(el: Object, cb: Function) makes an element clickable and executes the callback, also add keyboard support, when hitting enter on the element is same as clicking |
|
public |
byClass(name: String): HTMLElement | null | Element returns the first element with class |
|
public |
byClassAll(name: String): HTMLCollectionOf<Element> | Array returns the all elements with class |
|
public |
byId(id: String): HTMLElement shortcut for document.getElementById(id) |
|
public |
byQuery(q: String): HTMLElement shortcut for document.querySelector(id) |
|
public |
byQueryAll(q: String): NodeListOf<HTMLElement> shortcut for document.querySelectorAll(id) |
|
public |
clickable(el: Object, cb: Function) makes an element clickable and executes the callback, also add keyboard support, when hitting enter on the element is same as clicking |
|
public |
clickables(parent: HTMLElement | Element, query: String, cb: Function) makes elements matching the query clickable and runs the callback on them when clicked |
|
public |
create(n: String): HTMLElement create element with given tagname |
|
public |
forEachClass(name: String) runs the callback with all elements that have the given class as first argument |
|
public |
getSelectValue(el: HTMLElement | Element): any returns the currently selected value for a |
|
public |
hasFocus(el: HTMLElement | Element): boolean checks if given element is "activeElement" |
|
public |
hide(el: HTMLElement | Element) add class "hidden" to element |
|
public |
keyClick(event: KeyboardEvent, el: HTMLElement) can be used for making element keyboard usable and continue using inline onclick e.g. |
|
public |
show(el: HTMLElement | Element) remove class "hidden" from element |
|
public |
toggle(el: HTMLElement | Element) remove or add class "hidden" from element |
Public Methods
public asButton(el: Object, cb: Function) source
makes an element clickable and executes the callback, also add keyboard support, when hitting enter on the element is same as clicking
Params:
Name | Type | Attribute | Description |
el | Object | ||
cb | Function |
public byClass(name: String): HTMLElement | null | Element source
returns the first element with class
Params:
Name | Type | Attribute | Description |
name | String |
Return:
HTMLElement | null | Element | DOM element |
public byClassAll(name: String): HTMLCollectionOf<Element> | Array source
returns the all elements with class
Params:
Name | Type | Attribute | Description |
name | String |
Return:
HTMLCollectionOf<Element> | Array | DOM elements |
public byId(id: String): HTMLElement source
shortcut for document.getElementById(id)
Params:
Name | Type | Attribute | Description |
id | String |
Return:
HTMLElement | DOM element |
public byQuery(q: String): HTMLElement source
shortcut for document.querySelector(id)
Params:
Name | Type | Attribute | Description |
q | String |
Return:
HTMLElement | DOM element |
public byQueryAll(q: String): NodeListOf<HTMLElement> source
shortcut for document.querySelectorAll(id)
Params:
Name | Type | Attribute | Description |
q | String |
Return:
NodeListOf<HTMLElement> | DOM elements |
public clickable(el: Object, cb: Function) source
makes an element clickable and executes the callback, also add keyboard support, when hitting enter on the element is same as clicking
Params:
Name | Type | Attribute | Description |
el | Object | ||
cb | Function |
public clickables(parent: HTMLElement | Element, query: String, cb: Function) source
makes elements matching the query clickable and runs the callback on them when clicked
Params:
Name | Type | Attribute | Description |
parent | HTMLElement | Element | ||
query | String | ||
cb | Function |
public create(n: String): HTMLElement source
create element with given tagname
Params:
Name | Type | Attribute | Description |
n | String |
Return:
HTMLElement |
public forEachClass(name: String) source
runs the callback with all elements that have the given class as first argument
Params:
Name | Type | Attribute | Description |
name | String |
public getSelectValue(el: HTMLElement | Element): any source
returns the currently selected value for a
Params:
Name | Type | Attribute | Description |
el | HTMLElement | Element |
Return:
any |
public hasFocus(el: HTMLElement | Element): boolean source
checks if given element is "activeElement"
Params:
Name | Type | Attribute | Description |
el | HTMLElement | Element |
Return:
boolean |
public hide(el: HTMLElement | Element) source
add class "hidden" to element
Params:
Name | Type | Attribute | Description |
el | HTMLElement | Element |
public keyClick(event: KeyboardEvent, el: HTMLElement) source
can be used for making element keyboard usable and continue using inline onclick e.g. onkeypress="ele.keyClick(event,this)"
Params:
Name | Type | Attribute | Description |
event | KeyboardEvent | ||
el | HTMLElement |
public show(el: HTMLElement | Element) source
remove class "hidden" from element
Params:
Name | Type | Attribute | Description |
el | HTMLElement | Element |
public toggle(el: HTMLElement | Element) source
remove or add class "hidden" from element
Params:
Name | Type | Attribute | Description |
el | HTMLElement | Element |