|
|
|
@ -31,18 +31,18 @@ function rcube_treelist_widget(node, p)
|
|
|
|
|
check_droptarget: function(node){ return !node.virtual }
|
|
|
|
|
}, p || {});
|
|
|
|
|
|
|
|
|
|
var container = $(node);
|
|
|
|
|
var data = p.data || [];
|
|
|
|
|
var indexbyid = {};
|
|
|
|
|
var selection = null;
|
|
|
|
|
var drag_active = false;
|
|
|
|
|
var box_coords = {};
|
|
|
|
|
var item_coords = [];
|
|
|
|
|
var autoexpand_timer;
|
|
|
|
|
var autoexpand_item;
|
|
|
|
|
var body_scroll_top = 0;
|
|
|
|
|
var list_scroll_top = 0;
|
|
|
|
|
var me = this;
|
|
|
|
|
var container = $(node),
|
|
|
|
|
data = p.data || [],
|
|
|
|
|
indexbyid = {},
|
|
|
|
|
selection = null,
|
|
|
|
|
drag_active = false,
|
|
|
|
|
box_coords = {},
|
|
|
|
|
item_coords = [],
|
|
|
|
|
autoexpand_timer,
|
|
|
|
|
autoexpand_item,
|
|
|
|
|
body_scroll_top = 0,
|
|
|
|
|
list_scroll_top = 0,
|
|
|
|
|
me = this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/////// export public members and methods
|
|
|
|
@ -61,20 +61,17 @@ function rcube_treelist_widget(node, p)
|
|
|
|
|
this.get_item = get_item;
|
|
|
|
|
this.get_selection = get_selection;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/////// startup code (constructor)
|
|
|
|
|
|
|
|
|
|
// abort if node not found
|
|
|
|
|
if (!container.length)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (p.data) {
|
|
|
|
|
if (p.data)
|
|
|
|
|
index_data({ children:data });
|
|
|
|
|
}
|
|
|
|
|
// load data from DOM
|
|
|
|
|
else {
|
|
|
|
|
else
|
|
|
|
|
update_data();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// register click handlers on list
|
|
|
|
|
container.on('click', 'div.treetoggle', function(e){
|
|
|
|
@ -98,6 +95,7 @@ function rcube_treelist_widget(node, p)
|
|
|
|
|
function collapse(id, recursive, set)
|
|
|
|
|
{
|
|
|
|
|
var node;
|
|
|
|
|
|
|
|
|
|
if (node = indexbyid[id]) {
|
|
|
|
|
node.collapsed = typeof set == 'undefined' || set;
|
|
|
|
|
update_dom(node);
|
|
|
|
@ -218,6 +216,7 @@ function rcube_treelist_widget(node, p)
|
|
|
|
|
function update_node(id, updates, sort)
|
|
|
|
|
{
|
|
|
|
|
var li, node = indexbyid[id];
|
|
|
|
|
|
|
|
|
|
if (node) {
|
|
|
|
|
li = id2dom(id);
|
|
|
|
|
|
|
|
|
@ -277,6 +276,7 @@ function rcube_treelist_widget(node, p)
|
|
|
|
|
function remove(id)
|
|
|
|
|
{
|
|
|
|
|
var node, li;
|
|
|
|
|
|
|
|
|
|
if (node = indexbyid[id]) {
|
|
|
|
|
li = id2dom(id);
|
|
|
|
|
li.remove();
|
|
|
|
@ -345,12 +345,10 @@ function rcube_treelist_widget(node, p)
|
|
|
|
|
else
|
|
|
|
|
li.appendTo(parent);
|
|
|
|
|
|
|
|
|
|
if (typeof node.html == 'string') {
|
|
|
|
|
if (typeof node.html == 'string')
|
|
|
|
|
li.html(node.html);
|
|
|
|
|
}
|
|
|
|
|
else if (typeof node.html == 'object') {
|
|
|
|
|
else if (typeof node.html == 'object')
|
|
|
|
|
li.append(node.html);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (node.virtual)
|
|
|
|
|
li.addClass('virtual');
|
|
|
|
|