From 0e99d37a18cf81b549b8fc7e8948e9bd338deaad Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Mon, 01 Jun 2009 11:35:53 -0400
Subject: [PATCH] Use event system on the client to handle ajax callbacks

---
 program/js/common.js |   25 ++++---------------------
 1 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/program/js/common.js b/program/js/common.js
index 407da41..1fd10c2 100644
--- a/program/js/common.js
+++ b/program/js/common.js
@@ -288,8 +288,8 @@
 {
   var ret, h;
   if (typeof e == 'undefined')
-    e = {};
-  if (typeof e == 'object')
+    e = this;
+  else if (typeof e == 'object')
     e.event = evt;
   
   if (this._events && this._events[evt] && !this._event_exec) {
@@ -297,9 +297,9 @@
     for (var i=0; i < this._events[evt].length; i++) {
       if ((h = this._events[evt][i])) {
         if (typeof h.func == 'function')
-          ret = h.func.call ? h.func.call(h.obj, this, e) : h.func(this, e);
+          ret = h.func.call ? h.func.call(h.obj, e) : h.func(e);
         else if (typeof h.obj[h.func] == 'function')
-          ret = h.obj[h.func](this, e);
+          ret = h.obj[h.func](e);
               
         // cancel event execution
         if (typeof ret != 'undefined' && !ret)
@@ -634,20 +634,3 @@
     return o;
     }
   }
-
-
-// Fire event on specified element
-function exec_event(element,event)
-{  
-  if (document.createEventObject) {
-    // dispatch for IE  
-    var evt = document.createEventObject();
-    return element.fireEvent('on'+event,evt)
-  }
-  else {  
-    // dispatch for firefox + others  
-    var evt = document.createEvent("HTMLEvents");
-    evt.initEvent(event, true, true); // event type,bubbling,cancelable
-    return !element.dispatchEvent(evt);
-   }
-}

--
Gitblit v1.9.1