jQuery extensions

Version 1 17.03.2021

Extensions for jQuery library

Selectors

Function Return Description
$byId(string) jQuery Find element by id and return jQuery object. Same as $('#'+string) but four times faster and allows selector characters [] in id name.

Attributes

Function Return Description
.setClass(name) this Clear all class names and set new name.
.replaceClass( trueClass , falseClass) this Add/remove classes.
.replaceClass( condition , trueClass , falseClass) this Add/remove classes according to the condition: If true, add trueClass and remove falseClass.

Manipulation

Function Return Description
.prependUi(name,data) this Prebend eUi component.
.appendUi(name,data) this Append eUi component.
.addUi(name,data) this Alias to appendUi()
.newUi(name,data) eUi Append eUi component and return it.
.addContent(name,params) this  Load Html content and add it to the element.
.anchorTo(param) this  Set tooltip to element hover.
.moveTo(selector) this  Detach element and append it to another element (append)
.focusToEnd() this Set cursor position to end
.asElement(name,target) this Flip-flop to: eProtoElement.setElement(name,this)

Offset

Function Return Description
.anchorTo(target,h,v) this  Position element according to another element.
.getPosition() {} Get element position info

Data

Function Return Description
.updateData(name,value) bool  Set new value to data-name. Return TRUE if value was changed.

Form

Function Return Description
.focusAutocomplete() this Set element focus, if not Touch device. (autocomplete initial state: show keyboard or not).
.getFormData() json Take all values from closest form and return as jSon object.

Misc

Function Return Description
.scrollVisible(offset) this  Scroll parent element so that element is visible.
.scrollTo(target,o,cb) this  Smooth srollTop()
.scrollUp(int) this Scroll up given px
.scrollDown(int) this Scroll down given px
.preventScrollPropagation() this Prevent scroll -action to bubble up.
.moveVisible(offset) this  Siirrä niin että näkyy ruudulla