Skip to content
Browse files

enhance helperh & eventtargeth

  • Loading branch information...
1 parent 9c5ee1d commit 49a34bee47f090d932455d01357d35c8c9b7374a @akira-cn akira-cn committed Mar 21, 2012
Showing with 10 additions and 8 deletions.
  1. +1 −1 resource/js/core/helper.h.js
  2. +9 −7 resource/js/dom/eventtarget.h.js
View
2 resource/js/core/helper.h.js
@@ -54,7 +54,7 @@
fn = helper[i];
if(fn instanceof Function){
if (typeof wrapType != 'string') {
- wrapType = wrapConfig[i] || '';
+ wrapType = wrapConfig[i] || wrapConfig['*'] || '';
}
if ('queryer' == wrapType) { //如果方法返回查询结果,对返回值进行包装
ret[i] = FunctionH.rwrap(fn, wrapper, "returnValue");
View
16 resource/js/dom/eventtarget.h.js
@@ -93,7 +93,7 @@
function listener(el, sEvent, handler, userEventName) {
return Cache.get(el, sEvent + (userEventName ? '.' + userEventName : ''), handler) || function(e) {
//如果有hook并且hook没有返回false的话
- if (!userEventName || userEventName && EventTargetH._EventHooks[userEventName][sEvent](el, e)) {
+ if (!userEventName || userEventName && EventTargetH._EventHooks[userEventName][sEvent](el, e, handler)) {
return fireHandler(el, e, handler, sEvent); //继续fire
}
};
@@ -127,7 +127,7 @@
}
elements = QW.Selector.filter(elements, selector, el);
for (var i = 0, l = elements.length; i < l; ++i) {
- if (!userEventName || userEventName && EventTargetH._DelegateHooks[userEventName][sEvent](elements[i], e || window.event)) {
+ if (!userEventName || userEventName && EventTargetH._DelegateHooks[userEventName][sEvent](elements[i], e || window.event, handler)) {
fireHandler(elements[i], e, handler, sEvent);
}
if (elements[i].parentNode && elements[i].parentNode.nodeType == 11) { //fix remove elements[i] bubble bug
@@ -174,6 +174,7 @@
*/
fireHandler: function(el, e, handler, sEvent) {
e = standardize(e);
+ e.userType = sEvent;
return handler.call(el, e);
},
@@ -234,8 +235,8 @@
if (hooks) {
for (var i in hooks) {
var _listener = listener(el, i, handler, sEvent);
- EventTargetH.addEventListener(el, i, _listener);
Cache.add(_listener, el, i+'.'+sEvent, handler);
+ EventTargetH.on(el, i, _listener);
}
} else {
_listener = listener(el, sEvent, handler);
@@ -261,7 +262,7 @@
if (hooks) {
for (var i in hooks) {
var _listener = listener(el, i, handler, sEvent);
- EventTargetH.removeEventListener(el, i, _listener);
+ EventTargetH.un(el, i, _listener);
Cache.remove(el, i+'.'+sEvent, handler);
}
} else {
@@ -304,8 +305,8 @@
if (hooks) {
for (var i in hooks) {
var _listener = delegateListener(el, selector, i, handler, sEvent);
- EventTargetH.addEventListener(el, i, _listener, needCapture);
Cache.add(_listener, el, i+'.'+sEvent, handler, selector);
+ EventTargetH.delegate(el, selector, i, _listener);
}
} else {
_listener = delegateListener(el, selector, sEvent, handler);
@@ -333,7 +334,7 @@
if (hooks) {
for (var i in hooks) {
var _listener = delegateListener(el, selector, i, handler, sEvent);
- EventTargetH.removeEventListener(el, i, _listener, needCapture);
+ EventTargetH.undelegate(el, selector, i, _listener);
Cache.remove(el, i+'.'+sEvent, handler, selector);
}
} else {
@@ -434,11 +435,12 @@
var UA = navigator.userAgent;
if (/firefox/i.test(UA)) {
EventTargetH._EventHooks.mousewheel = EventTargetH._DelegateHooks.mousewheel = {
- 'DOMMouseScroll': function(e) {
+ 'DOMMouseScroll': function(el, e) {
return true;
}
};
}
+
mix(EventTargetH._EventHooks, {
'mouseenter': {
'mouseover': function(el, e) {

0 comments on commit 49a34be

Please sign in to comment.
Something went wrong with that request. Please try again.