From 8ff57d21dcae9206cb6e76179660c90ada30adcc Mon Sep 17 00:00:00 2001 From: luqiong <605601787@qq.com> Date: Thu, 21 Aug 2014 13:40:00 +0800 Subject: [PATCH] edit usePlugin --- .../webapp/script/editor/jstreeFactory.js | 2 +- .../main/webapp/script/editor/usePlugin.js | 35 ++++++++----------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/Bench4Q-Web/src/main/webapp/script/editor/jstreeFactory.js b/Bench4Q-Web/src/main/webapp/script/editor/jstreeFactory.js index 12aeee62..ecad85d4 100644 --- a/Bench4Q-Web/src/main/webapp/script/editor/jstreeFactory.js +++ b/Bench4Q-Web/src/main/webapp/script/editor/jstreeFactory.js @@ -79,7 +79,7 @@ function jstreeCreate(containerId){ "themes" : { "stripes" : true } }, "types" : { - "#" : { "max_depth" : 4, "valid_children" : ["page"] }, + "#" : { "max_depth" : 4, "valid_children" : ["page","default"] }, "page" : { "icon" : false, "valid_children" : ["batch"] }, "batch" : { "icon" : false, "valid_children" : ["default"] }, "default" : { "icon" : false, "valid_children" : [] } diff --git a/Bench4Q-Web/src/main/webapp/script/editor/usePlugin.js b/Bench4Q-Web/src/main/webapp/script/editor/usePlugin.js index 603165c3..0feb8602 100644 --- a/Bench4Q-Web/src/main/webapp/script/editor/usePlugin.js +++ b/Bench4Q-Web/src/main/webapp/script/editor/usePlugin.js @@ -6,17 +6,18 @@ function PluginModel(id, name) { } function UsePlugin() { + this.containerId = "usePluginList"; var usePlugin = this; this.map = new HashMap(); this.index = 1; this.usePluginEditorMap = new HashMap(); + jstreeCreate(this.containerId); + $("#addPlugin").click(function() { $("#addPlugin").addClass("clicked"); $("#selectUsePlugin").modal('show'); }); - $("#deletePlugin").click(function() { - - }); + $("#selectUsePlugin #ok").click( function() { var pluginName = $( @@ -25,36 +26,29 @@ function UsePlugin() { return; } var pluginModel = new PluginModel(usePlugin.index, pluginName); - - $("#usePluginList").append( - createRadio( pluginModel.id, pluginModel.nickName, - "usePlugin",pluginModel.name)); - + pos = "after"; + jstreeCreateNode("usePluginList",pluginName,pluginName,usePlugin.index,pos); usePlugin.map.put(pluginModel.id, pluginModel); - usePlugin.updateUsePlugin(); - usePlugin.createEditor(pluginModel); usePlugin.index++; $("#selectUsePlugin").modal('hide'); - }); $("#selectUsePlugin #cancel").click(function() { $("#selectUsePlugin").modal('hide'); }); + $("#removePlugin").click( function() { - var pluginId = $( - "#usePluginList input[name='usePlugin']:checked").attr( - "id"); - if (pluginId == undefined) { + var pluginId = getSelectedNodes(usePlugin.containerId); + if (!pluginId.length) { return; - } else { - usePlugin.map.remove(pluginId); - usePlugin.usePluginEditorMap.remove(pluginId); - usePlugin.createUsePlugin(usePlugin.map); - } + } + usePlugin.map.remove(pluginId); + usePlugin.usePluginEditorMap.remove(pluginId); + jstreeDeleteNode(usePlugin.containerId); + // usePlugin.createUsePlugin(usePlugin.map); $("#usePluginEditor").attr("usePlugin", ""); $("#usePluginEditor").html(""); @@ -63,6 +57,7 @@ function UsePlugin() { $("#usePluginList").html(""); usePlugin.map.clear(); usePlugin.usePluginEditorMap.clear(); + //jstreeClearNode(usePlugin.containerId); }); this.createUsePlugin = function(map) { $("#usePluginList").html("");