diff options
author | Manuel Carrasco Moñino <manuel.carrasco.m@gmail.com> | 2014-02-08 14:09:04 +0100 |
---|---|---|
committer | Manuel Carrasco Moñino <manuel.carrasco.m@gmail.com> | 2014-02-08 14:09:04 +0100 |
commit | 7296cef85e2f6fafd7e1d75253a125a868ec4d3a (patch) | |
tree | a1e25a5e2f59335f20e0f0171c1e071218d04663 | |
parent | ba1a17c85f7b56cd97e1dc85d7c9eabb0f643bf9 (diff) | |
download | gwtquery-7296cef85e2f6fafd7e1d75253a125a868ec4d3a.tar.gz gwtquery-7296cef85e2f6fafd7e1d75253a125a868ec4d3a.zip |
Adding support for triggering browser native events. Fixes issue #171
-rw-r--r-- | gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java | 32 | ||||
-rw-r--r-- | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java | 12 |
2 files changed, 27 insertions, 17 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java index bd29b38c..220ec36b 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java @@ -13,24 +13,22 @@ */ package com.google.gwt.query.client; +import static com.google.gwt.query.client.plugins.QueuePlugin.*; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; import com.google.gwt.core.client.JsArrayMixed; import com.google.gwt.core.client.JsArrayString; import com.google.gwt.core.client.ScriptInjector; -import com.google.gwt.dom.client.BodyElement; -import com.google.gwt.dom.client.ButtonElement; -import com.google.gwt.dom.client.Document; -import com.google.gwt.dom.client.Element; -import com.google.gwt.dom.client.InputElement; -import com.google.gwt.dom.client.Node; -import com.google.gwt.dom.client.NodeList; -import com.google.gwt.dom.client.OptionElement; -import com.google.gwt.dom.client.SelectElement; +import com.google.gwt.dom.client.*; import com.google.gwt.dom.client.Style.Display; import com.google.gwt.dom.client.Style.HasCssName; -import com.google.gwt.dom.client.TextAreaElement; import com.google.gwt.query.client.css.CSS; import com.google.gwt.query.client.css.HasCssValue; import com.google.gwt.query.client.css.TakesCssValue; @@ -62,13 +60,6 @@ import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.IsWidget; import com.google.gwt.user.client.ui.Widget; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import static com.google.gwt.query.client.plugins.QueuePlugin.Queue; - /** * GwtQuery is a GWT clone of the popular jQuery library. */ @@ -4469,6 +4460,13 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> { } /** + * Trigger a browser native event on each matched element. + */ + public GQuery trigger(NativeEvent event) { + return as(Events).trigger(event, new Function[] {}); + } + + /** * Trigger a set of events on each matched element. * * For keyboard events you can pass a second parameter which represents the key-code of the pushed diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java index e3642dec..c89cf884 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java @@ -17,6 +17,7 @@ import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.FormElement; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.Node; +import com.google.gwt.event.dom.client.HasNativeEvent; import com.google.gwt.query.client.Function; import com.google.gwt.query.client.GQuery; import com.google.gwt.query.client.js.JsUtils; @@ -261,6 +262,17 @@ public class Events extends GQuery { } /** + * Trigger a native event in all matched elements. + * + * @param nativeEvent the browser native event. + * @functions a set of function to run if the event is not canceled. + */ + public Events trigger(NativeEvent nativeEvent, Function... functions) { + dispatchEvent(nativeEvent, null, functions); + return this; + } + + /** * Trigger a html event in all matched elements. * * @param htmlEvent A string representing the desired html event. |