return to the incomplete input when submit script

return to the incomplete input when submit script
This commit is contained in:
daisyonly 2014-09-09 09:48:13 +08:00
parent 270c4b8d14
commit bc164c3ece
5 changed files with 49 additions and 11 deletions

View File

@ -326,6 +326,10 @@ function Behavior(usePlugin, containerId) {
}
this.getBehaviorEditorMap = function(){
return behaviorEditorMap;
}
this.getPages = function() {
updateBehaviorEditors();
var treeObj = $("#" + containerId).jstree(true);

View File

@ -16,22 +16,46 @@ $(function() {
});
});
function checkPluginsInput(plugins) {
function checkPluginsInput(plugins, usePlugin) {
for (var i = 0; i < plugins.length; i++){
for (var j = 0; j < plugins[i].parameters.length; j++){
if (plugins[i].parameters[j].check =="false")
if (plugins[i].parameters[j].check =="false"){
$("#tabs").tabs("option", "active", 0 );
var usePluginEditorMap = usePlugin.getUsePluginEditorMap();
$("#pluginEditor").append(usePluginEditorMap.get(plugins[i].id));
var inputs = $("#"+ plugins[i].parameters[j].key + " input");
for (var p = 0; p < inputs.length; p++){
if ($(inputs[p]).val() == ""){
$(inputs[p]).focus();
break;
}
}
return false;
}
}
}
return true;
}
function checkPagesInput(pages) {
function checkPagesInput(pages, usePlugin) {
for (var i = 0;i < pages.length; i++){
for (var j = 0; j < pages[i].batches.length; j++){
for (var k = 0; k < pages[i].batches[j].behaviors.length; k++){
for (var q = 0; q < pages[i].batches[j].behaviors[k].parameters.length; q++){
if (pages[i].batches[j].behaviors[k].parameters[q].check =="false"){
$("#tabs").tabs("option", "active", 1 );
var behaviorEditorMap = usePlugin.getBehaviorEditorMap();
$("#behaviorEditor").append(behaviorEditorMap.get(pages[i].batches[j].behaviors[k].id));
var inputs = $("#"+ pages[i].batches[j].behaviors[k].parameters[q].key + " input");
for (var p = 0; p < inputs.length; p++){
if ($(inputs[p]).val() == ""){
$(inputs[p]).focus();
break;
}
}
return false;
}
}

View File

@ -7,9 +7,10 @@ $(function() {
var formData = new FormData();
var plugins = usePlugin.getPlugins(formData);
var pages = usePlugin.getPages();
if(checkPluginsInput(plugins) && checkPagesInput(pages))
if(checkPluginsInput(plugins, usePlugin) && checkPagesInput(pages, usePlugin))
submitScript(pages, plugins, formData);
else
else{
information("Please complete the required parameters.");
}
});
});

View File

@ -39,7 +39,7 @@ $(function() {
var formData = new FormData();
var plugins = usePlugin.getPlugins(formData);
var pages = usePlugin.getPages();
if(checkPluginsInput(plugins) && checkPagesInput(pages))
if(checkPluginsInput(plugins, usePlugin) && checkPagesInput(pages, usePlugin))
updateScript(scriptId,pages,plugins,formData);
else
information("Please complete the required parameters.");

View File

@ -85,6 +85,11 @@ function UsePlugin(behaviorListContainerId) {
});
});
this.getUsePluginEditorMap = function() {
return usePluginEditorMap;
}
function getPluginList() {
var usePlugin = this;
$.post("loadPluginName", {}, function(data) {
@ -197,6 +202,10 @@ function UsePlugin(behaviorListContainerId) {
return behavior.getPages();
}
this.getBehaviorEditorMap = function(){
return behavior.getBehaviorEditorMap();
}
this.initPluginAndPages = function(scriptObj){
initPluginList(scriptObj.usePlugins);
behavior.initBehaviorList(scriptObj.pages);