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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Feb 22 11:54:09 EST 2007


Author: christoph
Date: 2007-02-22 11:54:09 -0500 (Thu, 22 Feb 2007)
New Revision: 1131

Modified:
   trunk/mapbender/http/javascripts/map.php
Log:
moved code from geometry.js

Modified: trunk/mapbender/http/javascripts/map.php
===================================================================
--- trunk/mapbender/http/javascripts/map.php	2007-02-22 16:52:34 UTC (rev 1130)
+++ trunk/mapbender/http/javascripts/map.php	2007-02-22 16:54:09 UTC (rev 1131)
@@ -180,9 +180,7 @@
 }
 
 function mb_mapObj_const(frameName, elementName, width, height, wms_index){
-	
 
-
    this.width = width;
    this.height = height;
    this.frameName = frameName;
@@ -1264,6 +1262,97 @@
 		return false;
 	}
 }
+
+
+// ----------------------------------------------------------------------------------------------------
+// DivTag
+// ----------------------------------------------------------------------------------------------------
+
+function DivTag (aTagName, aFrameName, aStyle) {
+	this.exists = function () { 
+		return (rootNode.getElementById(tagName))?true:false;
+	};
+	
+	var determineRootNode = function () {
+		node = document;
+		if (frameName !== "") {
+			if (checkFrame()) {node = window.frames[frameName].document;}
+			else {alert("frame "+frameName+" doesn't exist.");}
+		}
+		return node;	
+	};
+	
+	var reformatJavaStyle = function(aString) {
+		var newString = "";
+		for (var i = 0; i < aString.length; i++) {
+			if (aString.substr(i,1) != "-") {
+				newString += aString.substr(i,1); 
+			}
+			else {
+				i++;
+				newString += aString.substr(i,1).toUpperCase();
+			}
+		}
+		return newString;
+	}
+	
+	var setStyle = function () {
+		if (that.exists()) {
+			var node = rootNode.getElementById(tagName);
+			node.setAttribute("style", "");
+			
+			for (var attr in tagStyle) {
+				if (typeof(tagStyle[attr] != "function") && typeof(tagStyle[attr] != "object")) {
+					var evalString = "node.style."+reformatJavaStyle(attr)+" = \"" + tagStyle[attr] + "\";"; 
+					eval(evalString);				
+				}
+			}
+		}
+	}
+	
+	var create = function () {
+		if (!that.exists()) {
+			var divTag = rootNode.createElement("div");
+			var divTagAppended = rootNode.getElementsByTagName("body")[0].appendChild(divTag);
+			divTagAppended.id = tagName;
+		}
+		else {
+			that.clean();
+		}
+		setStyle();
+	};
+	var checkFrame = function () {
+		if (frameName !== "") {
+			return (typeof(window.frames[frameName]) != 'undefined');
+		}
+		return true;
+	};
+	
+	this.getTag = function() {
+		return rootNode.getElementById(tagName);
+	};
+	
+	var that = this;
+	var tagName = aTagName;
+	var frameName = aFrameName;
+	var rootNode = determineRootNode();
+	var tagStyle = aStyle;
+
+	create();
+}
+
+DivTag.prototype.write = function (someText) {
+	if (this.exists()) {
+		this.getTag().innerHTML = someText;
+	}
+};
+DivTag.prototype.clean = function () {
+	this.write("");
+};
+
+
+
+
 function mb_checkTag(frameName, tagName, elementId, appendAtTagName, attributes){
 	var oldElement;
 	var newElement;



More information about the Mapbender_commits mailing list