From 2e783da49474361b45c7c0bbb952502649f52c83 Mon Sep 17 00:00:00 2001 From: jdramaix Date: Thu, 21 Nov 2013 17:50:36 +0100 Subject: [PATCH] code review --- .../com/google/gwt/query/client/GQuery.java | 1 - .../gwt/query/client/plugins/Events.java | 5 +--- .../client/plugins/events/EventsListener.java | 26 +++++++++---------- 3 files changed, 14 insertions(+), 18 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 fac71b39..5950f6bf 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 @@ -1319,7 +1319,6 @@ public class GQuery implements Lazy { } } - /** * Bind a set of functions to the blur event of each matched element. Or trigger the blur event if * no functions are provided. 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 79b1d12c..e5552e3c 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 @@ -267,7 +267,7 @@ public class Events extends GQuery { * @functions a set of function to run if the event is not canceled. */ public Events triggerHtmlEvent(String htmlEvent, final Function... functions) { - return triggerHtmlEvent(htmlEvent, functions, null); + return triggerHtmlEvent(htmlEvent, null, functions); } /** @@ -384,9 +384,6 @@ public class Events extends GQuery { } private void callHandlers(Element e, NativeEvent evt, Function... functions){ - if (functions == null) { - return; - } for (Function f : functions) { f.setEvent(Event.as(evt)); f.f(e); 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 cde18e47..baf72679 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 @@ -141,19 +141,19 @@ public class EventsListener implements EventListener { Object[] arguments = new Object[0]; // The argument of the function will be first the data attached to the handler then the - // datas attached to the event. + // data attached to the event. if (eventData != null) { if (data != null){ - Object[] handlerDatas; + Object[] handlerData; if (data.getClass().isArray()) { - handlerDatas = (Object[]) data; + handlerData = (Object[]) data; } else { - handlerDatas = new Object[] {data}; + handlerData = new Object[] {data}; } - arguments = new Object[handlerDatas.length + eventData.length]; + arguments = new Object[handlerData.length + eventData.length]; int index = 0; - for (int i = 0; i < handlerDatas.length; i++, index++) { - arguments[index] = handlerDatas[i]; + for (int i = 0; i < handlerData.length; i++, index++) { + arguments[index] = handlerData[i]; } for (int i = 0; i < eventData.length; i++, index++) { arguments[index] = eventData[i]; @@ -175,7 +175,7 @@ public class EventsListener implements EventListener { } public boolean isTypeOf(String eName) { - return eventName != null ? eventName.equalsIgnoreCase(eName) : false; + return eventName != null && eventName.equalsIgnoreCase(eName); } /** @@ -248,7 +248,7 @@ public class EventsListener implements EventListener { } @Override - public boolean fire(Event event, Object[] eventDatas) { + public boolean fire(Event event, Object[] eventData) { if (isEmpty()) { return true; } @@ -298,8 +298,8 @@ public class EventsListener implements EventListener { if (stopElement == null || element.equals(stopElement)) { gqEvent.setCurrentElementTarget(element); // data - eventDatas = $(element).data("___event_datas"); - if (!f.fire(gqEvent, eventDatas)) { + eventData = $(element).data("___event_datas"); + if (!f.fire(gqEvent, eventData)) { stopElement = element; } } @@ -606,13 +606,13 @@ public class EventsListener implements EventListener { String ename = event.getType(); int etype = getTypeInt(ename); String originalEventType = GqEvent.getOriginalEventType(event); - Object[] handlerDatas = $(element).data("___event_datas"); + Object[] handlerData = $(element).data("___event_datas"); for (int i = 0, l = elementEvents.length(); i < l; i++) { BindFunction listener = elementEvents.get(i); if (listener != null && (listener.hasEventType(etype) || listener.isTypeOf(ename)) && (originalEventType == null || originalEventType.equals(listener.getOriginalEventType()))) { - if (!listener.fire(event, handlerDatas)) { + if (!listener.fire(event, handlerData)) { event.stopPropagation(); event.preventDefault(); } -- 2.39.5