From: Michael M Slusarz Date: Wed, 7 Jul 2010 05:15:18 +0000 (-0600) Subject: Bug #6832: Add confirm dialog when moving to notepad/tasklist X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=25e4e9f441d22b3df2b6f6396ff8b4be3063695c;p=horde.git Bug #6832: Add confirm dialog when moving to notepad/tasklist --- diff --git a/imp/js/mailbox.js b/imp/js/mailbox.js index b01ca5f04..074464556 100644 --- a/imp/js/mailbox.js +++ b/imp/js/mailbox.js @@ -105,26 +105,35 @@ var ImpMailbox = { _transfer: function(actID) { - var newFolder, tmbox; + var newFolder, target, tmbox; if (this.anySelected()) { + target = $F('targetMailbox1'); tmbox = $('targetMbox'); - tmbox.setValue($F('targetMailbox1')); + tmbox.setValue(target); // Check for a mailbox actually being selected. - if ($F(tmbox) == "\0create") { + if (target == "\0create") { newFolder = prompt(IMP.text.newfolder, ''); if (newFolder != null && newFolder != '') { $('newMbox').setValue(1); tmbox.setValue(newFolder); this.submit(actID); } + } else if (target.empty()) { + alert(IMP.text.target_mbox); + } else if (target.startsWith("\0notepad_") || + target.startsWith("\0tasklist_")) { + this.actIDconfirm = actID; + IMPDialog.display({ + cancel_text: IMP.text.no, + form_id: 'RB_ImpMailboxConfirm', + noinput: true, + ok_text: IMP.text.yes, + text: IMP.text.moveconfirm + }); } else { - if ($F(tmbox) == '') { - alert(IMP.text.target_mbox); - } else { - this.submit(actID); - } + this.submit(actID); } } else { alert(IMP.text.mailbox_selectone); @@ -379,7 +388,13 @@ document.observe('dom:loaded', function() { }); document.observe('IMPDialog:onClick', function(e) { - if (e.element().identify() == 'RB_ImpMailbox') { + switch (e.element().identify()) { + case 'RB_ImpMailbox': window.location = this.lastclick; + break; + + case 'RB_ImpMailboxConfirm': + this.submit(this.actIDconfirm); + break; } }.bindAsEventListener(ImpMailbox)); diff --git a/imp/js/message.js b/imp/js/message.js index 4714fea00..2e84c49ad 100644 --- a/imp/js/message.js +++ b/imp/js/message.js @@ -61,23 +61,34 @@ var ImpMessage = { _transfer: function(actID) { - var newFolder, tmbox = $('targetMbox'); - tmbox.setValue($F('target1')); + var newFolder, + target = $F('target1'), + tmbox = $('targetMbox'); + + tmbox.setValue(target); // Check for a mailbox actually being selected. - if ($F(tmbox) == "\0create") { + if (target == "\0create") { newFolder = window.prompt(IMP.text.newfolder, ''); if (newFolder != null && newFolder != '') { $('newMbox').setValue(1); tmbox.setValue(newFolder); this.submit(actID); } + } else if (target.empty()) { + window.alert(IMP.text.target_mbox); + } else if (target.startsWith("\0notepad_") || + target.startsWith("\0tasklist_")) { + this.actIDconfirm = actID; + IMPDialog.display({ + cancel_text: IMP.text.no, + form_id: 'RB_ImpMessageConfirm', + noinput: true, + ok_text: IMP.text.yes, + text: IMP.text.moveconfirm + }); } else { - if (!$F(tmbox)) { - window.alert(IMP.text.target_mbox); - } else { - this.submit(actID); - } + this.submit(actID); } }, @@ -187,3 +198,11 @@ var ImpMessage = { }; document.observe('dom:loaded', ImpMessage.onDomLoad.bind(ImpMessage)); + +document.observe('IMPDialog:onClick', function(e) { + switch (e.element().identify()) { + case 'RB_ImpMessageConfirm': + this.submit(this.actIDconfirm); + break; + } +}.bindAsEventListener(ImpMessage)); diff --git a/imp/mailbox.php b/imp/mailbox.php index c5e40fc70..8dfafeee0 100644 --- a/imp/mailbox.php +++ b/imp/mailbox.php @@ -309,7 +309,7 @@ $vtrash = $imp_search->isVTrashFolder() ? $imp_search->createSearchID($search_mbox) : null; -horde::addInlineScript(array( +Horde::addInlineScript(array( 'ImpMailbox.unread = ' . intval($unread) )); diff --git a/imp/message.php b/imp/message.php index d7aa9d415..d6f98cdb8 100644 --- a/imp/message.php +++ b/imp/message.php @@ -664,6 +664,12 @@ Horde::addInlineScript($inlineout['js_onload'], 'dom'); Horde::addScriptFile('effects.js', 'horde'); Horde::addScriptFile('imp.js', 'imp'); Horde::addScriptFile('message.js', 'imp'); + +if ($conf['tasklist']['use_notepad'] || $conf['tasklist']['use_tasklist']) { + Horde::addScriptFile('dialog.js', 'imp'); + Horde::addScriptFile('redbox.js', 'horde'); +} + IMP::prepareMenu(); Horde::noDnsPrefetch(); diff --git a/imp/templates/imp/javascript_defs.php b/imp/templates/imp/javascript_defs.php index c088c2dd7..6b26710c4 100644 --- a/imp/templates/imp/javascript_defs.php +++ b/imp/templates/imp/javascript_defs.php @@ -62,6 +62,7 @@ $code = array( 'login_password' => _("Please provide your password."), /* Strings used in multiple pages. */ + 'moveconfirm' => _("Are you sure you want to move the message(s)? (Some message information might get lost, like message headers, text formatting or attachments!)"), 'spam_report' => _("Are you sure you wish to report this message as spam?"), 'notspam_report' => _("Are you sure you wish to report this message as innocent?"), 'newfolder' => _("You are copying/moving to a new folder.") . "\n" . _("Please enter a name for the new folder:") . "\n",