diff options
author | xue <> | 2005-12-05 01:00:16 +0000 |
---|---|---|
committer | xue <> | 2005-12-05 01:00:16 +0000 |
commit | ccf76e430b7703db028966a845a966f50956f490 (patch) | |
tree | 9762b746f8b7d432dbe5e5cb8f38f90007e0e1b5 /framework/Web/Javascripts/extended/event.js | |
parent | 418baf36d477bcbdd6fb4eaf4037ea6a2d93f21c (diff) |
Diffstat (limited to 'framework/Web/Javascripts/extended/event.js')
-rw-r--r-- | framework/Web/Javascripts/extended/event.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/framework/Web/Javascripts/extended/event.js b/framework/Web/Javascripts/extended/event.js new file mode 100644 index 00000000..17a5432c --- /dev/null +++ b/framework/Web/Javascripts/extended/event.js @@ -0,0 +1,24 @@ +Object.extend(Event, {
+ OnLoad : function (fn) {
+ // opera onload is in document, not window
+ var w = document.addEventListener && !window.addEventListener ? document : window;
+ Event.__observe(w,'load',fn);
+ },
+ observe: function(elements, name, observer, useCapture) {
+ if(isElement(elements))
+ return this.__observe(elements, name, observer, useCapture);
+ for(var i=0; i<elements.length; i++)
+ this.__observe(elements[i], name, observer, useCapture);
+ },
+ __observe: function(element, name, observer, useCapture) {
+ var element = $(element);
+ useCapture = useCapture || false;
+
+ if (name == 'keypress' &&
+ ((navigator.appVersion.indexOf('AppleWebKit') > 0)
+ || element.attachEvent))
+ name = 'keydown';
+
+ this._observeAndCache(element, name, observer, useCapture);
+ }
+});
\ No newline at end of file |