| | |
| | | this.frame = this.list.parentNode; |
| | | |
| | | // set body events |
| | | if (this.keyboard) |
| | | rcube_event.add_listener({element:document, event:'keydown', object:this, method:'key_press'}); |
| | | if (this.keyboard) { |
| | | rcube_event.add_listener({element:document, event:'keyup', object:this, method:'key_press'}); |
| | | rcube_event.add_listener({element:document, event:'keydown', object:rcube_event, method:'cancel'}); |
| | | } |
| | | } |
| | | }, |
| | | |
| | |
| | | for (var n=0; n<this.selection.length; n++) |
| | | { |
| | | id = this.selection[n]; |
| | | if (this.rows[id].obj) |
| | | if (this.rows[id] && this.rows[id].obj) |
| | | { |
| | | this.set_classname(this.rows[id].obj, 'selected', true); |
| | | this.set_classname(this.rows[id].obj, 'unfocused', false); |
| | |
| | | */ |
| | | shift_select: function(id, control) |
| | | { |
| | | if (!this.rows[this.shift_start] || !this.selection.length) |
| | | this.shift_start = id; |
| | | |
| | | var from_rowIndex = this.rows[this.shift_start].obj.rowIndex; |
| | | var to_rowIndex = this.rows[id].obj.rowIndex; |
| | | |
| | |
| | | { |
| | | if (this.rows[id] && !multiple) |
| | | { |
| | | this.clear_selection(); |
| | | this.selection[0] = id; |
| | | this.set_classname(this.rows[id].obj, 'selected', true); |
| | | if (this.selection.length > 1 || !this.in_selection(id)) |
| | | { |
| | | this.clear_selection(); |
| | | this.selection[0] = id; |
| | | this.set_classname(this.rows[id].obj, 'selected', true); |
| | | } |
| | | } |
| | | else if (this.rows[id]) |
| | | { |
| | |
| | | */ |
| | | key_press: function(e) |
| | | { |
| | | if (this.focused != true) |
| | | if (this.focused != true) |
| | | return true; |
| | | |
| | | var keyCode = document.layers ? e.which : document.all ? event.keyCode : document.getElementById ? e.keyCode : 0; |
| | | var keyCode = rcube_event.get_keycode(e); |
| | | var mod_key = rcube_event.get_modifier(e); |
| | | switch (keyCode) |
| | | { |
| | | case 40: |
| | | case 38: |
| | | case 63233: // "down", in safari keypress |
| | | case 63232: // "up", in safari keypress |
| | | // Stop propagation so that the browser doesn't scroll |
| | | rcube_event.cancel(e); |
| | | return this.use_arrow_key(keyCode, mod_key); |
| | | break; |
| | | |
| | | default: |
| | | this.shiftkey = e.shiftKey; |
| | | this.key_pressed = keyCode; |
| | |
| | | use_arrow_key: function(keyCode, mod_key) |
| | | { |
| | | var new_row; |
| | | if (keyCode == 40) // down arrow key pressed |
| | | // Safari uses the nonstandard keycodes 63232/63233 for up/down, if we're |
| | | // using the keypress event (but not the keydown or keyup event). |
| | | if (keyCode == 40 || keyCode == 63233) // down arrow key pressed |
| | | new_row = this.get_next_row(); |
| | | else if (keyCode == 38) // up arrow key pressed |
| | | else if (keyCode == 38 || keyCode == 63232) // up arrow key pressed |
| | | new_row = this.get_prev_row(); |
| | | |
| | | if (new_row) |
| | |
| | | rcube_event.remove_listener({element:document, event:'mousemove', object:this, method:'drag_mouse_move'}); |
| | | rcube_event.remove_listener({element:document, event:'mouseup', object:this, method:'drag_mouse_up'}); |
| | | |
| | | this.focus(); |
| | | |
| | | return rcube_event.cancel(e); |
| | | }, |
| | | |