Change to work with IDs and non-id trees
parent
2ba68bd3bb
commit
1242eff76e
|
@ -7,6 +7,10 @@
|
||||||
* Based on the work of Mark Lee
|
* Based on the work of Mark Lee
|
||||||
* http://www.capricasoftware.co.uk
|
* http://www.capricasoftware.co.uk
|
||||||
*
|
*
|
||||||
|
* ID implementation by Aleks Drevenšek
|
||||||
|
*
|
||||||
|
* ID implementation fixed(changed) by Adrian Hinz
|
||||||
|
*
|
||||||
* This software is licensed under the Creative Commons Attribution-ShareAlike
|
* This software is licensed under the Creative Commons Attribution-ShareAlike
|
||||||
* 3.0 License.
|
* 3.0 License.
|
||||||
*
|
*
|
||||||
|
@ -81,8 +85,14 @@
|
||||||
.children("ul,li")
|
.children("ul,li")
|
||||||
.remove()
|
.remove()
|
||||||
.end();
|
.end();
|
||||||
|
var attr = li.attr('id');
|
||||||
|
if (typeof attr !== 'undefined' && attr !== false) {
|
||||||
|
return li.attr("id") == targetNode.attr("id");
|
||||||
|
}
|
||||||
|
else {
|
||||||
return li.html() == targetNode.html();
|
return li.html() == targetNode.html();
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var sourceLi = $('li').filter(function(){
|
var sourceLi = $('li').filter(function(){
|
||||||
|
@ -91,8 +101,14 @@
|
||||||
.children("ul,li")
|
.children("ul,li")
|
||||||
.remove()
|
.remove()
|
||||||
.end();
|
.end();
|
||||||
|
var attr = li.attr('id');
|
||||||
|
if (typeof attr !== 'undefined' && attr !== false) {
|
||||||
|
return li.attr("id") == sourceNode.attr("id");
|
||||||
|
}
|
||||||
|
else {
|
||||||
return li.html() == sourceNode.html();
|
return li.html() == sourceNode.html();
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var sourceliClone = sourceLi.clone();
|
var sourceliClone = sourceLi.clone();
|
||||||
|
@ -104,11 +120,21 @@
|
||||||
sourceUl.remove();
|
sourceUl.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var id = sourceLi.attr("id");
|
||||||
|
|
||||||
if(targetLi.children('ul').size() >0){
|
if(targetLi.children('ul').size() >0){
|
||||||
|
if (typeof id !== 'undefined' && id !== false) {
|
||||||
|
targetLi.children('ul').append('<li id="'+id+'">'+sourceliClone.html()+'</li>');
|
||||||
|
}else{
|
||||||
targetLi.children('ul').append('<li>'+sourceliClone.html()+'</li>');
|
targetLi.children('ul').append('<li>'+sourceliClone.html()+'</li>');
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if (typeof id !== 'undefined' && id !== false) {
|
||||||
|
targetLi.append('<ul><li id="'+id+'">'+sourceliClone.html()+'</li></ul>');
|
||||||
}else{
|
}else{
|
||||||
targetLi.append('<ul><li>'+sourceliClone.html()+'</li></ul>');
|
targetLi.append('<ul><li>'+sourceliClone.html()+'</li></ul>');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}); // handleDropEvent
|
}); // handleDropEvent
|
||||||
|
|
||||||
|
@ -146,7 +172,12 @@
|
||||||
.end()
|
.end()
|
||||||
.html();
|
.html();
|
||||||
|
|
||||||
|
var new_node_id = $node.attr("id")
|
||||||
|
if (typeof new_node_id !== 'undefined' && new_node_id !== false) {
|
||||||
|
$nodeDiv = $("<div>").addClass("node").attr("id", $node.attr("id")).append($nodeContent);
|
||||||
|
}else{
|
||||||
$nodeDiv = $("<div>").addClass("node").append($nodeContent);
|
$nodeDiv = $("<div>").addClass("node").append($nodeContent);
|
||||||
|
}
|
||||||
|
|
||||||
// Expand and contract nodes
|
// Expand and contract nodes
|
||||||
if ($childNodes.length > 0) {
|
if ($childNodes.length > 0) {
|
||||||
|
|
Loading…
Reference in New Issue