diff options
Diffstat (limited to 'framework/Web/Javascripts/extended')
-rw-r--r-- | framework/Web/Javascripts/extended/base.js | 2 | ||||
-rw-r--r-- | framework/Web/Javascripts/extended/event.js | 33 |
2 files changed, 31 insertions, 4 deletions
diff --git a/framework/Web/Javascripts/extended/base.js b/framework/Web/Javascripts/extended/base.js index e3ca729b..48927b75 100644 --- a/framework/Web/Javascripts/extended/base.js +++ b/framework/Web/Javascripts/extended/base.js @@ -29,6 +29,6 @@ function $(n,d) { Function.prototype.bindEvent = function() {
var __method = this, args = $A(arguments), object = args.shift();
return function(event) {
- return __method.call(object, event || window.event, args);
+ return __method.apply(object, [event || window.event].concat(args));
}
}
diff --git a/framework/Web/Javascripts/extended/event.js b/framework/Web/Javascripts/extended/event.js index a7514cda..b6dccf3b 100644 --- a/framework/Web/Javascripts/extended/event.js +++ b/framework/Web/Javascripts/extended/event.js @@ -26,12 +26,39 @@ Object.extend(Event, { return e.keyCode != null ? e.keyCode : e.charCode
},
+ isHTMLEvent : function(type)
+ {
+ var events = ['abort', 'blur', 'change', 'error', 'focus', 'load', 'reset', 'resize', 'scroll', 'select', 'submit', 'unload'];
+ return events.include(type);
+ },
+
+ isMouseEvent : function(type)
+ {
+ var events = ['click', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup'];
+ return events.include(type);
+ },
+
fireEvent : function(element,type)
{
if(document.createEvent)
- {
- var event = document.createEvent('HTMLEvents');
- event.initEvent(type, true, true);
+ {
+ if(Event.isHTMLEvent(type))
+ {
+ var event = document.createEvent('HTMLEvents');
+ event.initEvent(type, true, true);
+ }
+ else if(Event.isMouseEvent(type))
+ {
+ var event = document.createEvent('MouseEvents');
+ event.initMouseEvent(type,true,true,
+ document.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
+ }
+ else
+ {
+ if(Logger)
+ Logger.error("undefined event", type);
+ return;
+ }
element.dispatchEvent(event);
}
else if(element.fireEvent)
|