| | |
| | | |
| | | $Id$ |
| | | */ |
| | | |
| | | // Constants |
| | | var CONTROL_KEY = 1; |
| | | var SHIFT_KEY = 2; |
| | |
| | | this.gui_objects = new Object(); |
| | | this.commands = new Object(); |
| | | this.selection = new Array(); |
| | | this.last_selected = 0; |
| | | |
| | | // create public reference to myself |
| | | rcube_webmail_client = this; |
| | |
| | | |
| | | // load body click event |
| | | document.onmousedown = function(){ return rcube_webmail_client.reset_click(); }; |
| | | document.onkeydown = function(e){ return rcube_webmail_client.use_arrow_keys(e, msg_list_frame); }; |
| | | document.onkeydown = function(e){ return rcube_webmail_client.key_pressed(e, msg_list_frame); }; |
| | | |
| | | |
| | | // flag object as complete |
| | |
| | | e.cancelBubble = true; |
| | | }; |
| | | |
| | | // reset last clicked if user clicks on anything other than the message table |
| | | this.use_arrow_keys = function(e, msg_list_frame) { |
| | | this.key_pressed = function(e, msg_list_frame) { |
| | | if (this.in_message_list != true) |
| | | return true; |
| | | |
| | | var keyCode = document.layers ? e.which : document.all ? event.keyCode : document.getElementById ? e.keyCode : 0; |
| | | var mod_key = this.get_modifier(e); |
| | | var scroll_to = 0; |
| | | |
| | | var last_selected_row = this.list_rows[this.last_selected]; |
| | | switch (keyCode) { |
| | | case 40: |
| | | case 38: |
| | | return this.use_arrow_key(keyCode, mod_key, msg_list_frame); |
| | | break; |
| | | case 46: |
| | | return this.use_delete_key(keyCode, mod_key, msg_list_frame); |
| | | break; |
| | | default: |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | this.use_arrow_key = function(keyCode, mod_key, msg_list_frame) { |
| | | var scroll_to = 0; |
| | | if (keyCode == 40) { // down arrow key pressed |
| | | var new_row = last_selected_row.obj.nextSibling; |
| | | while (new_row && new_row.nodeType != 1) { |
| | | new_row = new_row.nextSibling; |
| | | } |
| | | new_row = this.get_next_row(); |
| | | if (!new_row) return false; |
| | | scroll_to = (Number(new_row.offsetTop) + Number(new_row.offsetHeight)) - Number(msg_list_frame.offsetHeight); |
| | | } else if (keyCode == 38) { // up arrow key pressed |
| | | var new_row = last_selected_row.obj.previousSibling; |
| | | while (new_row && new_row.nodeType != 1) { |
| | | new_row = new_row.previousSibling; |
| | | } |
| | | new_row = this.get_prev_row(); |
| | | if (!new_row) return false; |
| | | scroll_to = new_row.offsetTop; |
| | | } else {return true;} |
| | | |
| | | if (mod_key != CONTROL_KEY) |
| | | this.select_row(new_row.uid,mod_key); |
| | | this.select_row(new_row.uid,mod_key,true); |
| | | |
| | | if (((Number(new_row.offsetTop)) < (Number(msg_list_frame.scrollTop))) || |
| | | ((Number(new_row.offsetTop) + Number(new_row.offsetHeight)) > (Number(msg_list_frame.scrollTop) + Number(msg_list_frame.offsetHeight)))) { |
| | | msg_list_frame.scrollTop = scroll_to; |
| | | } |
| | | |
| | | return false; |
| | | }; |
| | | |
| | | this.use_delete_key = function(keyCode, mod_key, msg_list_frame){ |
| | | this.command('delete','',this); |
| | | return false; |
| | | } |
| | | |
| | | // get all message rows from HTML table and init each row |
| | | this.init_messagelist = function(msg_list) |
| | |
| | | if (!this.in_selection_before) |
| | | { |
| | | var mod_key = this.get_modifier(e); |
| | | this.select_row(id,mod_key); |
| | | this.select_row(id,mod_key,false); |
| | | } |
| | | |
| | | if (this.selection.length) |
| | |
| | | |
| | | // unselects currently selected row |
| | | if (!this.drag_active && this.in_selection_before==id) |
| | | this.select_row(id,mod_key); |
| | | this.select_row(id,mod_key,false); |
| | | |
| | | this.drag_start = false; |
| | | this.in_selection_before = false; |
| | |
| | | /********* (message) list functionality *********/ |
| | | /*********************************************************/ |
| | | |
| | | // get next and previous rows that are not hidden |
| | | this.get_next_row = function(){ |
| | | var last_selected_row = this.list_rows[this.last_selected]; |
| | | var new_row = last_selected_row.obj.nextSibling; |
| | | while (new_row && (new_row.nodeType != 1 || new_row.style.display == 'none')) { |
| | | new_row = new_row.nextSibling; |
| | | } |
| | | return new_row; |
| | | } |
| | | |
| | | this.get_prev_row = function(){ |
| | | var last_selected_row = this.list_rows[this.last_selected]; |
| | | var new_row = last_selected_row.obj.previousSibling; |
| | | while (new_row && (new_row.nodeType != 1 || new_row.style.display == 'none')) { |
| | | new_row = new_row.previousSibling; |
| | | } |
| | | return new_row; |
| | | } |
| | | |
| | | // highlight/unhighlight a row |
| | | this.highlight_row = function(id, multiple) |
| | | { |
| | |
| | | if (!this.in_selection(id)) // select row |
| | | { |
| | | this.selection[this.selection.length] = id; |
| | | this.set_classname(this.list_rows[id].obj, 'selected', true); |
| | | this.set_classname(this.list_rows[id].obj, 'selected', true); |
| | | } |
| | | else // unselect row |
| | | { |
| | |
| | | |
| | | |
| | | // selects or unselects the proper row depending on the modifier key pressed |
| | | this.select_row = function(id,mod_key) { |
| | | this.select_row = function(id,mod_key,with_arrow) { |
| | | if (!mod_key) { |
| | | this.shift_start = id; |
| | | this.highlight_row(id, false); |
| | |
| | | break; } |
| | | case CONTROL_KEY: { |
| | | this.shift_start = id; |
| | | this.highlight_row(id, true); |
| | | if (!with_arrow) |
| | | this.highlight_row(id, true); |
| | | break; |
| | | } |
| | | case CONTROL_SHIFT_KEY: { |
| | |
| | | } |
| | | } |
| | | } |
| | | this.last_selected = id; |
| | | if (this.last_selected != 0) { this.set_classname(this.list_rows[this.last_selected].obj, 'focused', false);} |
| | | this.last_selected = id; |
| | | this.set_classname(this.list_rows[id].obj, 'focused', true); |
| | | }; |
| | | |
| | | this.shift_select = function(id, control) { |
| | |
| | | // list messages of a specific mailbox |
| | | this.list_mailbox = function(mbox, page, sort) |
| | | { |
| | | this.last_selected = 0; |
| | | var add_url = ''; |
| | | var target = window; |
| | | |
| | |
| | | if (this.message_rows[id].obj) |
| | | this.message_rows[id].obj.style.display = 'none'; |
| | | } |
| | | next_row = this.get_next_row(); |
| | | prev_row = this.get_prev_row(); |
| | | new_row = (next_row) ? next_row : prev_row; |
| | | this.select_row(new_row.uid,false,false); |
| | | } |
| | | |
| | | var lock = false; |
| | |
| | | this.message_rows[id].obj.style.display = 'none'; |
| | | } |
| | | } |
| | | next_row = this.get_next_row(); |
| | | prev_row = this.get_prev_row(); |
| | | new_row = (next_row) ? next_row : prev_row; |
| | | this.select_row(new_row.uid,false,false); |
| | | |
| | | // send request to server |
| | | this.http_request('delete', '_uid='+a_uids.join(',')+'&_mbox='+escape(this.env.mailbox)+'&_from='+(this.env.action ? this.env.action : '')); |