svn commit: r156 - trunk/mapbender/http/javascripts/mod_digitize_tab.php

christoph at osgeo.org christoph at osgeo.org
Thu Apr 27 08:54:47 EDT 2006


Author: christoph
Date: 2006-04-27 12:54:47+0000
New Revision: 156

Modified:
   trunk/mapbender/http/javascripts/mod_digitize_tab.php

Log:
improved button handling: data now comes from element vars

-> it's possible to include or exclude certain button types

Modified: trunk/mapbender/http/javascripts/mod_digitize_tab.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/mod_digitize_tab.php?view=diff&rev=156&p1=trunk/mapbender/http/javascripts/mod_digitize_tab.php&p2=trunk/mapbender/http/javascripts/mod_digitize_tab.php&r1=155&r2=156
==============================================================================
--- trunk/mapbender/http/javascripts/mod_digitize_tab.php	(original)
+++ trunk/mapbender/http/javascripts/mod_digitize_tab.php	2006-04-27 12:54:47+0000
@@ -122,12 +122,6 @@
 	var currentMemberIndex = -1;
 	var currentGeometryIndex = -1;
 
-
-
-	var canvas = new Array();
-
-	
-
 	// ------------------------------------------------------------------------------------------------------------------------
 	// --- registered functions (begin) ---------------------------------------------------------------------------------------
 
@@ -189,105 +183,88 @@
 	}
 */	
 	
-	
-	// ------------------------------------------------------------------------------------------------------------------------
-	// --- preload images (begin) ---------------------------------------------------------------------------------------------
-
-	// up	 
-	var digitize_point_up = new Image(); digitize_point_up.src = "../img/button_digitize/text_up.png";
-	var digitize_line_up = new Image(); digitize_line_up.src = "../img/button_digitize/line_up.png";
-	var digitize_poly_up = new Image(); digitize_poly_up.src = "../img/button_digitize/poly_up.png";
-	var digitize_move_up = new Image(); digitize_move_up.src = "../img/button_digitize/move_up.png";
-	var digitize_addNode_up = new Image(); digitize_addNode_up.src = "../img/button_digitize/newNode_up.png";
-	var digitize_delNode_up = new Image(); digitize_delNode_up.src = "../img/button_digitize/delNode_up.png";
-	// down	 
-	var digitize_point_down = new Image(); digitize_point_down.src = "../img/button_digitize/text_down.png";
-	var digitize_line_down = new Image(); digitize_line_down.src = "../img/button_digitize/line_down.png";
-	var digitize_poly_down = new Image(); digitize_poly_down.src = "../img/button_digitize/poly_down.png";
-	var digitize_move_down = new Image(); digitize_move_down.src = "../img/button_digitize/move_down.png";
-	var digitize_addNode_down = new Image(); digitize_addNode_down.src = "../img/button_digitize/newNode_down.png";
-	var digitize_delNode_down = new Image(); digitize_delNode_down.src = "../img/button_digitize/delNode_down.png";
-	
-	// --- preload images (end) -----------------------------------------------------------------------------------------------
-	// ------------------------------------------------------------------------------------------------------------------------
-
 
 	// ------------------------------------------------------------------------------------------------------------------------
 	// --- button handling (begin) --------------------------------------------------------------------------------------------
 
-	function register_button(obj) {
-		parent.mb_regButton_frame("init_digitize_button", obj, mod_digitize_elName);
-	}
-	
-	function init_digitize_button(obj, ind){
-		parent.mb_button[ind] = obj;
-		parent.mb_button[ind].img_over = obj.src;
-		
-		if (obj.id == "dragBasePoint") {
-			parent.mb_button[ind].img_on = digitize_move_down.src;
-			parent.mb_button[ind].img_off = digitize_move_up.src;
+
+	function displayButtons() {
+		if (parseInt(buttonPoint)==1) {
+			var tagContent = "<img name=\""+buttonPointId+"\" onmouseover=\"registerButton('initButtonPoint')\" id=\""+buttonPointId+"\" title=\""+buttonPointTitleUp+"\" src=\""+buttonPointSrcUp+"\">"; 
+			parent.writeTag(mod_digitize_elName,"divButtonPoint",tagContent);
 		}
-		else if (obj.id == "setBasePoint"){
-			parent.mb_button[ind].img_on = digitize_addNode_down.src;
-			parent.mb_button[ind].img_off = digitize_addNode_up.src;
+		if (parseInt(buttonLine)==1) {
+			var tagContent = "<img name=\""+buttonLineId+"\" onmouseover=\"registerButton('initButtonLine')\" id=\""+buttonLineId+"\" title=\""+buttonLineTitleUp+"\" src=\""+buttonLineSrcUp+"\">"; 
+			parent.writeTag(mod_digitize_elName,"divButtonLine",tagContent);
 		}
-		else if (obj.id == "delBasePoint"){
-			parent.mb_button[ind].img_on = digitize_delNode_down.src;
-			parent.mb_button[ind].img_off = digitize_delNode_up.src;
+		if (parseInt(buttonPolygon)==1) {
+			var tagContent = "<img name=\""+buttonPolygonId+"\" onmouseover=\"registerButton('initButtonPolygon')\" id=\""+buttonPolygonId+"\" title=\""+buttonPolygonTitleUp+"\" src=\""+buttonPolygonSrcUp+"\">"; 
+			parent.writeTag(mod_digitize_elName,"divButtonPolygon",tagContent);
 		}
-		else if (obj.id == "Point"){
-			parent.mb_button[ind].img_on = digitize_point_down.src;
-			parent.mb_button[ind].img_off = digitize_point_up.src;
+		if (parseInt(buttonMove)==1) {
+			var tagContent = "<img name=\""+buttonMoveId+"\" onmouseover=\"registerButton('initButtonMove')\" id=\""+buttonMoveId+"\" title=\""+buttonMoveTitleUp+"\" src=\""+buttonMoveSrcUp+"\">"; 
+			parent.writeTag(mod_digitize_elName,"divButtonMove",tagContent);
 		}
-		else if (obj.id == "Line"){
-			parent.mb_button[ind].img_on = digitize_line_down.src;
-			parent.mb_button[ind].img_off = digitize_line_up.src;
+		if (parseInt(buttonInsert)==1) {
+			var tagContent = "<img name=\""+buttonInsertId+"\" onmouseover=\"registerButton('initButtonInsert')\" id=\""+buttonInsertId+"\" title=\""+buttonInsertTitleUp+"\" src=\""+buttonInsertSrcUp+"\">"; 
+			parent.writeTag(mod_digitize_elName,"divButtonInsert",tagContent);
 		}
-		else if (obj.id == "Polygon"){
-			parent.mb_button[ind].img_on = digitize_poly_down.src;
-			parent.mb_button[ind].img_off = digitize_poly_up.src;
+		if (parseInt(buttonDelete)==1) {
+			var tagContent = "<img name=\""+buttonDeleteId+"\" onmouseover=\"registerButton('initButtonDelete')\" id=\""+buttonDeleteId+"\" title=\""+buttonDeleteTitleUp+"\" src=\""+buttonDeleteSrcUp+"\">"; 
+			parent.writeTag(mod_digitize_elName,"divButtonDelete",tagContent);
 		}
-		parent.mb_button[ind].status = 0;
-		parent.mb_button[ind].elName = obj.id;
-		parent.mb_button[ind].fName = "";
-		parent.mb_button[ind].go = new Function ("digitize_click(parent.mb_button["+ind+"])");
-		parent.mb_button[ind].stop = new Function ("digitize_disable(parent.mb_button["+ind+"])");
 	}
 	
-	function digitize_click(obj) {
-		if (obj.id == "dragBasePoint") {
-			activeButton = obj.id;
-			setEvent(obj);
-		}
-		else if (obj.id == "setBasePoint"){
-			activeButton = obj.id;
-			setEvent(obj);
-		}
-		else if (obj.id == "delBasePoint"){
+	function registerButton(functionName) {
+		parent.mb_regButton_frame(functionName, mod_digitize_elName);
+	}
+	
+	function initButtonPoint(ind){
+		initButton(ind, buttonPointSrcUp, buttonPointSrcDown, buttonPointSrcUp, buttonPointTitleUp, buttonPointTitleDown, buttonPointId);
+	}
+
+	function initButtonLine(ind){
+		initButton(ind, buttonLineSrcUp, buttonLineSrcDown, buttonLineSrcUp, buttonLineTitleUp, buttonLineTitleDown, buttonLineId);
+	}
+
+	function initButtonPolygon(ind){
+		initButton(ind, buttonPolygonSrcUp, buttonPolygonSrcDown, buttonPolygonSrcUp, buttonPolygonTitleUp, buttonPolygonTitleDown, buttonPolygonId);
+	}
+
+	function initButtonMove(ind){
+		initButton(ind, buttonMoveSrcUp, buttonMoveSrcDown, buttonMoveSrcUp, buttonMoveTitleUp, buttonMoveTitleDown, buttonMoveId);
+	}
+
+	function initButtonInsert(ind){
+		initButton(ind, buttonInsertSrcUp, buttonInsertSrcDown, buttonInsertSrcUp, buttonInsertTitleUp, buttonInsertTitleDown, buttonInsertId);
+	}
+
+	function initButtonDelete(ind){
+		initButton(ind, buttonDeleteSrcUp, buttonDeleteSrcDown, buttonDeleteSrcUp, buttonDeleteTitleUp, buttonDeleteTitleDown, buttonDeleteId);
+	}
+
+	function initButton(ind, srcOver, srcDown, srcUp, titleUp, titleDown, id) {
+		parent.mb_button[ind] = document.getElementById(id);
+		parent.mb_button[ind].img_over = srcOver;
+		parent.mb_button[ind].img_on = srcDown;
+		parent.mb_button[ind].img_off = srcUp;
+		parent.mb_button[ind].title_on = titleUp;
+		parent.mb_button[ind].title_off = titleDown;
+		parent.mb_button[ind].status = 0;
+		parent.mb_button[ind].elName = id;
+		parent.mb_button[ind].fName = "";
+		parent.mb_button[ind].go = new Function ("digitizeEnable(parent.mb_button["+ind+"])");
+		parent.mb_button[ind].stop = new Function ("digitizeDisable(parent.mb_button["+ind+"])");
+	}	
+
+	function digitizeEnable(obj) {
+		if (obj.id == buttonMoveId || obj.id == buttonInsertId || obj.id == buttonDeleteId) {
 			activeButton = obj.id;
 			setEvent(obj);
 		}
-		else if (obj.id == "Point"){
+		else if (obj.id == buttonPointId || obj.id == buttonLineId || obj.id == buttonPolygonId){
 			activeButton = obj.id;
-			obj.title = "Finish editing";
-			currentMemberIndex = -1;
-			registerGeometry(obj);
-			storeSnappingCoordinates();
-			var el = parent.frames[mod_digitize_target].document;
-			el.onmousemove = mod_digitize_go;
-		}
-		else if (obj.id == "Line"){
-			activeButton = obj.id;
-			obj.title = "Finish editing";
-			currentMemberIndex = -1;
-			registerGeometry(obj);
-			storeSnappingCoordinates();
-			var el = parent.frames[mod_digitize_target].document;
-			el.onmousemove = mod_digitize_go;
-		}
-		else if (obj.id == "Polygon"){
-			activeButton = obj.id;
-			obj.title = "Finish editing";
+			obj.title = obj.title_off;
 			currentMemberIndex = -1;
 			registerGeometry(obj);
 			storeSnappingCoordinates();
@@ -296,28 +273,10 @@
 		}
 	}
 
-	function digitize_disable(obj) {
-		if (obj.id == "dragBasePoint") {
-		}
-		else if (obj.id == "setBasePoint"){
-		}
-		else if (obj.id == "delBasePoint"){
-		}
-		else if (obj.id == "Point"){
-			activeButton = null;
-			obj.title = "Add point";
-			closeGeometry(obj.id);
-			mod_digitize_timeout();
-		}
-		else if (obj.id == "Line"){
-			activeButton = null;
-			obj.title = "Add line";
-			closeGeometry(obj.id);
-			mod_digitize_timeout();
-		}
-		else if (obj.id == "Polygon"){
+	function digitizeDisable(obj) {
+		if (obj.id == buttonPointId || obj.id == buttonLineId || obj.id == buttonPolygonId){
 			activeButton = null;
-			obj.title = "Add polygon";
+			obj.title = obj.title_on;
 			closeGeometry(obj.id);
 			mod_digitize_timeout();
 		}
@@ -1827,36 +1786,23 @@
 	document.forms[1].submit();
 	return false;
 }
+
 	</script>
 	</head>
-	<body onload="registerFunctions()">
+	<body onload="registerFunctions();displayButtons()">
 	<table cellpadding='0' cellspacing='0' align = center>
 	<tr>
 		<td>
 			<form name='dig'>
 			<table cellpadding='0' cellspacing='2'>
 				<tr>
-					<td>
-					<img  name='Point' onmouseover='register_button(this)' id='Point' title="Add point" src = '../img/button_digitize/text_up.png'>
-					</td>
-					<td>
-					<img  name='Line' onmouseover='register_button(this)' id='Line'  title="Add line" src = '../img/button_digitize/line_up.png'>
-					</td>
-					<td>
-					<img  name='Polygon' onmouseover='register_button(this)' id='Polygon' title="Add polygon" src = '../img/button_digitize/poly_up.png'>
-					</td>
-					<td>
-					&nbsp;&nbsp;&nbsp;
-					</td>
-					<td>
-					<img  name='dragBasePoint' onmouseover='register_button(this)' id='dragBasePoint' title="Move node" src = '../img/button_digitize/move_up.png'>
-					</td>
-					<td>
-					<img  name='setBasePoint' onmouseover='register_button(this)' id='setBasePoint' title="Add node" src = '../img/button_digitize/newNode_up.png'>
-					</td>
-					<td>
-					<img  name='delBasePoint' onmouseover='register_button(this)' id='delBasePoint' title="Delete node" src = '../img/button_digitize/delNode_up.png'>
-					</td>
+					<td><div id = 'divButtonPoint'></div></td>
+					<td><div id = 'divButtonLine'></div></td>
+					<td><div id = 'divButtonPolygon'></div></td>
+					<td>&nbsp;&nbsp;&nbsp;</td>
+					<td><div id = 'divButtonMove'></div></td>
+					<td><div id = 'divButtonInsert'></div></td>
+					<td><div id = 'divButtonDelete'></div></td>
 				</tr>
 			</table>
 			</form>




More information about the Mapbender_commits mailing list