All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.swm.gwt.client.responsive.JsMatchMedia Maven / Gradle / Ivy

There is a newer version: 3.1
Show newest version
package de.swm.gwt.client.responsive;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.event.shared.HandlerRegistration;

/**
 * @author Ed Bras
 */
class JsMatchMedia extends JavaScriptObject implements IMatchMedia {

	// Required by GWT.
	protected JsMatchMedia() {
	}

	public final HandlerRegistration addMatchMediaChangeHandler(IMatchMediaChangeHandler handler) {
		return (handler == null) ? null : addHandler(handler);
	}

	// @formatter:off
	public final native boolean hasMatch() /*-{
        return this.matches;
    }-*/;

	public final native String getMedia() /*-{
        return this.media;
    }-*/;

	private void forward(IMatchMediaChangeHandler handler) {
		handler.onMatchMediaChange(this);
	}

	private native JsHandlerRegistration addHandler(IMatchMediaChangeHandler handler) /*-{
        func = function (matchMedia) {
            [email protected]::onMatchMediaChange(Lde/swm/gwt/client/responsive/IMatchMedia;)(matchMedia);
        }
        this.addListener(func);
        return {callback: func, match: this};
    }-*/;
	// @formatter:on

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy