tmt.core

tmt.core is a JavaScript library that offers some utility methods. It's mostly used as an helper for TMT Validator, CSI and Ajaxform, but it can be handy on his own too.

In order to use this library you need tmt_core.js

Samples

API

tmt.addEvent(obj, type, function) Developed by John Resig. For complete info see: http://ejohn.org/projects/flexible-javascript-events
tmt.get(field1, [field2]) Sort of an equivalent of the famous $() function. Just with a better name :-)
Accepts either ids (strings) or DOM node references
tmt.getAll(startNode) Returns an array containing all child nodes. If no starting node is passed, assume the document is the starting point
tmt.getAllNodes(startNode) Returns an array containing all child nodes. Unlike tmt.getAll, it return only elements of type Node.NODE_ELEMENT, no comments or other kind of nodes. If no starting node is passed, assume the document is the starting point
tmt.getNodesByAttribute(attName, startNode) Returns an array containing all child nodes that contain the given attribute. If no starting node is passed, assume the document is the starting point
tmt.getNodesByAttributeValue(attName, attValue, startNode) Returns an array containing all child nodes that contain the given attribute matching a given value. If no starting node is passed, assume the document is the starting point
tmt.filterNodesByAttribute(attName, nodes) Out of a node list, returns an array containing all nodes that contain the given attribute
tmt.filterNodesByAttributeValue(attName, attValue, nodes) Out of a node list, returns an array containing all nodes that contain the given attribute matching a given value
tmt.setNodeAttribute(nodeList, attName, attValue) Set the value of an attribute on a list of nodes. Accepts either an id (string) or DOM node reference
tmt.addClass(element, className) Add a CSS class to a given node. Accepts either an id (string) or DOM node reference
tmt.hasClass(element, className) Check if a given node use a CSS class. Accepts either an id (string) or DOM node reference
tmt.removeClass(element, className) Remove a CSS class from a given node. Accepts either an id (string) or DOM node reference
tmt.toggleClass(element, className) Toggle a CSS class from a given node. Accepts either an id (string) or DOM node reference
tmt.trim(str) Trim a given string
tmt.encodeEntities(str) Replace special XML character with the equivalent entities
tmt.unencodeEntities(str) Replace XML's entities with the equivalent character
tmt.hashToEncodeURI(obj) Turn a set of name/value pairs stored inside an object into a URI encoded string