From 9fc76cf05e61efd01a1a8dcc606b7dd12aa5f835 Mon Sep 17 00:00:00 2001 From: daisyonly <1241945585@qq.com> Date: Tue, 2 Sep 2014 14:40:00 +0800 Subject: [PATCH] Add "required" tips Add "required" tips --- .../script/scriptManager/editorFactory.js | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Bench4Q-Web/src/main/webapp/script/scriptManager/editorFactory.js b/Bench4Q-Web/src/main/webapp/script/scriptManager/editorFactory.js index 6464afa1..99565f9d 100644 --- a/Bench4Q-Web/src/main/webapp/script/scriptManager/editorFactory.js +++ b/Bench4Q-Web/src/main/webapp/script/scriptManager/editorFactory.js @@ -1,15 +1,17 @@ var EditorFactory = function() { }; -EditorFactory.prototype.createBaseEditor = function(label, id) { +EditorFactory.prototype.createBaseEditor = function(label, id, required) { if (label == null) { label = ""; } var containerBox = document.createElement("div"); $(containerBox).addClass("containerBox"); var boxHeader = document.createElement("div"); - var p = document.createElement("p") - $(p).html(label) + var p = document.createElement("p"); + if (required == "true") + label = label + "   (required)"; + $(p).html(label); $(boxHeader).append(p); $(boxHeader).addClass("containerHeader") $(containerBox).append(boxHeader); @@ -51,7 +53,7 @@ EditorFactory.prototype.createChoice = function(value, defaultValue, name, } EditorFactory.prototype.createField = function(label, name, required, size, id, value) { - var div = this.createBaseEditor(label, id); + var div = this.createBaseEditor(label, id, required); $(div).children(".editor").attr("editorType", "field"); $(div).children(".editor").append(this.createFieldLine(size, name, required, value)); return div; @@ -59,7 +61,7 @@ EditorFactory.prototype.createField = function(label, name, required, size, id, EditorFactory.prototype.createMultiField = function(label, name, required, size, id, value) { - var div = this.createBaseEditor(label, id); + var div = this.createBaseEditor(label, id, required); $(div).children(".editor").attr("editorType", "multiField"); if (value != null) { var values = value.split(";"); @@ -101,7 +103,7 @@ EditorFactory.prototype.createFieldLine = function(size, name, required, value) $(fieldName).html(name); var field = document.createElement("input"); $(field).attr("type", "text"); - if(required=="true"){ + if(required == "true"){ $(field).attr("required", "required"); } // $(field).attr("maxlength", size); @@ -114,7 +116,7 @@ EditorFactory.prototype.createFile = function(label, name, required, size, id, v size = 150; } - var div = this.createBaseEditor(label, id); + var div = this.createBaseEditor(label, id, required); $(div).children(".editor").attr("editorType", "file"); var fileEditor = document.createElement("div"); @@ -142,7 +144,7 @@ EditorFactory.prototype.createTable = /** */ function(label, name, required, cols, id, value) { - var div = this.createBaseEditor(label, id); + var div = this.createBaseEditor(label, id, required); $(div).children(".editor").attr("editorType", "table"); var headers = getHeaders(cols); @@ -273,7 +275,7 @@ EditorFactory.prototype.createDate = function(label, name, required, size, id, v if (size == null || size < 0) { size = 150 } - var div = this.createBaseEditor(label, id); + var div = this.createBaseEditor(label, id, required); $(div).children(".editor").attr("editorType", "date"); var dateLabel = document.createElement("label"); $(dateLabel).html(name);