Class CmsDomUtil

java.lang.Object
org.opencms.gwt.client.util.CmsDomUtil

public final class CmsDomUtil extends Object
Utility class to access the HTML DOM.

Since:
8.0.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    HTML tag attributes.
    static class 
    Helper class to encapsulate an attribute/value pair.
    static enum 
    CSS Colors.
    static enum 
    HTML entities.
    static enum 
    Form methods.
    static enum 
    CSS Properties.
    static enum 
    CSS Property values.
    static enum 
    HTML Tags.
    static enum 
    Enumeration of link/form targets.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addDisablingOverlay(com.google.gwt.dom.client.Element element)
    Adds an overlay div to the element.
    static void
    Adds a CSS style rule to a dynamically inserted style sheet.
    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
    clearHover(com.google.gwt.dom.client.Element element)
    Clears the elements hover state by removing it from the DOM and re-attaching it.
    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 String
    Generates a closing tag.
    static boolean
    Copy the text content of the matching element to the clip-board.
    static com.google.gwt.dom.client.Element
    This method will create an Element for the given HTML.
    static String
    createFaceHtml(String text, 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
    Creates an iFrame element with the given name attribute.
    static String
    Encloses the given text with the given tag.
    static void
    Ensures a script tag is present within the window document context.
    static void
    ensureJavaScriptIncluded(String javascriptLink, boolean async)
    Ensures a script tag is present within the window document context.
    static void
    ensureJavaScriptIncluded(String javascriptLink, boolean async, com.google.gwt.core.client.JavaScriptObject callback)
    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
    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 String
    escapeXml(String source)
    Escapes a String so it may be printed as text content or attribute value in a HTML page or an XML file.
    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(String action, CmsDomUtil.Method method, String target, Map<String,String> values)
    Generates a form element with hidden input fields.
    static com.google.gwt.dom.client.FormElement
    Generates a form element with hidden input fields.
    static com.google.gwt.dom.client.Element
    Returns the currently focused element.
    Gets the edit data for all oc-editable elements in the page.
    static com.google.gwt.dom.client.Element
    getAncestor(com.google.gwt.dom.client.Element element, String className)
    Returns the given element or it's closest ancestor with the given class.
    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, String className)
    Returns the given element or it's closest ancestor with the given tag and class.
    static 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.
    getEditablePosition(com.google.gwt.dom.client.Element editable)
    Determines the position of the list collector editable content.
    static String
    getEffectiveBackgroundColor(com.google.gwt.dom.client.Element element)
    Utility method to determine the effective background color.
    static List<com.google.gwt.dom.client.Element>
    Returns all elements from the DOM with the given CSS class.
    static List<com.google.gwt.dom.client.Element>
    getElementsByClass(String className, com.google.gwt.dom.client.Element rootElement)
    Returns all elements with the given CSS class including the root element.
    static List<com.google.gwt.dom.client.Element>
    Returns all elements from the DOM with the given CSS class and tag name.
    static List<com.google.gwt.dom.client.Element>
    getElementsByClass(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 com.google.gwt.dom.client.Element
    getFirstChildWithClass(com.google.gwt.dom.client.Element element, String className)
    Returns the first direct child matching the given class name.
    static com.google.gwt.dom.client.Element
    Gets the root <html> element.
    static int
    getIFrameContentHeight(com.google.gwt.dom.client.Element iframe)
    Returns the content height of the given iFrame 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 int
    Measures the scroll bar width.
    static com.google.gwt.core.client.JavaScriptObject
    Returns the DOM window object.
    static 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(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
    Checks whether the copy command is supported by the client browser.
    static boolean
    isJavaScriptPresent(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 String
    Message accessor.
    static String
    Message accessor.
    static List<com.google.gwt.dom.client.Element>
    nodeListToList(com.google.gwt.dom.client.NodeList<com.google.gwt.dom.client.Element> nodelist)
    Converts a NodeList to a List of elements.
    static String
    Generates an opening tag.
    static void
    openWindow(String url, String name, String features)
    Opens a new browser window.
    static com.google.gwt.core.client.JavaScriptObject
    parseJSON(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 com.google.gwt.dom.client.Element
    querySelector(String selector, com.google.gwt.dom.client.Element context)
    Returns the first element matching the given CSS selector.
    static com.google.gwt.dom.client.NodeList<com.google.gwt.dom.client.Element>
    querySelectorAll(String selector, com.google.gwt.dom.client.Element context)
    Returns a list of elements matching the given CSS selector.
    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 String
    Removes all script tags from the given string.
    static void
    resizeAncestor(com.google.gwt.user.client.ui.Widget parent)
    Calls I_CmsDescendantResizeHandler.onResizeDescendant() on the closest resizable ancestor.
    static void
    safeLoadStylesheets(String[] stylesheets, com.google.gwt.core.client.JavaScriptObject callback)
    Loads a list of stylesheets and invokes a Javascript callback after everything has been loaded.
    static void
    setAttribute(com.google.gwt.core.client.JavaScriptObject jso, 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, String key, String value)
    Sets an attribute on a Javascript object.
    static void
    Sets the stylesheet text for the stylesheet with the given ID.
    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
    Shows a message that a popup was blocked.
    static String
    Returns the text content to any HTML.
    static Map<String,String>
    updateStyle(com.google.gwt.dom.client.Style style, Map<String,String> properties)
    Updates a set of style properties on the given style object, and returns a map with the previous values.
    static com.google.gwt.user.client.ui.FlowPanel
    wrapScrollable(com.google.gwt.user.client.ui.Widget widget)
    Wraps a widget in a scrollable FlowPanel.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • addDisablingOverlay

      public static void addDisablingOverlay(com.google.gwt.dom.client.Element element)
      Adds an overlay div to the element.

      Parameters:
      element - the element
    • addDynamicStyleRule

      public static void addDynamicStyleRule(String rule)
      Adds a CSS style rule to a dynamically inserted style sheet.

      Parameters:
      rule - the style rule
    • checkPositionInside

      public 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.

      Use -1 for x or y to ignore one ordering orientation.

      Parameters:
      element - the element
      x - the client x position, use -1 to ignore x position
      y - the client y position, use -1 to ignore y position
      Returns:
      true if the given position is over the given element
    • clearHover

      public static void clearHover(com.google.gwt.dom.client.Element element)
      Clears the elements hover state by removing it from the DOM and re-attaching it.

      Parameters:
      element - the element
    • clearOpacity

      public static void clearOpacity(com.google.gwt.dom.client.Element element)
      Removes the opacity attribute from the element's inline-style.

      Parameters:
      element - the DOM element to manipulate
    • clone

      public static com.google.gwt.dom.client.Element clone(com.google.gwt.dom.client.Element element)
      Clones the given element.

      It creates a new element with the same tag, and sets the class attribute, and sets the innerHTML.

      Parameters:
      element - the element to clone
      Returns:
      the cloned element
    • close

      public static String close(CmsDomUtil.Tag tag)
      Generates a closing tag.

      Parameters:
      tag - the tag to use
      Returns:
      HTML code
    • copyToClipboard

      public static boolean copyToClipboard(String selector)
      Copy the text content of the matching element to the clip-board.

      Parameters:
      selector - the query selector matching the target element
      Returns:
      in case the command was executed successfully
    • createElement

      public static com.google.gwt.dom.client.Element createElement(String html) throws Exception
      This method will create an 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.

      Parameters:
      html - the HTML to use for the element
      Returns:
      the created element
      Throws:
      Exception - if something goes wrong
    • createFaceHtml

      public static String createFaceHtml(String text, String imageClass, com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant align)
      Convenience method to assemble the HTML to use for a button face.

      Parameters:
      text - text the up face text to set, set to null to not show any
      imageClass - the up face image class to use, set to null to not show any
      align - the alignment of the text in reference to the image
      Returns:
      the HTML
    • createIFrameElement

      public static com.google.gwt.dom.client.Element createIFrameElement(String name)
      Creates an iFrame element with the given name attribute.

      Parameters:
      name - the name attribute value
      Returns:
      the iFrame element
    • enclose

      public static String enclose(CmsDomUtil.Tag tag, String text, CmsDomUtil.AttributeValue... attrs)
      Encloses the given text with the given tag.

      Parameters:
      tag - the tag to use
      text - the text to enclose
      attrs - the optional tag attributes
      Returns:
      HTML code
    • ensureJavaScriptIncluded

      public static void ensureJavaScriptIncluded(String javascriptLink)
      Ensures a script tag is present within the window document context.

      Parameters:
      javascriptLink - the link to the java script resource
    • ensureJavaScriptIncluded

      public static void ensureJavaScriptIncluded(String javascriptLink, boolean async)
      Ensures a script tag is present within the window document context.

      Parameters:
      javascriptLink - the link to the java script resource
    • ensureJavaScriptIncluded

      public static void ensureJavaScriptIncluded(String javascriptLink, boolean async, com.google.gwt.core.client.JavaScriptObject callback)
      Ensures a script tag is present within the window document context.

      Parameters:
      javascriptLink - the link to the java script resource
    • ensureMouseOut

      public static void ensureMouseOut(com.google.gwt.dom.client.Element element)
      Triggers a mouse-out event for the given element.

      Useful in case something is capturing all events.

      Parameters:
      element - the element to use
    • ensureMouseOut

      public static void ensureMouseOut(com.google.gwt.event.shared.HasHandlers target)
      Triggers a mouse-out event for the given target.

      Useful in case something is capturing all events.

      Parameters:
      target - the target to use
    • ensureMouseOver

      public static void ensureMouseOver(com.google.gwt.dom.client.Element element)
      Triggers a mouse-over event for the given element.

      Useful in case something is capturing all events.

      Parameters:
      element - the element to use
    • ensureStyleSheetIncluded

      public static void ensureStyleSheetIncluded(String styleSheetLink)
      Checks the window.document for given style-sheet and includes it if required.

      Parameters:
      styleSheetLink - the style-sheet link
    • ensureVisible

      public 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.

      Assuming the scrollbars are on the container element, and that the element is a child of the container element.

      Parameters:
      containerElement - the container element, has to be parent of the element
      element - the element to be seen
      animationTime - the animation time for scrolling, use zero for no animation
    • escapeXml

      public static String escapeXml(String source)
      Escapes a String so it may be printed as text content or attribute value in a HTML page or an XML file.

      This method replaces the following characters in a String:

      • < with &lt;
      • > with &gt;
      • & with &amp;
      • " with &quot;

      Parameters:
      source - the string to escape
      Returns:
      the escaped string
    • fireFocusEvent

      public static void fireFocusEvent(com.google.gwt.user.client.ui.Widget widget)
      Fires a focus event for the given widget.

      Parameters:
      widget - the widget
    • fixFlashZindex

      public 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.

      Parameters:
      element - the element to work on
    • generateHiddenForm

      public static com.google.gwt.dom.client.FormElement generateHiddenForm(String action, CmsDomUtil.Method method, String target, Map<String,String> values)
      Generates a form element with hidden input fields.

      Parameters:
      action - the form action
      method - the form method
      target - the form target
      values - the input values
      Returns:
      the generated form element
    • generateHiddenForm

      public static com.google.gwt.dom.client.FormElement generateHiddenForm(String action, CmsDomUtil.Method method, CmsDomUtil.Target target, Map<String,String> values)
      Generates a form element with hidden input fields.

      Parameters:
      action - the form action
      method - the form method
      target - the form target
      values - the input values
      Returns:
      the generated form element
    • getActiveElement

      public static com.google.gwt.dom.client.Element getActiveElement()
      Returns the currently focused element.

      Returns:
      the currently focused element
    • getAllEditableDataForPage

      Gets the edit data for all oc-editable elements in the page.

      Returns:
      the list of edit data
    • getAncestor

      public static com.google.gwt.dom.client.Element getAncestor(com.google.gwt.dom.client.Element element, String className)
      Returns the given element or it's closest ancestor with the given class.

      Returns null if no appropriate element was found.

      Parameters:
      element - the element
      className - the class name
      Returns:
      the matching element
    • getAncestor

      public 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.

      Returns null if no appropriate element was found.

      Parameters:
      element - the element
      tag - the tag name
      Returns:
      the matching element
    • getAncestor

      public static com.google.gwt.dom.client.Element getAncestor(com.google.gwt.dom.client.Element element, CmsDomUtil.Tag tag, String className)
      Returns the given element or it's closest ancestor with the given tag and class.

      Returns null if no appropriate element was found.

      Parameters:
      element - the element
      tag - the tag name
      className - the class name
      Returns:
      the matching element
    • getCurrentStyle

      public static String getCurrentStyle(com.google.gwt.dom.client.Element element, CmsDomUtil.Style style)
      Returns the computed style of the given element.

      Parameters:
      element - the element
      style - the CSS property
      Returns:
      the currently computed style
    • getCurrentStyleFloat

      public 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.

      Parameters:
      element - the element
      style - the CSS property
      Returns:
      the currently computed style
    • getCurrentStyleInt

      public static int getCurrentStyleInt(com.google.gwt.dom.client.Element element, CmsDomUtil.Style style)
      Returns the computed style of the given element as number.

      Parameters:
      element - the element
      style - the CSS property
      Returns:
      the currently computed style
    • getEditablePosition

      public static CmsPositionBean getEditablePosition(com.google.gwt.dom.client.Element editable)
      Determines the position of the list collector editable content.

      Parameters:
      editable - the editable marker tag
      Returns:
      the position
    • getEffectiveBackgroundColor

      public static String getEffectiveBackgroundColor(com.google.gwt.dom.client.Element element)
      Utility method to determine the effective background color.

      Parameters:
      element - the element
      Returns:
      the background color
    • getElementsByClass

      public static List<com.google.gwt.dom.client.Element> getElementsByClass(String className)
      Returns all elements from the DOM with the given CSS class.

      Parameters:
      className - the class name to look for
      Returns:
      the matching elements
    • getElementsByClass

      public static List<com.google.gwt.dom.client.Element> getElementsByClass(String className, com.google.gwt.dom.client.Element rootElement)
      Returns all elements with the given CSS class including the root element.

      Parameters:
      className - the class name to look for
      rootElement - the root element of the search
      Returns:
      the matching elements
    • getElementsByClass

      public static List<com.google.gwt.dom.client.Element> getElementsByClass(String className, CmsDomUtil.Tag tag)
      Returns all elements from the DOM with the given CSS class and tag name.

      Parameters:
      className - the class name to look for
      tag - the tag
      Returns:
      the matching elements
    • getElementsByClass

      public static List<com.google.gwt.dom.client.Element> getElementsByClass(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.

      Parameters:
      className - the class name to look for
      tag - the tag
      rootElement - the root element of the search
      Returns:
      the matching elements
    • getFirstChildWithClass

      public static com.google.gwt.dom.client.Element getFirstChildWithClass(com.google.gwt.dom.client.Element element, String className)
      Returns the first direct child matching the given class name.

      Parameters:
      element - the parent element
      className - the class name to match
      Returns:
      the child element
    • getHtmlElement

      public static com.google.gwt.dom.client.Element getHtmlElement()
      Gets the root <html> element.
      Returns:
      the html element
    • getIFrameContentHeight

      public static int getIFrameContentHeight(com.google.gwt.dom.client.Element iframe)
      Returns the content height of the given iFrame element.

      Parameters:
      iframe - the iFrame element
      Returns:
      the content height
    • getPosition

      public static int getPosition(com.google.gwt.dom.client.Element e)
      Returns the element position relative to its siblings.

      Parameters:
      e - the element to get the position for
      Returns:
      the position, or -1 if not found
    • getPositioningParent

      public 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.

      Parameters:
      child - the element
      Returns:
      the positioning parent element (may be null)
    • getRelativeX

      public 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.

      Parameters:
      x - the coordinate to use
      target - the element whose coordinate system is to be used
      Returns:
      the relative horizontal position
      See Also:
      • MouseEvent.getRelativeX(com.google.gwt.dom.client.Element)
    • getRelativeY

      public 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.

      Parameters:
      y - the coordinate to use
      target - the element whose coordinate system is to be used
      Returns:
      the relative vertical position
      See Also:
      • MouseEvent.getRelativeY(com.google.gwt.dom.client.Element)
    • getScrollbarWidth

      public static int getScrollbarWidth()
      Measures the scroll bar width.

      Returns:
      the scroll bar width
    • getWindow

      public static com.google.gwt.core.client.JavaScriptObject getWindow()
      Returns the DOM window object.

      Returns:
      the DOM window object
    • getZIndex

      public static String getZIndex(com.google.gwt.dom.client.Style style)
      Returns the Z index from the given style.

      This is a workaround for a bug with Style.getZIndex() which occurs with IE in hosted mode.

      Parameters:
      style - the style object from which the Z index property should be fetched
      Returns:
      the z index
    • hasBackground

      public static boolean hasBackground(com.google.gwt.dom.client.Element element)
      Utility method to determine if the given element has a set background.

      Parameters:
      element - the element
      Returns:
      true if the element has a background set
    • hasBackgroundImage

      public static boolean hasBackgroundImage(com.google.gwt.dom.client.Element element)
      Utility method to determine if the given element has a set background image.

      Parameters:
      element - the element
      Returns:
      true if the element has a background image set
    • hasBorder

      public static boolean hasBorder(com.google.gwt.dom.client.Element element)
      Utility method to determine if the given element has a set border.

      Parameters:
      element - the element
      Returns:
      true if the element has a border
    • hasClass

      public static boolean hasClass(String className, com.google.gwt.dom.client.Element element)
      Indicates if the given element has a CSS class.

      Parameters:
      className - the class name to look for
      element - the element
      Returns:
      true if the element has the given CSS class
    • hasDimension

      public static boolean hasDimension(com.google.gwt.dom.client.Element element)
      Returns if the given element has any dimension.

      All visible elements should have a dimension.

      Parameters:
      element - the element to test
      Returns:
      true if the given element has any dimension
    • isCopyToClipboardSupported

      public static boolean isCopyToClipboardSupported()
      Checks whether the copy command is supported by the client browser.

      Returns:
      true if the copy command is supported
    • isJavaScriptPresent

      public static boolean isJavaScriptPresent(String javascriptLink)
      Checks whether a given script resource is present within the window context.

      Parameters:
      javascriptLink - the resource URL
      Returns:
      true if the script resource is present within the window context
    • makeScrollable

      public static void makeScrollable(com.google.gwt.dom.client.Element elem)
      Gives an element the overflow:auto property.

      Parameters:
      elem - a DOM element
    • makeScrollable

      public static void makeScrollable(com.google.gwt.user.client.ui.Widget widget)
      Gives the element of a widget the overflow:auto property.

      Parameters:
      widget - the widget to make scrollable
    • messagePopupBlocked

      public static String messagePopupBlocked()
      Message accessor.

      Returns:
      the message string
    • messagePopupBlockedTitle

      Message accessor.

      Returns:
      the message string
    • nodeListToList

      public static List<com.google.gwt.dom.client.Element> nodeListToList(com.google.gwt.dom.client.NodeList<com.google.gwt.dom.client.Element> nodelist)
      Converts a NodeList to a List of elements.

      Parameters:
      nodelist - the node list
      Returns:
      the list of elements
    • open

      public static String open(CmsDomUtil.Tag tag, CmsDomUtil.AttributeValue... attrs)
      Generates an opening tag.

      Parameters:
      tag - the tag to use
      attrs - the optional tag attributes
      Returns:
      HTML code
    • openWindow

      public static void openWindow(String url, String name, String features)
      Opens a new browser window. The "name" and "features" arguments are specified here.
      Parameters:
      url - the URL that the new window will display
      name - the name of the window (e.g. "_blank")
      features - the features to be enabled/disabled on this window
    • parseJSON

      public static com.google.gwt.core.client.JavaScriptObject parseJSON(String jsonString)
      Parses the given string into a JSON object.

      Parameters:
      jsonString - the string to parse
      Returns:
      the JSON object
    • positionElement

      public 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.

      Parameters:
      elem - the element to position
      referenceElement - the element relative to which the first element should be positioned
      dx - the x offset relative to the reference element
      dy - the y offset relative to the reference element
    • positionElementInside

      public 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.

      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.

      Parameters:
      element - the child element
      parent - the parent element
      currentIndex - the current index position of the element, use -1 if element is not attached to the parent yet
      x - the client x position, use -1 to ignore x position
      y - the client y position, use -1 to ignore y position
      Returns:
      the new index position
    • querySelector

      public static com.google.gwt.dom.client.Element querySelector(String selector, com.google.gwt.dom.client.Element context)
      Returns the first element matching the given CSS selector.

      Parameters:
      selector - the CSS selector
      context - the context element, may be null
      Returns:
      the matching element
    • querySelectorAll

      public static com.google.gwt.dom.client.NodeList<com.google.gwt.dom.client.Element> querySelectorAll(String selector, com.google.gwt.dom.client.Element context)
      Returns a list of elements matching the given CSS selector.

      Parameters:
      selector - the CSS selector
      context - the context element, may be null
      Returns:
      the list of matching elements
    • removeDisablingOverlay

      public static void removeDisablingOverlay(com.google.gwt.dom.client.Element element)
      Removes any present overlay from the element and it's children.

      Parameters:
      element - the element
    • removeScriptTags

      public static com.google.gwt.dom.client.Element removeScriptTags(com.google.gwt.dom.client.Element element)
      Removes all script tags from the given element.

      Parameters:
      element - the element to remove the script tags from
      Returns:
      the resulting element
    • removeScriptTags

      public static String removeScriptTags(String source)
      Removes all script tags from the given string.

      Parameters:
      source - the source string
      Returns:
      the resulting string
    • resizeAncestor

      public static void resizeAncestor(com.google.gwt.user.client.ui.Widget parent)
      Calls I_CmsDescendantResizeHandler.onResizeDescendant() on the closest resizable ancestor.

      Parameters:
      parent - the parent widget
    • safeLoadStylesheets

      public static void safeLoadStylesheets(String[] stylesheets, com.google.gwt.core.client.JavaScriptObject callback)
      Loads a list of stylesheets and invokes a Javascript callback after everything has been loaded.

      Parameters:
      stylesheets - the array of stylesheet uris
      callback - the callback to call after everything is loaded
    • setAttribute

      public static void setAttribute(com.google.gwt.core.client.JavaScriptObject jso, String key, com.google.gwt.core.client.JavaScriptObject value)
      Sets an attribute on a Javascript object.

      Parameters:
      jso - the Javascript object
      key - the attribute name
      value - the new attribute value
    • setAttribute

      public static void setAttribute(com.google.gwt.core.client.JavaScriptObject jso, String key, String value)
      Sets an attribute on a Javascript object.

      Parameters:
      jso - the Javascript object
      key - the attribute name
      value - the new attribute value
    • setStylesheetText

      public static void setStylesheetText(String id, String styleText)
      Sets the stylesheet text for the stylesheet with the given ID.

      If the stylesheet with the id does not already exist, it is created.

      Parameters:
      id - the stylesheet id
      styleText - the stylesheet text
    • showOverlay

      public static void showOverlay(com.google.gwt.dom.client.Element element, boolean show)
      Sets a CSS class to show or hide a given overlay. Will not add an overlay to the element.

      Parameters:
      element - the parent element of the overlay
      show - true to show the overlay
    • showPopupBlockerMessage

      public static void showPopupBlockerMessage()
      Shows a message that a popup was blocked.

    • stripHtml

      public static String stripHtml(String html)
      Returns the text content to any HTML.
      Parameters:
      html - the HTML
      Returns:
      the text content
    • updateStyle

      public static Map<String,String> updateStyle(com.google.gwt.dom.client.Style style, Map<String,String> properties)
      Updates a set of style properties on the given style object, and returns a map with the previous values. If a value in the map is null, it is interpreted as clearing the style property with that name.
      Parameters:
      style - the style object to update
      properties - the map of properties to change
      Returns:
      the map of previous values of the given properties
    • wrapScrollable

      public static com.google.gwt.user.client.ui.FlowPanel wrapScrollable(com.google.gwt.user.client.ui.Widget widget)
      Wraps a widget in a scrollable FlowPanel.

      Parameters:
      widget - the original widget
      Returns:
      the wrapped widget