Add (unified) get_next/get_prev/get_single_selection methods for list and treelist widgets

pull/6040/head
Aleksander Machniak 7 years ago
parent 93111b3bd7
commit 19ad6b15e8

@ -951,6 +951,22 @@ get_last_row: function()
return null;
},
get_next: function()
{
var row;
if (row = this.get_next_row()) {
return row.uid;
}
},
get_prev: function()
{
var row;
if (row = this.get_prev_row()) {
return row.uid;
}
},
row_tagname: function()
{
var row_tagnames = { table:'tr', ul:'li', '*':'div' };

@ -95,6 +95,9 @@ function rcube_treelist_widget(node, p)
this.get_item = get_item;
this.get_node = get_node;
this.get_selection = get_selection;
this.get_next = get_next;
this.get_prev = get_prev;
this.get_single_selection = get_selection;
this.is_search = is_search;
this.reset_search = reset_search;
@ -921,6 +924,44 @@ function rcube_treelist_widget(node, p)
}
function get_next()
{
var node, child;
if (selection && (node = id2dom(selection))) {
child = node.children('ul').children('li:first');
if (child.length) {
return dom2id(child);
}
node = node.next();
if (node.length) {
return dom2id(node);
}
}
}
function get_prev()
{
var node, prev, child;
if (selection && (node = id2dom(selection))) {
prev = node.prev();
child = prev.find('li:last');
if (child.length) {
return dom2id(child);
}
if (prev.length) {
return dom2id(prev);
}
node = node.parent().parent();
if (node.length && node.is('li')) {
return dom2id(node);
}
}
}
///// drag & drop support
/**

Loading…
Cancel
Save