diff options
author | Manolo Carrasco <manolo@apache.org> | 2014-12-21 10:45:35 +0100 |
---|---|---|
committer | Manolo Carrasco <manolo@apache.org> | 2014-12-21 10:45:35 +0100 |
commit | a8511be680e954b370123bd4710dad29e220348d (patch) | |
tree | d54e4a16060e9e70882aae1fcc1eda1a36977ceb /gwtquery-core/src | |
parent | 3019c9d1418d51d78f6852df8fc4dafd78b6b57f (diff) | |
download | gwtquery-a8511be680e954b370123bd4710dad29e220348d.tar.gz gwtquery-a8511be680e954b370123bd4710dad29e220348d.zip |
make hasHandlers public so as it can be used in plugins
Diffstat (limited to 'gwtquery-core/src')
-rw-r--r-- | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java | 35 |
1 files changed, 18 insertions, 17 deletions
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 a9dae295..a7a65b43 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 @@ -142,13 +142,7 @@ public class EventsListener implements EventListener { @Override public boolean hasHandlers(EventsListener l) { - for (int i = 0, j = l.elementEvents.length(); i < j; i++) { - BindFunction function = l.elementEvents.get(i); - if (function.isTypeOf(delegateType)) { - return true; - } - } - return false; + return l.hasHandlers(BITLESS, type); } } @@ -732,15 +726,9 @@ public class EventsListener implements EventListener { } public void unbind(int eventbits, String namespace, String eventName, Function f) { - elementEvents = unbindFunctions(elementEvents, eventbits, namespace, eventName, f); - } - - public static JsObjectArray<BindFunction> unbindFunctions(JsObjectArray<BindFunction> list, - int eventbits, String namespace, String eventName, Function f) { JsObjectArray<BindFunction> newList = JsObjectArray.createArray().cast(); - for (int i = 0; i < list.length(); i++) { - BindFunction listener = list.get(i); - + for (int i = 0; i < elementEvents.length(); i++) { + BindFunction listener = elementEvents.get(i); boolean matchNS = isNullOrEmpty(namespace) || listener.nameSpace.equals(namespace); boolean matchEV = eventbits <= 0 || listener.hasEventType(eventbits); boolean matchEVN = matchEV || listener.isTypeOf(eventName); @@ -753,10 +741,23 @@ public class EventsListener implements EventListener { continue; } } - newList.add(listener); } - return newList; + elementEvents = newList; + } + + /** + * Return true if the element is listening for the + * given eventBit or eventName. + */ + public boolean hasHandlers(int eventBits, String eventName) { + for (int i = 0, j = elementEvents.length(); i < j; i++) { + BindFunction function = elementEvents.get(i); + if (function.hasEventType(eventBits) || function.isTypeOf(eventName)) { + return true; + } + } + return false; } private static boolean isNullOrEmpty(String s) { |