Class tsCompatibility

Author
Giovanni Capalbo <gcapalbo@users.sourceforge.net>
License
This source file is subject to the LGPL license, which is available online at this address: http://www.gnu.org/copyleft/lesser.html

This class is intended to abstract specific browser functionality into one class so that there is just one interface to the functionality contained herein. All attributes and methods in this class are static so that they can be referenced globally without instantiating new objects.



Attribute Summary


NameDescription
fixedPositioningTrue if the current browser supports CSS fixed positioning, false if not.
IETrue if the current browser is any version of Internet Explorer, false if not.


Method Summary


Return TypeSignature
numberabsoluteX(node)
numberabsoluteY(node)
voidaddEventListener(obj, type, fcn, phase)
numberclientHeight(obj)
numberclientWidth(obj)
XMLHttpRequestcreateXMLHttpRequest()
HTMLElementeventTarget(e)
voidfireClickEvent(obj)
voidfireKeyEvent(obj, charToPress)
numbernumericalValue(value)
voidremoveEventListener(obj, type, fcn, phase)


Attribute Details

fixedPositioning

NOTE: This attribute is static, so it is referenced as tsCompatibility.fixedPositioning
Type
boolean
Description
True if the current browser supports CSS fixed positioning, false if not.
Access
public



IE

NOTE: This attribute is static, so it is referenced as tsCompatibility.IE
Type
boolean
Description
True if the current browser is any version of Internet Explorer, false if not.
Access
public


Method Details

absoluteX

NOTE: This method is static, so it is referenced as tsCompatibility.absoluteX
Description
Retrieves the x-coordinate of the given HTMLElement in relation to the upper-left corner of the browser's client area.
Parameters
TypeNameDescription
HTMLElementnodeThe HTMLElement.
Return
number; The x-coordinate.
Access
public



absoluteY

NOTE: This method is static, so it is referenced as tsCompatibility.absoluteY
Description
Retrieves the y-coordinate of the given HTMLElement in relation to the upper-left corner of the browser's client area.
Parameters
TypeNameDescription
HTMLElementnodeThe HTMLElement.
Return
number; The y-coordinate.
Access
public



addEventListener

NOTE: This method is static, so it is referenced as tsCompatibility.addEventListener
Description
Adds an event listener to an HTMLElement.
Parameters
TypeNameDescription
mixedobjThe object to add the event listener to, can be an HTMLElement or the window object.
stringtypeThe type of event to add ('click', 'mouseover', etc.).
functionfcnThe function to execute when the event happens.
booleanphasetrue to detect the event in the capturing phase, false for bubbling phase.
Return
void
Access
public



clientHeight

NOTE: This method is static, so it is referenced as tsCompatibility.clientHeight
Description
Retrieves the height of the given object's client area.
Parameters
TypeNameDescription
mixedobjThe object whose client height to retrieve. Can be an HTMLElement or the window object.
Return
number; The height of the client area.
Access
public



clientWidth

NOTE: This method is static, so it is referenced as tsCompatibility.clientWidth
Description
Retrieves the width of the given object's client area.
Parameters
TypeNameDescription
mixedobjThe object whose client width to retrieve. Can be an HTMLElement or the window object.
Return
number; The width of the client area.
Access
public



createXMLHttpRequest

NOTE: This method is static, so it is referenced as tsCompatibility.createXMLHttpRequest
Description
Creates an XMLHttpRequest object.
Parameters
(none)
Return
XMLHttpRequest; The XMLHttpRequest object, or null on error.
Access
public



eventTarget

NOTE: This method is static, so it is referenced as tsCompatibility.eventTarget
Description
Retrieves the HTMLElement that is being acted upon by a specific event.
Parameters
TypeNameDescription
EventeThe event that was fired.
Return
HTMLElement; The element that the event was fired upon.
Access
public



fireClickEvent

NOTE: This method is static, so it is referenced as tsCompatibility.fireClickEvent
Description
Fires a click event on the given HTMLElement.
Parameters
TypeNameDescription
HTMLElementobjThe element to fire upon.
Return
void
Access
public



fireKeyEvent

NOTE: This method is static, so it is referenced as tsCompatibility.fireKeyEvent
Description
Fires a keydown and keyup event on the given HTMLElement.
Parameters
TypeNameDescription
HTMLElementobjThe object to fire upon.
mixedcharToPressThe character to press (either the numerical code or string representation is ok, e.g., 0x41 or "A").
Return
void
Access
public



numericalValue

NOTE: This method is static, so it is referenced as tsCompatibility.numericalValue
Description
Strips the 'px' off of a string and returns its value as a number. This function should be used for retrieving height, width, etc. style parameters as integers only in the rare events that the offsetHeight/offsetWidth,etc. attributes do not work.
Parameters
TypeNameDescription
stringvalueThe style value whose numerical value to retreive.
Return
number; The value.
Access
public



removeEventListener

NOTE: This method is static, so it is referenced as tsCompatibility.removeEventListener
Description
Removes an event listener from an HTMLElement.
Parameters
TypeNameDescription
HTMLElementobjThe element to remove the event listener from.
stringtypeThe type of event to remove ('click', 'mouseover', etc.).
functionfcnThe function associated with the event.
booleanphasetrue if the event was detected in the capturing phase, false for bubbling phase.
Return
void
Access
public