From 9b3fdc25c171d2b2461af42224ea16ad6c032c49 Mon Sep 17 00:00:00 2001 From: alecpl Date: Fri, 19 Mar 2010 11:20:12 +0000 Subject: - Implemented messages copying using drag&drop + SHIFT (#1484086) --- program/js/app.js | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 5 deletions(-) (limited to 'program/js') diff --git a/program/js/app.js b/program/js/app.js index 87ee76c8f..7c86bb0e8 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -197,7 +197,7 @@ function rcube_webmail() if (this.env.action=='show' || this.env.action=='preview') { - this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'delete', + this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'copy', 'delete', 'open', 'mark', 'edit', 'viewsource', 'download', 'print', 'load-attachment', 'load-headers', true); if (this.env.next_uid) @@ -674,6 +674,11 @@ function rcube_webmail() this.copy_contact(null, props); break; + case 'copy': + if (this.task == 'mail') + this.copy_messages(props); + break; + case 'mark': if (props) this.mark_message(props); @@ -1194,10 +1199,14 @@ function rcube_webmail() // handle mouse release when dragging if (this.drag_active && model && this.env.last_folder_target) { + var mbox = model[this.env.last_folder_target].id; + $(this.get_folder_li(this.env.last_folder_target)).removeClass('droptarget'); - this.command('moveto', model[this.env.last_folder_target].id); this.env.last_folder_target = null; list.draglayer.hide(); + + if (!this.drag_menu(e, mbox)) + this.command('moveto', mbox); } // reset 'pressed' buttons @@ -1209,6 +1218,29 @@ function rcube_webmail() } }; + this.drag_menu = function(e, mbox) + { + var modkey = rcube_event.get_modifier(e); + var menu = $('#'+this.gui_objects.message_dragmenu); + + if (menu && modkey == SHIFT_KEY) { + var pos = rcube_event.get_mouse_pos(e); + this.env.drag_mbox = mbox; + menu.css({top: (pos.y-10)+'px', left: (pos.x-10)+'px'}).show(); + return true; + } + }; + + this.drag_menu_action = function(action) + { + var menu = $('#'+this.gui_objects.message_dragmenu); + if (menu) { + menu.hide(); + } + this.command(action, this.env.drag_mbox); + this.env.drag_mbox = null; + }; + this.drag_start = function(list) { var model = this.task == 'mail' ? this.env.mailboxes : this.env.address_sources; @@ -1389,12 +1421,12 @@ function rcube_webmail() { this.enable_command('reply', 'reply-all', 'forward', false); this.enable_command('show', 'print', 'open', 'edit', 'download', 'viewsource', selected); - this.enable_command('delete', 'moveto', 'mark', (list.selection.length > 0 ? true : false)); + this.enable_command('delete', 'moveto', 'copy', 'mark', (list.selection.length > 0 ? true : false)); } else { this.enable_command('show', 'reply', 'reply-all', 'forward', 'print', 'edit', 'open', 'download', 'viewsource', selected); - this.enable_command('delete', 'moveto', 'mark', (list.selection.length > 0 ? true : false)); + this.enable_command('delete', 'moveto', 'copy', 'mark', (list.selection.length > 0 ? true : false)); } // start timer for message preview (wait for double click) @@ -2121,6 +2153,32 @@ function rcube_webmail() $(row.obj).removeClass('unroot'); }; + // copy selected messages to the specified mailbox + this.copy_messages = function(mbox) + { + // exit if current or no mailbox specified or if selection is empty + if (!mbox || mbox == this.env.mailbox || (!this.env.uid && (!this.message_list || !this.message_list.get_selection().length))) + return; + + var add_url = '&_target_mbox='+urlencode(mbox)+'&_from='+(this.env.action ? this.env.action : ''); + var a_uids = new Array(); + + if (this.env.uid) + a_uids[0] = this.env.uid; + else + { + var selection = this.message_list.get_selection(); + var id; + for (var n=0; n