add insertAfter and insertBefore in plugin.jsp

This commit is contained in:
zhengyingying 2014-03-28 11:46:07 +08:00
parent 3705b2d81b
commit 6b05316265
4 changed files with 70 additions and 31 deletions

View File

@ -119,6 +119,8 @@ plugin_jsp_plugins=Plug-ins
plugin_jsp_behavior=Behavior
plugin_jsp_addScriptName=Please add ScriptName
plugin_jsp_scriptName=Script Name:
plugin_jsp_insertBefore=Insert Before
plugin_jsp_insertAfter=Insert After
script_jsp_makeScript=ScriptEdit
script_jsp_recordScript=RecordScript
script_jsp_refresh=RefreshPage

View File

@ -120,6 +120,8 @@ plugin_jsp_plugins=\u63D2\u4EF6
plugin_jsp_behavior=\u52A8\u4F5C
plugin_jsp_addScriptName=\u8BF7\u8F93\u5165\u811A\u672C\u540D
plugin_jsp_scriptName=\u811A\u672C\u540D\uFF1A
plugin_jsp_insertBefore=\u524D\u5BFC\u5165
plugin_jsp_insertAfter=\u540E\u5BFC\u5165
script_jsp_makeScript=\u811A\u672C\u7F16\u8F91
script_jsp_recordScript=\u5F55\u5236\u811A\u672C
script_jsp_refresh=\u5237\u65B0\u9875\u9762

View File

@ -12,7 +12,7 @@
<meta name="author" content="Kai Ren">
<title>Create scripts by yourself.</title>
<!-- The styles -->
<link rel="shortcut icon" href="image/bench4q.png">
<link rel="shortcut icon" href="img/bench4q.png">
<link id="bs-css" href="css/bootstrap-cerulean.css" rel="stylesheet">
<style type="text/css">
body {
@ -30,6 +30,7 @@ body {
<link href='css/uniform.default.css' rel='stylesheet'>
<link href='css/colorbox.css' rel='stylesheet'>
<link href='css/jquery.noty.css' rel='stylesheet'>
<link href='css/noty_theme_default.css' rel='stylesheet'>
<link href='css/elfinder.min.css' rel='stylesheet'>
<link href='css/elfinder.theme.css' rel='stylesheet'>
<link href='css/opa-icons.css' rel='stylesheet'>
@ -43,7 +44,7 @@ body {
<![endif]-->
<!-- The fav icon -->
<link rel="shortcut icon" href="image/favicon.ico">
<link rel="shortcut icon" href="img/favicon.ico">
</head>
<body>
@ -143,10 +144,16 @@ body {
<div class="box-content row-fluid">
<div id="behaviorArea" class="listArea span9"></div>
<div class="span3 button-div">
<div class="hide" id="insertBefore">
<button type="submit" class="btn btn-primary btn-width"
onClick="insert();">
<fmt:message key="plugin_jsp_insertBefore" />
</button>
</div>
<div>
<button type="submit" class="btn btn-primary btn-width"
id="insertBehavior_Plugin" onClick="insertPlugin();">
<fmt:message key="plugin_jsp_insert" />
onClick="insertAfter();">
<fmt:message key="plugin_jsp_insertAfter" />
</button>
</div>
<div>
@ -262,4 +269,4 @@ body {
<script src="script/plugin-new.js"></script>
</fmt:bundle>
</body>
</html>
</html>

View File

@ -6,6 +6,8 @@ var pluginChoosedList = new Array();
var pluginIndex = new HashMap();
var pluginList = new Array();
var pluginMethodList = new Array();
var clickNode = -1;
var place= "";
var index = 0;
var num = 0;
$(document).ready(function() {
@ -108,15 +110,18 @@ function removePlugin() {
document.getElementById("pluginArea").removeChild(last);
}
function insertBefore() {
function insert() {
place = "before";
insertPlugin();
}
function insertAfter() {
place = "after";
insertPlugin();
}
function insertPlugin() {
document.getElementById("pluginMethod").innerHTML = "";
$('#myModal_Behavior').modal('show');
var chooesedPluginHtml = "";
@ -177,38 +182,61 @@ function behaviorFinish() {
$('#myModal_Behavior').modal('hide');
}
}
var mark;
function showPluginMethod(plugin, method) {
var behaviorData = plugin + "." + method;
pluginMethodList.push(behaviorData);
var length=pluginMethodList.length;
var documentChild=document.getElementById("showPluginMethod").childNodes;
if (place == "before") {
for(var j=length-1;j>=clickNode;j--){
pluginMethodList[j+1]=pluginMethodList[j];
$(documentChild[j]).attr("id",parseInt(j+1));
}
mark=clickNode;
} else if (place == "after") {
mark=parseInt(clickNode+1);
for(var j=length-1;j>=clickNode+1;j--){
pluginMethodList[j+1]=pluginMethodList[j];
$(documentChild[j]).attr("id",parseInt(j+1));
}
}
$('#insertBefore').attr("class","show");
pluginMethodList[mark]=behaviorData;
$('#myModal_Behavior').modal('hide');
createPluginMethodLines(behaviorData,mark);
}
var div = document.createElement("div");
var p = document.createElement("p");
var i = document.createElement("i");
var textNode = document.createTextNode(behaviorData);
i.setAttribute("class", "icon-hand-right");
p.setAttribute("class", index);
p.setAttribute("onClick", "showMethodDocument(this)");// loadMethodParams
p.setAttribute("style", "cursor:pointer;");
p.appendChild(i);
p.appendChild(textNode);
div.appendChild(p);
document.getElementById('behaviorArea').appendChild(div);
loadMethodParams(behaviorData, index);
index++;
function createPluginMethodLines(behaviorData,mark){
document.getElementById("showPluginMethod").innerHTML="";
document.getElementById('behaviorArea').innerHTML="";
for(var j=0;j<pluginMethodList.length;j++){
var div = document.createElement("div");
var p = document.createElement("p");
var i = document.createElement("i");
var textNode = document.createTextNode(pluginMethodList[j]);
i.setAttribute("class", "icon-hand-right");
p.setAttribute("class", j);
p.setAttribute("onClick", "showMethodDocument(this)");// loadMethodParams
p.setAttribute("style", "cursor:pointer;");
p.appendChild(i);
p.appendChild(textNode);
div.appendChild(p);
document.getElementById('behaviorArea').appendChild(div);
loadMethodParams(pluginMethodList[j],j);
}
}
function showMethodDocument(selectedNode) {
var behaviorIndex = $(selectedNode).attr("class");
clickNode = $(selectedNode).attr("class");
var length = $("#showPluginMethod").children().length;
var div = $("#showPluginMethod").children();
$(div[behaviorIndex]).attr("class", "show");
$(div[behaviorIndex]).show();
for (var i = 0; i < length; i++) {
if (div[i].getAttribute("id") != behaviorIndex) {
$(div[i]).hide();
for(var j=0;j<length;j++){
if (div[j].getAttribute("id") == clickNode) {
$(div[j]).show();
}else{
$(div[j]).hide();
}
}
$('#submitBehaviors').attr("class", "show");