Class CmsDomUtil


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

    Since:
    8.0.0
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addDisablingOverlay​(com.google.gwt.dom.client.Element element)
      Adds an overlay div to the element.
      static void addDynamicStyleRule​(java.lang.String rule)
      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 java.lang.String close​(CmsDomUtil.Tag tag)
      Generates a closing tag.
      static boolean copyToClipboard​(java.lang.String selector)
      Copy the text content of the matching element to the clip-board.
      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 ensureJavaScriptIncluded​(java.lang.String javascriptLink, boolean async)
      Ensures a script tag is present within the window document context.
      static void ensureJavaScriptIncluded​(java.lang.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 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 java.lang.String escapeXml​(java.lang.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​(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.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.Element getActiveElement()
      Returns the currently focused element.
      static java.util.List<CmsEditableDataJSO> getAllEditableDataForPage()
      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, java.lang.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, java.lang.String className)
      Returns the given element or it's closest ancestor with the given tag and 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, com.google.gwt.dom.client.Element rootElement)
      Returns all elements with the given CSS class including the root element.
      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 com.google.gwt.dom.client.Element getFirstChildWithClass​(com.google.gwt.dom.client.Element element, java.lang.String className)
      Returns the first direct child matching the given class name.
      static com.google.gwt.dom.client.Element getHtmlElement()
      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 getScrollbarWidth()
      Measures the scroll bar width.
      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 isCopyToClipboardSupported()
      Checks whether the copy command is supported by the client browser.
      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.util.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 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 com.google.gwt.dom.client.Element querySelector​(java.lang.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​(java.lang.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 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_CmsDescendantResizeHandler.onResizeDescendant() on the closest resizable ancestor.
      static void safeLoadStylesheets​(java.lang.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, 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 setStylesheetText​(java.lang.String id, java.lang.String styleText)
      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 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 java.util.Map<java.lang.String,​java.lang.String> updateStyle​(com.google.gwt.dom.client.Style style, java.util.Map<java.lang.String,​java.lang.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 Detail

      • 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​(java.lang.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 java.lang.String close​(CmsDomUtil.Tag tag)
        Generates a closing tag.

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

        public static boolean copyToClipboard​(java.lang.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​(java.lang.String html)
                                                               throws java.lang.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:
        java.lang.Exception - if something goes wrong
      • createFaceHtml

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

        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​(java.lang.String name)
        Creates an iFrame element with the given name attribute.

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

        public static java.lang.String enclose​(CmsDomUtil.Tag tag,
                                               java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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 java.lang.String escapeXml​(java.lang.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​(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.

        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​(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.

        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
      • getAncestor

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

        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,
                                                                    java.lang.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 java.lang.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 java.lang.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 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.

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

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

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

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

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

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

        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,
                                                                               java.lang.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 java.lang.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​(java.lang.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​(java.lang.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 java.lang.String messagePopupBlocked()
        Message accessor.

        Returns:
        the message string
      • messagePopupBlockedTitle

        public static java.lang.String messagePopupBlockedTitle()
        Message accessor.

        Returns:
        the message string
      • nodeListToList

        public static java.util.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 java.lang.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​(java.lang.String url,
                                      java.lang.String name,
                                      java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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 java.lang.String removeScriptTags​(java.lang.String source)
        Removes all script tags from the given string.

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

        public static void safeLoadStylesheets​(java.lang.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,
                                        java.lang.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,
                                        java.lang.String key,
                                        java.lang.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​(java.lang.String id,
                                             java.lang.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
      • stripHtml

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

        public static java.util.Map<java.lang.String,​java.lang.String> updateStyle​(com.google.gwt.dom.client.Style style,
                                                                                         java.util.Map<java.lang.String,​java.lang.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