From 170c8820f17bc778b3a6fdfa799e7dccf20cf207 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 21 Oct 2009 02:29:50 -0600 Subject: [PATCH] Handle notifications in compose screen without msgs_auto awkwardness --- imp/compose-dimp.php | 4 ++-- imp/js/compose-dimp.js | 33 +++++++++++++-------------------- kronolith/js/kronolith.js | 4 +--- 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/imp/compose-dimp.php b/imp/compose-dimp.php index 3a8d308b8..2f072cca0 100644 --- a/imp/compose-dimp.php +++ b/imp/compose-dimp.php @@ -72,7 +72,7 @@ if (count($_POST)) { $result->info = end($info); $result->imp_compose = $imp_compose->getCacheId(); } - Horde::sendHTTPResponse(Horde::prepareResponse($result, $GLOBALS['imp_notify'], false), 'js-json'); + Horde::sendHTTPResponse(Horde::prepareResponse($result, $GLOBALS['imp_notify']), 'js-json'); exit; } @@ -196,7 +196,7 @@ if (count($_POST)) { } } - Horde::sendHTTPResponse(Horde::prepareResponse($result, !$result->success || !Horde_Util::getFormData('nonotify') ? $GLOBALS['imp_notify'] : null, false), 'json'); + Horde::sendHTTPResponse(Horde::prepareResponse($result, $GLOBALS['imp_notify']), 'json'); exit; } diff --git a/imp/js/compose-dimp.js b/imp/js/compose-dimp.js index 099fe94fb..9e6c2a7b6 100644 --- a/imp/js/compose-dimp.js +++ b/imp/js/compose-dimp.js @@ -10,8 +10,9 @@ var DimpCompose = { // Variables defaulting to empty/false: // auto_save_interval, button_pressed, compose_cursor, dbtext, - // drafts_mbox, editor_on, knl, mp_padding, resizebcc, resizecc, - // resizeto, row_height, sbtext, skip_spellcheck, spellcheck, uploading + // drafts_mbox, editor_on, is_popup, knl, mp_padding, resizebcc, + // resizecc, resizeto, row_height, sbtext, skip_spellcheck, spellcheck, + // uploading last_msg: '', textarea_ready: true, @@ -26,8 +27,7 @@ var DimpCompose = { updateDraftsMailbox: function() { - if (DIMP.baseWindow && - DIMP.baseWindow.DimpBase && + if (this.is_popup && DIMP.baseWindow.DimpBase.folder == DIMP.conf_compose.drafts_mbox) { DIMP.baseWindow.DimpBase.poll(); } @@ -37,8 +37,7 @@ var DimpCompose = { { if (DIMP.conf_compose.qreply) { this.closeQReply(); - } else if ((DIMP.baseWindow && DIMP.baseWindow.DimpBase) || - DIMP.conf_compose.popup) { + } else if (this.is_popup || DIMP.conf_compose.popup) { DimpCore.closePopup(); } else { DimpCore.redirect(DIMP.conf.URI_DIMP); @@ -150,7 +149,7 @@ var DimpCompose = { uniqueSubmit: function(action) { - var db, params, sb, + var db, sb, c = $('compose'); if (DIMP.SpellCheckerObject && @@ -221,11 +220,7 @@ var DimpCompose = { // Use an AJAX submit here so that we can do javascript-y stuff // before having to close the window on success. - params = c.serialize(true); - if (!DIMP.baseWindow || !DIMP.baseWindow.DimpBase) { - params.nonotify = true; - } - DimpCore.doAction('*' + DIMP.conf.URI_COMPOSE, params, null, this.uniqueSubmitCallback.bind(this)); + DimpCore.doAction('*' + DIMP.conf.URI_COMPOSE, c.serialize(true), null, this.uniqueSubmitCallback.bind(this)); } }, @@ -251,10 +246,9 @@ var DimpCompose = { this.updateDraftsMailbox(); if (d.action == 'save_draft') { - if (DIMP.baseWindow && - DIMP.baseWindow.DimpBase && - !DIMP.conf_compose.qreply) { + if (this.is_popup && !DIMP.conf_compose.qreply) { DIMP.baseWindow.DimpCore.showNotifications(r.msgs); + r.msgs = []; } if (DIMP.conf_compose.close_draft) { return this.closeCompose(); @@ -264,7 +258,7 @@ var DimpCompose = { case 'send_message': this.button_pressed = false; - if (DIMP.baseWindow && DIMP.baseWindow.DimpBase) { + if (this.is_popup) { if (d.reply_type) { DIMP.baseWindow.DimpBase.flag(d.reply_type == 'reply' ? '\\answered' : '$forwarded', true, { index: d.index, mailbox: d.reply_folder, noserver: true }); } @@ -284,6 +278,7 @@ var DimpCompose = { if (!DIMP.conf_compose.qreply) { DIMP.baseWindow.DimpCore.showNotifications(r.msgs); + r.msgs = []; } } return this.closeCompose(); @@ -322,10 +317,6 @@ var DimpCompose = { } this.dbtext = this.sbtext = null; } - - if (!r.msgs_noauto) { - DimpCore.showNotifications(r.msgs); - } }, onNoSpellError: function(action) @@ -758,6 +749,8 @@ var DimpCompose = { DimpCore.growler_log = false; DimpCore.init(); + this.is_popup = (DIMP.baseWindow && DIMP.baseWindow.DimpBase); + /* Attach event handlers. */ document.observe('change', this.changeHandler.bindAsEventListener(this)); Event.observe(window, 'resize', this.resizeMsgArea.bind(this)); diff --git a/kronolith/js/kronolith.js b/kronolith/js/kronolith.js index 80965957d..9e37a59d4 100644 --- a/kronolith/js/kronolith.js +++ b/kronolith/js/kronolith.js @@ -92,9 +92,7 @@ KronolithCore = { } this.server_error = 0; - if (!r.msgs_noauto) { - this.showNotifications(r.msgs); - } + this.showNotifications(r.msgs); if (this.onDoActionComplete) { this.onDoActionComplete(r); -- 2.11.0