From 2bb1f633fb2c5055a561414b5650a9247662169b Mon Sep 17 00:00:00 2001 From: alecpl Date: Fri, 21 May 2010 08:42:59 +0000 Subject: [PATCH] - Added 'actionbefore', 'actionafter', 'responsebefore', 'responseafter' events - Removed response.callbacks feature --- CHANGELOG | 2 ++ program/js/app.js | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 7c7b66550..eda0cb1a4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ CHANGELOG RoundCube Webmail =========================== +- Added 'actionbefore', 'actionafter', 'responsebefore', 'responseafter' events +- Removed response.callbacks feature - Fix double-addition of e-mail domain to content ID in HTML images - Read and send messages with format=flowed (#1484370), fixes word wrapping issues (#1486543) - Fix duplicated attachments when forwarding a message (#1486487) diff --git a/program/js/app.js b/program/js/app.js index 5e081d9a3..991ba0385 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -439,7 +439,8 @@ function rcube_webmail() return ret !== null ? ret : (obj ? false : true); } - // trigger plugin hook + // trigger plugin hooks + this.triggerEvent('actionbefore', {props:props, action:command}); var event_ret = this.triggerEvent('before'+command, props); if (typeof event_ret != 'undefined') { // abort if one the handlers returned false @@ -865,7 +866,7 @@ function rcube_webmail() // all checks passed, send message this.set_busy(true, 'sendingmessage'); var form = this.gui_objects.messageform; - form.target = "savetarget"; + form.target = 'savetarget'; form._draft.value = ''; form.submit(); @@ -880,7 +881,7 @@ function rcube_webmail() // Reset the auto-save timer self.clearTimeout(this.save_timer); - this.upload_file(props) + this.upload_file(props) break; case 'remove-attachment': @@ -896,7 +897,7 @@ function rcube_webmail() var uid; if (uid = this.get_single_uid()) this.goto_url('compose', '_reply_uid='+uid+'&_mbox='+urlencode(this.env.mailbox)+(command=='reply-all' ? '&_all=1' : ''), true); - break; + break; case 'forward': var uid; @@ -1045,6 +1046,7 @@ function rcube_webmail() } this.triggerEvent('after'+command, props); + this.triggerEvent('actionafter', {props:props, action:command}); return obj ? false : true; }; @@ -4908,6 +4910,9 @@ function rcube_webmail() if (response.unlock) this.set_busy(false); + this.triggerEvent('responsebefore', {response: response}); + this.triggerEvent('responsebefore'+response.action, {response: response}); + // set env vars if (response.env) this.set_env(response.env); @@ -4925,12 +4930,6 @@ function rcube_webmail() 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) { case 'delete': @@ -4989,6 +4988,9 @@ function rcube_webmail() } break; } + + this.triggerEvent('responseafter', {response: response}); + this.triggerEvent('responseafter'+response.action, {response: response}); }; // handle HTTP request errors