Created
December 18, 2015 14:09
-
-
Save bduisenov/c5ac3ea376fd8396184f to your computer and use it in GitHub Desktop.
gwt jsinterop for jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.gwt.dom.client.Element; | |
import jsinterop.annotations.JsFunction; | |
import jsinterop.annotations.JsMethod; | |
import jsinterop.annotations.JsPackage; | |
import jsinterop.annotations.JsType; | |
/** | |
* Created by bduisenov on 27/10/15. | |
*/ | |
@JsType(namespace = JsPackage.GLOBAL, name = "jQuery", isNative = true) | |
public class jQuery { | |
@FunctionalInterface | |
@JsFunction | |
public interface func { | |
void apply(); | |
} | |
@FunctionalInterface | |
@JsFunction | |
public interface func1 { | |
void apply(String val); | |
} | |
public native void click(func func); | |
public native jQuery keypress(func func); | |
public native jQuery keydown(func func); | |
public native jQuery keyup(func func); | |
public native jQuery focus(); | |
public native void change(func func); | |
public native jQuery on(String action, func func); | |
public native jQuery filter(String predicate); | |
public native String val(); | |
public native void val(String val); | |
public native String text(); | |
public native void text(String text); | |
public native jQuery append(String html); | |
public native jQuery append(jQuery jq); | |
public native jQuery before(Element element); | |
public native jQuery before(jQuery jq); | |
public native jQuery children(); | |
public native jQuery first(); | |
public native jQuery append(Element jq); | |
public native jQuery remove(); | |
public native jQuery hide(); | |
public native jQuery hide(int duration); | |
public native jQuery hide(int duration, func complete); | |
public native jQuery show(); | |
public native jQuery show(int duration); | |
public native jQuery show(int duration, func complete); | |
public native boolean is(String selector); | |
public native String css(String propertyName); | |
public native String css(String propertyName, String val); | |
public native jQuery addClass(String val); | |
public native jQuery removeClass(String val); | |
public native jQuery toggleClass(String val); | |
public native jQuery toggleClass(String val, boolean state); | |
public native boolean hasClass(String val); | |
public native String attr(String name); | |
public native jQuery attr(String name, String val); | |
public native jQuery fadeIn(int duration); | |
public native jQuery fadeIn(int duration, func onComplete); | |
public native jQuery fadeOut(int duration); | |
public native jQuery fadeOut(int duration, func onComplete); | |
public native jQuery width(String val); | |
public native jQuery width(int val); | |
public native int width(); | |
public native jQuery find(String selector); | |
public native String html(); | |
public native jQuery html(String html); | |
@JsType(namespace = "jQuery", name = "Deferred", isNative = true) | |
public static class Deferred { | |
public native Deferred done(func func); | |
public native Deferred fail(func func); | |
public native Deferred reject(); | |
public native Deferred then(func doneCallbacks, func failCallbacks); | |
public native String state(); | |
public native Deferred always(func func); | |
public native Deferred resolve(String val); | |
public native Deferred resolve(); | |
} | |
public static class Alias { | |
@JsMethod(namespace = JsPackage.GLOBAL, name = "jQuery") | |
public static native jQuery $(String selector); | |
@JsMethod(namespace = JsPackage.GLOBAL, name = "jQuery") | |
public static native jQuery $(jQuery element); | |
@JsMethod(namespace = JsPackage.GLOBAL, name = "jQuery") | |
public static native jQuery $(Element element); | |
@JsMethod(namespace = JsPackage.GLOBAL, name = "jQuery") | |
public static native jQuery $(String selector, jQuery context); | |
@JsMethod(namespace = JsPackage.GLOBAL, name = "jQuery") | |
public static native jQuery $(String selector, Element context); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment