* @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);
}
/**
}
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);
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];
}
public boolean isTypeOf(String eName) {
- return eventName != null ? eventName.equalsIgnoreCase(eName) : false;
+ return eventName != null && eventName.equalsIgnoreCase(eName);
}
/**
}
@Override
- public boolean fire(Event event, Object[] eventDatas) {
+ public boolean fire(Event event, Object[] eventData) {
if (isEmpty()) {
return true;
}
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;
}
}
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();
}