[Mapbender-commits] r8565 - trunk/mapbender/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Feb 20 05:00:06 PST 2013


Author: verenadiewald
Date: 2013-02-20 05:00:05 -0800 (Wed, 20 Feb 2013)
New Revision: 8565

Modified:
   trunk/mapbender/http/javascripts/mod_digitize_tab.php
Log:
Enable input type="checkbox" for digitize form

Modified: trunk/mapbender/http/javascripts/mod_digitize_tab.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_digitize_tab.php	2013-02-18 20:19:24 UTC (rev 8564)
+++ trunk/mapbender/http/javascripts/mod_digitize_tab.php	2013-02-20 13:00:05 UTC (rev 8565)
@@ -2529,6 +2529,48 @@
 	return formElementHtml;
 }
 
+function prepareCheckbox (formElementHtml, categoryName, isMandatory, elementLabel, elementValue, styleId) {
+	var classString = (styleId == '0') ? "" : styleId;
+	var patternString = "<input";
+	var pattern = new RegExp(patternString);
+		
+	// set category
+	if (categoryName) {
+		formElementHtml = formElementHtml.replace(pattern, patternString + " category='" + categoryName + "' ");
+	}
+
+	if (isMandatory) {
+		// set border if mandatory
+		classString += " mandatory";
+	}
+	classString = (classString !== "") ? " class='"+classString+"' " : " ";
+	formElementHtml = formElementHtml.replace(pattern, patternString + classString);
+
+	// set name of input to elementlabel
+	patternString = "name\s*=\s*\\*('|\")\w+\\*('|\")";
+	pattern = new RegExp(patternString);
+	if (pattern.test(formElementHtml)) {
+		formElementHtml = formElementHtml.replace(pattern, "name='" + elementLabel + "'");
+	}
+	else {
+		patternString = "<input";
+		pattern = new RegExp(patternString);
+		formElementHtml = formElementHtml.replace(pattern, "<input name='" + elementLabel + "'");
+	}
+	
+	// preselect the correct entry
+	patternString = "<input";
+	pattern = new RegExp(patternString);
+	if(elementValue !== "") {
+		formElementHtml = formElementHtml.replace(pattern, patternString + " checked value='"+elementValue+"'");
+	}
+	else {
+		formElementHtml = formElementHtml.replace(pattern, patternString);
+	}
+
+	return formElementHtml;
+}
+
 function prepareTextArea (formElementHtml, categoryName, isMandatory, elementLabel, elementValue, styleId) {
 	var classString = (styleId == '0') ? "" : styleId;
 	var patternString = "<textarea";
@@ -2749,11 +2791,16 @@
 							if (pattern.test(formElementHtml)) {
 								formElementHtml = prepareUploadField(formElementHtml, "", isMandatory, elementLabel, elementValue, styleId);
 							}
-                                                        var patternString = "hasMapdependentSelect";
+                            var patternString = "hasMapdependentSelect";
 							pattern = new RegExp(patternString);
 							if (pattern.test(formElementHtml)) {
 								formElementHtml = prepareMapdependentSelect(formElementHtml, "", isMandatory, elementLabel, elementValue, styleId);
 							}
+                            var patternString = "checkbox";
+							pattern = new RegExp(patternString);
+							if (pattern.test(formElementHtml)) {
+								formElementHtml = prepareCheckbox(formElementHtml, "", isMandatory, elementLabel, elementValue, styleId);
+							}
 							str += formElementHtml;
 						}
 						
@@ -2911,6 +2958,20 @@
 						errorMessage = msgObj.messageErrorFormEvaluation;
 					}
 				}
+				else if (myform.elements[i].type == "checkbox"){
+					if (myform.elements[i].id) {
+						var elementId = String(myform.elements[i].id).replace(/mb_digitize_form_/, "");
+						if(myform.elements[i].checked == true) {
+							d.get(m).e.setElement(elementId, myform.elements[i].value);
+						}
+						else {
+							d.get(m).e.setElement(elementId, "");
+						}
+					}
+					else {
+						errorMessage = msgObj.messageErrorFormEvaluation;
+					}
+				}
 			}
 		}
 		else {



More information about the Mapbender_commits mailing list