From 9a0153324eeb1f0e808cb1a063d1f37d49ad48e2 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sun, 15 Dec 2013 10:01:38 +0100 Subject: [PATCH] Implemented menu actions to copy/move messages, added folder-selector widget (#1484086) --- CHANGELOG | 1 + program/include/rcmail.php | 25 +++-- program/js/app.js | 113 +++++++++++++++++++-- program/localization/en_US/labels.inc | 1 + skins/classic/common.css | 51 ++++++++++ skins/classic/functions.js | 1 + skins/classic/includes/messagetoolbar.html | 5 +- skins/classic/mail.css | 17 ---- skins/classic/templates/message.html | 4 +- skins/larry/images/listicons.png | Bin 26546 -> 37369 bytes skins/larry/includes/mailtoolbar.html | 2 + skins/larry/mail.css | 6 -- skins/larry/styles.css | 32 ++++++ skins/larry/templates/message.html | 4 +- skins/larry/ui.js | 5 +- 15 files changed, 224 insertions(+), 43 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c5574b13f..a4088cc58 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ CHANGELOG Roundcube Webmail =========================== +- Implemented menu actions to copy/move messages, added folder-selector widget (#1484086) - Fix regression where only first new folder was placed in correct place on the list (#1489472) - Fix issue where children of selected and collapsed thread were skipped on various actions (#1489457) - Fix issue where groups were not deleted when "Replace entire addressbook" option on contacts import was used (#1489420) diff --git a/program/include/rcmail.php b/program/include/rcmail.php index 35ade8a41..cefbc4d14 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -1282,13 +1282,22 @@ class rcmail extends rcube } else { $js_mailboxlist = array(); - $out = html::tag('ul', $attrib, $rcmail->render_folder_tree_html($a_mailboxes, $mbox_name, $js_mailboxlist, $attrib), html::$common_attrib); + $tree = $rcmail->render_folder_tree_html($a_mailboxes, $mbox_name, $js_mailboxlist, $attrib); + + if ($type != 'js') { + $out = html::tag('ul', $attrib, $tree, html::$common_attrib); + + $rcmail->output->include_script('treelist.js'); + $rcmail->output->add_gui_object('mailboxlist', $attrib['id']); + $rcmail->output->set_env('unreadwrap', $attrib['unreadwrap']); + $rcmail->output->set_env('collapsed_folders', (string)$rcmail->config->get('collapsed_folders')); + } - $rcmail->output->include_script('treelist.js'); - $rcmail->output->add_gui_object('mailboxlist', $attrib['id']); $rcmail->output->set_env('mailboxes', $js_mailboxlist); - $rcmail->output->set_env('unreadwrap', $attrib['unreadwrap']); - $rcmail->output->set_env('collapsed_folders', (string)$rcmail->config->get('collapsed_folders')); + + // we can't use object keys in javascript because they are unordered + // we need sorted folders list for folder-selector widget + $rcmail->output->set_env('mailboxes_list', array_keys($js_mailboxlist)); } return $out; @@ -1473,9 +1482,13 @@ class rcmail extends rcube $jslist[$folder['id']] = array( 'id' => $folder['id'], 'name' => $foldername, - 'virtual' => $folder['virtual'] + 'virtual' => $folder['virtual'], ); + if (!empty($folder_class)) { + $jslist[$folder['id']]['class'] = $folder_class; + } + if (!empty($folder['folders'])) { $out .= html::tag('ul', array('style' => ($is_collapsed ? "display:none;" : null)), $this->render_folder_tree_html($folder['folders'], $mbox_name, $jslist, $attrib, $nestLevel+1)); diff --git a/program/js/app.js b/program/js/app.js index cbe61ab4a..138fcbb13 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -842,14 +842,14 @@ function rcube_webmail() case 'move': case 'moveto': // deprecated if (this.task == 'mail') - this.move_messages(props); + this.move_messages(props, obj); else if (this.task == 'addressbook') this.move_contacts(props); break; case 'copy': if (this.task == 'mail') - this.copy_messages(props); + this.copy_messages(props, obj); else if (this.task == 'addressbook') this.copy_contacts(props); break; @@ -1411,8 +1411,6 @@ function rcube_webmail() this.drag_start = function(list) { - var model = this.task == 'mail' ? this.env.mailboxes : this.env.contactfolders; - this.drag_active = true; if (this.preview_timer) @@ -2612,10 +2610,12 @@ function rcube_webmail() }; // copy selected messages to the specified mailbox - this.copy_messages = function(mbox) + this.copy_messages = function(mbox, obj) { if (mbox && typeof mbox === 'object') mbox = mbox.id; + else if (!mbox) + return this.folder_selector(obj, function(folder) { ref.command('copy', folder); }); // exit if current or no mailbox specified if (!mbox || mbox == this.env.mailbox) @@ -2632,10 +2632,12 @@ function rcube_webmail() }; // move selected messages to the specified mailbox - this.move_messages = function(mbox) + this.move_messages = function(mbox, obj) { if (mbox && typeof mbox === 'object') mbox = mbox.id; + else if (!mbox) + return this.folder_selector(obj, function(folder) { ref.command('move', folder); }); // exit if current or no mailbox specified if (!mbox || mbox == this.env.mailbox) @@ -6553,6 +6555,105 @@ function rcube_webmail() elem.onclick = function() { rcmail.command('show-headers', '', elem); }; }; + // create folder selector popup, position and display it + this.folder_selector = function(obj, callback) + { + var container = this.folder_selector_element; + + if (!container) { + var rows = [], + delim = this.env.delimiter, + ul = $(' diff --git a/skins/larry/mail.css b/skins/larry/mail.css index 8e1634ad7..d3b09c087 100644 --- a/skins/larry/mail.css +++ b/skins/larry/mail.css @@ -417,12 +417,6 @@ a.iconbutton.threadmode.selected { right: 0; } -#messagetoolbar .toolbarselect { - position: absolute; - bottom: 6px; - right: 3px; -} - #messagesearchtools { position: absolute; right: 0; diff --git a/skins/larry/styles.css b/skins/larry/styles.css index 61f35b094..21d93c106 100644 --- a/skins/larry/styles.css +++ b/skins/larry/styles.css @@ -2329,6 +2329,38 @@ ul.toolbarmenu li span.conversation { z-index: 255; } +/*** folder selector ***/ + +#folder-selector li a span { + background: url("images/listicons.png") 4px -2021px no-repeat; + display: block; + height: 17px; + min-height: 14px; + padding: 4px 4px 1px 28px; + overflow: hidden; + max-width: 120px; + text-overflow: ellipsis; +} + +#folder-selector li a.virtual { + opacity: .2; +} + +#folder-selector li a.inbox span { + background-position: 4px -2049px; +} +#folder-selector li a.drafts span { + background-position: 4px -1388px; +} +#folder-selector li a.sent span { + background-position: 4px -2074px; +} +#folder-selector li a.trash span { + background-position: 4px -1508px; +} +#folder-selector li a.junk span { + background-position: 4px -2100px; +} /*** attachment list ***/ diff --git a/skins/larry/templates/message.html b/skins/larry/templates/message.html index e63705f76..df92b7511 100644 --- a/skins/larry/templates/message.html +++ b/skins/larry/templates/message.html @@ -16,9 +16,6 @@ -
- -
@@ -36,6 +33,7 @@
+
diff --git a/skins/larry/ui.js b/skins/larry/ui.js index d203acf57..d66131075 100644 --- a/skins/larry/ui.js +++ b/skins/larry/ui.js @@ -369,8 +369,10 @@ function rcube_mail_ui() function body_mouseup(e) { var config, obj, target = e.target; + if (target.className == 'inner') target = e.target.parentNode; + for (var id in popups) { obj = popups[id]; config = popupconfig[id]; @@ -379,9 +381,10 @@ function rcube_mail_ui() && !config.toggle && (!config.editable || !target_overlaps(target, obj.get(0))) && (!config.sticky || !rcube_mouse_is_over(e, obj.get(0))) + && !$(target).is('.folder-selector-link') ) { var myid = id+''; - window.setTimeout(function(){ show_popupmenu(myid, false) }, 10); + window.setTimeout(function() { show_popupmenu(myid, false); }, 10); } } }