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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Jul 20 08:59:45 EDT 2007


Author: christoph
Date: 2007-07-20 08:59:45 -0400 (Fri, 20 Jul 2007)
New Revision: 1521

Modified:
   trunk/mapbender/http/javascripts/mod_wfs_gazetteer_client.php
Log:
fixed #68

http://trac.osgeo.org/mapbender/ticket/68

Modified: trunk/mapbender/http/javascripts/mod_wfs_gazetteer_client.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_wfs_gazetteer_client.php	2007-07-20 12:50:32 UTC (rev 1520)
+++ trunk/mapbender/http/javascripts/mod_wfs_gazetteer_client.php	2007-07-20 12:59:45 UTC (rev 1521)
@@ -38,7 +38,6 @@
 <?php
 include '../include/dyn_css.php';
 ?>
-<style id="wfsConfStyle" type="text/css"></style>
 <script type="text/javascript">
 <?php 
 	echo "var targetString = '" . $target . "';";
@@ -63,10 +62,37 @@
 		node.removeChild(childNode);
 	}
 }
+/**
+ * removes whitespaces and endlines before and after a string
+ *
+ */ 
+function trimString (str) {
+	return str.replace(/^\s+|\s+|\n+$/g, '');
+}
 
+
 function appendStyles() {
-	var wfsConfStyleNode = document.getElementById("wfsConfStyle");
-	wfsConfStyleNode.innerHTML = global_wfsConfObj[global_selectedWfsConfId].g_style + global_wfsConfObj[global_selectedWfsConfId].g_res_style;
+	var styleObj;
+	var rule = global_wfsConfObj[global_selectedWfsConfId].g_style + global_wfsConfObj[global_selectedWfsConfId].g_res_style;
+	if (parent.ie) {
+		var styleSheetObj=document.createStyleSheet();
+		styleObj=styleSheetObj.owningElement || styleSheetObj.ownerNode;
+		styleObj.setAttribute("type","text/css");
+		ruleArray = rule.split("}");
+		for (var i=0; i < ruleArray.length - 1; i++) {
+			var currentRule = trimString(ruleArray[i]);
+			var nameValueArray = currentRule.split("{");
+			var name = nameValueArray[0];
+			var value = nameValueArray[1];
+			styleSheetObj.addRule(name,value);
+		}
+	}
+	else {
+		styleObj=document.createElement("style");
+		styleObj.setAttribute("type","text/css");
+		document.getElementsByTagName("head")[0].appendChild(styleObj);
+		styleObj.appendChild(document.createTextNode(rule+"\n"));		
+	}
 }
 
 //----------------------------------------------------------------------------------
@@ -129,7 +155,8 @@
 	removeChildNodes(resultDiv);
 	
 	var divContainer = document.createElement("div");
-	divContainer.setAttribute("class", global_wfsConfObj[global_selectedWfsConfId].g_label_id);
+	divContainer.className = global_wfsConfObj[global_selectedWfsConfId].g_label_id;
+	
 	divContainer.innerHTML = global_wfsConfObj[global_selectedWfsConfId].g_label;
 	
 	form.appendChild(divContainer);
@@ -138,20 +165,21 @@
 
 	for (var i = 0; i < wfsConfElementArray.length; i++){
 		var spanNode = document.createElement("span");
-		spanNode.setAttribute("class", wfsConfElementArray[i].f_label_id);
+		spanNode.setAttribute("id", "ttttt");
+		spanNode.className = wfsConfElementArray[i].f_label_id;
 		spanNode.innerHTML = wfsConfElementArray[i].f_label;
-
 		var inputNode = document.createElement("input");
 		inputNode.type = "text";
-		inputNode.setAttribute("class", wfsConfElementArray[i].f_style_id);
+		inputNode.className = wfsConfElementArray[i].f_style_id;
 		inputNode.id = wfsConfElementArray[i].element_name;
-
+		
 		form.appendChild(spanNode);
 		form.appendChild(inputNode);
+		form.appendChild(document.createElement("br"));
 	}
 	var submitButton = document.createElement("input");
 	submitButton.type = "submit";
-	submitButton.setAttribute("class", global_wfsConfObj[global_selectedWfsConfId].g_button_id);
+	submitButton.className = global_wfsConfObj[global_selectedWfsConfId].g_button_id;
 	submitButton.value = global_wfsConfObj[global_selectedWfsConfId].g_button;
 	
 	form.appendChild(submitButton);



More information about the Mapbender_commits mailing list