public final class CmsDomUtil
extends java.lang.Object
限定符和类型 | 类和说明 |
---|---|
static class |
CmsDomUtil.Attribute
HTML tag attributes.
|
static class |
CmsDomUtil.AttributeValue
Helper class to encapsulate an attribute/value pair.
|
static class |
CmsDomUtil.Color
CSS Colors.
|
static class |
CmsDomUtil.Entity
HTML entities.
|
static class |
CmsDomUtil.Method
Form methods.
|
static class |
CmsDomUtil.Style
CSS Properties.
|
static class |
CmsDomUtil.StyleValue
CSS Property values.
|
static class |
CmsDomUtil.Tag
HTML Tags.
|
static class |
CmsDomUtil.Target
Enumeration of link/form targets.
|
限定符和类型 | 方法和说明 |
---|---|
static void |
addDisablingOverlay(com.google.gwt.dom.client.Element element)
Adds an overlay div to the element.
|
static boolean |
checkPositionInside(com.google.gwt.dom.client.Element element,
int x,
int y)
Returns if the given client position is over the given element.
|
static void |
clearOpacity(com.google.gwt.dom.client.Element element)
Removes the opacity attribute from the element's inline-style.
|
static com.google.gwt.dom.client.Element |
clone(com.google.gwt.dom.client.Element element)
Clones the given element.
|
static java.lang.String |
close(CmsDomUtil.Tag tag)
Generates a closing tag.
|
static com.google.gwt.dom.client.Element |
createElement(java.lang.String html)
This method will create an
Element for the given HTML. |
static java.lang.String |
createFaceHtml(java.lang.String text,
java.lang.String imageClass,
com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant align)
Convenience method to assemble the HTML to use for a button face.
|
static com.google.gwt.dom.client.Element |
createIFrameElement(java.lang.String name)
Creates an iFrame element with the given name attribute.
|
static java.lang.String |
enclose(CmsDomUtil.Tag tag,
java.lang.String text,
CmsDomUtil.AttributeValue... attrs)
Encloses the given text with the given tag.
|
static void |
ensureJavaScriptIncluded(java.lang.String javascriptLink)
Ensures a script tag is present within the window document context.
|
static void |
ensureMouseOut(com.google.gwt.dom.client.Element element)
Triggers a mouse-out event for the given element.
|
static void |
ensureMouseOut(com.google.gwt.event.shared.HasHandlers target)
Triggers a mouse-out event for the given target.
|
static void |
ensureMouseOver(com.google.gwt.dom.client.Element element)
Triggers a mouse-over event for the given element.
|
static void |
ensureStyleSheetIncluded(java.lang.String styleSheetLink)
Checks the window.document for given style-sheet and includes it if required.
|
static void |
ensureVisible(com.google.gwt.dom.client.Element containerElement,
com.google.gwt.dom.client.Element element,
int animationTime)
Ensures that the given element is visible.
|
static void |
fireFocusEvent(com.google.gwt.user.client.ui.Widget widget)
Fires a focus event for the given widget.
|
static void |
fixFlashZindex(com.google.gwt.dom.client.Element element)
Ensures any embedded flash players are set opaque so UI elements may be placed above them.
|
static com.google.gwt.dom.client.FormElement |
generateHiddenForm(java.lang.String action,
CmsDomUtil.Method method,
CmsDomUtil.Target target,
java.util.Map<java.lang.String,java.lang.String> values)
Generates a form element with hidden input fields.
|
static com.google.gwt.dom.client.FormElement |
generateHiddenForm(java.lang.String action,
CmsDomUtil.Method method,
java.lang.String target,
java.util.Map<java.lang.String,java.lang.String> values)
Generates a form element with hidden input fields.
|
static com.google.gwt.dom.client.Element |
getAncestor(com.google.gwt.dom.client.Element element,
CmsDomUtil.Tag tag)
Returns the given element or it's closest ancestor with the given tag name.
|
static com.google.gwt.dom.client.Element |
getAncestor(com.google.gwt.dom.client.Element element,
CmsDomUtil.Tag tag,
java.lang.String className)
Returns the given element or it's closest ancestor with the given tag and class.
|
static com.google.gwt.dom.client.Element |
getAncestor(com.google.gwt.dom.client.Element element,
java.lang.String className)
Returns the given element or it's closest ancestor with the given class.
|
static java.lang.String |
getCurrentStyle(com.google.gwt.dom.client.Element element,
CmsDomUtil.Style style)
Returns the computed style of the given element.
|
static double |
getCurrentStyleFloat(com.google.gwt.dom.client.Element element,
CmsDomUtil.Style style)
Returns the computed style of the given element as floating point number.
|
static int |
getCurrentStyleInt(com.google.gwt.dom.client.Element element,
CmsDomUtil.Style style)
Returns the computed style of the given element as number.
|
static CmsPositionBean |
getEditablePosition(com.google.gwt.dom.client.Element editable)
Determines the position of the list collector editable content.
|
static java.lang.String |
getEffectiveBackgroundColor(com.google.gwt.dom.client.Element element)
Utility method to determine the effective background color.
|
static java.util.List<com.google.gwt.dom.client.Element> |
getElementsByClass(java.lang.String className)
Returns all elements from the DOM with the given CSS class.
|
static java.util.List<com.google.gwt.dom.client.Element> |
getElementsByClass(java.lang.String className,
CmsDomUtil.Tag tag)
Returns all elements from the DOM with the given CSS class and tag name.
|
static java.util.List<com.google.gwt.dom.client.Element> |
getElementsByClass(java.lang.String className,
CmsDomUtil.Tag tag,
com.google.gwt.dom.client.Element rootElement)
Returns all elements with the given CSS class and tag name including the root element.
|
static java.util.List<com.google.gwt.dom.client.Element> |
getElementsByClass(java.lang.String className,
com.google.gwt.dom.client.Element rootElement)
Returns all elements with the given CSS class including the root element.
|
static int |
getPosition(com.google.gwt.dom.client.Element e)
Returns the element position relative to its siblings.
|
static com.google.gwt.dom.client.Element |
getPositioningParent(com.google.gwt.dom.client.Element child)
Returns the next ancestor to the element with an absolute, fixed or relative position.
|
static int |
getRelativeX(int x,
com.google.gwt.dom.client.Element target)
Gets the horizontal position of the given x-coordinate relative to a given element.
|
static int |
getRelativeY(int y,
com.google.gwt.dom.client.Element target)
Gets the vertical position of the given y-coordinate relative to a given element.
|
static com.google.gwt.core.client.JavaScriptObject |
getWindow()
Returns the DOM window object.
|
static java.lang.String |
getZIndex(com.google.gwt.dom.client.Style style)
Returns the Z index from the given style.
|
static boolean |
hasBackground(com.google.gwt.dom.client.Element element)
Utility method to determine if the given element has a set background.
|
static boolean |
hasBackgroundImage(com.google.gwt.dom.client.Element element)
Utility method to determine if the given element has a set background image.
|
static boolean |
hasBorder(com.google.gwt.dom.client.Element element)
Utility method to determine if the given element has a set border.
|
static boolean |
hasClass(java.lang.String className,
com.google.gwt.dom.client.Element element)
Indicates if the given element has a CSS class.
|
static boolean |
hasDimension(com.google.gwt.dom.client.Element element)
Returns if the given element has any dimension.
|
static boolean |
isJavaScriptPresent(java.lang.String javascriptLink)
Checks whether a given script resource is present within the window context.
|
static void |
makeScrollable(com.google.gwt.dom.client.Element elem)
Gives an element the overflow:auto property.
|
static void |
makeScrollable(com.google.gwt.user.client.ui.Widget widget)
Gives the element of a widget the overflow:auto property.
|
static java.lang.String |
messagePopupBlocked()
Message accessor.
|
static java.lang.String |
messagePopupBlockedTitle()
Message accessor.
|
static java.lang.String |
open(CmsDomUtil.Tag tag,
CmsDomUtil.AttributeValue... attrs)
Generates an opening tag.
|
static void |
openWindow(java.lang.String url,
java.lang.String name,
java.lang.String features)
Opens a new browser window.
|
static com.google.gwt.core.client.JavaScriptObject |
parseJSON(java.lang.String jsonString)
Parses the given string into a JSON object.
|
static void |
positionElement(com.google.gwt.dom.client.Element elem,
com.google.gwt.dom.client.Element referenceElement,
int dx,
int dy)
Positions an element in the DOM relative to another element.
|
static int |
positionElementInside(com.google.gwt.dom.client.Element element,
com.google.gwt.dom.client.Element parent,
int currentIndex,
int x,
int y)
Positions an element inside the given parent, reordering the content of the parent and returns the new position index.
|
static void |
removeDisablingOverlay(com.google.gwt.dom.client.Element element)
Removes any present overlay from the element and it's children.
|
static com.google.gwt.dom.client.Element |
removeScriptTags(com.google.gwt.dom.client.Element element)
Removes all script tags from the given element.
|
static java.lang.String |
removeScriptTags(java.lang.String source)
Removes all script tags from the given string.
|
static void |
resizeAncestor(com.google.gwt.user.client.ui.Widget parent)
Calls
I_DescendantResizeHandler.onResizeDescendant() on the closest resizable ancestor. |
static void |
setAttribute(com.google.gwt.core.client.JavaScriptObject jso,
java.lang.String key,
com.google.gwt.core.client.JavaScriptObject value)
Sets an attribute on a Javascript object.
|
static void |
setAttribute(com.google.gwt.core.client.JavaScriptObject jso,
java.lang.String key,
java.lang.String value)
Sets an attribute on a Javascript object.
|
static void |
showOverlay(com.google.gwt.dom.client.Element element,
boolean show)
Sets a CSS class to show or hide a given overlay.
|
static void |
showPopupBlockerMessage()
Shows a message that a popup was blocked.
|
static java.lang.String |
stripHtml(java.lang.String html)
Returns the text content to any HTML.
|
static com.google.gwt.user.client.ui.FlowPanel |
wrapScrollable(com.google.gwt.user.client.ui.Widget widget)
Wraps a widget in a scrollable FlowPanel.
|
public static void addDisablingOverlay(com.google.gwt.dom.client.Element element)
element
- the elementpublic static boolean checkPositionInside(com.google.gwt.dom.client.Element element, int x, int y)
Use -1
for x or y to ignore one ordering orientation.
element
- the elementx
- the client x position, use -1
to ignore x positiony
- the client y position, use -1
to ignore y positiontrue
if the given position is over the given elementpublic static void clearOpacity(com.google.gwt.dom.client.Element element)
element
- the DOM element to manipulatepublic static com.google.gwt.dom.client.Element clone(com.google.gwt.dom.client.Element element)
It creates a new element with the same tag, and sets the class attribute, and sets the innerHTML.
element
- the element to clonepublic static java.lang.String close(CmsDomUtil.Tag tag)
tag
- the tag to usepublic static com.google.gwt.dom.client.Element createElement(java.lang.String html) throws java.lang.Exception
Element
for the given HTML.
The HTML should have a single root tag, if not, the first tag will be used and all others discarded.Script-tags will be removed.
html
- the HTML to use for the elementjava.lang.Exception
- if something goes wrongpublic static java.lang.String createFaceHtml(java.lang.String text, java.lang.String imageClass, com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant align)
text
- text the up face text to set, set to null
to not show anyimageClass
- the up face image class to use, set to null
to not show anyalign
- the alignment of the text in reference to the imagepublic static com.google.gwt.dom.client.Element createIFrameElement(java.lang.String name)
name
- the name attribute valuepublic static java.lang.String enclose(CmsDomUtil.Tag tag, java.lang.String text, CmsDomUtil.AttributeValue... attrs)
tag
- the tag to usetext
- the text to encloseattrs
- the optional tag attributespublic static void ensureJavaScriptIncluded(java.lang.String javascriptLink)
javascriptLink
- the link to the java script resourcepublic static void ensureMouseOut(com.google.gwt.dom.client.Element element)
Useful in case something is capturing all events.
element
- the element to usepublic static void ensureMouseOut(com.google.gwt.event.shared.HasHandlers target)
Useful in case something is capturing all events.
target
- the target to usepublic static void ensureMouseOver(com.google.gwt.dom.client.Element element)
Useful in case something is capturing all events.
element
- the element to usepublic static void ensureStyleSheetIncluded(java.lang.String styleSheetLink)
styleSheetLink
- the style-sheet linkpublic static void ensureVisible(com.google.gwt.dom.client.Element containerElement, com.google.gwt.dom.client.Element element, int animationTime)
Assuming the scrollbars are on the container element, and that the element is a child of the container element.
containerElement
- the container element, has to be parent of the elementelement
- the element to be seenanimationTime
- the animation time for scrolling, use zero for no animationpublic static void fireFocusEvent(com.google.gwt.user.client.ui.Widget widget)
widget
- the widgetpublic static void fixFlashZindex(com.google.gwt.dom.client.Element element)
element
- the element to work onpublic static com.google.gwt.dom.client.FormElement generateHiddenForm(java.lang.String action, CmsDomUtil.Method method, java.lang.String target, java.util.Map<java.lang.String,java.lang.String> values)
action
- the form actionmethod
- the form methodtarget
- the form targetvalues
- the input valuespublic static com.google.gwt.dom.client.FormElement generateHiddenForm(java.lang.String action, CmsDomUtil.Method method, CmsDomUtil.Target target, java.util.Map<java.lang.String,java.lang.String> values)
action
- the form actionmethod
- the form methodtarget
- the form targetvalues
- the input valuespublic static com.google.gwt.dom.client.Element getAncestor(com.google.gwt.dom.client.Element element, java.lang.String className)
Returns null
if no appropriate element was found.
element
- the elementclassName
- the class namepublic static com.google.gwt.dom.client.Element getAncestor(com.google.gwt.dom.client.Element element, CmsDomUtil.Tag tag)
Returns null
if no appropriate element was found.
element
- the elementtag
- the tag namepublic static com.google.gwt.dom.client.Element getAncestor(com.google.gwt.dom.client.Element element, CmsDomUtil.Tag tag, java.lang.String className)
Returns null
if no appropriate element was found.
element
- the elementtag
- the tag nameclassName
- the class namepublic static java.lang.String getCurrentStyle(com.google.gwt.dom.client.Element element, CmsDomUtil.Style style)
element
- the elementstyle
- the CSS propertypublic static double getCurrentStyleFloat(com.google.gwt.dom.client.Element element, CmsDomUtil.Style style)
element
- the elementstyle
- the CSS propertypublic static int getCurrentStyleInt(com.google.gwt.dom.client.Element element, CmsDomUtil.Style style)
element
- the elementstyle
- the CSS propertypublic static CmsPositionBean getEditablePosition(com.google.gwt.dom.client.Element editable)
editable
- the editable marker tagpublic static java.lang.String getEffectiveBackgroundColor(com.google.gwt.dom.client.Element element)
element
- the elementpublic static java.util.List<com.google.gwt.dom.client.Element> getElementsByClass(java.lang.String className)
className
- the class name to look forpublic static java.util.List<com.google.gwt.dom.client.Element> getElementsByClass(java.lang.String className, com.google.gwt.dom.client.Element rootElement)
className
- the class name to look forrootElement
- the root element of the searchpublic static java.util.List<com.google.gwt.dom.client.Element> getElementsByClass(java.lang.String className, CmsDomUtil.Tag tag)
className
- the class name to look fortag
- the tagpublic static java.util.List<com.google.gwt.dom.client.Element> getElementsByClass(java.lang.String className, CmsDomUtil.Tag tag, com.google.gwt.dom.client.Element rootElement)
className
- the class name to look fortag
- the tagrootElement
- the root element of the searchpublic static int getPosition(com.google.gwt.dom.client.Element e)
e
- the element to get the position for-1
if not foundpublic static com.google.gwt.dom.client.Element getPositioningParent(com.google.gwt.dom.client.Element child)
child
- the elementnull
)public static int getRelativeX(int x, com.google.gwt.dom.client.Element target)
x
- the coordinate to usetarget
- the element whose coordinate system is to be usedMouseEvent.getRelativeX(com.google.gwt.dom.client.Element)
public static int getRelativeY(int y, com.google.gwt.dom.client.Element target)
y
- the coordinate to usetarget
- the element whose coordinate system is to be usedMouseEvent.getRelativeY(com.google.gwt.dom.client.Element)
public static com.google.gwt.core.client.JavaScriptObject getWindow()
public static java.lang.String getZIndex(com.google.gwt.dom.client.Style style)
This is a workaround for a bug with Style.getZIndex()
which occurs with IE in
hosted mode.
style
- the style object from which the Z index property should be fetchedpublic static boolean hasBackground(com.google.gwt.dom.client.Element element)
element
- the elementtrue
if the element has a background setpublic static boolean hasBackgroundImage(com.google.gwt.dom.client.Element element)
element
- the elementtrue
if the element has a background image setpublic static boolean hasBorder(com.google.gwt.dom.client.Element element)
element
- the elementtrue
if the element has a borderpublic static boolean hasClass(java.lang.String className, com.google.gwt.dom.client.Element element)
className
- the class name to look forelement
- the elementtrue
if the element has the given CSS classpublic static boolean hasDimension(com.google.gwt.dom.client.Element element)
All visible elements should have a dimension.
element
- the element to testtrue
if the given element has any dimensionpublic static boolean isJavaScriptPresent(java.lang.String javascriptLink)
javascriptLink
- the resource URLtrue
if the script resource is present within the window contextpublic static void makeScrollable(com.google.gwt.dom.client.Element elem)
elem
- a DOM elementpublic static void makeScrollable(com.google.gwt.user.client.ui.Widget widget)
widget
- the widget to make scrollablepublic static java.lang.String messagePopupBlocked()
public static java.lang.String messagePopupBlockedTitle()
public static java.lang.String open(CmsDomUtil.Tag tag, CmsDomUtil.AttributeValue... attrs)
tag
- the tag to useattrs
- the optional tag attributespublic static void openWindow(java.lang.String url, java.lang.String name, java.lang.String features)
url
- the URL that the new window will displayname
- the name of the window (e.g. "_blank")features
- the features to be enabled/disabled on this windowpublic static com.google.gwt.core.client.JavaScriptObject parseJSON(java.lang.String jsonString)
jsonString
- the string to parsepublic static void positionElement(com.google.gwt.dom.client.Element elem, com.google.gwt.dom.client.Element referenceElement, int dx, int dy)
elem
- the element to positionreferenceElement
- the element relative to which the first element should be positioneddx
- the x offset relative to the reference elementdy
- the y offset relative to the reference elementpublic static int positionElementInside(com.google.gwt.dom.client.Element element, com.google.gwt.dom.client.Element parent, int currentIndex, int x, int y)
This is none absolute positioning. Use for drag and drop reordering of drop targets.
Use -1
for x or y to ignore one ordering orientation.
element
- the child elementparent
- the parent elementcurrentIndex
- the current index position of the element, use -1 if element is not attached to the parent yetx
- the client x position, use -1
to ignore x positiony
- the client y position, use -1
to ignore y positionpublic static void removeDisablingOverlay(com.google.gwt.dom.client.Element element)
element
- the elementpublic static com.google.gwt.dom.client.Element removeScriptTags(com.google.gwt.dom.client.Element element)
element
- the element to remove the script tags frompublic static java.lang.String removeScriptTags(java.lang.String source)
source
- the source stringpublic static void resizeAncestor(com.google.gwt.user.client.ui.Widget parent)
I_DescendantResizeHandler.onResizeDescendant()
on the closest resizable ancestor.parent
- the parent widgetpublic static void setAttribute(com.google.gwt.core.client.JavaScriptObject jso, java.lang.String key, com.google.gwt.core.client.JavaScriptObject value)
jso
- the Javascript objectkey
- the attribute namevalue
- the new attribute valuepublic static void setAttribute(com.google.gwt.core.client.JavaScriptObject jso, java.lang.String key, java.lang.String value)
jso
- the Javascript objectkey
- the attribute namevalue
- the new attribute valuepublic static void showOverlay(com.google.gwt.dom.client.Element element, boolean show)
element
- the parent element of the overlayshow
- true
to show the overlaypublic static void showPopupBlockerMessage()
public static java.lang.String stripHtml(java.lang.String html)
html
- the HTMLpublic static com.google.gwt.user.client.ui.FlowPanel wrapScrollable(com.google.gwt.user.client.ui.Widget widget)
widget
- the original widget