diff options
author | Manolo Carrasco <manolo@apache.org> | 2014-12-30 13:52:32 +0100 |
---|---|---|
committer | Manolo Carrasco <manolo@apache.org> | 2014-12-30 13:52:32 +0100 |
commit | 37cff9a5acb515c13b299b842971bb1d128a4359 (patch) | |
tree | 812bb9236416a57440ec7ffdc9cb4b3dd193ac57 /gwtquery-core/src | |
parent | e4ea1388ed6ac6ee6d1ab594202da418110cdbc8 (diff) | |
download | gwtquery-37cff9a5acb515c13b299b842971bb1d128a4359.tar.gz gwtquery-37cff9a5acb515c13b299b842971bb1d128a4359.zip |
Change EvPart name, remove focusin/focusout aliases.
Diffstat (limited to 'gwtquery-core/src')
4 files changed, 14 insertions, 39 deletions
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 d7f7e7df..55190938 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 @@ -21,7 +21,7 @@ import com.google.gwt.query.client.Function; import com.google.gwt.query.client.GQuery; import com.google.gwt.query.client.js.JsUtils; import com.google.gwt.query.client.plugins.events.EventsListener; -import com.google.gwt.query.client.plugins.events.EventsListener.EvPart; +import com.google.gwt.query.client.plugins.events.EventsListener.EventName; import com.google.gwt.user.client.Event; /** @@ -300,7 +300,7 @@ public class Events extends GQuery { * @param functions a set of function to run. */ public Events triggerHtmlEvent(String htmlEvent, Object[] datas, final Function... functions) { - for (EvPart part : EvPart.split(htmlEvent)) { + for (EventName part : EventName.split(htmlEvent)) { NativeEvent e = document.createHtmlEvent(part.eventName, true, true); JsUtils.prop(e, "namespace", part.nameSpace); if ("submit".equals(part.eventName)){ diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java index a6e5912e..f6f2113a 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java @@ -34,6 +34,7 @@ import com.google.gwt.user.client.EventListener; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Map; /** * This class implements an event queue instance for one Element. The queue instance is configured @@ -73,22 +74,22 @@ public class EventsListener implements EventListener { /** * Utility class to split a list of events with or without namespaces */ - public static class EvPart { + public static class EventName { public final String nameSpace; public final String eventName; - public EvPart(String n, String e) { + public EventName(String n, String e) { nameSpace = n; eventName = e; } - public static List<EvPart> split(String events) { - List<EvPart> ret = new ArrayList<EvPart>(); + public static List<EventName> split(String events) { + List<EventName> ret = new ArrayList<EventName>(); String[] parts = events.split("[\\s,]+"); for (String event : parts) { String[] tmp = event.split("\\.", 2); String eventName = tmp[0]; String nameSpace = tmp.length > 1 ? tmp[1] : null; - ret.add(new EvPart(nameSpace, eventName)); + ret.add(new EventName(nameSpace, eventName)); } return ret; } @@ -354,18 +355,14 @@ public class EventsListener implements EventListener { public static String MOUSEENTER = "mouseenter"; public static String MOUSELEAVE = "mouseleave"; - public static String FOCUSIN = "focusin"; - public static String FOCUSOUT = "focusout"; - public static HashMap<String, SpecialEvent> special; + public static Map<String, SpecialEvent> special; static { // Register some special events which already exist in jQuery special = new HashMap<String, SpecialEvent>(); special.put(MOUSEENTER, new MouseSpecialEvent(MOUSEENTER, "mouseover")); special.put(MOUSELEAVE, new MouseSpecialEvent(MOUSELEAVE, "mouseout")); - special.put(FOCUSIN, new DefaultSpecialEvent(FOCUSIN, "focus")); - special.put(FOCUSOUT, new DefaultSpecialEvent(FOCUSOUT, "blur")); } public static void clean(Element e) { @@ -470,7 +467,7 @@ public class EventsListener implements EventListener { unbind(events, null); } - for (EvPart ev : EvPart.split(events)) { + for (EventName ev : EventName.split(events)) { SpecialEvent hook = special.get(ev.eventName); boolean bind = hook == null || hook.setup(element) == false; for (Function function : funcs) { @@ -491,7 +488,7 @@ public class EventsListener implements EventListener { } public void die(String events, String cssSelector) { - for (EvPart ev : EvPart.split(events)) { + for (EventName ev : EventName.split(events)) { SpecialEvent hook = special.get(ev.eventName); boolean unbind = hook == null || hook.tearDown(element) == false; if (unbind) { @@ -582,7 +579,7 @@ public class EventsListener implements EventListener { } public void live(String events, String cssSelector, Object data, Function... funcs) { - for (EvPart ev : EvPart.split(events)) { + for (EventName ev : EventName.split(events)) { SpecialEvent hook = special.get(ev.eventName); boolean bind = hook == null || hook.setup(element) == false; for (Function function : funcs) { @@ -708,7 +705,7 @@ public class EventsListener implements EventListener { } public void unbind(String events, Function f) { - for (EvPart ev : EvPart.split(events)) { + for (EventName ev : EventName.split(events)) { SpecialEvent hook = special.get(ev.eventName); boolean unbind = hook == null || hook.tearDown(element) == false; if (unbind) { diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/SpecialEvent.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/SpecialEvent.java index cc4020b9..8083b098 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/SpecialEvent.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/SpecialEvent.java @@ -112,4 +112,4 @@ public interface SpecialEvent { * before calling remove. */ boolean tearDown(Element e); -}
\ No newline at end of file +} diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java index 0ad8ae40..315999a1 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java @@ -455,28 +455,6 @@ public class GQueryEventsTestGwt extends GWTTestCase { assertEquals("", $("p", e).css("border", false)); } - @DoNotRunWith({Platform.HtmlUnitLayout}) - public void testSpecialFocusInOut() { - $(e).html("<p>Content</p>"); - $("p", e).on(EventsListener.FOCUSIN, new Function() { - public void f(Element elem) { - GQuery.console.log("focus"); - $(elem).css("background-color", "red"); - } - }); - $("p", e).focus(); - assertEquals("red", $("p", e).css("background-color", false)); - - // blur - $("p", e).on(EventsListener.FOCUSOUT, new Function() { - public void f(Element elem) { - $(elem).css("background-color", "white"); - } - }); - $("p", e).blur(); - assertEquals("white", $("p", e).css("background-color", false)); - } - public void testLazyMethods() { $(e).css(CSS.COLOR.with(RGBColor.WHITE)); assertEquals("white", $(e).css("color", false)); |