Unified and simplified keypress event handling on a list widget

pull/6828/head
Aleksander Machniak 5 years ago
parent b25699d2ac
commit 84c4d062c6

@ -22,7 +22,7 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
{multiselect:true, draggable:false, keyboard:true});
rcmail.keys_list
.addEventListener('select', function(o) { rcmail.enigma_keylist_select(o); })
.addEventListener('keypress', function(o) { rcmail.enigma_keylist_keypress(o); })
.addEventListener('keypress', function(o) { rcmail.list_keypress(o, {del: 'plugin.enigma-key-delete'}); })
.init()
.focus();
@ -353,19 +353,6 @@ rcube_webmail.prototype.enigma_keylist_select = function(list)
this.enable_command('plugin.enigma-key-delete', 'plugin.enigma-key-export-selected', list.get_selection().length > 0);
};
rcube_webmail.prototype.enigma_keylist_keypress = function(list)
{
if (list.modkey == CONTROL_KEY)
return;
if (list.key_pressed == list.DELETE_KEY || list.key_pressed == list.BACKSPACE_KEY)
this.command('plugin.enigma-key-delete');
else if (list.key_pressed == 33)
this.command('previouspage');
else if (list.key_pressed == 34)
this.command('nextpage');
};
// load key frame
rcube_webmail.prototype.enigma_loadframe = function(url)
{

@ -67,9 +67,10 @@ if (window.rcmail) {
{multiselect:false, draggable:true, keyboard:true});
rcmail.filters_list
.addEventListener('select', function(e) { rcmail.managesieve_select(e); })
.addEventListener('dragstart', function(e) { rcmail.managesieve_dragstart(e); })
.addEventListener('dragend', function(e) { rcmail.managesieve_dragend(e); })
.addEventListener('select', function(o) { rcmail.managesieve_select(o); })
.addEventListener('keypress', function(o) { rcmail.list_keypress(o, {del: 'plugin.managesieve-del'}); })
.addEventListener('dragstart', function(o) { rcmail.managesieve_dragstart(o); })
.addEventListener('dragend', function(o) { rcmail.managesieve_dragend(o); })
.addEventListener('initrow', function(row) {
row.obj.onmouseover = function() { rcmail.managesieve_focus_filter(row); };
row.obj.onmouseout = function() { rcmail.managesieve_unfocus_filter(row); };

@ -269,7 +269,7 @@ function rcube_webmail()
this.message_list
.addEventListener('initrow', function(o) { ref.init_message_row(o); })
.addEventListener('dblclick', function(o) { ref.msglist_dbl_click(o); })
.addEventListener('keypress', function(o) { ref.msglist_keypress(o); })
.addEventListener('keypress', function(o) { ref.list_keypress(o); })
.addEventListener('select', function(o) { ref.msglist_select(o); })
.addEventListener('dragstart', function(o) { ref.drag_start(o); })
.addEventListener('dragmove', function(e) { ref.drag_move(e); })
@ -509,7 +509,7 @@ function rcube_webmail()
{multiselect:true, draggable:this.gui_objects.folderlist?true:false, keyboard:true});
this.contact_list
.addEventListener('initrow', function(o) { ref.triggerEvent('insertrow', { cid:o.uid, row:o }); })
.addEventListener('keypress', function(o) { ref.contactlist_keypress(o); })
.addEventListener('keypress', function(o) { ref.list_keypress(o); })
.addEventListener('select', function(o) { ref.contactlist_select(o); })
.addEventListener('dragstart', function(o) { ref.drag_start(o); })
.addEventListener('dragmove', function(e) { ref.drag_move(e); })
@ -588,11 +588,7 @@ function rcube_webmail()
{multiselect:false, draggable:false, keyboard:true});
this.identity_list
.addEventListener('select', function(o) { ref.identity_select(o); })
.addEventListener('keypress', function(o) {
if (o.key_pressed == o.ENTER_KEY) {
ref.identity_select(o);
}
})
.addEventListener('keypress', function(o) { ref.list_keypress(o); })
.init()
.focus();
}
@ -600,7 +596,6 @@ function rcube_webmail()
this.sections_list = new rcube_list_widget(this.gui_objects.sectionslist, {multiselect:false, draggable:false, keyboard:true});
this.sections_list
.addEventListener('select', function(o) { ref.section_select(o); })
.addEventListener('keypress', function(o) { if (o.key_pressed == o.ENTER_KEY) ref.section_select(o); })
.init()
.focus();
}
@ -611,6 +606,7 @@ function rcube_webmail()
this.responses_list = new rcube_list_widget(this.gui_objects.responseslist, {multiselect:false, draggable:false, keyboard:true});
this.responses_list
.addEventListener('select', function(o) { ref.response_select(o); })
.addEventListener('keypress', function(o) { ref.list_keypress(o); })
.init()
.focus();
}
@ -1901,6 +1897,20 @@ function rcube_webmail()
return true;
}
// Common handler for a keypress event on a list widget
this.list_keypress = function(list, conf)
{
if (list.modkey == CONTROL_KEY)
return;
if (list.key_pressed == list.DELETE_KEY || list.key_pressed == list.BACKSPACE_KEY)
this.command(conf && conf.del ? conf.del : 'delete');
else if (list.key_pressed == 33)
this.command(conf && conf.prev ? conf.prev : 'previouspage');
else if (list.key_pressed == 34)
this.command(conf && conf.next ? conf.next : 'nextpage');
};
this.msglist_select = function(list)
{
if (this.preview_timer)
@ -1966,21 +1976,6 @@ function rcube_webmail()
this.show_message(uid, false, false);
};
this.msglist_keypress = function(list)
{
if (list.modkey == CONTROL_KEY)
return;
if (list.key_pressed == list.ENTER_KEY)
this.command('show');
else if (list.key_pressed == list.DELETE_KEY || list.key_pressed == list.BACKSPACE_KEY)
this.command('delete');
else if (list.key_pressed == 33)
this.command('previouspage');
else if (list.key_pressed == 34)
this.command('nextpage');
};
this.msglist_get_preview = function()
{
var uid = this.get_single_uid();
@ -6097,12 +6092,6 @@ function rcube_webmail()
/********* address book methods *********/
/*********************************************************/
this.contactlist_keypress = function(list)
{
if (list.key_pressed == list.DELETE_KEY)
this.command('delete');
};
this.contactlist_select = function(list)
{
if (this.preview_timer)

Loading…
Cancel
Save