|
GWT Tk 0.2.3 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectasquare.gwt.tk.client.util.DomUtil
public class DomUtil
Utility methods for working with DOM.
| Constructor Summary | |
|---|---|
DomUtil()
|
|
| Method Summary | |
|---|---|
static void |
appendText(Element element,
String text,
boolean create)
Appends text to a #text node which is a child of the element. |
static void |
clean(Element parent)
Removes all of the element's children. |
static int |
eventGetAbsoluteX(Event event)
Get the mouse x coordinate relative to the document's origin. |
static int |
eventGetAbsoluteY(Event event)
Get the mouse y coordinate relative to the document's origin. |
static char |
eventGetCharCode(Event event)
Gets the unicode character from a keypress event. |
static char |
eventGetKeyCode(Event event)
Gets a code representing a specific keyboard key which was pressed or released. |
static List |
findElementsWithClass(Element element,
String className,
List result)
Creates a list of all elements contained by the specified element (inclusive) which have the specified CSS class (in GWT terms stylename). |
static String |
getAttribute(UIObject uio,
String name)
Gets an attribute on the specified UIObject's element. |
static int |
getDocumentScrollHeight()
Get the height of the document. |
static int |
getDocumentScrollWidth()
Get the width of the document. |
static String |
getId(Element e)
|
static String |
getId(UIObject uio)
Gets the id attribute of the specified UIObject's element. |
static int |
getIntAttribute(UIObject uio,
String name)
Gets an int attribute on the specified UIObject's element. |
static int |
getIntStyleAttribute(UIObject uio,
String name)
Gets a CSS style property for the specified UIObject's element. |
static int |
getPixelStyleAttribute(UIObject uio,
String name)
Gets a CSS style property for the specified UIObject's element. |
static String |
getStyleAttribute(UIObject uio,
String name)
Gets a CSS style property for the specified UIObject's element. |
static int |
getViewportHeight()
Get the height of the GWT application's primary viewport, aka "client area". |
static int |
getViewportScrollX()
Get the horizontal scroll offset of the GWT application's primary window. |
static int |
getViewportScrollY()
Get the vertical scroll offset of the GWT application's primary window. |
static int |
getViewportWidth()
Get the width of the GWT application's primary viewport, aka "client area". |
static boolean |
isMac()
Determines if the browser is running on the Mac OS. |
static boolean |
isQuirksMode()
Reads document.compatMode and returns true
if the property exists and equals "BackCompat". |
static boolean |
isWin()
Determines if the browser is running on a Windows OS. |
static void |
setAttribute(UIObject uio,
String name,
String value)
Sets an attribute on the specified UIObject's element. |
static void |
setId(Element e,
String id)
|
static void |
setId(UIObject uio,
String id)
Sets the id attribute of the specified UIObject's element. |
static void |
setIntAttribute(UIObject uio,
String name,
int value)
Sets an int attribute on the specified UIObject's element. |
static void |
setIntStyleAttribute(UIObject uio,
String name,
int value)
Sets a CSS style property for the specified UIObject's element. |
static void |
setPixelStyleAttribute(UIObject uio,
String name,
int value)
Sets a CSS style property for the specified UIObject's element. |
static void |
setStyleAttribute(UIObject uio,
String name,
String value)
Sets a CSS style property for the specified UIObject's element. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DomUtil()
| Method Detail |
|---|
public static void appendText(Element element,
String text,
boolean create)
element - an element containing a text node as a first child (e.g. a Label or HTML)text - text to appendcreate - true to create a text node if one is not found
NullPointerException - if element is null
IllegalArgumentException - if element has no child nodes
JavaScriptException - if a #text node is
not foundpublic static String getId(UIObject uio)
uio - the UIObject
null if the id attribute is not set
public static void setId(UIObject uio,
String id)
Usage notes:
#fooPackage-barPanel {
border: groove black 1px;
text-align: left;
}
uio - the UIObjectid - a unique id. It is a good practice to namespace ids to avoid
future id confilicts, i.e. organization.project.foo.public static String getId(Element e)
e - a native DOM element
null if the id attribute is not setgetId(UIObject)
public static void setId(Element e,
String id)
e - a native DOM elementid - a unique id. It is a good practice to namespace ids to avoid
future id confilicts, i.e. organization.project.foo.setId(UIObject, String)
public static String getAttribute(UIObject uio,
String name)
uio - a UIObjectname - an attribute name, in "camelCase"
null if the
attribute is not defined
public static void setAttribute(UIObject uio,
String name,
String value)
uio - a UIObjectname - the attribute name, in "camelCase"value - a value
public static int getIntAttribute(UIObject uio,
String name)
uio - a UIObjectname - the attribute name, in "camelCase"
0 if the attribute is not defined
public static void setIntAttribute(UIObject uio,
String name,
int value)
uio - a UIObjectname - the attribute name, in "camelCase"value - an int value
public static String getStyleAttribute(UIObject uio,
String name)
uio - a UIObjectname - a CSS style property name, in "camelCase"
null if the
property is not set
public static void setStyleAttribute(UIObject uio,
String name,
String value)
uio - a UIObjectname - a CSS style property name, in "camelCase"value - a valid CSS property value
public static int getIntStyleAttribute(UIObject uio,
String name)
uio - a UIObjectname - a CSS style property name, in "camelCase"
null if the property is not
set
public static void setIntStyleAttribute(UIObject uio,
String name,
int value)
uio - a UIObjectname - a CSS style property name, in "camelCase"value - an int value
public static int getPixelStyleAttribute(UIObject uio,
String name)
uio - a UIObjectname - a CSS style property name, in "camelCase"
null if the
property is not set
public static void setPixelStyleAttribute(UIObject uio,
String name,
int value)
uio - a UIObjectname - a CSS style property name, in "camelCase"value - an int value, in screen pixels
public static List findElementsWithClass(Element element,
String className,
List result)
element - the element which is at the root of the hierarchy that you wish to searchclassName - the name of the CSS class to search forresult - a writable list which will be returned as the result (for recursion).
Typically, you pass null and the list will
be created on the fly.
public static boolean isQuirksMode()
document.compatMode and returns true
if the property exists and equals "BackCompat". Supported on Opera, IE
and Mozilla. Always returns false in Safari because the
property is not defined.
Note: Safari does have a quirks mode, but you cannot determine this from JavaScript.
true if the browser is rendering in quirks modepublic static boolean isMac()
true if the browser is running on a Macpublic static boolean isWin()
true if the browser is running on Windowspublic static int getViewportWidth()
public static int getViewportHeight()
public static int getViewportScrollX()
public static int getViewportScrollY()
public static int getDocumentScrollWidth()
public static int getDocumentScrollHeight()
public static char eventGetKeyCode(Event event)
event - a keydown or keyup event
IllegalArgumentException - if event is other than onkeydown or
onkeyuppublic static char eventGetCharCode(Event event)
Delete).
event - a keypress event
IllegalArgumentException - if event is other than onkeypresspublic static int eventGetAbsoluteX(Event event)
DOM.eventGetClientX(Event) in that it includes the
area hidden by document scroll.
event - a native DOM event object
public static int eventGetAbsoluteY(Event event)
DOM.eventGetClientY(Event) in that it includes the
area hidden by document scroll.
event - a native DOM event object
public static void clean(Element parent)
parent - a DOM element
IllegalArgumentException - if parent is null
|
GWT Tk 0.2.3 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||