Home Reference Source
public class | source

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:

NameTypeAttributeDescription
el Object
cb Function

public byClass(name: String): HTMLElement | null | Element source

returns the first element with class

Params:

NameTypeAttributeDescription
name String

Return:

HTMLElement | null | Element

DOM element

public byClassAll(name: String): HTMLCollectionOf<Element> | Array source

returns the all elements with class

Params:

NameTypeAttributeDescription
name String

Return:

HTMLCollectionOf<Element> | Array

DOM elements

public byId(id: String): HTMLElement source

shortcut for document.getElementById(id)

Params:

NameTypeAttributeDescription
id String

Return:

HTMLElement

DOM element

public byQuery(q: String): HTMLElement source

shortcut for document.querySelector(id)

Params:

NameTypeAttributeDescription
q String

Return:

HTMLElement

DOM element

public byQueryAll(q: String): NodeListOf<HTMLElement> source

shortcut for document.querySelectorAll(id)

Params:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
parent HTMLElement | Element
query String
cb Function

public create(n: String): HTMLElement source

create element with given tagname

Params:

NameTypeAttributeDescription
n String

Return:

HTMLElement

public forEachClass(name: String) source

runs the callback with all elements that have the given class as first argument

Params:

NameTypeAttributeDescription
name String

public getSelectValue(el: HTMLElement | Element): any source

returns the currently selected value for a

Params:

NameTypeAttributeDescription
el HTMLElement | Element

Return:

any

public hasFocus(el: HTMLElement | Element): boolean source

checks if given element is "activeElement"

Params:

NameTypeAttributeDescription
el HTMLElement | Element

Return:

boolean

public hide(el: HTMLElement | Element) source

add class "hidden" to element

Params:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
event KeyboardEvent
el HTMLElement

public show(el: HTMLElement | Element) source

remove class "hidden" from element

Params:

NameTypeAttributeDescription
el HTMLElement | Element

public toggle(el: HTMLElement | Element) source

remove or add class "hidden" from element

Params:

NameTypeAttributeDescription
el HTMLElement | Element