[Mapbender-commits] r5339 - in trunk/mapbender: http/javascripts lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jan 19 06:40:20 EST 2010


Author: christoph
Date: 2010-01-19 06:40:18 -0500 (Tue, 19 Jan 2010)
New Revision: 5339

Removed:
   trunk/mapbender/lib/style.js
Modified:
   trunk/mapbender/http/javascripts/map.php
   trunk/mapbender/http/javascripts/mod_overview.js
   trunk/mapbender/lib/ajax.js
   trunk/mapbender/lib/alignButton.js
   trunk/mapbender/lib/backwards_compatibility_to_2.6.js
   trunk/mapbender/lib/button.js
   trunk/mapbender/lib/core.js
   trunk/mapbender/lib/div.js
   trunk/mapbender/lib/exception.js
   trunk/mapbender/lib/extent.js
   trunk/mapbender/lib/list.js
   trunk/mapbender/lib/point.js
Log:
refactoring

Modified: trunk/mapbender/http/javascripts/map.php
===================================================================
--- trunk/mapbender/http/javascripts/map.php	2010-01-19 11:39:03 UTC (rev 5338)
+++ trunk/mapbender/http/javascripts/map.php	2010-01-19 11:40:18 UTC (rev 5339)
@@ -26,26 +26,6 @@
 ini_set('session.bug_compat_42',0); 
 ini_set('session.bug_compat_warn',0);
 
-/*
-// may be added at a later stage
-$gui_changed=0;
-$new_wmc=0;
-
-if (!$_REQUEST["layer_preview"] && Mapbender::session()->get("mb_user_gui") && Mapbender::session()->get("mb_user_gui") != $_REQUEST["gui_id"]) {
-	$gui_changed=1;
-}
-
-if (!Mapbender::session()->get('mb_wmc') || ($gui_changed==1) ||	($_REQUEST['layer_preview'] && $_REQUEST['portal_services'])) {
-	$new_wmc=1;
-}
-
-if (isset($_REQUEST['layer_preview']) && $_REQUEST['layer_preview'] != 0) {
-	Mapbender::session()->set('layer_preview',$_REQUEST['portal_services');
-}
-else {
-	Mapbender::session()->set('layer_preview',0);
-}
-*/
 Mapbender::session()->set("mb_user_gui", $gui_id);
 
 ob_start();
@@ -53,9 +33,9 @@
 //
 // Define global variables (TODO: move to mapbender object later on)
 //
-echo "var mb_nr = '".session_id()."';";
-echo "var mb_session_name = '".session_name()."';";
-echo "var mb_myLogin = '".Mapbender::session()->get("mb_login")."';";
+echo "var mb_nr = Mapbender.sessionId = '".session_id()."';";
+echo "var mb_session_name = Mapbender.sessionName = '".session_name()."';";
+echo "var mb_myLogin = Mapbender.loginUrl = '".Mapbender::session()->get("mb_login")."';";
 echo "var mb_styleID = '".md5(Mapbender::session()->get("mb_user_name"))."';";
 echo "var mb_myBBOX = '".Mapbender::session()->get("mb_myBBOX")."';";
 echo "Mapbender.locale = '" . Mapbender::session()->get("mb_locale") . "';";
@@ -75,10 +55,10 @@
 // Load external JavaScript libraries
 //
 $extPath = dirname(__FILE__) . "/../extensions/";
-$extFileArray = array(  "jquery-ui-1.7.2.custom/js/jquery-1.3.2.min.js", 
-						"jqjson.min.js" // , 
-//						"jquery.form.js"
-						);
+$extFileArray = array(
+	"jquery-ui-1.7.2.custom/js/jquery-1.3.2.min.js", 
+	"jqjson.min.js" 
+);
 
 for ($i = 0; $i < count($extFileArray); $i++) {
 	$currentFile = $extPath . $extFileArray[$i];
@@ -92,37 +72,20 @@
 	}
 }
 
-?>
-// this replaces the old init function
-$(function () {
-	initModules();
-	
-	// creates the map objects (mapframe1, overview...)
-	eventInitMap.trigger();
-
-	eventBeforeInit.trigger();
-
-	// initialisation
-	eventInit.trigger();
-	
-	eventAfterInit.trigger();
-	
-});
-<?php
 //
 // Load internal JavaScript libraries
 //
 $libPath = dirname(__FILE__) . "/../../lib/";
-$libFileArray = array(  "exception.js", 
-						"ajax.js", 
-						"basic.js",
-						"div.js",
-						"list.js",
-						"point.js",
-						"style.js",
-						"button.js",
-						"extent.js",
-						"backwards_compatibility_to_2.6.js"
+$libFileArray = array(
+	"exception.js", 
+	"ajax.js", 
+	"basic.js",
+	"div.js",
+	"list.js",
+	"point.js",
+	"button.js",
+	"extent.js",
+	"backwards_compatibility_to_2.6.js"
 );
 
 for ($i = 0; $i < count($libFileArray); $i++) {
@@ -170,13 +133,6 @@
 $modulesNotRelyingOnGlobalsArray = explode(",", MODULES_NOT_RELYING_ON_GLOBALS);
 ?>
 Mapbender.modules = {};
-Mapbender.addModule = function (name, obj) {
-	if (name && !Mapbender.modules[name]) {	
-		Mapbender.modules[name] = obj;
-		return true;
-	}
-	return false;
-};
 <?php
 $executeJsPluginsArray = array();
 
@@ -277,7 +233,23 @@
 	}
 }
 
-echo "\nfunction initModules () {\n";
-echo implode("\n", $executeJsPluginsArray);
-echo "}\n";
+$jsText = implode("\n", $executeJsPluginsArray);
+echo <<<JS
+
+$(function () {
+	$jsText
+	
+	// creates the map objects (mapframe1, overview...)
+	Mapbender.events.initMaps.trigger();
+
+	Mapbender.events.beforeInit.trigger();
+
+	// initialisation
+	Mapbender.events.init.trigger();
+	
+	Mapbender.events.afterInit.trigger();
+	
+});
+
+JS;
 ?>
\ No newline at end of file

Modified: trunk/mapbender/http/javascripts/mod_overview.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_overview.js	2010-01-19 11:39:03 UTC (rev 5338)
+++ trunk/mapbender/http/javascripts/mod_overview.js	2010-01-19 11:40:18 UTC (rev 5339)
@@ -74,13 +74,13 @@
 	
 	$this.data("isMap", true);
 
-	Mapbender.modules[options.id] = $.extend(new Mapbender.Map(
+	$this.mapbender(new Mapbender.Map(
 		'', 
 		options.id, 
 		options.width, 
 		options.height, 
 		options.overview_wms
-	), Mapbender.modules[options.id]); 
+	)); 
 
 	map = Mapbender.modules[options.id];
 	map.isOverview = true;

Modified: trunk/mapbender/lib/ajax.js
===================================================================
--- trunk/mapbender/lib/ajax.js	2010-01-19 11:39:03 UTC (rev 5338)
+++ trunk/mapbender/lib/ajax.js	2010-01-19 11:40:18 UTC (rev 5339)
@@ -1,9 +1,3 @@
-/* 
-* $Id: map_obj.js 2413 2008-04-23 16:21:04Z christoph $
-* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
-* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
-*/
-
 /**
  * Package: Ajax
  * 
@@ -15,6 +9,15 @@
  *
  * Help:
  * <none>
+ * 
+ * Maintainer:
+ * http://www.mapbender.org/Christoph_Baudson
+ * 
+ * License:
+ * Copyright (c) 2009, Open Source Geospatial Foundation
+ * This program is dual licensed under the GNU General Public License 
+ * and Simplified BSD license.  
+ * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
  */
 Mapbender.Ajax = {
 	/**
@@ -41,6 +44,14 @@
  *
  * Help:
  * <none>
+ * Maintainer:
+ * http://www.mapbender.org/Christoph_Baudson
+ * 
+ * License:
+ * Copyright (c) 2009, Open Source Geospatial Foundation
+ * This program is dual licensed under the GNU General Public License 
+ * and Simplified BSD license.  
+ * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
  */
 /**
  * Constructor: Mapbender.Ajax.Request
@@ -99,8 +110,8 @@
 			"params": $.toJSON(parameters),
 			"id": null
 		};
-	}
-}
+	};
+};
 
 /**
  * Package: Request
@@ -113,6 +124,15 @@
  *
  * Help:
  * <none>
+ * 
+ * Maintainer:
+ * http://www.mapbender.org/Christoph_Baudson
+ * 
+ * License:
+ * Copyright (c) 2009, Open Source Geospatial Foundation
+ * This program is dual licensed under the GNU General Public License 
+ * and Simplified BSD license.  
+ * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
  */
 /**
  * Constructor: Mapbender.Ajax.Request
@@ -174,7 +194,7 @@
 			internalError = true;
 			return;
 		}
-		var resultObj = eval('(' + json + ')');
+		var resultObj = $.parseJSON(json);
 		// some severe error has occured
 		if (typeof(resultObj) != "object" || status != "success") {
 			message = Mapbender.Ajax.Messages.fatalError;
@@ -220,7 +240,7 @@
 			result = resultObj.result.data;
 		}
 		return;
-	}
+	};
 
 	/**
 	 * Method: send
@@ -287,7 +307,7 @@
 			"params": $.toJSON(parameters),
 			"id": id
 		};
-	}
+	};
     return this;
 };
 Mapbender.Ajax.Request.prototype = new Mapbender.Ajax.Notification();

Modified: trunk/mapbender/lib/alignButton.js
===================================================================
--- trunk/mapbender/lib/alignButton.js	2010-01-19 11:39:03 UTC (rev 5338)
+++ trunk/mapbender/lib/alignButton.js	2010-01-19 11:40:18 UTC (rev 5339)
@@ -12,7 +12,7 @@
 			}
 			var minY;
 			$(".ui-selected").each(function() {
-				var currentMinY = parseInt(this.style.top);
+				var currentMinY = parseInt(this.style.top, 10);
 				if ((!minY && minY !== 0 ) || currentMinY < minY) {
 					minY = currentMinY;
 				}
@@ -35,7 +35,7 @@
 			}
 			var minX;
 			$(".ui-selected").each(function() {
-				var currentMinX = parseInt(this.style.left);
+				var currentMinX = parseInt(this.style.left, 10);
 				if ((!minX && minX !== 0 ) || currentMinX < minX) {
 					minX = currentMinX;
 				}
@@ -59,14 +59,14 @@
 			}
 			var maxY;
 			$(".ui-selected").each(function() {
-				var currentMaxY = parseInt(this.style.top) + parseInt(this.style.height);
+				var currentMaxY = parseInt(this.style.top, 10) + parseInt(this.style.height, 10);
 				if ((!maxY && maxY !== 0) || currentMaxY > maxY) {
 					maxY = currentMaxY;
 				}
 			});
 	
 			$(".ui-selected").each(function() {
-				var newY = maxY - parseInt(this.style.height);
+				var newY = maxY - parseInt(this.style.height, 10);
 				this.style.top = newY + "px";
 			});
 		}
@@ -84,16 +84,16 @@
 			}
 			var maxX;
 			$(".ui-selected").each(function() {
-				var currentMaxX = parseInt(this.style.left) + parseInt(this.style.width);
+				var currentMaxX = parseInt(this.style.left, 10) + parseInt(this.style.width, 10);
 				if ((!maxX && maxX !== 0) || currentMaxX > maxX) {
 					maxX = currentMaxX;
 				}
 			});
 	
 			$(".ui-selected").each(function() {
-				var newX = maxX - parseInt(this.style.width);
+				var newX = maxX - parseInt(this.style.width, 10);
 				this.style.left = newX + "px";
 			});
 		}
 	}
-}
\ No newline at end of file
+};
\ No newline at end of file

Modified: trunk/mapbender/lib/backwards_compatibility_to_2.6.js
===================================================================
--- trunk/mapbender/lib/backwards_compatibility_to_2.6.js	2010-01-19 11:39:03 UTC (rev 5338)
+++ trunk/mapbender/lib/backwards_compatibility_to_2.6.js	2010-01-19 11:40:18 UTC (rev 5339)
@@ -1,3 +1,15 @@
+var Point = Mapbender.Point;
+
+function init(){
+	new Mb_warning("deprecated: old body onload init! Remove onload='init()' from the body element attributes.");
+}
+
+/**
+ * @deprecated, use $("#module_id:maps").mapbender()
+ */
+var mb_mapObj = [];
+
+
 var clickX;
 var clickY;
 
@@ -161,3 +173,81 @@
 		var error = new Mb_exception('map.php: mb_ajax_json:'+e);
 	}
 }
+
+/**
+ * @ignore
+ */
+function mapToReal(frameName, aPoint) {
+	var ind = getMapObjIndexByName(frameName);
+	return mb_mapObj[ind].convertPixelToReal(aPoint);
+}
+/**
+ * @ignore
+ */
+function realToMap(frameName, aPoint) {
+	var ind = getMapObjIndexByName(frameName);
+	return mb_mapObj[ind].convertRealToPixel(aPoint);
+}
+
+/**
+ * @ignore
+ */
+function roundToDigits(aFloat, numberOfDigits) {
+	return Math.round(aFloat*Math.pow(10, parseInt(numberOfDigits, 10)))/Math.pow(10, parseInt(numberOfDigits, 10));
+}
+
+
+/**
+ * creates a style tag in the head of the document.
+ *
+ */
+var StyleTag = function() {
+
+	/**
+	 * Creates the style tag in the head of the document. Something like a constructor. 
+	 *
+	 */
+	var createStyleTag = function() {
+		// TODO: Internet Explorer routine seems a little buggy
+		if ($.browser.msie) {
+			// create a Style Sheet object (IE only)
+			//styleSheetObj=document.createStyleSheet();
+			// get the DOM node of the style sheet object, set the type
+			//styleObj=styleSheetObj.owningElement || styleSheetObj.ownerNode;
+			//styleObj.setAttribute("type","text/css");
+			
+			// alternative way for IE: take existing styleSheet with index 0 instead of creating a new one
+			styleSheetObj=document.styleSheets[0];
+		}
+		else {
+			// create the style node, set the style
+			styleObj=document.createElement("style");
+			styleObj.setAttribute("type","text/css");
+			// append the node to the head
+			document.getElementsByTagName("head")[0].appendChild(styleObj);
+		}
+	};
+	
+	/**
+	 * Adds a class className with the CSS in cssString
+	 */
+	this.addClass = function(className,cssString) {
+		// TODO: Internet Explorer routine seems a little buggy
+		if ($.browser.msie) {
+			//add new style declaration to chosen styleSheet 
+			var cssRules = cssString.split(";");
+			for (i=0; i<cssRules.length-1; i++){
+				styleSheetObj.addRule("."+className,cssRules[i]);
+			}
+		}
+		else {
+			// insert the content via createTextNode
+			styleObj.appendChild(document.createTextNode("."+className+"{\n\t"+cssString+"\n}\n"));				
+		}
+	};
+	
+	var styleObj;
+	var styleSheetObj; //IE only...
+	
+	createStyleTag();
+};

Modified: trunk/mapbender/lib/button.js
===================================================================
--- trunk/mapbender/lib/button.js	2010-01-19 11:39:03 UTC (rev 5338)
+++ trunk/mapbender/lib/button.js	2010-01-19 11:40:18 UTC (rev 5339)
@@ -1,9 +1,35 @@
-/*
- ***************************************************************************************
- *   button handling
- ***************************************************************************************
+/**
+ * Package: Button
+ *
+ * Description:
+ * Adds a clickable button to Mapbender
+ * 
+ * Files:
+ *  - lib/button.js
+ *
+ * Help:
+ * <none>
+ *
+ * Maintainer:
+ * http://www.mapbender.org/User:Christoph_Baudson
+ * 
+ * Parameters:
+ * options.over      - URL to img representing the "over" status
+ * options.on        - URL to img representing the "on" status
+ * options.off       - URL to img representing the "off" status (default)
+ * options.go        - a function to be executed once the button is pressed
+ * options.stop      - a function to be executed once the button is disabled
+ * options.off       - URL to img representing the "off" status (default)
+ * options.name      - the ID of the corresponding DOM element
+ *
+ * License:
+ * Copyright (c) 2009, Open Source Geospatial Foundation
+ * This program is dual licensed under the GNU General Public License 
+ * and Simplified BSD license.  
+ * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
  */
 
+
 Mapbender.Button = function (options) {
 	mb_regButton(options);
 };
@@ -18,7 +44,7 @@
 		var options = wii;
 		mb_button[ind] = options.domElement;
 		mb_button[ind].img_over = options.over ? options.over : "";
-		mb_button[ind].img_on = options.on ? options.on : ""
+		mb_button[ind].img_on = options.on ? options.on : "";
 		mb_button[ind].img_off = options.off ? options.off : "";
 		mb_button[ind].status = options.status ? options.status : 0;
 		mb_button[ind].elName = options.name ? options.name : "";
@@ -125,7 +151,7 @@
 
 function mb_enableButton (elName) {
 	for (var i = 0; i < mb_button.length; i++) {
-		if (mb_button[i].elName === elName && mb_button[i].status == 0) {
+		if (mb_button[i].elName === elName && mb_button[i].status === 0) {
 			mb_button_click(i);
 			return;
 		}
@@ -189,7 +215,7 @@
 		callback: updateButtonTooltips
 	});
 	req.send();
-};
+}
 
 Mapbender.events.localize.register(function () {
 	mb_localizeButtons();

Modified: trunk/mapbender/lib/core.js
===================================================================
--- trunk/mapbender/lib/core.js	2010-01-19 11:39:03 UTC (rev 5338)
+++ trunk/mapbender/lib/core.js	2010-01-19 11:40:18 UTC (rev 5339)
@@ -1,79 +1,107 @@
-var currentWmcExtensionData = {};
-var restoredWmcExtensionData = {};
+/**
+ * License:
+ * Copyright (c) 2009, Open Source Geospatial Foundation
+ * This program is dual licensed under the GNU General Public License 
+ * and Simplified BSD license.  
+ * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
+ */
 
-//var mb_MapRequestSubFunctions = [];
-//var mb_MapRequestPreFunctions = [];
-//var mb_MapObjectSubFunctions = [];
-//var mb_GetScalePreFunctions = [];
-//var mb_FeatureInfoPreFunctions = [];
-//var mb_loadWmsSubFunctions = [];
-//var mb_InitFunctions = [];
-var mb_WfsReadSubFunctions = [];
-var mb_WfsWriteSubFunctions = [];
-var mb_l10nFunctions = [];
-
 /**
  * Triggered after a map is requested.
  */
-var eventAfterMapRequest = Mapbender.events.afterMapRequest = new MapbenderEvent();
+Mapbender.events.afterMapRequest = new MapbenderEvent();
 
 /**
- * Triggered after aall map images have been loaded.
+ * Triggered when Mapbender is loaded and after the map object has been initialised.
  */
-var eventAfterMapImagesReady = new MapbenderEvent();
+Mapbender.events.init = new MapbenderEvent();
 
 /**
- * Triggered before a map is requested.
+ * Triggered before eventInit.
  */
-var eventBeforeMapRequest = new MapbenderEvent();
+Mapbender.events.beforeInit = new MapbenderEvent();
 
 /**
- * Triggered before a feature info is requested.
+ * Triggered after Mapbender is loaded and has been initialised.
+ * Used to trigger initial map requests
  */
-var eventBeforeFeatureInfo = new MapbenderEvent();
+Mapbender.events.afterInit = new MapbenderEvent();
+
 /**
- * Triggered after a WMS has been loaded.
+ * Initializes the map object. Triggered when Mapbender is loaded. 
  */
-var eventAfterLoadWMS = new MapbenderEvent();
+Mapbender.events.initMaps = new MapbenderEvent();
 
 /**
- * Triggered when Mapbender is loaded and after the map object has been initialised.
+ * Switches the locale. Triggered by module switch_locale or onload(?) 
  */
-var eventInit = Mapbender.events.init = new MapbenderEvent();
+Mapbender.events.localize = new MapbenderEvent();
 
+
+Mapbender.events.init.register(function() {
+	// remove the splash screen, show the application
+	$("#loading_mapbender").remove();
+	$("#complete_mapbender").show();
+});
+
+Mapbender.events.afterInit.register(function () {
+	// performs a map request for each map frame
+	$(":maps").each(function () {
+		$(this).mapbender(function () {
+			this.setMapRequest();
+		});
+	});
+});
+
+
+
+
+//
+//
+// DEPRECATED, FOR BACKWARDS COMPATIBILITY
+//
+//
+
+var eventAfterMapRequest = Mapbender.events.afterMapRequest;
+var eventInit = Mapbender.events.init;
+var eventBeforeInit = Mapbender.events.beforeInit;
+var eventAfterInit = Mapbender.events.afterInit;
+var eventInitMap = Mapbender.events.initMaps;
+var eventLocalize = Mapbender.events.localize;
+
 /**
- * Triggered before eventInit.
+ * Triggered after the map has been resized
  */
-var eventBeforeInit = Mapbender.events.beforeInit = new MapbenderEvent();
+var eventResizeMap = new MapbenderEvent();
 
 /**
- * Triggered after Mapbender is loaded and has been initialised.
- * Used to trigger initial map requests
+ * Triggered after aall map images have been loaded.
  */
-var eventAfterInit = Mapbender.events.afterInit = new MapbenderEvent();
+var eventAfterMapImagesReady = new MapbenderEvent();
 
 /**
- * Initializes the map object. Triggered when Mapbender is loaded. 
+ * Triggered before a map is requested.
  */
-var eventInitMap = Mapbender.events.initMaps = new MapbenderEvent();
+var eventBeforeMapRequest = new MapbenderEvent();
 
-Mapbender.events.init.register(function() {
-	$lm = $("#loading_mapbender");
-	$cm = $("#complete_mapbender");
-	$lm.remove();
-	$cm.show();
-});
-
 /**
- * Switches the locale. Triggered by module switch_locale or onload(?) 
+ * Triggered before a feature info is requested.
  */
-var eventLocalize = Mapbender.events.localize = new MapbenderEvent();
-
+var eventBeforeFeatureInfo = new MapbenderEvent();
 /**
- * Triggered after the map has been resized
+ * Triggered after a WMS has been loaded.
  */
-var eventResizeMap = new MapbenderEvent();
+var eventAfterLoadWMS = new MapbenderEvent();
 
+
+
+var currentWmcExtensionData = {};
+var restoredWmcExtensionData = {};
+
+var mb_WfsReadSubFunctions = [];
+var mb_WfsWriteSubFunctions = [];
+var mb_l10nFunctions = [];
+
 /**
  * deprecated wrapped function
  * @deprecated
@@ -140,7 +168,7 @@
  * @deprecated
  */
 function mb_registerL10nFunctions(stringFunction) {
-	eventLocalize.register(stringFunction)
+	eventLocalize.register(stringFunction);
 //	mb_l10nFunctions[mb_l10nFunctions.length] = stringFunction;
 }
 
@@ -156,13 +184,6 @@
 }
 
 /**
- * Called in index.php on body onload
- */
-function init(){
-	new Mb_warning("deprecated: old body onload init! Remove onload='init()' from the body element attributes.");
-}
-
-/**
  * deprecated function for writing content within a tag via innerHTML
  * @deprecated
  */
@@ -177,15 +198,3 @@
 		}
 	}
 }
-
-/**
- * @deprecated, use $("#module_id:maps")
- */
-var mb_mapObj = [];
-
-eventAfterInit.register(function () {
-	// performs a map request for each map frame
-	for (var i = 0; i < mb_mapObj.length; i++){
-		mb_mapObj[i].setMapRequest();
-	}      	
-});

Modified: trunk/mapbender/lib/div.js
===================================================================
--- trunk/mapbender/lib/div.js	2010-01-19 11:39:03 UTC (rev 5338)
+++ trunk/mapbender/lib/div.js	2010-01-19 11:40:18 UTC (rev 5339)
@@ -1,12 +1,15 @@
-/* 
-* $Id: map_obj.js 2413 2008-04-23 16:21:04Z christoph $
-* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
-* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
-*/
+/**
+ * License:
+ * Copyright (c) 2009, Open Source Geospatial Foundation
+ * This program is dual licensed under the GNU General Public License 
+ * and Simplified BSD license.  
+ * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
+ */
 
 /**
  * @class Represents a div tag. May be located in any frame of Mapbender.
  * 
+ * @deprecated
  * @constructor
  * @param aTagName {String} the name of the tag
  * @param aFrameName {String} the name of frame where the div tag is being created

Modified: trunk/mapbender/lib/exception.js
===================================================================
--- trunk/mapbender/lib/exception.js	2010-01-19 11:39:03 UTC (rev 5338)
+++ trunk/mapbender/lib/exception.js	2010-01-19 11:40:18 UTC (rev 5339)
@@ -1,13 +1,7 @@
-/* 
-* $Id: map_obj.js 2413 2008-04-23 16:21:04Z christoph $
-* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
-* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
-*/
-
 (function () {
 	
 	//An abstract class, logs JavaScript events like errors, warnings etc.
-	function Mb_log () {
+	var Mb_log = function () {
 		var that = this;
 		
 		var levelArray = global_log_levels.split(",");
@@ -83,6 +77,12 @@
 	 *
 	 * Help:
 	 * <none>
+	 * 
+	 * License:
+	 * Copyright (c) 2009, Open Source Geospatial Foundation
+	 * This program is dual licensed under the GNU General Public License 
+	 * and Simplified BSD license.  
+	 * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
 	 */
 	/**
 	 * Constructor: Exception
@@ -93,7 +93,8 @@
 	Mapbender.Exception = function (message) {
 		var level = "error";
 		this.throwException(message, level);
-	}
+	};
+	
 	Mapbender.Exception.prototype = new Mb_log();
 	
 	/**
@@ -107,6 +108,12 @@
 	 *
 	 * Help:
 	 * <none>
+	 * 
+	 * License:
+	 * Copyright (c) 2009, Open Source Geospatial Foundation
+	 * This program is dual licensed under the GNU General Public License 
+	 * and Simplified BSD license.  
+	 * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
 	 */
 	/**
 	 * Constructor: Warning
@@ -117,7 +124,8 @@
 	Mapbender.Warning = function (message) {
 		var level = "warning";
 		this.throwException(message, level);
-	}
+	};
+	
 	Mapbender.Warning.prototype = new Mb_log();
 	 
 	/**
@@ -131,6 +139,12 @@
 	 *
 	 * Help:
 	 * <none>
+	 * 
+	 * License:
+	 * Copyright (c) 2009, Open Source Geospatial Foundation
+	 * This program is dual licensed under the GNU General Public License 
+	 * and Simplified BSD license.  
+	 * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
 	 */
 	/**
 	 * Constructor: Notice
@@ -141,7 +155,8 @@
 	Mapbender.Notice = function (message) {
 		var level = "notice";
 		this.throwException(message, level);
-	}
+	};
+	
 	Mapbender.Notice.prototype = new Mb_log();
 
 })();

Modified: trunk/mapbender/lib/extent.js
===================================================================
--- trunk/mapbender/lib/extent.js	2010-01-19 11:39:03 UTC (rev 5338)
+++ trunk/mapbender/lib/extent.js	2010-01-19 11:40:18 UTC (rev 5339)
@@ -84,16 +84,6 @@
 		}
 	};
 
-	/**
-	 * Method: toString
-	 * 
-	 * Description:
-	 * Returns a comma-separated list of all four coordinates
-	 */
-	this.toString = function () {
-		return this.min.x + "," + this.min.y + "," + this.max.x + "," + this.max.y;
-	};
-	
 	var isPoint = function (param) {
 		if (typeof param === "object" && param.constructor === Point) {
 			return true;
@@ -108,14 +98,6 @@
 		return false;
 	};
 	
-	this.getSouthWest = function () {
-		return this.min;
-	};
-	
-	this.getNorthEast = function () {
-		return this.max;
-	};
-	
 	if (isExtent(minx)) {
 		this.set(Mapbender.cloneObject(minx.min), Mapbender.cloneObject(minx.max));
 	}
@@ -135,3 +117,21 @@
 		);
 	}
 };
+
+/**
+ * Method: toString
+ * 
+ * Description:
+ * Returns a comma-separated list of all four coordinates
+ */
+Mapbender.Extent.prototype.toString = function () {
+	return this.min.x + "," + this.min.y + "," + this.max.x + "," + this.max.y;
+};
+
+Mapbender.Extent.prototype.getSouthWest = function () {
+	return this.min;
+};
+	
+Mapbender.Extent.prototype.getNorthEast = function () {
+	return this.max;
+};

Modified: trunk/mapbender/lib/list.js
===================================================================
--- trunk/mapbender/lib/list.js	2010-01-19 11:39:03 UTC (rev 5338)
+++ trunk/mapbender/lib/list.js	2010-01-19 11:40:18 UTC (rev 5339)
@@ -1,13 +1,17 @@
-/* 
-* $Id: map_obj.js 2413 2008-04-23 16:21:04Z christoph $
-* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
-* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
-*/
-
 /**
- * @class A List object is an array of arbitrary objects with additional methods. 
+ * Package: List
+ * 
+ * Description:
+ * A List object is an array of arbitrary objects with additional methods.
+ * 
+ * Files:
+ *  - lib/list.js
  *
- * @constructor
+ * License:
+ * Copyright (c) 2009, Open Source Geospatial Foundation
+ * This program is dual licensed under the GNU General Public License 
+ * and Simplified BSD license.  
+ * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
  */
 var List = function() {
 	
@@ -114,4 +118,3 @@
 	
 	this.list = null;
 };
-

Modified: trunk/mapbender/lib/point.js
===================================================================
--- trunk/mapbender/lib/point.js	2010-01-19 11:39:03 UTC (rev 5338)
+++ trunk/mapbender/lib/point.js	2010-01-19 11:40:18 UTC (rev 5339)
@@ -1,18 +1,31 @@
-/* 
-* $Id:point.js 2476 2008-05-28 15:03:41Z christoph $
-* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
-* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
-*/
-//http://www.mapbender.org/index.php/point.js
-
 /**
- * @class A class representing a two-dimensional point.
+ * Package: Point
+ * 
+ * Description:
+ * A class representing a two- (or three-) dimensional point.
+ * 
+ * Files:
+ *  - lib/point.js
  *
- * @constructor
- * @param {Float} x x value of the {@link Point}
- * @param {Float} y y value of the {@link Point}
+ * License:
+ * Copyright (c) 2009, Open Source Geospatial Foundation
+ * This program is dual licensed under the GNU General Public License 
+ * and Simplified BSD license.  
+ * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
  */
- Mapbender.Point = Point = function (x, y, z){
+
+/**
+ * Constructor: Point
+ * 
+ * Description:
+ * just pass a Point in order to clone it.
+ * 
+ * Parameters:
+ * x      - the x coordinate
+ * y      - the y coordinate
+ * z      - *[optional]* the z coordinate
+ */
+Mapbender.Point = function (x, y, z){
 	if (typeof x === "object" && x.constructor === Mapbender.Point) {
 		this.x = x.x;
 		this.y = x.y;
@@ -20,81 +33,76 @@
 		return;
 	}
 
- 	/**
- 	 * x value of the {@link Point}
- 	 *
-	 * @type Float
-	 */
 	this.x = parseFloat(x);
- 	/**
- 	 * y value of the {@link Point}
-	 *
-	 * @type Float
-	 */
 	this.y = parseFloat(y);
-	
-	this.z = z;
-	
-}
+	this.z = parseFloat(z);
+};
+
 /**
  * computes the distance between a {@link Point} p and this {@link Point}
  *
  * @param {Point} p the distance between this {@link Point} and the {@link Point} p is computed.
  * @return {Float} the distance between the two {@link Point} objects.
  */
-Point.prototype.dist = function(p){
+Mapbender.Point.prototype.dist = function(p){
 	return Math.sqrt(Math.pow(this.y-p.y,2) + Math.pow(this.x-p.x,2)) ;
 };
+
 /**
  * checks if the coordinates of this {@link Point} match the coordinates of a {@link Point} p
  *
  * @param {Point} p 
  * @return {Boolean} true if the two points are equal; elso false
  */
-Point.prototype.equals = function(p){
+Mapbender.Point.prototype.equals = function(p){
 	if (this.x == p.x && this.y == p.y) {return true;}
 	return false;
 };
+
 /**
  * subtracts a {@link Point} p from this {@link Point}
  *
  * @param {Point} p 
  * @return a new {@link Point} with the difference of the two points
  */
-Point.prototype.minus = function(p){
-	return new Point(this.x-p.x, this.y-p.y);
+Mapbender.Point.prototype.minus = function(p){
+	return new Mapbender.Point(this.x-p.x, this.y-p.y);
 };
+
 /**
  * adds this {@link Point} to a {@link Point} p
  *
  * @param {Point} p 
  * @return a new {@link Point} with the sum of the two points
  */
-Point.prototype.plus = function(p){
-	return new Point(this.x+p.x, this.y+p.y);
+Mapbender.Point.prototype.plus = function(p){
+	return new Mapbender.Point(this.x+p.x, this.y+p.y);
 };
+
 /**
  * divides this {@link Point} by a scalar c
  *
  * @param {Float} c divisor
  * @return a new {@link Point} divided by c
  */
-Point.prototype.dividedBy = function(c){
+Mapbender.Point.prototype.dividedBy = function(c){
 	if (c !== 0) {
-		return new Point(this.x/c, this.y/c);
+		return new Mapbender.Point(this.x/c, this.y/c);
 	}
-	var e = new Mb_exception("Point.dividedBy: Division by zero");
+	var e = new Mapbender.Exception("Point.dividedBy: Division by zero");
 	return false;
 };
+
 /**
  * multiplies this {@link Point} by a scalar c
  *
  * @param {Float} c factor
  * @return a new {@link Point} multiplied by c
  */
-Point.prototype.times = function(c){
-	return new Point(this.x*c, this.y*c);
+Mapbender.Point.prototype.times = function(c){
+	return new Mapbender.Point(this.x*c, this.y*c);
 };
+
 /**
  * rounds the coordinates to numOfDigits digits
  *
@@ -102,14 +110,20 @@
  * @return a new {@link Point} rounded to numOfDigits digits
  * @type Point
  */
-Point.prototype.round = function(numOfDigits){
-	return new Point(roundToDigits(this.x, numOfDigits), roundToDigits(this.y, numOfDigits));
+Mapbender.Point.prototype.round = function(numOfDigits){
+	var roundToDigits = function (aFloat, numberOfDigits) {
+		var d = parseInt(numberOfDigits, 10);
+		return Math.round(aFloat * Math.pow(10, d))	/ Math.pow(10, d);
+	};
+	
+	return new Mapbender.Point(roundToDigits(this.x, numOfDigits), roundToDigits(this.y, numOfDigits));
 };
+
 /**
  * @returns a {String} representation of this Point
  * @type String
  */
-Point.prototype.toString = function(){
+Mapbender.Point.prototype.toString = function(){
 	if (typeof(this.z == "undefined")) {
 		return "[" + this.x + ", " + this.y + "]";
 	}
@@ -117,28 +131,3 @@
 		return "[" + this.x + ", " + this.y + ", " + this.z + "]";
 	}
 };
-
-
-//------------------------------------------------------------------------
-// possible improvement: point has flag: map OR real. additional functions: toReal, toMap
-/**
- * @ignore
- */
-function mapToReal(frameName, aPoint) {
-	var ind = getMapObjIndexByName(frameName);
-	return mb_mapObj[ind].convertPixelToReal(aPoint);
-}
-/**
- * @ignore
- */
-function realToMap(frameName, aPoint) {
-	var ind = getMapObjIndexByName(frameName);
-	return mb_mapObj[ind].convertRealToPixel(aPoint);
-}
-
-/**
- * @ignore
- */
-function roundToDigits(aFloat, numberOfDigits) {
-	return Math.round(aFloat*Math.pow(10, parseInt(numberOfDigits, 10)))/Math.pow(10, parseInt(numberOfDigits, 10));
-}

Deleted: trunk/mapbender/lib/style.js
===================================================================
--- trunk/mapbender/lib/style.js	2010-01-19 11:39:03 UTC (rev 5338)
+++ trunk/mapbender/lib/style.js	2010-01-19 11:40:18 UTC (rev 5339)
@@ -1,54 +0,0 @@
-/**
- * creates a style tag in the head of the document.
- *
- */
-var StyleTag = function() {
-
-	/**
-	 * Creates the style tag in the head of the document. Something like a constructor. 
-	 *
-	 */
-	var createStyleTag = function() {
-		// TODO: Internet Explorer routine seems a little buggy
-		if ($.browser.msie) {
-			// create a Style Sheet object (IE only)
-			//styleSheetObj=document.createStyleSheet();
-			// get the DOM node of the style sheet object, set the type
-			//styleObj=styleSheetObj.owningElement || styleSheetObj.ownerNode;
-			//styleObj.setAttribute("type","text/css");
-			
-			// alternative way for IE: take existing styleSheet with index 0 instead of creating a new one
-			styleSheetObj=document.styleSheets[0];
-		}
-		else {
-			// create the style node, set the style
-			styleObj=document.createElement("style");
-			styleObj.setAttribute("type","text/css");
-			// append the node to the head
-			document.getElementsByTagName("head")[0].appendChild(styleObj);
-		}
-	};
-	
-	/**
-	 * Adds a class className with the CSS in cssString
-	 */
-	this.addClass = function(className,cssString) {
-		// TODO: Internet Explorer routine seems a little buggy
-		if ($.browser.msie) {
-			//add new style declaration to chosen styleSheet 
-			var cssRules = cssString.split(";");
-			for (i=0; i<cssRules.length-1; i++){
-				styleSheetObj.addRule("."+className,cssRules[i]);
-			}
-		}
-		else {
-			// insert the content via createTextNode
-			styleObj.appendChild(document.createTextNode("."+className+"{\n\t"+cssString+"\n}\n"));				
-		}
-	};
-	
-	var styleObj;
-	var styleSheetObj; //IE only...
-	
-	createStyleTag();
-};



More information about the Mapbender_commits mailing list