Monitus UI Library

util  4

Monitus UI Library > util > MUI.util.dom
Search:
 
Filters

static Class MUI.util.dom

These utilities provide generic utilities for manipulating the DOM.

Methods

add_event

static void add_event ( pElement , pEventType , pFunction , pUseCapture )
Add an event listener to an object.
Parameters:
pElement <object> the element to listen to.
pEventType <string> the event to listen for. Ex: "load", "click", ...
pFunction <function> the function to execute when the event fires
pUseCapture <boolean> parameter of the same name in the DOM addEventListener function.
Returns: void

get_object

static object get_object ( pTag , pSelector , pRoot )
Get a the first object on the page, that matches the selector.

Selectors: see MUI.util.dom.get_objects

Parameters:
pTag <string> the tag to look for. Ex: "img", "input", etc...
pSelector <string> the selector; see note above.
pRoot <object> the object to look into. Optional; defaults to the whole document.
Returns: object
the first object found, or null if none found.

get_objects

static array get_objects ( pTag , pSelector , pRoot )
Get a list of objects on the page.

Selectors: supported selectors are:

  • .myClass: will return all objects whose class contains "myClass"; it's a shortcut for {class=myClass}
  • .myClass[indices]: will return, from the list of all objects whose class contains "myClass", the item(s) at indices "indices" (ex: [1,2])
  • {anAttribute=aValue}: will return all objects whose attribute "anAttribute" is equal to "aValue"; the value can be a string, or a RegExp-like string: ##.
  • {anAttribute=aValue}[indices]: will return, from the list of all objects whose attribute "anAttribute" is equal to "aValue", the item(s) at indices "indices" (ex: [1,2])
  • anythingElse: will return all objects whose id is equal to "&anythingElsequot;

Parameters:
pTag <string> the tag to look for. Ex: "img", "input", etc...
pSelector <string> the selector; see note above.
pRoot <object> the object to look into. Optional; defaults to the whole document.
Returns: array
list of found objects; empty array if none found.

ready

static void ready ( pCallback )
Execute code when the DOM is ready to be manipulated; this is usually faster than waiting for the onload event.
Parameters:
pCallback <function> what to execute when the DOM is ready.
Returns: void

rename_element

static void rename_element ( pElement , pSuffix , pDeep )
Rename an element, by adding a suffix, and its dependants, if applicable. For instance, some form filed might have labels associated with them; this function will also adjust the "for" attribute of the label.
Parameters:
pElement <object> the element to rename.
pSuffix <string> the suffix to add to the object's name.
pDeep <boolean> also rename all the object's children?
Returns: void

wait_object

static void wait_object ( pObjectName , pCallBack , pArguments )
Wait for a javascript object instance to be created in the window.
Parameters:
pObjectName <string> the name of the intance to wait for; basicalyl, the name of the variable.
pCallBack <function> the code to run when the instance is created.
pArguments <array> an array of arguments passed to the callback function.
Returns: void


Copyright © 2017 Yahoo! Inc. All rights reserved.