Class CmsMediaQuery

java.lang.Object
com.google.gwt.core.client.JavaScriptObject
org.opencms.gwt.client.util.CmsMediaQuery

public final class CmsMediaQuery extends com.google.gwt.core.client.JavaScriptObject
GWT wrapper for programmatic media query checking.

An instance of this class can be created from the media query rule text usign the parse() method. Checking if the media query applies can be either done using the matches() method, or by adding a listener with the addListener method if you need to keep track of changes.

  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Hidden constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    Adds a listener to detect when the matching state of the media query changes.
    final boolean
    Checks if the media query matches.
    parse(String text)
    Creates a new instance using the given media query rule.

    Methods inherited from class com.google.gwt.core.client.JavaScriptObject

    cast, createArray, createArray, createFunction, createObject, equals, hashCode, toSource, toString

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

  • Method Details

    • parse

      public static CmsMediaQuery parse(String text)
      Creates a new instance using the given media query rule.
      Parameters:
      text - the rule text
      Returns:
      the new media query
    • addListener

      public final void addListener(Consumer<Boolean> callback)
      Adds a listener to detect when the matching state of the media query changes.
      Parameters:
      callback - the callback to call with the matching state as a parameter
    • matches

      public final boolean matches()
      Checks if the media query matches.
      Returns:
      true if the media query matches