refactor code to scriptEdit,add function to edit plugin
in editScript.js
This commit is contained in:
parent
e47d05f7e3
commit
a8019b1e79
|
@ -242,7 +242,7 @@ a {
|
|||
background-color: #F5F5F5;
|
||||
}
|
||||
|
||||
.all-behaviors #behaviorUl {
|
||||
.all-behaviors #behaviorUl,#usePlugin {
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
|
|
@ -272,7 +272,7 @@ body {
|
|||
<script src="script/pluginModel.js"></script>
|
||||
<script src="script/plugin-new.js"></script>
|
||||
<script src="script/submitPluginMessage.js"></script>
|
||||
<script src="script/behaviorsForm.js"></script>
|
||||
<script src="script/paramInfosForm.js"></script>
|
||||
</fmt:bundle>
|
||||
</body>
|
||||
</html>
|
|
@ -139,9 +139,9 @@ body {
|
|||
<div class="box-content row-fluid">
|
||||
<div id="behaviorArea" class="listArea span8"></div>
|
||||
<div class="span4 button-div">
|
||||
<div class="hide" id="insertBefore">
|
||||
<div class="hide" id="insertBeforeButton">
|
||||
<button type="submit" class="btn btn-primary btn-width"
|
||||
onClick="insert();">
|
||||
id="insertBefore">
|
||||
<fmt:message key="plugin_jsp_insertBefore" />
|
||||
</button>
|
||||
</div>
|
||||
|
@ -153,14 +153,13 @@ body {
|
|||
</div>
|
||||
<div>
|
||||
<button type="submit" class="btn btn-primary btn-width"
|
||||
id="removeBehavior_Plugin"
|
||||
onClick="removeInsertPluginByClicked();">
|
||||
id="removeBehaviorWithPlugin">
|
||||
<fmt:message key="plugin_jsp_remove" />
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit" class="btn btn-primary btn-width"
|
||||
onClick="clearPluginMethodList();">
|
||||
id="clearBehaviorWithPluginList">
|
||||
<fmt:message key="plugin_jsp_clear" />
|
||||
</button>
|
||||
</div>
|
||||
|
@ -238,7 +237,7 @@ body {
|
|||
<div class="modal-footer">
|
||||
|
||||
<button type="button" class="btn btn-primary btn-width"
|
||||
onClick="behaviorFinish();" id="behaviorFinish">
|
||||
id="behaviorFinish">
|
||||
<fmt:message key="plugin_jsp_finish" />
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary btn-width" onClick=""
|
||||
|
@ -270,11 +269,12 @@ body {
|
|||
<script src="lib/chrisma/js/theme.js"></script>
|
||||
<script src="script/base.js"></script>
|
||||
<script src="script/plugin.js"></script>
|
||||
<script src="script/paramInfosForm.js"></script>
|
||||
<script src="script/pluginModel.js"></script>
|
||||
<script src="script/ScriptEditor/ContainerManager.js"></script>
|
||||
<script src="script/ScriptEditor/usePluginEditor.js"></script>
|
||||
<script src="script/ScriptEditor/scriptEditor.js"></script>
|
||||
|
||||
<!-- <script src="script/pluginModel.js"></script>
|
||||
<script src="script/ScriptEditor/useBehaviorEditor.js"></script>
|
||||
<script src="script/ScriptEditor/scriptEditor.js"></script><!-- <script src="script/pluginModel.js"></script>
|
||||
<script src="script/pluginCommon.js"></script>
|
||||
<script src="script/plugin-new.js"></script>
|
||||
<script src="script/submitPluginMessage.js"></script>
|
||||
|
|
|
@ -42,10 +42,8 @@
|
|||
<ul style="cursor: pointer" class="nav nav-tabs">
|
||||
<li id="tow1" class="on" onclick='refresh();setTab("tow",1,3);'><a
|
||||
href="#">View</a></li>
|
||||
<li id="tow2" onclick='setTab("tow",2,3);'><a
|
||||
href="#">EditBehaviors</a></li>
|
||||
<li id="tow3" onclick='setTab("tow",3,3);editPlugin();'><a
|
||||
href="#">EditPlugins</a></li>
|
||||
<li id="tow2" onclick='setTab("tow",2,3);'><a href="#">EditBehaviors</a></li>
|
||||
<li id="tow3" onclick='setTab("tow",3,3);'><a href="#">EditPlugins</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="span10">
|
||||
|
@ -93,43 +91,40 @@
|
|||
</div>
|
||||
|
||||
<div id="cont_tow_3" class="one" style="display: none">
|
||||
<div class="box span6">
|
||||
<div class="box-header well" data-original-title>
|
||||
<i class="icon-pencil left"></i>
|
||||
<h2>
|
||||
<span><fmt:message key="plugin_jsp_plugins" />(usePlugins)</span>
|
||||
</h2>
|
||||
<div class="box-icon">
|
||||
<a href="#" class="btn btn-minimize btn-round"><i
|
||||
class="icon-chevron-up"></i></a>
|
||||
<div class="all-plugins btn-group span12">
|
||||
<a class="btn dropdown-toggle" href="#" data-toggle="dropdown">
|
||||
<span class="hidden-phone"> All plug-ins </span> <span
|
||||
class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" id="allPlugins">
|
||||
<li><a onclick="choosePlugin(this);">All</a></li>
|
||||
<li class="divider"></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-content row-fluid span12">
|
||||
|
||||
<div id="editPluginArea" class="listArea span8"></div>
|
||||
<div class=" span4 button-div">
|
||||
<div>
|
||||
<button type="submit" class="btn btn-primary btn-width"
|
||||
id="addPlugin" onClick="addPlugin();">
|
||||
<fmt:message key="plugin_jsp_add" />
|
||||
<div class="row-fluid">
|
||||
<div id="usePlugins" class="all-behaviors span4">
|
||||
<ul id="usePlugin">
|
||||
</ul>
|
||||
</div>
|
||||
<div class="span8">
|
||||
<div id="pluginParamArea"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="usePluginAction" style="float:right">
|
||||
<button type="button" class="btn btn-primary" id="submit"
|
||||
title="save edit">
|
||||
<fmt:message key="script_edit_jsp_save"></fmt:message>
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary" id="cancel"
|
||||
title="cancel edit">
|
||||
<fmt:message key="script_edit_jsp_cancel" />
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary" id="validate"
|
||||
title="validate edit">
|
||||
<fmt:message key="script_edit_jsp_validate"></fmt:message>
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit" class="btn btn-primary btn-width"
|
||||
id="removePlugin" onClick="removePluginByClicked();">
|
||||
<fmt:message key="plugin_jsp_remove" />
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit" class="btn btn-primary btn-width"
|
||||
id="removeAllPlugin" onClick="clearPluginChoosedList();">
|
||||
<fmt:message key="plugin_jsp_clear" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="span6" id="editPluginParams"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -162,7 +157,7 @@
|
|||
<script src="script/base.js"></script>
|
||||
<script src="script/pluginCommon.js"></script>
|
||||
<script src="script/jsonEditorApp.js"></script>
|
||||
<script src="script/behaviorsForm.js"></script>
|
||||
<script src="script/paramInfosForm.js"></script>
|
||||
<script src="script/pluginModel.js"></script>
|
||||
<script src="script/editScript.js"></script>
|
||||
</fmt:bundle>
|
||||
|
|
|
@ -49,3 +49,55 @@ Container.prototype. createALine=function(name, index, list) {
|
|||
div.appendChild(p);
|
||||
return div;
|
||||
};
|
||||
Container.prototype.showChoosedLines = function(container, clickNode) {
|
||||
var choosedNode = container.children();
|
||||
for (var i = 0; i < choosedNode.length; i++) {
|
||||
if (i == clickNode) {
|
||||
$(choosedNode[i]).find("p").attr("class", "visited");
|
||||
|
||||
} else {
|
||||
$(choosedNode[i]).find("p").attr("class", "");
|
||||
}
|
||||
}
|
||||
};
|
||||
Container.prototype.showChoosedParamInfos = function(container, clickNode) {
|
||||
var div = container.children();// pluginParams
|
||||
for (var j = 0; j < div.length; j++) {
|
||||
if (div[j].getAttribute("id") == clickNode) {
|
||||
$(div[j]).show();
|
||||
} else {
|
||||
$(div[j]).hide();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Container.prototype.createBehaviorWithPluginLines = function(behavior) {
|
||||
this.behaviorParamConfigContianer.html("");
|
||||
this.useBehaviorListContainer.html("");
|
||||
for (var j = 0; j < behavior.behaviorWithPluginList.length; j++) {
|
||||
var div = this.createALine(behavior.behaviorWithPluginList[j], j,
|
||||
"pluginMethodList");
|
||||
if (j == behavior.clickPluginBehaviorNode) {
|
||||
$(div).find("p").attr("class", "visited");
|
||||
}
|
||||
document.getElementById('behaviorArea').appendChild(div);
|
||||
behavior.useParamInforsContainerInit(j);
|
||||
}
|
||||
};
|
||||
|
||||
Container.prototype.createParamInforsContainer = function(data, name, index) {
|
||||
var documentHtml = "";
|
||||
var boxHeader = "";
|
||||
var paramHtml = "";
|
||||
boxHeader = "<div class='box-header well' data-original-title> "
|
||||
+ "<i class='icon-pencil left'></i>" + "<h2>sample:<i>" + name
|
||||
+ "</i></h2></div>";
|
||||
if (data != null) {
|
||||
paramHtml = createPluginsOrBehaviorsForm(data, index);
|
||||
}
|
||||
documentHtml = "<div id='" + index + "' class='hide'><p class='hide'>"
|
||||
+ name + "</p><div class='span12 box' style='margin-left:-2px;'>"
|
||||
+ boxHeader + "<div class='box-content'>" + paramHtml + "</div>"
|
||||
+ "</div></div>";
|
||||
return documentHtml;
|
||||
};
|
||||
|
|
|
@ -1,20 +1,37 @@
|
|||
var container = new Container();
|
||||
var plugin = new Plugin(container);
|
||||
|
||||
var behavior = new Behavior(container, plugin);
|
||||
var files = [];
|
||||
$(document).ready(function() {
|
||||
pluginEditor();
|
||||
});
|
||||
function pluginEditor() {
|
||||
pluginEditorInit();
|
||||
});
|
||||
|
||||
$("#addPlugin").click(function(e) {
|
||||
$("#myModal_Plugin").modal('show');
|
||||
});
|
||||
|
||||
$("#pluginFinish").click(function(e) {
|
||||
$('#pluginArea').html("");
|
||||
plugin.addUsePlugin();
|
||||
var item = $("input[type='radio']:checked").val();
|
||||
plugin.addUsePlugin(item);
|
||||
plugin.usePluginContainerInit(container.usePluginContainer);
|
||||
plugin.usePluginParamInfosContainerInit(item);
|
||||
$("#myModal_Plugin").modal('hide');
|
||||
$("input[type=file]").change(function(event) {
|
||||
fileChange(event);
|
||||
});
|
||||
});
|
||||
|
||||
function fileChange(event) {
|
||||
$.each(event.target.files, function(index, file) {
|
||||
var reader = new FileReader();
|
||||
reader.onload = function(event) {
|
||||
object = {};
|
||||
object.filename = file.name;
|
||||
object.data = event.target.result;
|
||||
files.push(object);
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -25,25 +42,82 @@ function pluginEditorInit() {
|
|||
function choosePlugin(selectedNode) {
|
||||
plugin.setClickPluginChoosedNodeIndex(selectedNode);
|
||||
plugin.setClickPluginChoosedNodeName(selectedNode);
|
||||
alert(plugin.clickPluginChoosedNodeName);
|
||||
plugin.showChoosedPluginLine(container.usePluginContainer);
|
||||
plugin.showChoosedPluginParamInfos(container.pluginParamConfigContainer);
|
||||
container.showChoosedLines(container.usePluginContainer,
|
||||
plugin.clickPluginChoosedNodeIndex);
|
||||
container.showChoosedParamInfos(container.pluginParamConfigContainer,
|
||||
plugin.clickPluginChoosedNodeIndex);
|
||||
}
|
||||
|
||||
$('#removePlugin').click(function() {
|
||||
plugin.deleteUsePlugin(plugin.clickPluginChoosedNodeName);
|
||||
plugin.removeUsePluginByClicked(container.usePluginContainer);
|
||||
plugin.removeUsePluginParamInfos();
|
||||
container.usePluginContainer.html("");
|
||||
plugin.usePluginContainerInit(container.usePluginContainer);
|
||||
});
|
||||
|
||||
$('#removeAllPlugin').click(function() {
|
||||
plugin.clearUsePluginContainer(container.usePluginContainer);
|
||||
container.usePluginContainer.html("");// pluginArea
|
||||
container.pluginParamConfigContainer.html("");// pluginParams
|
||||
});
|
||||
|
||||
function behaviorEditor() {
|
||||
var behavior = new Behavior(container, plugin);
|
||||
$('#insertAfter').click(function(e) {
|
||||
container.behaviorListForPlugin.html("");
|
||||
$('#myModal_Behavior').modal('show');
|
||||
behavior.insertAUsePlugin("after", co);
|
||||
behavior.usePluginListContainerInit("after", container.usePluginModal);
|
||||
$('#insertBeforeButton').attr("class", "show");
|
||||
});
|
||||
|
||||
$('#insertBefore').click(function() {
|
||||
container.behaviorListForPlugin.html("");
|
||||
$('#myModal_Behavior').modal('show');
|
||||
behavior.usePluginListContainerInit("before", container.usePluginModal);
|
||||
});
|
||||
|
||||
$('#insertPluginAreaPlugins').click(function() {
|
||||
var pluginName = $("input[type='radio']:checked").val();
|
||||
behavior.getBehaviorListOfOnePlugin(pluginName);
|
||||
});
|
||||
|
||||
$('#behaviorFinish').click(function() {
|
||||
var plugin = $("input[name='plugin']:checked").val();
|
||||
var behaivor = $("input[name='method']:checked").val();
|
||||
if (plugin != null && plugin != "" && behaivor != null && behaivor != "") {
|
||||
behavior.useBehaviorOfOnePluginContainerInit(plugin, behaivor);
|
||||
behavior.createBehaviorWithPluginLines();
|
||||
// container.createBehaviorWithPluginLines(behavior);
|
||||
$("input[type=file]").change(function(event) {
|
||||
fileChange(event);
|
||||
});
|
||||
} else {
|
||||
alert("The plugin or the method can not be null!");
|
||||
$('#myModal_Behavior').modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
function showMethodDocument(selectedNode) {
|
||||
behavior.clickPluginBehaviorNode = parseInt($(selectedNode).attr("id"));
|
||||
container.showChoosedLines(container.useBehaviorListContainer,
|
||||
behavior.clickPluginBehaviorNode);
|
||||
container.showChoosedParamInfos(container.behaviorParamConfigContianer,
|
||||
behavior.clickPluginBehaviorNode);
|
||||
$('#submitBehaviors').attr("class", "show");
|
||||
}
|
||||
|
||||
$('#removeBehaviorWithPlugin').click(function() {
|
||||
behavior.removeInsertPluginByClicked();
|
||||
behavior.removeUseBehaviorWithPluginParamInfo();
|
||||
container.createBehaviorWithPluginLines(behavior);
|
||||
});
|
||||
|
||||
$('#clearBehaviorWithPluginList').click(function() {
|
||||
behavior.clearBehaviorWithPluginList();
|
||||
});
|
||||
|
||||
$('#pluginCancel').click(function() {
|
||||
$('#myModal_Plugin').modal('hide');
|
||||
});
|
||||
|
||||
$('#behaviorCancel').click(function() {
|
||||
$('#myModal_Behavior').modal('hide');
|
||||
});
|
||||
|
|
|
@ -2,10 +2,20 @@ var Behavior = function(containerManager, plugin) {
|
|||
this.containerManager = containerManager;
|
||||
this.plugin = plugin;
|
||||
this.clickPluginBehaviorNode = -1;
|
||||
this.insertLocation = "after";
|
||||
this.behaviorList = [];// 存放所有方法及其对应的parameter
|
||||
this.behaviorWithPluginList = new Array();
|
||||
};
|
||||
|
||||
Behavior.prototype.insertAUsePlugin = function(insertLocation, container) {
|
||||
Behavior.prototype.setClickPluginBehaviorNode = function(
|
||||
clickPluginBehaviorNode) {
|
||||
this.clickPluginBehaviorNode = clickPluginBehaviorNode;
|
||||
};
|
||||
|
||||
Behavior.prototype.usePluginListContainerInit = function(insertLocation,
|
||||
container) {
|
||||
var chooesedPluginHtml = "";
|
||||
this.setInsertLocation(insertLocation);
|
||||
for (var i = 0; i < this.plugin.usePluginList.length; i++) {
|
||||
chooesedPluginHtml += this.containerManager.createLineWithRadio(
|
||||
this.plugin.usePluginList[i], "plugin");
|
||||
|
@ -13,27 +23,11 @@ Behavior.prototype.insertAUsePlugin = function(insertLocation, container) {
|
|||
container.html(chooesedPluginHtml);// insertPluginAreaPlugins
|
||||
};
|
||||
|
||||
function insert() {
|
||||
place = "before";
|
||||
insertPlugin();
|
||||
}
|
||||
Behavior.prototype.setInsertLocation = function(insertLocation) {
|
||||
this.insertLocation = insertLocation;
|
||||
};
|
||||
|
||||
function insertAfter() {
|
||||
place = "after";
|
||||
insertPlugin();
|
||||
}
|
||||
|
||||
function insertPlugin() {
|
||||
document.getElementById("pluginMethod").innerHTML = "";
|
||||
$('#myModal_Behavior').modal('show');
|
||||
|
||||
}
|
||||
|
||||
$('#insertPluginAreaPlugins').click(function() {
|
||||
var pluginName = $("input[type='radio']:checked").val();
|
||||
getBehaviorList(pluginName);
|
||||
});
|
||||
function loadBehaviorList(plugin) {
|
||||
Behavior.prototype.loadBehaviorList = function(plugin) {
|
||||
var behaviors = null;
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
|
@ -50,156 +44,97 @@ function loadBehaviorList(plugin) {
|
|||
}
|
||||
});
|
||||
return behaviors;
|
||||
}
|
||||
function getBehaviorList(pluginName) {
|
||||
var methodHtml = "";
|
||||
var type = pluginName.split("_");
|
||||
var plugin = type[0];
|
||||
behaviorList.splice(0, behaviorList.length);
|
||||
var behaviors = loadBehaviorList(plugin);
|
||||
};
|
||||
|
||||
Behavior.prototype.getBehaviorListOfOnePlugin = function(pluginName) {
|
||||
var behaviorHtml = "";
|
||||
this.behaviorList.splice(0, this.behaviorList.length);
|
||||
var behaviors = this.loadBehaviorList(pluginName.split("_")[0]);
|
||||
for (var i = 0; i < behaviors.length; i++) {
|
||||
behaviorList.push(behaviors[i].name);
|
||||
behaviorList[behaviors[i].name] = behaviors[i].paramInfoModels;
|
||||
methodHtml += createLineWithRadio(behaviors[i].name, "method");
|
||||
}
|
||||
document.getElementById("pluginMethod").innerHTML = methodHtml;
|
||||
this.behaviorList.push(behaviors[i].name);
|
||||
this.behaviorList[behaviors[i].name] = behaviors[i].paramInfoModels;
|
||||
behaviorHtml += this.containerManager.createLineWithRadio(
|
||||
behaviors[i].name, "method");
|
||||
}
|
||||
this.containerManager.behaviorListForPlugin.html(behaviorHtml);
|
||||
};
|
||||
|
||||
function behaviorFinish() {
|
||||
var plugin = $("input[name='plugin']:checked").val();
|
||||
var method = $("input[name='method']:checked").val();
|
||||
if (plugin != null && plugin != "" && method != null && method != "") {
|
||||
showPluginMethodLine(plugin, method);
|
||||
} else {
|
||||
alert("The plugin or the method shouldn't be null!");
|
||||
$('#myModal_Behavior').modal('hide');
|
||||
}
|
||||
}
|
||||
|
||||
var mark;
|
||||
function showPluginMethodLine(plugin, method) {
|
||||
var behaviorData = plugin + "." + method;
|
||||
var length = pluginMethodList.length;
|
||||
var documentChild = document.getElementById("showPluginMethod").childNodes;
|
||||
if (place == "before") {
|
||||
for (var j = length - 1; j >= clickPluginMethodNode; j--) {
|
||||
pluginMethodList[j + 1] = pluginMethodList[j];
|
||||
Behavior.prototype.useBehaviorOfOnePluginContainerInit = function(plugin,
|
||||
behaivor) {
|
||||
var behaviorWithPlugin = plugin + "." + behaivor;
|
||||
var length = this.behaviorWithPluginList.length;
|
||||
var documentChild = this.containerManager.behaviorParamConfigContianer
|
||||
.children();
|
||||
if (this.insertLocation == "before") {
|
||||
for (var j = length - 1; j > parseInt(this.clickPluginBehaviorNode - 1); j--) {
|
||||
alert("j=" + j);
|
||||
this.behaviorWithPluginList[j + 1] = this.behaviorWithPluginList[j];
|
||||
$(documentChild[j]).attr("id", parseInt(j + 1));
|
||||
}
|
||||
mark = clickPluginMethodNode;
|
||||
clickPluginMethodNode = parseInt(clickPluginMethodNode + 1);
|
||||
pluginMethodList[mark] = behaviorData;
|
||||
} else if (place == "after") {
|
||||
mark = parseInt(clickPluginMethodNode + 1);
|
||||
if (clickPluginMethodNode == parseInt(length - 1)
|
||||
&& clickPluginMethodNode != -1) {
|
||||
pluginMethodList.push(behaviorData);
|
||||
this.behaviorWithPluginList[parseInt(this.clickPluginBehaviorNode)] = behaviorWithPlugin;
|
||||
this
|
||||
.setClickPluginBehaviorNode(parseInt(this.clickPluginBehaviorNode + 1));
|
||||
} else if (this.insertLocation == "after") {
|
||||
if (this.clickPluginBehaviorNode == parseInt(length - 1)
|
||||
|| this.clickPluginBehaviorNode == -1) {
|
||||
this.behaviorWithPluginList.push(behaviorWithPlugin);
|
||||
} else {
|
||||
for (var j = parseInt(length - 1); j >= mark; j--) {
|
||||
pluginMethodList[j + 1] = pluginMethodList[j];
|
||||
for (var j = parseInt(length - 1); j > parseInt(this.clickPluginBehaviorNode); j--) {
|
||||
this.behaviorWithPluginList[j + 1] = this.behaviorWithPluginList[j];
|
||||
$(documentChild[j]).attr("id", parseInt(j + 1));
|
||||
}
|
||||
pluginMethodList[mark] = behaviorData;
|
||||
this.behaviorWithPluginList[parseInt(this.clickPluginBehaviorNode + 1)] = behaviorWithPlugin;
|
||||
}
|
||||
}
|
||||
$('#insertBefore').attr("class", "show");
|
||||
$('#myModal_Behavior').modal('hide');
|
||||
createPluginMethodLines();
|
||||
}
|
||||
};
|
||||
|
||||
function createPluginMethodLines() {
|
||||
document.getElementById("showPluginMethod").innerHTML = "";
|
||||
document.getElementById('behaviorArea').innerHTML = "";
|
||||
for (var j = 0; j < pluginMethodList.length; j++) {
|
||||
var div = createALine(pluginMethodList[j], j, "pluginMethodList");
|
||||
if (j == clickPluginMethodNode) {
|
||||
Behavior.prototype.createBehaviorWithPluginLines = function() {
|
||||
this.containerManager.behaviorParamConfigContianer.html("");
|
||||
this.containerManager.useBehaviorListContainer.html("");
|
||||
for (var j = 0; j < this.behaviorWithPluginList.length; j++) {
|
||||
var div = this.containerManager.createALine(
|
||||
this.behaviorWithPluginList[j], j, "pluginMethodList");
|
||||
if (j == this.clickPluginBehaviorNode) {
|
||||
$(div).find("p").attr("class", "visited");
|
||||
}
|
||||
document.getElementById('behaviorArea').appendChild(div);
|
||||
loadMethodParams(pluginMethodList[j], j);
|
||||
}
|
||||
this.useParamInforsContainerInit(j);
|
||||
}
|
||||
};
|
||||
|
||||
function showMethodDocument(selectedNode) {
|
||||
clickPluginMethodNode = parseInt($(selectedNode).attr("id"));
|
||||
var length = $("#showPluginMethod").children().length;
|
||||
var behaviorAreaChild = $('#behaviorArea').children();
|
||||
var div = $("#showPluginMethod").children();
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (behaviorAreaChild[i].getAttribute("id") != clickPluginMethodNode) {
|
||||
$(behaviorAreaChild[i]).find("p").attr("class", "");
|
||||
} else {
|
||||
$(behaviorAreaChild[i]).find("p").attr("class", "visited");
|
||||
}
|
||||
}
|
||||
for (var j = 0; j < length; j++) {
|
||||
if (div[j].getAttribute("id") == clickPluginMethodNode) {
|
||||
$(div[j]).show();
|
||||
} else {
|
||||
$(div[j]).hide();
|
||||
}
|
||||
}
|
||||
$('#submitBehaviors').attr("class", "show");
|
||||
}
|
||||
Behavior.prototype.useParamInforsContainerInit = function(index) {
|
||||
var behaviorName = this.behaviorWithPluginList[index].split('.')[1];
|
||||
document.getElementById("showPluginMethod").innerHTML += this.containerManager
|
||||
.createParamInforsContainer(this.behaviorList[behaviorName],
|
||||
this.behaviorWithPluginList[index], index);
|
||||
};
|
||||
|
||||
function removeInsertPluginByClicked() {
|
||||
Behavior.prototype.removeInsertPluginByClicked = function() {
|
||||
var length = $('#behaviorArea').children().length;
|
||||
var removeDocumentNode = document.getElementById("showPluginMethod").childNodes;
|
||||
for (var i = parseInt(clickPluginMethodNode + 1); i < length; i++) {
|
||||
pluginMethodList[i - 1] = pluginMethodList[i];
|
||||
for (var i = parseInt(this.clickPluginBehaviorNode + 1); i < length; i++) {
|
||||
this.behaviorWithPluginList[i - 1] = this.behaviorWithPluginList[i];
|
||||
}
|
||||
pluginMethodList.splice(length - 1, 1);// js Array remove element
|
||||
createPluginMethodLines();
|
||||
this.behaviorWithPluginList.splice(length - 1, 1);
|
||||
if (this.behaviorWithPluginList.length == 0) {
|
||||
this.setClickPluginBehaviorNode(-1);
|
||||
}
|
||||
};
|
||||
|
||||
Behavior.prototype.removeUseBehaviorWithPluginParamInfo = function() {
|
||||
var removeDocumentNode = $("#showPluginMethod").children();
|
||||
for (var j = 0; j < length; j++) {
|
||||
if ($(removeDocumentNode[j]).attr("id") == clickPluginMethodNode) {
|
||||
if ($(removeDocumentNode[j]).attr("id") == this.clickPluginBehaviorNode) {
|
||||
document.getElementById("showPluginMethod").removeChild(
|
||||
removeDocumentNode[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function clearPluginMethodList() {
|
||||
pluginMethodList.splice(0, pluginMethodList.length);
|
||||
document.getElementById('behaviorArea').innerHTML = "";
|
||||
document.getElementById("showPluginMethod").innerHTML = "";
|
||||
Behavior.prototype.clearBehaviorWithPluginList = function() {
|
||||
this.behaviorWithPluginList.splice(0, this.behaviorWithPluginList.length);
|
||||
this.setClickPluginBehaviorNode(-1);
|
||||
$('#behaviorArea').html("");
|
||||
$('#showPluginMethod').html("");
|
||||
$('#submitBehaviors').attr("class", "hide");
|
||||
}
|
||||
|
||||
function loadMethodParams(behaviorData, behaviorIndex) {
|
||||
var temp = behaviorData.split('.');
|
||||
var method = temp[1];
|
||||
var data = behaviorList[method];// data 为List<ParamInfoModel>
|
||||
document.getElementById("showPluginMethod").innerHTML += createAEditText(
|
||||
data, behaviorData, behaviorIndex);
|
||||
}
|
||||
|
||||
// 生成页面显示
|
||||
function createAEditText(data, name, index) {
|
||||
var documentHtml = "";
|
||||
var boxHeader = "";
|
||||
var fieldHTML = "";
|
||||
boxHeader = "<div class='box-header well' data-original-title> "
|
||||
+ "<i class='icon-pencil left'></i>" + "<h2>sample:<i>" + name
|
||||
+ "</i></h2></div>";
|
||||
if (data != null) {
|
||||
fieldHTML = createPluginsOrBehaviorsForm(data, index);
|
||||
}
|
||||
documentHtml = "<div id='" + index + "' class='hide'><p class='hide'>"
|
||||
+ name + "</p><div class='span12 box' style='margin-left:-2px;'>"
|
||||
+ boxHeader + "<div class='box-content'>" + fieldHTML + "</div>"
|
||||
+ "</div></div>";
|
||||
return documentHtml;
|
||||
}
|
||||
|
||||
function cancelBehavior(selectedNode) {
|
||||
var divNode = selectedNode.parentNode.parentNode.parentNode;
|
||||
$(divNode).hide();
|
||||
}
|
||||
|
||||
$('#pluginCancel').click(function() {
|
||||
$('#myModal_Plugin').modal('hide');
|
||||
});
|
||||
|
||||
$('#behaviorCancel').click(function() {
|
||||
$('#myModal_Behavior').modal('hide');
|
||||
});
|
||||
};
|
||||
|
|
|
@ -3,10 +3,12 @@ var Plugin = function(containerManager) {
|
|||
this.pluginNameList = null;
|
||||
this.pluginIndex = new HashMap();
|
||||
this.usePluginList = new Array();
|
||||
this.pluginParamInfoList = [];
|
||||
this.clickPluginChoosedNodeIndex = 0;
|
||||
this.clickPluginChoosedNodeName = "";
|
||||
this.loadPluginNameList();
|
||||
this.loadPluginList();
|
||||
this.setPluginParamInfoList();
|
||||
this.containerManager = containerManager;
|
||||
};
|
||||
Plugin.prototype.loadPluginNameList = function() {
|
||||
|
@ -25,7 +27,7 @@ Plugin.prototype.loadPluginNameList = function() {
|
|||
}
|
||||
plugin.pluginNameList = response.data;
|
||||
for (var i = 0; i < plugin.pluginNameList.length; i++) {
|
||||
plugin.pluginIndex.put(plugin.pluginNameList[i], 0);
|
||||
plugin.pluginIndex.put(plugin.pluginNameList[i], -1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -43,7 +45,7 @@ Plugin.prototype.loadPluginList = function() {
|
|||
alert(response.failedMessage);
|
||||
return;
|
||||
}
|
||||
plugin.pluginList = response.data;
|
||||
plugin.pluginList = response.data;// List<PluginUIModel>pluginUIModels
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -58,15 +60,13 @@ Plugin.prototype.pluginListContainerInit = function(container) {
|
|||
$(this).attr("checked", "checked");
|
||||
});
|
||||
};
|
||||
Plugin.prototype.addUsePlugin = function() {
|
||||
var item = $("input[type='radio']:checked").val();
|
||||
Plugin.prototype.addUsePlugin = function(item) {
|
||||
this.pluginIndex.put(item, this.pluginIndex.get(item) + 1);
|
||||
this.usePluginList.push(this.createUsePluginName(item, this.pluginIndex
|
||||
.get(item)));
|
||||
|
||||
};
|
||||
Plugin.prototype.usePluginContainerInit = function(container) {
|
||||
|
||||
for (var i = 0; i < this.usePluginList.length; i++) {
|
||||
var pluginName = this.usePluginList[i];
|
||||
var div = this.containerManager.createALine(pluginName, i,
|
||||
|
@ -77,15 +77,15 @@ Plugin.prototype.usePluginContainerInit = function(container) {
|
|||
Plugin.prototype.configPluginContainerInit = function(container) {
|
||||
|
||||
};
|
||||
Plugin.prototype.deleteUsePlugin = function(pluginName) {
|
||||
|
||||
for (var i = 0; i < this.usePluginList.length; i++) {
|
||||
if (this.usePluginList[i] == pluginName) {
|
||||
this.usePluginList.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
// Plugin.prototype.deleteUsePlugin = function(pluginName) {
|
||||
//
|
||||
// for (var i = 0; i < this.usePluginList.length; i++) {
|
||||
// if (this.usePluginList[i] == pluginName) {
|
||||
// this.usePluginList.splice(i, 1);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// };
|
||||
Plugin.prototype.createUsePluginName = function(pluginName, index) {
|
||||
return pluginName + '_' + index;
|
||||
};
|
||||
|
@ -98,433 +98,43 @@ Plugin.prototype.setClickPluginChoosedNodeName=function(selectedNode){
|
|||
this.clickPluginChoosedNodeName = selectedNode.lastChild.nodeValue;
|
||||
};
|
||||
|
||||
Plugin.prototype.showChoosedPluginLine = function(container) {
|
||||
var pluginChoosedNode = container.children();// pluginArea
|
||||
for (var i = 0; i < pluginChoosedNode.length; i++) {
|
||||
if (i == this.clickPluginChoosedNodeIndex) {
|
||||
$(pluginChoosedNode[i]).find("p").attr("class", "visited");
|
||||
Plugin.prototype.setPluginParamInfoList = function() {
|
||||
for (var i = 0; i < this.pluginList.length; i++) {
|
||||
var pluginInfoModel = this.pluginList[i].pluginInfoModel;
|
||||
this.pluginParamInfoList.push(pluginInfoModel.name);
|
||||
this.pluginParamInfoList[pluginInfoModel.name] = pluginInfoModel.paramInfoModels;
|
||||
}
|
||||
};
|
||||
|
||||
} else {
|
||||
$(pluginChoosedNode[i]).find("p").attr("class", "");
|
||||
Plugin.prototype.usePluginParamInfosContainerInit = function(item) {
|
||||
var data = this.pluginParamInfoList[item];
|
||||
document.getElementById("pluginParams").innerHTML += this.containerManager
|
||||
.createParamInforsContainer(data,
|
||||
this.usePluginList[this.usePluginList.length - 1],
|
||||
this.usePluginList.length - 1);
|
||||
};
|
||||
|
||||
Plugin.prototype.removeUsePluginByClicked = function(container) {
|
||||
for (var i = parseInt(this.clickPluginChoosedNodeIndex + 1); i < this.usePluginList.length; i++) {
|
||||
this.usePluginList[i - 1] = this.usePluginList[i];
|
||||
}
|
||||
this.usePluginList.splice(length - 1, 1);
|
||||
};
|
||||
|
||||
Plugin.prototype.removeUsePluginParamInfos = function() {
|
||||
var removeDocumentNode = document.getElementById("pluginParams").childNodes;
|
||||
for (var i = 0; i < removeDocumentNode.length; i++) {
|
||||
if ($(removeDocumentNode[i]).attr("id") == this.clickPluginChoosedNodeIndex) {
|
||||
document.getElementById("pluginParams").removeChild(
|
||||
removeDocumentNode[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Plugin.prototype.showChoosedPluginParamInfos = function(container) {
|
||||
var div = container.children();// pluginParams
|
||||
for (var j = 0; j < div.length; j++) {
|
||||
if (div[j].getAttribute("id") == this.clickPluginChoosedNodeIndex) {
|
||||
$(div[j]).show();
|
||||
} else {
|
||||
$(div[j]).hide();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//Plugin.prototype.removeUsePluginByClicked = function(container) {
|
||||
// for (var i = parseInt(this.clickPluginChoosedNode + 1); i < this.usePluginList.length; i++) {
|
||||
// this.usePluginList[i - 1] = this.usePluginList[i];
|
||||
// }
|
||||
// this.usePluginList.splice(length - 1, 1);
|
||||
// this.usePluginContainerInit(container);
|
||||
//};
|
||||
|
||||
Plugin.prototype.clearUsePluginContainer=function(container){
|
||||
Plugin.prototype.clearUsePluginContainer = function() {
|
||||
this.usePluginList.splice(0, this.usePluginList.length);
|
||||
for (var i = 0; i < this.pluginNameList.length; i++) {
|
||||
this.pluginIndex.put(this.pluginNameList[i], 0);
|
||||
}
|
||||
container.html("");//pluginArea
|
||||
};
|
||||
|
||||
// function createPluginChoosedLines() {
|
||||
// document.getElementById('pluginArea').innerHTML = "";
|
||||
//
|
||||
// }
|
||||
// var pluginChoosedList = new Array();
|
||||
// var pluginIndex = new HashMap();
|
||||
// var pluginList = new Array();
|
||||
// var pluginMethodList = new Array();
|
||||
// var usePluginList = new Array();
|
||||
// var pageList = new Array();
|
||||
// var behaviors = new Array();
|
||||
// var behaviorList = [];// 存放所有方法及其对应的parameter
|
||||
// var pluginParamList = [];// 一个plug-in名一个paramInfoModels list
|
||||
// var clickPluginMethodNode = -1;
|
||||
// var clickPluginChoosedNode = 0;
|
||||
// var place = "";
|
||||
// var parameters = [];
|
||||
//
|
||||
// function setTab(name, m, n) {
|
||||
// for (var i = 1; i <= n; i++) {
|
||||
// var menu = document.getElementById(name + i);
|
||||
// var showDiv = document.getElementById("cont_" + name + "_" + i);
|
||||
// menu.className = i == m ? "on" : "";
|
||||
// showDiv.style.display = i == m ? "block" : "none";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// $(document).ready(function() {
|
||||
// loadPluginList();
|
||||
// loadPluginParams();
|
||||
// });
|
||||
//
|
||||
// function showScriptByJsonData(jsonData) {
|
||||
// getPluginName(jsonData);
|
||||
// getBehaviorInfo(jsonData);
|
||||
// createPluginChoosedLines();
|
||||
// createPluginMethodLines();
|
||||
// }
|
||||
//
|
||||
// function getPluginName(jsonData) {
|
||||
// for (var i = 0; i < jsonData.usePlugins.length; i++) {
|
||||
// var name = jsonData.usePlugins[i].name;
|
||||
// pluginChoosedList.push(name);
|
||||
// var aPluginIndex = pluginIndex.get(name);
|
||||
// pluginIndex.put(name, aPluginIndex + 1);
|
||||
// var data = getParamInfoModelList(name.split("_")[0]);// paramInfoModels
|
||||
// document.getElementById("pluginParams").innerHTML += createAEditText(
|
||||
// data, name, i);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// function loadBehaviorParamInfos(behaviorMethod) {
|
||||
// $.each(modelData.pages, function(i, item) {
|
||||
// $.each(item.batches, function(i, item) {
|
||||
// if (item.Id == plugin_id) {
|
||||
// $.each(item.behaviors, function(i, item) {
|
||||
// if (item.id == behavior_id) {
|
||||
// plugin = item.use;
|
||||
// method = item.name;
|
||||
// $.each(item.parameters, function(i, item) {
|
||||
// parameters.push(item.key);
|
||||
// parameters[item.key] = item.value;
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// function getBehaviorInfo(jsonData) {
|
||||
// var paramInfoModels;
|
||||
// $
|
||||
// .each(
|
||||
// jsonData.pages,
|
||||
// function(i, item) {
|
||||
// $
|
||||
// .each(
|
||||
// item.batches,
|
||||
// function(i, item) {
|
||||
// $
|
||||
// .each(
|
||||
// item.behaviors,
|
||||
// function(i, item) {
|
||||
// pluginMethodList
|
||||
// .push(text);
|
||||
// plugin = item.use;
|
||||
// method = item.name;
|
||||
// var text = plugin
|
||||
// + "."
|
||||
// + methods;
|
||||
// parameters
|
||||
// .splice(
|
||||
// 0,
|
||||
// parameters.length);
|
||||
// $
|
||||
// .each(
|
||||
// item.parameters,
|
||||
// function(
|
||||
// i,
|
||||
// item) {
|
||||
// parameters
|
||||
// .push(item.key);
|
||||
// parameters[item.key] = item.value;
|
||||
// });
|
||||
// var data = "";
|
||||
// loadBehaviorList(plugin);
|
||||
// for (var i = 0; i < data.length; i++) {
|
||||
// if (data[i].name == item.name) {
|
||||
// paramInfoModels = data[i].paramInfoModels;
|
||||
// document
|
||||
// .getElementById("showPluginMethod").innerHTML += createAEditText(
|
||||
// paramInfoModels,
|
||||
// text,
|
||||
// item.id);
|
||||
// createForm(item.id);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
//
|
||||
|
||||
// function getParamInfoModelList(plugin) {
|
||||
// return pluginParamList[plugin];
|
||||
// }
|
||||
//
|
||||
// function pluginFinish() {
|
||||
// $('#myModal_Plugin').modal('hide');
|
||||
// var pluginName;
|
||||
// var item = $("input[type='radio']:checked").val();
|
||||
// var aPluginIndex = pluginIndex.get(item);
|
||||
// pluginIndex.put(item, aPluginIndex + 1);
|
||||
// pluginName = item + "_" + aPluginIndex;
|
||||
// pluginChoosedList.push(pluginName);
|
||||
// createPluginChoosedLines();
|
||||
// var data = getParamInfoModelList(item);// paramInfoModels
|
||||
// document.getElementById("pluginParams").innerHTML += createAEditText(data,
|
||||
// pluginName, pluginChoosedList.length - 1);
|
||||
// }
|
||||
//
|
||||
// function choosePlugin(selectedNode) {
|
||||
// clickPluginChoosedNode = $(selectedNode).attr("id");
|
||||
// var pluginChoosedNode = $('#pluginArea').children();
|
||||
// var div = document.getElementById("pluginParams").childNodes;
|
||||
// showChoosedPluginInfo(pluginChoosedNode, div);
|
||||
// }
|
||||
//
|
||||
// function showChoosedPluginInfo(pluginChoosedNode, div) {
|
||||
// // 显示选中
|
||||
// showChoosedPluginLine(pluginChoosedNode);
|
||||
// // 显示文档
|
||||
// showChoosedPluginParamInfos(div);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// function showChoosedPluginLine(pluginChoosedNode) {
|
||||
// for (var i = 0; i < pluginChoosedNode.length; i++) {
|
||||
// if (i == clickPluginChoosedNode) {
|
||||
// $(pluginChoosedNode[i]).find("p").attr("class", "visited");
|
||||
//
|
||||
// } else {
|
||||
// $(pluginChoosedNode[i]).find("p").attr("class", "");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// function showChoosedPluginParamInfos(div) {
|
||||
// for (var j = 0; j < div.length; j++) {
|
||||
// if (div[j].getAttribute("id") == clickPluginChoosedNode) {
|
||||
// $(div[j]).show();
|
||||
// } else {
|
||||
// $(div[j]).hide();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// function removePluginByClicked() {
|
||||
// var length = pluginChoosedList.length;
|
||||
// for (var i = parseInt(clickPluginChoosedNode + 1); i < length; i++) {
|
||||
// pluginChoosedList[i - 1] = pluginChoosedList[i];
|
||||
// }
|
||||
// pluginChoosedList.splice(length - 1, 1);
|
||||
// createPluginChoosedLines();
|
||||
// }
|
||||
//
|
||||
// function clearPluginChoosedList() {
|
||||
// pluginChoosedList.splice(0, pluginChoosedList.length);
|
||||
// for (var i = 0; i < pluginList.length; i++) {
|
||||
// pluginIndex.put(pluginList[i], 0);
|
||||
// }
|
||||
// document.getElementById('pluginArea').innerHTML = "";
|
||||
// }
|
||||
//
|
||||
// function insert() {
|
||||
// place = "before";
|
||||
// insertPlugin();
|
||||
// }
|
||||
//
|
||||
// function insertAfter() {
|
||||
// place = "after";
|
||||
// insertPlugin();
|
||||
// }
|
||||
//
|
||||
// function insertPlugin() {
|
||||
// document.getElementById("pluginMethod").innerHTML = "";
|
||||
// $('#myModal_Behavior').modal('show');
|
||||
// var chooesedPluginHtml = "";
|
||||
// for (var i = 0; i < pluginChoosedList.length; i++) {
|
||||
// chooesedPluginHtml += createLineWithRadio(pluginChoosedList[i],
|
||||
// "plugin");
|
||||
// }
|
||||
// $("#insertPluginAreaPlugins").html(chooesedPluginHtml);
|
||||
// }
|
||||
//
|
||||
// $('#insertPluginAreaPlugins').click(function() {
|
||||
// var pluginName = $("input[type='radio']:checked").val();
|
||||
// getBehaviorList(pluginName);
|
||||
// });
|
||||
// function loadBehaviorList(plugin) {
|
||||
// var behaviors = null;
|
||||
// $.ajax({
|
||||
// type : "POST",
|
||||
// url : "loadBehaviorList",
|
||||
// data : "pluginName=" + plugin,
|
||||
// dataType : "json",
|
||||
// async : false,
|
||||
// success : function(response) {
|
||||
// if (!response.success) {
|
||||
// alert(response.failedMessage);
|
||||
// return;
|
||||
// }
|
||||
// behaviors = response.data;
|
||||
// }
|
||||
// });
|
||||
// return behaviors;
|
||||
// }
|
||||
// function getBehaviorList(pluginName) {
|
||||
// var methodHtml = "";
|
||||
// var type = pluginName.split("_");
|
||||
// var plugin = type[0];
|
||||
// behaviorList.splice(0, behaviorList.length);
|
||||
// var behaviors = loadBehaviorList(plugin);
|
||||
// for (var i = 0; i < behaviors.length; i++) {
|
||||
// behaviorList.push(behaviors[i].name);
|
||||
// behaviorList[behaviors[i].name] = behaviors[i].paramInfoModels;
|
||||
// methodHtml += createLineWithRadio(behaviors[i].name, "method");
|
||||
// }
|
||||
// document.getElementById("pluginMethod").innerHTML = methodHtml;
|
||||
// }
|
||||
//
|
||||
// function behaviorFinish() {
|
||||
// var plugin = $("input[name='plugin']:checked").val();
|
||||
// var method = $("input[name='method']:checked").val();
|
||||
// if (plugin != null && plugin != "" && method != null && method != "") {
|
||||
// showPluginMethodLine(plugin, method);
|
||||
// } else {
|
||||
// alert("The plugin or the method shouldn't be null!");
|
||||
// $('#myModal_Behavior').modal('hide');
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// var mark;
|
||||
// function showPluginMethodLine(plugin, method) {
|
||||
// var behaviorData = plugin + "." + method;
|
||||
// var length = pluginMethodList.length;
|
||||
// var documentChild = document.getElementById("showPluginMethod").childNodes;
|
||||
// if (place == "before") {
|
||||
// for (var j = length - 1; j >= clickPluginMethodNode; j--) {
|
||||
// pluginMethodList[j + 1] = pluginMethodList[j];
|
||||
// $(documentChild[j]).attr("id", parseInt(j + 1));
|
||||
// }
|
||||
// mark = clickPluginMethodNode;
|
||||
// clickPluginMethodNode = parseInt(clickPluginMethodNode + 1);
|
||||
// pluginMethodList[mark] = behaviorData;
|
||||
// } else if (place == "after") {
|
||||
// mark = parseInt(clickPluginMethodNode + 1);
|
||||
// if (clickPluginMethodNode == parseInt(length - 1)
|
||||
// && clickPluginMethodNode != -1) {
|
||||
// pluginMethodList.push(behaviorData);
|
||||
// } else {
|
||||
// for (var j = parseInt(length - 1); j >= mark; j--) {
|
||||
// pluginMethodList[j + 1] = pluginMethodList[j];
|
||||
// $(documentChild[j]).attr("id", parseInt(j + 1));
|
||||
// }
|
||||
// pluginMethodList[mark] = behaviorData;
|
||||
// }
|
||||
// }
|
||||
// $('#insertBefore').attr("class", "show");
|
||||
// $('#myModal_Behavior').modal('hide');
|
||||
// createPluginMethodLines();
|
||||
// }
|
||||
//
|
||||
// function createPluginMethodLines() {
|
||||
// document.getElementById("showPluginMethod").innerHTML = "";
|
||||
// document.getElementById('behaviorArea').innerHTML = "";
|
||||
// for (var j = 0; j < pluginMethodList.length; j++) {
|
||||
// var div = createALine(pluginMethodList[j], j, "pluginMethodList");
|
||||
// if (j == clickPluginMethodNode) {
|
||||
// $(div).find("p").attr("class", "visited");
|
||||
// }
|
||||
// document.getElementById('behaviorArea').appendChild(div);
|
||||
// loadMethodParams(pluginMethodList[j], j);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// function showMethodDocument(selectedNode) {
|
||||
// clickPluginMethodNode = parseInt($(selectedNode).attr("id"));
|
||||
// var length = $("#showPluginMethod").children().length;
|
||||
// var behaviorAreaChild = $('#behaviorArea').children();
|
||||
// var div = $("#showPluginMethod").children();
|
||||
// for (var i = 0; i < length; i++) {
|
||||
// if (behaviorAreaChild[i].getAttribute("id") != clickPluginMethodNode) {
|
||||
// $(behaviorAreaChild[i]).find("p").attr("class", "");
|
||||
// } else {
|
||||
// $(behaviorAreaChild[i]).find("p").attr("class", "visited");
|
||||
// }
|
||||
// }
|
||||
// for (var j = 0; j < length; j++) {
|
||||
// if (div[j].getAttribute("id") == clickPluginMethodNode) {
|
||||
// $(div[j]).show();
|
||||
// } else {
|
||||
// $(div[j]).hide();
|
||||
// }
|
||||
// }
|
||||
// $('#submitBehaviors').attr("class", "show");
|
||||
// }
|
||||
//
|
||||
// function removeInsertPluginByClicked() {
|
||||
// var length = $('#behaviorArea').children().length;
|
||||
// var removeDocumentNode =
|
||||
// document.getElementById("showPluginMethod").childNodes;
|
||||
// for (var i = parseInt(clickPluginMethodNode + 1); i < length; i++) {
|
||||
// pluginMethodList[i - 1] = pluginMethodList[i];
|
||||
// }
|
||||
// pluginMethodList.splice(length - 1, 1);// js Array remove element
|
||||
// createPluginMethodLines();
|
||||
// for (var j = 0; j < length; j++) {
|
||||
// if ($(removeDocumentNode[j]).attr("id") == clickPluginMethodNode) {
|
||||
// document.getElementById("showPluginMethod").removeChild(
|
||||
// removeDocumentNode[j]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// function clearPluginMethodList() {
|
||||
// pluginMethodList.splice(0, pluginMethodList.length);
|
||||
// document.getElementById('behaviorArea').innerHTML = "";
|
||||
// document.getElementById("showPluginMethod").innerHTML = "";
|
||||
// $('#submitBehaviors').attr("class", "hide");
|
||||
// }
|
||||
//
|
||||
// function loadMethodParams(behaviorData, behaviorIndex) {
|
||||
// var temp = behaviorData.split('.');
|
||||
// var method = temp[1];
|
||||
// var data = behaviorList[method];// data 为List<ParamInfoModel>
|
||||
// document.getElementById("showPluginMethod").innerHTML += createAEditText(
|
||||
// data, behaviorData, behaviorIndex);
|
||||
// }
|
||||
//
|
||||
// // 生成页面显示
|
||||
// function createAEditText(data, name, index) {
|
||||
// var documentHtml = "";
|
||||
// var boxHeader = "";
|
||||
// var fieldHTML = "";
|
||||
// boxHeader = "<div class='box-header well' data-original-title> "
|
||||
// + "<i class='icon-pencil left'></i>" + "<h2>sample:<i>" + name
|
||||
// + "</i></h2></div>";
|
||||
// if (data != null) {
|
||||
// fieldHTML = createPluginsOrBehaviorsForm(data, index);
|
||||
// }
|
||||
// documentHtml = "<div id='" + index + "' class='hide'><p class='hide'>"
|
||||
// + name + "</p><div class='span12 box' style='margin-left:-2px;'>"
|
||||
// + boxHeader + "<div class='box-content'>" + fieldHTML + "</div>"
|
||||
// + "</div></div>";
|
||||
// return documentHtml;
|
||||
// }
|
||||
//
|
||||
// function cancelBehavior(selectedNode) {
|
||||
// var divNode = selectedNode.parentNode.parentNode.parentNode;
|
||||
// $(divNode).hide();
|
||||
// }
|
||||
//
|
||||
// $('#pluginCancel').click(function() {
|
||||
// $('#myModal_Plugin').modal('hide');
|
||||
// });
|
||||
//
|
||||
// $('#behaviorCancel').click(function() {
|
||||
// $('#myModal_Behavior').modal('hide');
|
||||
// });
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
var pluginNameList = new Array();
|
||||
var parameters = [];
|
||||
var parameterList = [];
|
||||
var usePluginParamInfosList = [];
|
||||
var pluginList;
|
||||
var behaviorChoosed;
|
||||
var behaviorName;
|
||||
var pluginName;
|
||||
|
@ -19,6 +21,8 @@ function loadUsePluigns(data) {
|
|||
}
|
||||
if (flag == false) {
|
||||
pluginNameList.push(usePlugin.id);
|
||||
usePluginParamInfosList.push(usePlugin.id);
|
||||
usePluginParamInfosList[usePlugin.id] = usePlugin.parameters;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +31,8 @@ function loadUsePluigns(data) {
|
|||
createALi(ulNode, pluginNameList[p], "choosePlugin");
|
||||
}
|
||||
loadBehaviors("all");
|
||||
pluginList = loadPluginList();
|
||||
usePluginParamInfosContainerInit();
|
||||
}
|
||||
|
||||
function createALi(ulNode, name, action) {
|
||||
|
@ -37,8 +43,10 @@ function createALi(ulNode, name, action) {
|
|||
divider.setAttribute("class", "divider");
|
||||
if (action == "choosePlugin") {
|
||||
a.setAttribute("onClick", "choosePlugin(this);");
|
||||
} else {
|
||||
} else if (action == "chooseBehavior") {
|
||||
a.setAttribute("onClick", "chooseBehavior(this);");
|
||||
} else if (action == "chooseUsePlugin") {
|
||||
a.setAttribute("onClick", "chooseUsePlugin(this)");
|
||||
}
|
||||
a.appendChild(textNode);
|
||||
li.appendChild(a);
|
||||
|
@ -46,6 +54,21 @@ function createALi(ulNode, name, action) {
|
|||
ulNode.appendChild(divider);
|
||||
}
|
||||
|
||||
function chooseUsePlugin(selectedNode) {
|
||||
document.getElementById("action").style.display = "none";
|
||||
document.getElementById("pluginParamArea").innerHTML = "";
|
||||
var usePlugin = selectedNode.firstChild.nodeValue;
|
||||
createUsePluginParamInfosPage(usePlugin);
|
||||
}
|
||||
|
||||
function usePluginParamInfosContainerInit() {
|
||||
var ul = document.getElementById("usePlugin");
|
||||
for (var i = 0; i < usePluginParamInfosList.length; i++) {
|
||||
var usePluginName = usePluginParamInfosList[i];
|
||||
createALi(ul, usePluginName, "chooseUsePlugin");
|
||||
}
|
||||
}
|
||||
|
||||
function choosePlugin(selectedNode) {
|
||||
pluginName = selectedNode.firstChild.nodeValue;
|
||||
if (pluginName == "All") {
|
||||
|
@ -73,7 +96,7 @@ function loadBehaviors(mark) {
|
|||
$.each(item.behaviors, function(i, item) {
|
||||
var text = item.use + ":" + Id + "." + item.name + ":"
|
||||
+ item.id;
|
||||
createALi(ul, text, "");
|
||||
createALi(ul, text, "chooseBehavior");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -91,6 +114,26 @@ function chooseBehavior(selectedNode) {
|
|||
createBehaviorParamPage(behaviorMethod);
|
||||
}
|
||||
|
||||
function createUsePluginParamInfosPage(usePluginName) {
|
||||
var pluginHtml = "";
|
||||
var index = 0;
|
||||
for (var i = 0; i < pluginList.length; i++) {
|
||||
var pluginInfoModel = pluginList[i].pluginInfoModel;
|
||||
if (pluginInfoModel.name == usePluginName) {
|
||||
index = i;
|
||||
var paramInfoModels = pluginInfoModel.paramInfoModels;
|
||||
for (var j = 0; j < paramInfoModels.length; j++) {
|
||||
var paramInfoModel = paramInfoModels[j];
|
||||
pluginHtml += createModelByType(
|
||||
usePluginParamInfosList[usePluginName], paramInfoModel,
|
||||
index);
|
||||
}
|
||||
}
|
||||
}
|
||||
document.getElementById("pluginParamArea").innerHTML = createAEditText(
|
||||
pluginHtml, usePluginName, index);
|
||||
}
|
||||
|
||||
function createBehaviorParamPage(behaviorData) {
|
||||
var plugin = "", method = "";
|
||||
var behaviorHTML = "";
|
||||
|
@ -123,7 +166,8 @@ function createBehaviorParamPage(behaviorData) {
|
|||
.push(item.key);
|
||||
behaviorParameters[item.key] = item.value;
|
||||
});
|
||||
var behaviorList = loadBehaviorList(plugin.split("_")[0]);// List<BehaviorInfoModel>
|
||||
var behaviorList = loadBehaviorList(plugin
|
||||
.split("_")[0]);// List<BehaviorInfoModel>
|
||||
for (var j = 0; j < behaviorList.length; j++) {
|
||||
if (behaviorList[j].name == method) {
|
||||
paramInfoModels = behaviorList[j].paramInfoModels;
|
||||
|
@ -132,9 +176,10 @@ function createBehaviorParamPage(behaviorData) {
|
|||
}
|
||||
for (var k = 0; k < paramInfoModels.length; k++) {
|
||||
paramInfoModel = paramInfoModels[k];
|
||||
behaviorHTML += createParamInfoModelWithBehaviorParams(
|
||||
behaviorHTML += createParamInfoModelWithParams(
|
||||
paramInfoModel,
|
||||
behaviorParameters,behavior_id);
|
||||
behaviorParameters,
|
||||
behavior_id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -165,8 +210,8 @@ function createAEditText(behaviorHTML, behaviorData, behavior_id) {
|
|||
return documentHtml;
|
||||
}
|
||||
|
||||
function createParamInfoModelWithBehaviorParams(paramInfoModel,
|
||||
behaviorParameters,behaviorIndex) {
|
||||
function createParamInfoModelWithParams(paramInfoModel, behaviorParameters,
|
||||
behaviorIndex) {
|
||||
var name = paramInfoModel.name;
|
||||
var value = behaviorParameters[name];
|
||||
return createModelByType(value, paramInfoModel, behaviorIndex);
|
||||
|
@ -222,9 +267,26 @@ function loadBehaviorList(plugin){
|
|||
return behaviors;
|
||||
}
|
||||
|
||||
function loadPluginList() {
|
||||
var pluginList = null;
|
||||
$.ajax({
|
||||
type : 'POST',
|
||||
url : 'loadPluginUIList',
|
||||
data : {},
|
||||
dataType : 'json',
|
||||
async : false,
|
||||
success : function(response) {
|
||||
if (!response.success) {
|
||||
alert(response.failedMessage);
|
||||
return;
|
||||
}
|
||||
pluginList = response.data;// List<PluginUIModel>pluginUIModels
|
||||
}
|
||||
});
|
||||
return pluginList;
|
||||
}
|
||||
|
||||
function saveFormModification() {
|
||||
alert("saveFormModification");
|
||||
var div = document.getElementById("showPluginMethodForm").firstChild;
|
||||
var contents = div.lastChild.lastChild.childNodes;
|
||||
var length = contents.length;
|
||||
|
@ -306,7 +368,3 @@ function modifyJsonData() {
|
|||
});
|
||||
parameterList.splice(0, parameterList.length);
|
||||
}
|
||||
|
||||
function editPlugin() {
|
||||
window.location.href("plugin.jsp?jsonData=" + modelData);
|
||||
}
|
||||
|
|
|
@ -123,8 +123,6 @@ function getBehaviorInfo(jsonData) {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function loadPluginParams() {
|
||||
$
|
||||
.post(
|
||||
|
|
|
@ -110,9 +110,9 @@ function refresh(){
|
|||
location.replace(location) ;
|
||||
}
|
||||
|
||||
//$('#createScript').click(function(){
|
||||
// window.open("plugin.jsp");
|
||||
//});
|
||||
$('#createScript').click(function(){
|
||||
window.open("plugin-old.jsp");
|
||||
window.open("plugin.jsp");
|
||||
});
|
||||
//$('#createScript').click(function(){
|
||||
// window.open("plugin-old.jsp");
|
||||
//});
|
Loading…
Reference in New Issue