edit clear jstree
This commit is contained in:
parent
9d874db5be
commit
e0b0f7eeb4
|
@ -201,6 +201,7 @@ function Behavior(usePlugin) {
|
|||
$("#behaviorEditor").attr("behavior", "");
|
||||
});
|
||||
$("#clearBehavior").click(function() {
|
||||
$("#insertChildDiv").addClass("hide");
|
||||
behavior.behaviorList = [];
|
||||
behavior.behaviorEditorMap.clear();
|
||||
//clear tree
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
* node,"after" or "before" means the sibling node of the selected node
|
||||
*/
|
||||
function jstreeCreateNode(containerId,data,name,id,pos){
|
||||
var ref = $("#"+containerId).jstree(true);
|
||||
var parentNode = ref.get_selected();
|
||||
var treeObj = $("#"+containerId).jstree(true);
|
||||
var parentNode = treeObj.get_selected();
|
||||
var childNode = null;
|
||||
if(!parentNode.length){
|
||||
parentNode=null;
|
||||
|
@ -16,9 +16,9 @@ function jstreeCreateNode(containerId,data,name,id,pos){
|
|||
else{
|
||||
parentNode = parentNode[0];
|
||||
}
|
||||
childNode = ref.create_node(parentNode,{text:name,id:id,data:data,type:"default"},pos);
|
||||
childNode = treeObj.create_node(parentNode,{text:name,id:id,data:data,type:"default"},pos);
|
||||
if(childNode) {
|
||||
ref.open_node(parentNode);
|
||||
treeObj.open_node(parentNode);
|
||||
//jstreeSelectNode(containerId,childNode);
|
||||
}
|
||||
}
|
||||
|
@ -28,32 +28,43 @@ function jstreeCreateNode(containerId,data,name,id,pos){
|
|||
* @param containerId the id of jstree container
|
||||
*/
|
||||
function jstreeDeleteNode(containerId){
|
||||
var ref = $("#"+containerId).jstree(true);
|
||||
var parentNode = ref.get_selected();
|
||||
var treeObj = $("#"+containerId).jstree(true);
|
||||
var parentNode = treeObj.get_selected();
|
||||
if(!parentNode.length){return false;}
|
||||
ref.delete_node(parentNode);
|
||||
return ref.element.context.id;
|
||||
treeObj.delete_node(parentNode);
|
||||
return treeObj.element.context.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* delete all node
|
||||
* @param containerId the id of jstree container
|
||||
*/
|
||||
function jstreeClearNode(containerId){
|
||||
var treeObj = $("#"+containerId).jstree(true);
|
||||
var nodes = treeObj.get_children_dom("#");
|
||||
while(nodes.length){
|
||||
treeObj.delete_node(nodes);
|
||||
nodes = treeObj.get_children_dom("#");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param containerId the id of jstree container
|
||||
* @param node the id of to be selected node
|
||||
*/
|
||||
function jstreeSelectNode(containerId,node){
|
||||
var ref = $("#"+containerId).jstree(true);
|
||||
ref.deselect_all();
|
||||
ref.select_node(node);
|
||||
var treeObj = $("#"+containerId).jstree(true);
|
||||
treeObj.deselect_all();
|
||||
treeObj.select_node(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param containerId the id of jstree container
|
||||
|
||||
function jstreeRenameNode(containerId){
|
||||
var ref = $("#"+containerId).jstree(true);
|
||||
var sel = ref.get_selected();
|
||||
if(!sel.length){return false;}
|
||||
sel = sel[0];
|
||||
ref.edit(sel);
|
||||
} */
|
||||
*/
|
||||
function getSelectedNodes(containerId){
|
||||
var treeObj = $("#"+containerId).jstree(true);
|
||||
return treeObj.get_selected(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param containerId the id of jstree container
|
||||
|
@ -66,40 +77,20 @@ function jstreeCreate(containerId){
|
|||
"themes" : { "stripes" : true }
|
||||
},
|
||||
"types" : {
|
||||
"default" : {"icon" : "/images/tree_icon.png"}
|
||||
"default" : {"icon" : false}
|
||||
},
|
||||
"contextmenu" : {
|
||||
"items" : function(node) {
|
||||
var tmp = $.jstree.defaults.contextmenu.items();
|
||||
delete tmp.create;
|
||||
delete tmp.ccp;
|
||||
if(node.data!="page" && node.data!="batch"){
|
||||
delete tmp.rename;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
},
|
||||
"plugins" : [ "contextmenu","dnd","types","wholerow" ]
|
||||
}).on('select_node.jstree',function(e,data){
|
||||
if(data.selected.length>1){
|
||||
var ref = $("#"+containerId).jstree(true);
|
||||
ref.deselect_all();
|
||||
ref.select_node(data.node);
|
||||
}
|
||||
"plugins" : [ "contextmenu","types","wholerow" ]
|
||||
})
|
||||
return $("#"+containerId).jstree(true);
|
||||
}
|
||||
|
||||
function getSelectedNodes(containerId){
|
||||
var treeObj = $("#"+containerId).jstree(true);
|
||||
return treeObj.get_selected(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param containerId the id of jstree container
|
||||
*/
|
||||
function jstreeClearNode(containerId){
|
||||
var ref = $("#"+containerId).jstree(true);
|
||||
var parentNode = ref.get_selected("#");
|
||||
if(!parentNode.length){return false;}
|
||||
ref.delete_node(parentNode);
|
||||
return ref.element.context.id;
|
||||
}
|
Loading…
Reference in New Issue