public final class MdlGwtUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DISABLED
The disabled property name.
|
Modifier and Type | Method and Description |
---|---|
static void |
addClass(com.google.gwt.dom.client.Element element,
Object style) |
static void |
addStyle(com.google.gwt.user.client.ui.UIObject object,
Object style)
When
UIObject.addStyleName(String) is invoked with an empty style
name, it raises an exception. |
static void |
assertIndex(int size,
int index)
Make sure the index provided as input is inside the range of possible
elements of a list.
|
static double |
getProperty(com.google.gwt.dom.client.Element elt,
String prop)
Retrieve the property value for an element.
|
static void |
insureId(com.google.gwt.dom.client.Element element)
Makes sure the element parameter have an id.
|
static boolean |
mouseOutOfBounds(com.google.gwt.dom.client.Element element,
int x,
int y)
Is the mouse out of the element bounds.
|
static void |
removeClass(com.google.gwt.dom.client.Element element,
Object style)
Same behavior as
removeStyle(UIObject, Object) applied
to Element . |
static void |
removeStyle(com.google.gwt.user.client.ui.UIObject object,
Object style)
Same behavior as
addStyle(UIObject, Object) but for
UIObject.removeStyleName(String) . |
static void |
setEnabled(com.google.gwt.dom.client.Element elt,
boolean enabled)
apply the disabled property for a DOM element if the element should be
disabled.
|
static void |
setFor(com.google.gwt.dom.client.Element element,
String value)
Helper method that sets the value to the "for" attribute in a DOM element.
|
static void |
setProperty(com.google.gwt.dom.client.Element elt,
String prop,
double val)
Set the property for a DOM element object, not to be confused with element
attributes.
|
public static final String DISABLED
public static void setEnabled(com.google.gwt.dom.client.Element elt, boolean enabled)
elt
- the target elementenabled
- true
to remove the disabled property and
false
to add itpublic static void insureId(com.google.gwt.dom.client.Element element)
element
- the element for which an id should be insuredpublic static void setFor(com.google.gwt.dom.client.Element element, String value)
element
- the target element to be processedvalue
- the value tobe set to the "for" attributepublic static void setProperty(com.google.gwt.dom.client.Element elt, String prop, double val)
Set the property for a DOM element object, not to be confused with element attributes.
To distinguish between properties and attributes lets consider the
following input element :
<input id="inrang" type="range" min="0"
max="100">
PROPERTY
=>
inrang["value"] = 50; ATTRIBUTE
=>
inrang.setAttribute("value", 0);elt
- the target elementprop
- the target propertyval
- the target valuepublic static double getProperty(com.google.gwt.dom.client.Element elt, String prop)
elt
- the target element of the value setprop
- the target property to setpublic static void assertIndex(int size, int index)
size
- the size of the listindex
- the index to be checkedpublic static void addStyle(com.google.gwt.user.client.ui.UIObject object, Object style)
UIObject.addStyleName(String)
is invoked with an empty style
name, it raises an exception. In mdl, the absence of a selector is
interpreted as the default option for the behavior. For this reason, we
need an alternative to UIObject.addStyleName(String)
that does not
raise an exception when it encounter an empty css selector.object
- the widget to which the css selector will be appliedstyle
- any Object
with a Object.toString()
method
returning the css selector to be applied.public static void removeStyle(com.google.gwt.user.client.ui.UIObject object, Object style)
addStyle(UIObject, Object)
but for
UIObject.removeStyleName(String)
.object
- the widget to which the css selector will be appliedstyle
- any Object
with a Object.toString()
method
returning the css selector to be applied.addStyle(UIObject, Object)
public static void addClass(com.google.gwt.dom.client.Element element, Object style)
element
- the Element
to which the css class will be appliedstyle
- any Object
with a Object.toString()
method
returning the css class to be applied.assertStyle(Object, Object)
public static void removeClass(com.google.gwt.dom.client.Element element, Object style)
removeStyle(UIObject, Object)
applied
to Element
.element
- the Element
to which the css selector will be appliedstyle
- any Object
with a Object.toString()
method
returning the css selector to be applied.public static boolean mouseOutOfBounds(com.google.gwt.dom.client.Element element, int x, int y)
element
- the target elementx
- the horizontal absolute position of the mousey
- the vertical absolute position of the mousetrue
if the mouse out of the element boundsCopyright © 2016 com.github.ilyes4j. All rights reserved.