Package org.opencms.gwt.client.util
Class CmsMediaQuery
java.lang.Object
com.google.gwt.core.client.JavaScriptObject
org.opencms.gwt.client.util.CmsMediaQuery
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
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
addListener
(Consumer<Boolean> callback) Adds a listener to detect when the matching state of the media query changes.final boolean
matches()
Checks if the media query matches.static CmsMediaQuery
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
-
Constructor Details
-
CmsMediaQuery
protected CmsMediaQuery()Hidden constructor.
-
-
Method Details
-
parse
Creates a new instance using the given media query rule.- Parameters:
text
- the rule text- Returns:
- the new media query
-
addListener
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
Checks if the media query matches.- Returns:
- true if the media query matches
-