Package org.opencms.gwt.client.util
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
CmsMediaQuery()
Hidden constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(java.util.function.Consumer<java.lang.Boolean> callback)
Adds a listener to detect when the matching state of the media query changes.boolean
matches()
Checks if the media query matches.static CmsMediaQuery
parse(java.lang.String text)
Creates a new instance using the given media query rule.
-
-
-
Constructor Detail
-
CmsMediaQuery
protected CmsMediaQuery()
Hidden constructor.
-
-
Method Detail
-
parse
public static CmsMediaQuery parse(java.lang.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(java.util.function.Consumer<java.lang.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
-
-