public GQuery die(int eventbits, String nameSpace) {
EventsListener.getInstance(Element.is(currentContext) ? (Element) currentContext : body).die(
- eventbits, nameSpace, currentSelector);
+ eventbits, nameSpace, null, currentSelector);
return this;
}
public GQuery live(int eventbits, String nameSpace, final Object data, Function... funcs) {
EventsListener.getInstance(Element.is(currentContext) ? (Element) currentContext : body).live(
- eventbits, nameSpace, currentSelector, data, funcs);
+ eventbits, nameSpace, null, currentSelector, data, funcs);
return this;
}
/**
* Remove the BindFunction associated to this cssSelector
*/
- public void removeBindFunctionForSelector(String cssSelector, String nameSpace) {
- if (nameSpace == null || nameSpace.length() == 0) {
+ public void removeBindFunctionForSelector(String cssSelector, String nameSpace, String originalEventName) {
+ if (nameSpace == null && originalEventName == null) {
bindFunctionBySelector.delete(cssSelector);
} else {
JsObjectArray<BindFunction> functions = bindFunctionBySelector.get(cssSelector);
for (int i = 0; i < functions.length(); i++) {
BindFunction f = functions.get(i);
- if (!nameSpace.equals(f.nameSpace)) {
+ boolean matchNamespace = nameSpace == null || nameSpace.equals(f.nameSpace);
+ boolean matchOriginalEventName = originalEventName == null || originalEventName.equals(f.originalEventType);
+
+ if (!matchNamespace || !matchOriginalEventName) {
newFunctions.add(f);
}
}
eventName = subparts[0];
}
+
+ //handle special event like mouseenter or mouseleave
+ SpecialEvent hook = special.get(eventName);
+ eventName = hook != null ? hook.getDelegateType() : eventName;
+ String originalEventName = hook != null ? hook.getOriginalType() : null;
+
int b = getTypeInt(eventName);
- die(b, nameSpace, cssSelector);
+ die(b, nameSpace, originalEventName, cssSelector);
}
}
- public void die(int eventbits, String nameSpace, String cssSelector) {
+ public void die(int eventbits, String nameSpace, String originalEventName,String cssSelector) {
if (eventbits <= 0) {
for (String k : liveBindFunctionByEventType.keys()) {
LiveBindFunction liveBindFunction = liveBindFunctionByEventType.<JsCache> cast().get(k);
- liveBindFunction.removeBindFunctionForSelector(cssSelector, nameSpace);
+ liveBindFunction.removeBindFunctionForSelector(cssSelector, nameSpace, null);
}
} else {
LiveBindFunction liveBindFunction = liveBindFunctionByEventType.get(eventbits);
if (liveBindFunction != null) {
- liveBindFunction.removeBindFunctionForSelector(cssSelector, nameSpace);
+ liveBindFunction.removeBindFunctionForSelector(cssSelector, nameSpace, originalEventName);
}
}
}
eventName = subparts[0];
}
+ //handle special event like mouseenter or mouseleave
+ SpecialEvent hook = special.get(eventName);
+ eventName = hook != null ? hook.getDelegateType() : eventName;
+ String originalEventName = hook != null ? hook.getOriginalType() : null;
+
int b = getTypeInt(eventName);
for (Function function : funcs) {
- //Function handler = hook != null ? hook.createDelegateHandler(function) : function;
- live(b, nameSpace, cssSelector, data, function);
+ Function handler = hook != null ? hook.createDelegateHandler(function) : function;
+ live(b, nameSpace, originalEventName, cssSelector, data, handler);
}
}
}
- public void live(int eventbits, String nameSpace, String cssSelector, Object data, Function... funcs) {
+ public void live(int eventbits, String nameSpace, String originalEventName, String cssSelector, Object data, Function... funcs) {
for (int i = 0; i < 28; i++) {
int event = (int) Math.pow(2, i);
if ((eventbits & event) == event) {
}
for (Function f : funcs) {
- // TODO handle special event by passing original event name
liveBindFunction.addBindFunctionForSelector(cssSelector, new BindFunction(event, nameSpace,
- null, f, data));
+ originalEventName, f, data));
}
}
}