diff options
Diffstat (limited to 'program/js')
-rw-r--r-- | program/js/app.js | 6 | ||||
-rw-r--r-- | program/js/common.js | 8 |
2 files changed, 10 insertions, 4 deletions
diff --git a/program/js/app.js b/program/js/app.js index 5e323e229..4f12e808a 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -3923,6 +3923,12 @@ function rcube_webmail() console.log(response.exec); eval(response.exec); } + + // execute callback functions of plugins + if (response.callbacks && response.callbacks.length) { + for (var i=0; i < response.callbacks.length; i++) + this.triggerEvent(response.callbacks[i][0], response.callbacks[i][1]); + } // process the response data according to the sent action switch (response.action) { diff --git a/program/js/common.js b/program/js/common.js index 25b654612..1fd10c255 100644 --- a/program/js/common.js +++ b/program/js/common.js @@ -288,8 +288,8 @@ triggerEvent: function(evt, e) { 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 @@ triggerEvent: function(evt, e) 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) |