DomAPI Home
DomAPI

domapi

domapi.js is responsible for bringing the DomAPI engine online. It contains support for loading additional units as well as some global vars and constants. It also has the crucial browser-sniffing code used by the rest of the library.

domapi.js contains all the critical methods and properties that make the DomAPI what it is. Without it, none of the components could work. Most every page you create will need to include this file.

This is the only unit that needs to be included using a <script> tag. For every other unit you need to include, you use the domapi.loadUnit() function.


Methods unique to domapi

Properties unique to domapi


Methods
Array.prototype.deleteItem ( index )

This method extends the array Object to have an deleteItem() method.
This method removes the item at the selected index from the array. The array is assumed to be zero-based, that is, the first item is index number zero.

Example:
  myArray.deleteItem(6); // removes the 5th item (zero is the first item)
Parameters:
Parameter Type Required Default Description
index integer Y   Index of the item to delete 
back to top
Array.prototype.deleteValue ( value )

This method extends the array Object to have an deleteValue method.
This method removes all items in the array that have the specified value. Value can be any primitive type or Object, including elements.

Example:
  var myArray = ["dog", "cat", "bird"];

myArray.deleteValue("cat"); // removes the second item
Parameters:
Parameter Type Required Default Description
value variant Y   Value to delete from the array 
back to top
Array.prototype.indexOf ( value )

This method extends the array Object to have an indexOf() method.
indexOf() returns the zero-based index of a String value contained within the array. If a match is not found, it returns -1.
All arrays you create (when this unit is loaded) automatically have this method. You need not do anything special to install it.

Example:
  var myArray = ["cat", "dog"];
myArray.indexOf("dog");   // returns 1
myArray.indexOf("plane"); // returns -1
Parameters:
Parameter Type Required Default Description
value variant Y   Value to locate in the array 
back to top
Array.prototype.insert ( index, value )

Inserts a given value into the array at a given position.

Example:
  var myArray = ["a", "b", "d", "e"];
myArray.insert(2, "c");
Parameters:
Parameter Type Required Default Description
index integer Y   Index to insert the new item at. 
value variant Y   Value to insert into the array. 
back to top
Array.prototype.pop ()

This method extends the array Object to have an pop method.
This method returns the last item in the array and decreases the array length by one. The array is assumed to be zero-based, that is, the first item is index number zero.

Example:
  var myArray = [];
myArray.push("test 1");
myArray.push("test 2");
alert(myArray.pop()); // displays "test 2"
alert(myArray.length); // displays "1"
See also:  Array.prototype.push
back to top
Array.prototype.push ( value )

This method extends the array Object to have an push method.
This method increases the array length by one and add the given value to the end.

Example:
  var myArray = [];
myArray.push("test 1");
myArray.push("test 2");
alert(myArray.pop()); // displays "test 2"
alert(myArray.length); // displays "1"
Parameters:
Parameter Type Required Default Description
value variant Y   Item to push onto the array stack. 
See also:  Array.prototype.pop
back to top
Array.prototype.swap ( i, j )

Gives all Arrays a swap() method.

Example:
  var myArray = ["cat", "dog"];
myArray.swap(0,1);
Parameters:
Parameter Type Required Default Description
i integer Y   First item's index 
j integer Y   Second item's index. 
back to top
Component( arg ) type : Object

The "arg" parameter fed to this method is an inline Object. See below for accepted parameters.
Any parameters not listed here that you add may also be attached to any returned Object.

The object returned by this function works as an interface layer between components and the base Elm

Every GUI component in DomAPI inherits all the properties of this class, as well as the elm class.

You never have to explicitly create an instance of the Component class, this is all taken care of by the author of the GUI control.
For instance, the Component class has a boolean property called doRollover as you can see below. If you were to therefore create a Button instance on your page, it would have a doRollover property as well, since it inherits it from the Component class.

This function returns a Component object. See there for additional properties and methods.

Available "arg" Parameters:
Parameter Type Required Default Description
doBGFill boolean   true  Boolean value that determines whether or not the component's background is transparent.

Actual implementaion depends on the component author. 
doBorder boolean   true  Boolean value that determines whether or not the component's border is visible.

Actual implementaion depends on the component author. 
doDepress boolean   true  Boolean value that determines whether or not the component's animates selections.

Actual implementaion depends on the component author. 
doRollover boolean   true  Boolean value that determines whether or not the component's animates rollovers.

Actual implementaion depends on the component author. 
doRolloverFill boolean   true  Boolean value that determines whether or not the component's fills backgrounds during a rollover.

Actual implementaion depends on the component author. 
isComponent boolean Y true    
back to top
Elm( arg ) type : Object

The "arg" parameter fed to this method is an inline Object. See below for accepted parameters.
Any parameters not listed here that you add may also be attached to any returned Object.

This method is the heart of the API. It takes a single parameter which is an inline Object containing all it's constructor parameters.
All Components call this method as well, so anything listed here also applies to Component constructors.

See the tutorial on the Elm Object for more detailed information on this method and the tutorial on using inline Objects.

Example:
  var e1 = domapi.Elm({x:100, y:100, bgcolor:"red"});
var e2 = domapi.Elm({parent:e1, type:"IFRAME", w:500, h:300});
Available "arg" Parameters:
Parameter Type Required Default Description
parent HTMLElement   body  Existing element you want this new Elm inserted into. Defaults to the document body. Must be a reference, not an id. Use document.getElementById(id) or domapi.getElm(id) to convert an id to a reference. 
x integer     Left position in pixels.

NOTE: If both x and y are omitted, the Elm is relatively positioned. If either or both are present, it's absolutely positioned. 
y integer     Top position in pixels.

NOTE: If both x and y are omitted, the Elm is relatively positioned. If either or both are present, it's absolutely positioned. 
w integer     Width in pixels.

NOTE: If both w and h are present, the Elm's overflow is set to "hidden". 
h integer     Height in pixels.

NOTE: If both w and h are present, the Elm's overflow is set to "hidden". 
id String     Instead of creating a new Elm, will use the HTMLElement identified by this id. 
ref HTMLElement     Instead of creating a new Elm, will use this HTMLElement instead. 
type String   DIV  Type of element to create the Elm as.
DIV, SPAN, IFRAME, P etc.... 
color String     initial foreground color (doesn't really apply to Components, just Elms) 
bgcolor String     initial background color (doesn't really apply to Components, just Elms) 
skipAdd boolean   false  Whether or not to insert the Elm into the document immediately. If set to true, it is up to you to call the DOM method appendChild() when and where you want it inserted. 
skipStyle boolean   false  Skips the code that applies initial styling. This can improve performance if not needed. Currently this only includes setting the fore and background colors.

NOTE: If ref or id were passed in the arg param, skipStyle defaults to true instead. 
skipPosition boolean   false  Skips the code that applies initial positioning. This can improve performance if not needed. Currently this includes setting style left, top, width, height, overflow and position.

NOTE: If ref or id were passed in the arg param, skipPosition defaults to true instead. 
back to top
String.prototype.addUrlParam ( name, value ) type : String

Appends a URL param to a string, automatically adding in a "?" or "&" as needed.

Parameters:
Parameter Type Required Default Description
name String Y     
value String Y     
back to top
String.prototype.toMixedCase () type : String

Extends the String class to include a method to convert the first character of every word to a capital letter.

Example:
  var s = "the quick brown fox";
s = s.toMixedCase();
// yeilds "The Quick Brown Fox"
back to top
String.prototype.trim () type : String

Removes extra spaces from around a string.

back to top
addEvent ( target, type, fn, useCapture )

Assigns a function to fire when a given Event occurs on an element. For example, to be able to respond to the browser's onresize Event:

domapi.addEvent(window,"resize", myResizeFunction, true);

function myResizeFunction(){
  alert('Browser was resized!');
  alert('New width='+domapi.bodyWidth());
};

Parameters:
Parameter Type Required Default Description
target HTMLElement Y   Element to attach the event to 
type String Y   Event type, minus the "on" prefix. Examples: "mouseup", "resize", "click", etc.... 
fn Function Y   The function that will be the event handler. 
useCapture boolean   false  Only used if the browser is Mozilla based. Cooresponds to the useCapture option of the DOM addEventListener() method. 
See also:  removeEvent
back to top
addUrlParam ( s, name, value ) type : String

Appends a URL param to a string, automatically adding in a "?" or "&" as needed.

Example:
  domapi.addUrlParam('www.site.com', 'user', 'admin');
// returns 'www.site.com?user=admin'

domapi.addUrlParam('www.site.com?action=login', 'user', 'admin');
// returns 'www.site.com?action=login&user=admin'
Parameters:
Parameter Type Required Default Description
s String Y     
name String Y     
value String Y     
See also:  String.prototype.addUrlParam
back to top
assertUnit ( name )

If the specified unit has not been loaded, this will load it inline (synchronously). Useful for delaying loading rarely used units until they are absolutely needed. This method does nothing if the unit has already been loaded.

Example:
  domapi.assertUnit("my_unit");
methodFromMyUnit();
Parameters:
Parameter Type Required Default Description
name String Y   The unitname. 
back to top
bodyElm () type : HTMLElement

Returns a pointer to the DOM representation of the page's tag.

Example:
  domapi.bodyElm().style.color = "gray";
back to top
bodyHeight () type : integer

Returns the height of the page.

Example:
  elm1.setH( domapi.bodyHeight() - 20);
See also:  bodyWidth
back to top
bodyWidth () type : integer

Returns the width of the page.

Example:
  elm1.setW( domapi.bodyWidth() - 20);
See also:  bodyHeight
back to top
boxValuesIn ( top, right, bottom, left ) type : String

The first parameter of this function can be an array of up to four values. If so, it get's it's input from the array. If any are missing, it calculates them just like boxValuesOut() does.
The return value of this function is in CSS format like such:
boxValuesIn(0,5,0,10) ---> "0px 5px 0px 10px"
boxValuesIn(0,5) ---> "0px 5px 0px 5px"
boxValuesIn(Array[5,10,0]) ---> "5px 10px 0px 10px"


Many Elm methods indirectly call boxValuesIn(). For instance, elm1.setB([2,4]);

Example:
  elm1.style.padding = domapi.boxValuesIn(5,10);
Parameters:
Parameter Type Required Default Description
top integer Y     
right integer       
bottom integer       
left integer       
See also:  boxValuesOut
back to top
boxValuesOut ( style, pre, post ) type : Array

Used internally by elm methods that deal with CSS box properties. The first parameter is a pointer to a style object.
The second parameter is a box category such as "border", "padding" or "margin". The third is an optional postfix such as "width".
The function always returns a 4 element array.

Many Elm methods indirectly call boxValuesIn(). For instance, alert(elm1.getB()[2]);

Example:
  // example 1 - get array of padding values
var p = domapi.boxValuesOut(elm1.style, "padding");

// example 2 - get array of border widths
var p = domapi.boxValuesOut(elm1.style, "border", "Widths");
Parameters:
Parameter Type Required Default Description
style Object Y   The style property of a given element. 
pre String Y   Prepended by 
post String     Postfixed by 
See also:  boxValuesIn
back to top
copyObject ( obj ) type : variant

Creates a copy of a provided Object and returns it.

Parameters:
Parameter Type Required Default Description
obj Object Y   The object to make a copy of. 
back to top
dump ( variable )

Requires core.loadUnit("debug"); before can be used!

Shortcut to debug.dump_var()

Example:
  domapi.dump(elm1.style.margin);
Parameters:
Parameter Type Required Default Description
variable variant Y     
back to top
dumpSource ()

Requires core.loadUnit("debug"); before can be used!

Shortcut to debug.dumpSource()

back to top
findNextSibling ( node, kind ) type : HTMLElement

Searches for the next sibling of a given node that matches a certain type. Returns a reference to the found node or null if none are found.

Example:
  domapi.findNextSibling(elm1, "IMG"); // returns the next IMG

domapi.findNextSibling(item1, "LISTBOXITEM"); // returns the Listbox item
Parameters:
Parameter Type Required Default Description
node HTMLElement Y   Node to look for siblings of. 
kind variant Y   Can be either a nodeName or a domAPIObjType
back to top
findParent ( node, kind ) type : HTMLElement

This method walks up the DOM tree starting from the Element passed until it either locates a particular node type or reaches the top. If it succeeds in locating a parent node of the specified type, it returns it, otherwise it returns null.
The node type to search for can be either an HTMLElement name such as "TABLE" or it can be a DomAPI node type such as "PAGECONTROL"

Example:
  domapi.findParent(elm1, "DIV"); // returns and parent DIV

domapi.findParent(item1, "LISTBOX"); // returns the Listbox parent of an item
Parameters:
Parameter Type Required Default Description
node HTMLElement Y   Node to find parent for 
kind String Y   Can be either a nodeName or a domAPIObjType 
See also:  findTarget
back to top
findTarget ( event, kind ) type : HTMLElement

This method is very similar to findParent() except that it uses the target of the given event as it's starting point.

Example:
  elm1.onclick = function(E){
  myNode = domapi.findTarget(E,"DIV");
};
Parameters:
Parameter Type Required Default Description
event Event Y     
kind String Y   node type to find 
See also:  findParent
back to top
formatGetString ( messageLookup, params ) type : String

Used by the lang.js unit for multilingual messages.

Similar to domapi.getString() but also accepts a string of formating parameters for use with strings that have placeholders. See sysutils.formatString() for information on formating parameters.

Example:
  alert(domapi.formatGetString("VAL_NUMBER", ["Zip Code"]));
Parameters:
Parameter Type Required Default Description
messageLookup String Y   One of the message indexes declared in lang.js
params Array Y   parameters for formatString() 
See also:  formatString
back to top
getElm ( id ) type : HTMLElement

This is identical to typing document.getElementById("id"), just more convenient.

Parameters:
Parameter Type Required Default Description
id String Y     
back to top
getNodeIndex ( element ) type : integer

When you have a group of nodes that have the same parent (i.e. they are all siblings) this function will return the relative index of a single node. For example, if I had 10 <LI> tags in a <UL>, using this function on the 5th <LI> would return 4. (the first item is always zero)

Example:
  // find element's index amongst its siblings
var i = domapi.getNodeIndex(domapi.getElm("itemID"));
Parameters:
Parameter Type Required Default Description
element HTMLElement Y   Element to find the index of 
back to top
getString ( lookup ) type : String

Used to return a string constant from the multilingual engine. (lang.js)

String constants are returned in the currently selected language. Overwrite domapi.lang.index to change the current language. (defaults to english)

Example:
  domapi.getString("MONTHS"); // returns an array of month names
Parameters:
Parameter Type Required Default Description
lookup String Y   One of the constants defined in lang.js 
back to top
getTarget ( event ) type : HTMLElement

Returns the target element of a given Event;

Example:
  onmouseover = function(E){
  var nodeInQuestion = domapi.findTarget(E);
};
Parameters:
Parameter Type Required Default Description
event Event Y     
back to top
getTrueOffset ( element ) type : Array

Recursivly walks up the parentage of a given element and sums up it's page offset. Returns a two element array [x,y] which contains offset in pixels.

Example:
  var A = domapi.getTrueOffset(elm1);
alert(A[0]); // x
alert(A[1]); // y
Parameters:
Parameter Type Required Default Description
element HTMLElement Y     
back to top
getZRange ( element ) type : Array

returns a two element array containing the lowest and highest style.z-index 's for the given element and all it's parents, right on up the tree.

Example:
  var myArray = domapi.getZRange(elm1);
alert("highest is " + myArray[1]);
Parameters:
Parameter Type Required Default Description
element HTMLElement Y     
back to top
guid () type : String

Generates a unique id.

Guids take the form of "GUID_1", "GUID_2", etc...

back to top
insertElm ( element, target, where )

This method is essentially identical to calling Microsoft's insertAdjacentElement DOM method, with the following exceptions:

  • It works in Mozilla as well
  • It ensures that the element's style.position is "static" first.
This is the method you use when you want to add a component or elm into the page flow. For instance, to add a spinedit component into a <td> with the id "td1", you'd do the following:
insertElm(spinedit1,getElm("td1"),"afterBegin");
Now the spinedit is no longer positioned absolutely, and will "flow" with the page. This is very useful for mingling components in with standard form elements.

The where param is a string designating where in relation to the target to place the element. Valid entries are:
  • beforeBegin
  • afterBegin
  • beforeEnd
  • afterEnd
For instance, to move an image with id "img1" to a place in the document just after a paragraph with id "p1", you'd do the following:
insertElm(getElm("img1"), getElm("td1"), "afterEnd");

Parameters:
Parameter Type Required Default Description
element HTMLElement Y   element to insert 
target HTMLElement Y   Element to receive the inserted element 
where String   afterBegin  Where to insert the element into the target. 
See also:  transferElm
back to top
isMouseOver ( event, element ) type : boolean

Provided an Event and a target element, this method returns true if the mouse was over that element during the event.

Parameters:
Parameter Type Required Default Description
event Event Y     
element HTMLElement Y     
back to top
isNil ( value ) type : boolean

Returns true if the sent item is either null or of zero length.

Example:
  if(domapi.isNil(somevar)){
  // do something
}
Parameters:
Parameter Type Required Default Description
value variant Y     
back to top
loadIframe ( iframe, url, doCacheBuster )

Given an iframe and an url, this method replaces the content of the iframe's document.

NOTE: The page is loaded in a new thread, to correct for gecko rendering problems.

Parameters:
Parameter Type Required Default Description
iframe HTMLElement Y     
url String Y     
doCacheBuster boolean   true  If true, DomAPI will add a name/value to the url, designed to be unique enough to warrant the browser to not use a cached version. The name is 'dacb' (Dom Api Cache Buster) and the value is a random number, based on the current client timestamp. 
back to top
loadLang ()

Loads a language (localization) file for use by the system. The default langauge file is English and is loaded automatically. You can change the language used by the system by calling domapi.loadLang(). The language file also controls other system aspects such as date formatting and calendar holidays.

Check the src/lang folder for available languages.

Example:
  domapi.loadLang("SPA"); // Spanish
back to top
loadTheme ( themeName )

Only the system theme is loaded automatically. To use any other themes, use this method, preferably before you create any components.

Example:
  domapi.loadTheme("aqua");
Parameters:
Parameter Type Required Default Description
themeName String Y   Name of the theme to load. This is assumed to reside in the domapi.themePath which is src/themes/ by default. 
See also:  theme
  themes
  themePath
back to top
loadUnit ( unitName )

Includes a code unit on the page. name is the unit's name with no path or extension.
All unit names are lowercase.
If a unit is included on a page more than once, all but the first call are ignored.
Refer to domapi.unitLoaded() should you need to know which units have already been included on the page.

You can specify a relative path to the unit if it's not included in the source tree. When this is done, all paths are relative to the src folder. For example: domapi.loadUnit("../../myFolder/myunit");

Note that file extensions are never used. They MUST be .js

Example:
  domapi.loadUnit("color");
domapi.loadUnit("pagecontrol");
Parameters:
Parameter Type Required Default Description
unitName String Y     
See also:  unitLoaded
back to top
mousePosition () type : Array

Returns a two element array containing the current mouse location when an event was fired, such as onmousemove.

Example:
  elm1.onmousemove = function(E){
  var x = domapi.mousePosition(E)[0];
  var y = domapi.mousePosition(E)[1];
};
back to top
nodeSort( arg ) type : Object

Requires core.loadUnit("nodesort"); before can be used!

The "arg" parameter fed to this method is an inline Object. See below for accepted parameters.
Any parameters not listed here that you add may also be attached to any returned Object.

This method will sort the siblings of a given HTMLElement.

Example:
  // sort the rows of a table based on the second column
var t = domapi.getElm("table1");
domapi.nodeSort({
  nodelist        : t.rows,
  collection      : "cells",
  collectionIndex : 1
});
Available "arg" Parameters:
Parameter Type Required Default Description
nodelist HTMLElement Y   The list you want sorted. For example pass a <ul> to have items sorted. 
direction integer   sdAscending  Sort direction

Valid entries are
  • sdAscending
  • sdDescending
 
type integer   stAlpha  Type of date being sorted. Use stAlpha for strings, stNumeric for numbers.

Other sort types may be added later, or you can provide your own compare function. 
collection String     A sub object to sort on. For example, if nodelist was a colletion of <TR>s, collection can be "cells" to sort a particular column. 
collectionIndex integer   If a collection was specified, this is the index within it. For example, if nodelist were the rows in a table and collection is "cells", collectionIndex would be the column index. 
low integer   Index to start sorting from. For example, to skip the first item in the list, pass 1. 
high integer   nodelist.length  Index to sort up to.
Leave this parameter off to sort all the way to the end. 
compare Function     Custom compare method. You can provide your own compare method. The engine will pass this method two items from nodelist.
You must return -1,0 or 1.

-1 = first item is less then the second 0 = take no action 1 = second item is less than first 
back to top
preventBubble ( event )

Stops the given event from progating through the DOM tree.

Example:
  elm1.onclick = function(E){
  domapi.preventBubble(E);  // stop the event from traveling up the DOM
};
Parameters:
Parameter Type Required Default Description
event Event Y     
back to top
rBool ( var, default ) type : boolean

Ensures that a given property has a value and is boolean. If not, it returns the second parameter which is a bool, or false if none was provided. This function is invaluable when writing components or overloaded functions in which not all the parameters may have been passed.

Example:
  b = domapi.rBool(b);  // make sure b had a boolean value
Parameters:
Parameter Type Required Default Description
var variant Y   variable to assert 
default boolean   false    
See also:  rInt
  rVal
back to top
rColor ( color ) type : String

Asserts a 'color'. Always returns a hex string.

Parameters:
Parameter Type Required Default Description
color String   #FFFFFF    
back to top
rInt ( var, default ) type : integer

Ensures that a given property has a value and is an integer. If not, it returns the second parameter which is an integer, or zero if none was provided. This function is invaluable when writing components or overloaded functions in which not all the parameters may have been passed.

Example:
  x = domapi.rInt(x,10); // default to 10 if x is not defined
Parameters:
Parameter Type Required Default Description
var variant Y   Variable to assert 
default integer     
See also:  rInt
  rBool
back to top
rVal ( var, default ) type : String

Ensures that a given property has a value. If not, it returns the second parameter which is the default. This function is invaluable when writing components or overloaded functions in which not all the parameters may have been passed.

Example:
  name = domapi.rVal(name, "new item"); // default to new item if name is not defined
Parameters:
Parameter Type Required Default Description
var variant Y   Variable to assert 
default String       
See also:  rInt
  rBool
back to top
regHook ( name, handler )

All Elm methods can have event handlers attached to them.
These handlers apply to all onscreen Elms. The actual target Elm is passed to the handler, as well as the complete argument list sent to the original method.

Hooks are turned off by default. To turn them on, set core.useElmHooks.

Example:
  // create handler function
function myMoveToEvent(elm,args){
  alert(elm.id);
};

// define the moveTo hook
domapi.regHook("moveTo", myMoveToEvent);

// any calls to moveTo on ANY elm will now call the handler
elm1.moveTo(10,10); // fired myMoveToEvent
Parameters:
Parameter Type Required Default Description
name String Y   Name of the Elm method to hook into. For instance, "moveTo". 
handler Function Y   Event handler to fire when the named method is called. 
See also:  useElmHooks
  unRegHook
back to top
removeEvent ( target, type, fn, useCapture )

Removes an Event assigned by addEvent().

You must provide exactly the same parameters you used when calling domapi.addEvent()

Example:
  domapi.addEvent(window,"resize", myResizeFunction, true);

function myResizeFunction(){
  alert('Browser was resized!');
  alert('New width='+bodyWidth());
};

domapi.removeEvent(window,"resize", myResizeFunction);
Parameters:
Parameter Type Required Default Description
target HTMLElement Y   Element the event is attached to 
type String Y   Type of the event, minus the "on" prefix. Examples: "mouseup", "resize", "click", etc.... 
fn Function Y   The handler to remove 
useCapture boolean   false  Only used if the browser is Mozilla based. Cooresponds to the useCapture option of the DOM addEventListener() method. 
See also:  addEvent
back to top
scrollBarWidth () type : integer

Returns the width that the browser allocates for scrollbars.

Example:
  var sbw = domapi.scrollBarWidth();
alert(sbw);
back to top
scrollLeft () type : integer

Returns how far left the page has been scrolled in pixels. Starts out as zero. Should never return a negative number.

Example:
  elm1.setX(domapi.scrollLeft() - 100);
See also:  scrollTop
back to top
scrollTop () type : integer

Returns how far down the page has been scrolled in pixels. Starts out as zero. Should never return a negative number.

Example:
  elm1.setY(domapi.scrollTop() - 100);
See also:  scrollLeft
back to top
swapNodes ( node1, node2 )

DOM compliant method to swap two nodes in the tree.

Parameters:
Parameter Type Required Default Description
node1 HTMLElement Y     
node2 HTMLElement Y     
back to top
textHeight ( value, font ) type : integer

Returns the height in pixels that the given text would take in the font provided. Font should be in CCS notation, and will default to the body's font if not provided.

Example:
  var h = domapi.textHeight("test string", "8pt sans-serif");
Parameters:
Parameter Type Required Default Description
value String Y     
font String   body font    
See also:  textWidth
back to top
textWidth ( value, font ) type : integer

Returns the width in pixels that the given text would take in the font provided. Font should be in CCS notation, and will default to the body's font if not provided.

Example:
  var w = domapi.textWidth("test string", "8pt sans-serif");
Parameters:
Parameter Type Required Default Description
value String Y     
font String   body font    
See also:  textHeight
back to top
toMixedCase ( s ) type : String

Converts the first character of every word in a string to a capital letter.

Parameters:
Parameter Type Required Default Description
s String Y     
back to top
transferElm ( element, target )

Removes a element from the document and inserts it into the target element at the end.

Example:
  domapi.transferElm(elm1, elm2); // move elm1 into elm2
Parameters:
Parameter Type Required Default Description
element HTMLElement Y   element to move 
target HTMLElement Y   Element to receive the moved element 
See also:  insertElm
back to top
trim ( s ) type : String

Removes extra spaces from around a string.

Parameters:
Parameter Type Required Default Description
s String Y     
back to top
unRegHook ( name, fn )

Removes a hook previously created with domapi.regHook(). You must pass the same name and fn used in regHook().

Parameters:
Parameter Type Required Default Description
name String Y   Name of the Elm method to remove the hook for. 
fn Function Y   Event handler to remove from the hooked method. 
See also:  regHook
  useElmHooks
back to top
unitLoaded ( value ) type : boolean

Returns false if the named unit has not been included on the page. If it has, it returns the path to it.
If you simply need to know if it was included and don't need the path, use domAPILibs.indexOf(name) instead as it has better performance.

Example:
  var bool = domapi.unitLoaded("tree");
if(!bool)alert("Tree unit was not loaded");
Parameters:
Parameter Type Required Default Description
value String Y     
See also:  loadUnit
back to top
unload ()

This method is used to free up all memory used by DomAPI when the page unloads. This will automatically be called when you page unloads, unless you've written your own onunload event. If you do, remember to call domapi.unload() within it.

back to top
Properties
browser type : integer

Integer constant of user's browser type. Possible values are:

btUnknown
btOpera
btIExplore
btSafari
btChimera
btKonqueror
btNetscape
btMozilla
Value is readonly.

Example:
  if(domapi.browser == btSafari){
  // do safari specific tasks
}
See also:  platform
  major
  minor
back to top
clearElementPropsLevel type : integer default value : 1

Controls the depth of the prop clearing code. This runs at onunload and is used to avoid memory leakage by removing any explicit events from your HTML elements. Possible values are 0,1 or 2. 0 turns off the feature - 1 removes only the most common events (onmouseover etc..) and 2 does the most thorough job. The lower the value, the faster the code runs, the higher the value, the more you're protected from memory leaks. 1 is the recommended value.

back to top
compressed type : boolean

Determines whether or not loadUnit() uses compressed versions of files or not.
Change this setting before calling loadUnit()

This property is determined by what domapi.js file you loaded. For instance, if you used domapi_c.js, then compressed is true.

Value is readonly.

back to top
doClearEventCache type : boolean default value : true

Can be used to turn off the clearing of the event cache. Each event created using domapi.addEvent() is added to a cache. This is normally flushed during onunload to avoid any memory leaks. Turning this feature off can improve performance but is not recommended.

back to top
imagePath type : String

Relative path from domapi.js to the DomAPI images folder.

Value is readonly.

Example:
  document.getElementById("img1").src = domapi.imagePath + "print.gif";
See also:  libPath
  themePath
back to top
isGecko type : boolean

True if browser is gecko based (Netscape, Mozilla, Chimera, etc...).

Value is readonly.

back to top
isIE type : boolean

True if browser is Internet Explorer.

Value is readonly.

back to top
isIE5Mac type : boolean

Browser is a Internet Explorer 5 on Macintosh.

Shorthand for (domapi.isIEMac && domapi.major == 5)

Value is readonly.

back to top
isIEMac type : boolean

Browser is a Internet Explorer on Macintosh.

Shorthand for (domapi.platform == ptMacintosh && domapi.isIE)

Value is readonly.

back to top
isKHTML type : boolean

True if browser is Konqueror or Safari based.

Value is readonly.

back to top
isNS type : boolean

True if browser is Mozilla based.

This property is deprecated, use domapi.isGecko instead.

Value is readonly.

back to top
isStrict type : boolean

Document being viewed is using a strict DTD, example:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

DomAPI needs to make adjustments to the way elms are handled in order to ensure your pages look the same in both transitional and strict mode. Transistional is sometimes called "quirks mode".

Value is readonly.

back to top
libPath type : String

This was the path that was provided in the domapi_c.js script tag. It is very useful for relative path to graphics.
Most components that use default graphics, will use this path. See also domapi.imagePath and domapi.themePath.

Value is readonly.

Example:
  document.getElementById("img1").src = domapi.libPath + "images/print.gif";
See also:  imagePath
  themePath
back to top
loaded type : boolean

This property indicates the status of the library as it it loading. If will be false right up until the Window's onload event fires. After that its always true.

back to top
major type : integer

Major version number of user's browser. For instance if browser is IE5.2, major is 5.

Value is readonly.

See also:  platform
  browser
  minor
back to top
minor type : integer

Minor version number of user's browser. For instance if browser is IE5.2, minor is 2.

Value is readonly.

See also:  platform
  browser
  major
back to top
needsBoxFix type : boolean

Browser does not render CSS box attributes according to W3C specification. Internally, domapi_c.js makes corrections to ensure proper rendering.

Value is readonly.

back to top
platform type : integer

Contains the user's platform as an integer constant. Possible values are:

ptUnknown
ptWindows
ptMacintosh
ptLinux
ptUnix
Value is readonly.

See also:  browser
  major
  minor
back to top
theme type : Theme

Pointer to the Theme currently in use. the default Theme is "system". Additional Themes can be loaded by using domapi.loadTheme() and their apply() methods.

Example:
  var b = domapi.theme.border.width;
See also:  themes
  themePath
  loadTheme
back to top
themePath type : String

Relative path from domapi.js to the DomAPI themes folder. Used by the skinning engine for locating images.

See also:  theme
  themes
  loadTheme
back to top
themes type : Array

Collection of all themes available. There will be at least one in here representing the default Theme which is stored in the theme property. More are added by using domapi.loadTheme() and then calling their apply() methods.

See also:  theme
  themePath
  loadTheme
back to top
unloadHooks type : Array

You can push functions onto this array, that you called when domapi unloads.

back to top
urlParams type : Array

Contains name/value pairs for anything included in the url.

back to top
useElmHooks type : boolean default value : false

Toggles the use of Elm "hooks" which are essentially user-defined event handlers. Hooks are turned off by default.

See also:  regHook
  unRegHook
back to top
version type : String

Version number of DomAPI build.

Value is readonly.

back to top
DHTML by www.domapi.com