diff options
author | Aleksander Machniak <alec@alec.pl> | 2015-01-13 10:45:23 +0100 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2015-01-13 10:54:53 +0100 |
commit | db780e10e4981f15da653d8fc53e0fb80c8cce9a (patch) | |
tree | 0821a0e6aff2359c481022b607d6c7a82f19b3b4 | |
parent | 04994005e7f83a9ae48bd177b898dd17f7aa8e24 (diff) |
Fix bug where Drafts list wasn't updated on draft-save action in new window (#1490225)
That if the window was opened using "Edit" button, not double-click on a message.
Conflicts:
CHANGELOG
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | program/js/app.js | 31 |
2 files changed, 22 insertions, 10 deletions
@@ -6,6 +6,7 @@ CHANGELOG Roundcube Webmail - Fix bug where sent message was saved in Sent folder even if disabled by user (#1490208) - Fix checks based on window.ActiveXObject in IE > 10 - Fix XSS issue in style attribute handling (#1490227) +- Fix bug where Drafts list wasn't updated on draft-save action in new window (#1490225) RELEASE 1.0.4 ------------- diff --git a/program/js/app.js b/program/js/app.js index 43e3dd40a..f132a2c3b 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -3669,14 +3669,13 @@ function rcube_webmail() this.set_draft_id = function(id) { - var rc; - if (id && id != this.env.draft_id) { - if (rc = this.opener()) { - // refresh the drafts folder in opener window - if (rc.env.task == 'mail' && rc.env.action == '' && rc.env.mailbox == this.env.drafts_mailbox) - rc.command('checkmail'); - } + var filter = {task: 'mail', action: ''}, + rc = this.opener(false, filter) || this.opener(true, filter); + + // refresh the drafts folder in the opener window + if (rc && rc.env.mailbox == this.env.drafts_mailbox) + rc.command('checkmail'); this.env.draft_id = id; $("input[name='_draft_saveid']").val(id); @@ -7457,12 +7456,24 @@ function rcube_webmail() }; // get window.opener.rcmail if available - this.opener = function() + this.opener = function(deep, filter) { + var i, win = window.opener; + // catch Error: Permission denied to access property rcmail try { - if (window.opener && !opener.closed && opener.rcmail) - return opener.rcmail; + if (win && !win.closed) { + // try parent of the opener window, e.g. preview frame + if (deep && (!win.rcmail || win.rcmail.env.framed) && win.parent && win.parent.rcmail) + win = win.parent; + + if (win.rcmail && filter) + for (i in filter) + if (win.rcmail.env[i] != filter[i]) + return; + + return win.rcmail; + } } catch (e) {} }; |