diff options
author | Aleksander Machniak <alec@alec.pl> | 2014-06-24 12:03:53 +0200 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2014-06-24 12:03:53 +0200 |
commit | e306ac72fc0cc09ed3563d883fcc5bd3ff98dfdf (patch) | |
tree | 2da896fe50030bd041ff5502f193d91828ca05ea | |
parent | 7706df99f03fb5e492c92994d8e36620406a7a1a (diff) | |
parent | bde467d8da9fd78b169d58ece3e87ea99c6d3e68 (diff) |
Merge branch 'master' of github.com:roundcube/roundcubemail
-rw-r--r-- | program/js/treelist.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/program/js/treelist.js b/program/js/treelist.js index 631a81a6a..052d77bd5 100644 --- a/program/js/treelist.js +++ b/program/js/treelist.js @@ -339,18 +339,22 @@ function rcube_treelist_widget(node, p) if (updates.id || updates.html || updates.children || updates.classes || updates.parent) { if (updates.parent && (parent_node = indexbyid[updates.parent])) { // remove reference from old parent's child list - if (old_parent = indexbyid[dom2id(parent_ul.closest('li'))]) { + if (parent_ul.closest('li').length && (old_parent = indexbyid[dom2id(parent_ul.closest('li'))])) { old_parent.children = $.grep(old_parent.children, function(elem, i){ return elem.id != node.id; }); } + // append to new parent node parent_ul = id2dom(updates.parent).children('ul').first(); if (!parent_node.children) parent_node.children = []; parent_node.children.push(node); } + else if (updates.parent !== undefined) { + parent_ul = container; + } $.extend(node, updates); - render_node(node, parent_ul, li); + li = render_node(node, parent_ul, li); } if (node.id != id) { @@ -677,7 +681,7 @@ function rcube_treelist_widget(node, p) */ function dom2id(li) { - var domid = li.attr('id').replace(new RegExp('^' + (p.id_prefix) || '%'), '').replace(/--xsR$/, ''); + var domid = String(li.attr('id')).replace(new RegExp('^' + (p.id_prefix) || '%'), '').replace(/--xsR$/, ''); return p.id_decode ? p.id_decode(domid) : domid; } |