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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Aug 12 08:49:00 EDT 2011


Author: verenadiewald
Date: 2011-08-12 05:49:00 -0700 (Fri, 12 Aug 2011)
New Revision: 8061

Modified:
   trunk/mapbender/http/javascripts/mod_tooltip.php
Log:
http://trac.osgeo.org/mapbender/ticket/863

Modified: trunk/mapbender/http/javascripts/mod_tooltip.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_tooltip.php	2011-08-12 12:46:40 UTC (rev 8060)
+++ trunk/mapbender/http/javascripts/mod_tooltip.php	2011-08-12 12:49:00 UTC (rev 8061)
@@ -1,7 +1,7 @@
 <?php
 # $Id: mod_toggleModule.php 2238 2008-03-13 14:24:56Z christoph $
 # http://www.mapbender.org/index.php/mod_toggleModule.php
-# Copyright (C) 2002 CCGIS 
+# Copyright (C) 2002 CCGIS
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -32,14 +32,14 @@
 	$e = new mb_exception("tooltip.php: Configuration file " . $wfs_conf_filename . " not found.");
 }
 
-echo "var tooltipTarget ='".$e_target[0]."';"; 
+echo "var tooltipTarget ='".$e_target[0]."';";
 
 include '../include/dyn_js.php';
 ?>
 //tolerance when we ask wfs (comes from conf file)
 if(typeof(mb_wfs_tolerance)==='undefined') {
 	var mb_wfs_tolerance = 8;
-}	
+}
 
 var targetArray = tooltipTarget.split(",");
 
@@ -61,7 +61,7 @@
 if(typeof(tooltip_disableWms)==='undefined')
 	var tooltip_disableWms = "0";
 if(typeof(tooltip_disableWfs)==='undefined')
-	var tooltip_disableWfs = "0";	
+	var tooltip_disableWfs = "0";
 try{
 	var no_result_text = eval(tooltip_noResultArray);
 }catch(e){
@@ -78,23 +78,35 @@
 var tooltipMsg = {'title':"<?php echo _mb("Information");?>"};
 
 function mod_tooltipInit(){
-	var tooltip_map = getMapObjByName(tooltipTarget);
-	var ind = getMapObjIndexByName(tooltipTarget);
-	var myMapObj = mb_mapObj[ind];		
+        var ind = getMapObjIndexByName(tooltipTarget);
+	var myMapObj = mb_mapObj[ind];
+        var domNode = myMapObj.getDomElement();
 
-	var map_el = myMapObj.getDomElement();
+        $(domNode).bind("mousemove", function (e) {
+            var tooltip_map = getMapObjByName(tooltipTarget);
+            point = tooltip_map.getMousePosition(e);
+            mod_tooltip_run(point);
+        });
+        $(domNode).bind("mouseout", function() {
+            mouseMoves=0;
+        });
 
-	$(map_el.ownerDocument).mousemove(function(event){
-		point = tooltip_map.getMousePosition(event);
-		//mb_getMousePos(event,myMapObj.getMousePosition(event));
-		mod_tooltip_run(point);
-	}).mouseout(function(){
-		mouseMoves=0;
-	});
 }
 
 eventInit.register(mod_tooltipInit); //initialize tooltips!
 
+Mapbender.events.afterMapRequest.register(function () {
+    var ind = getMapObjIndexByName(tooltipTarget);
+	var myMapObj = mb_mapObj[ind];
+        var domNode = myMapObj.getDomElement();
+
+        $(domNode).bind("mousemove", function (e) {
+            var tooltip_map = getMapObjByName(tooltipTarget);
+            point = tooltip_map.getMousePosition(e);
+            mod_tooltip_run(point);
+        });
+});
+
 function mod_tooltip_run(point){
 	mouseMoves++;
 	var currentMouseMoves = mouseMoves;
@@ -113,18 +125,18 @@
 	point_geom.addPoint(mapToReal(tooltipTarget,point));
 	visibleRequest = 0;
 
-	if(tooltip_disableWms != '1') {	
+	if(tooltip_disableWms != '1') {
 		//FeatureInfo requests
 		urls = mb_mapObj[ind].getFeatureInfoRequests(point);
 		tooltipWmsRequestCount = urls.length;
-		numberOfFinishedWmsRequests	= 0;	
+		numberOfFinishedWmsRequests	= 0;
 		for(var j=0;j < urls.length;j++){
-			mb_ajax_post("../extensions/ext_featureInfoTunnel.php", {url:urls[j]}, 
+			mb_ajax_post("../extensions/ext_featureInfoTunnel.php", {url:urls[j]},
 				checkFeatureInfoResults);
 		}
 	}
-	
-	if(tooltip_disableWfs != '1') {	
+
+	if(tooltip_disableWfs != '1') {
 		//WFS requests
 		requests = getWfsRequests(tooltipTarget, point_geom, true);
 		tooltipWfsRequestCount = requests.length;
@@ -139,7 +151,7 @@
 						if (typeof(currentRequest) === "object" && typeof(currentRequest.js_wfs_conf_id) !== "undefined") {
 							for (var i = 0; i < geom.count(); i++) {
 								geom.get(i).wfs_conf = parseInt(currentRequest.js_wfs_conf_id);
-							}					
+							}
 						}
 					}
 					checkWfsResultsFinished(geom);
@@ -158,12 +170,12 @@
 			displayResultDoc("");
 		return;
 	}
-	
+
 	for(var k=0;k < no_result_text.length;k++){
 		if(js_code.indexOf(no_result_text[k])!==-1){
 			if(!isFirstResult()) {
 				displayResultDoc("");
-			}	
+			}
 			return;
 		}
 	}
@@ -183,10 +195,10 @@
 			//generate and output result
 			//if(resultGeomArray.count()>1) {
 				var html = createSimpleWfsResultHtml(resultGeomArray);
-			//}	
+			//}
 			//else {
 			//	var html = createDetailedWfsResultHtml(resultGeomArray);
-			//}	
+			//}
 			displayResultDoc(html);
 		}
 		else if(!isFirstResult())
@@ -207,7 +219,7 @@
 	if(tooltip_destinationFrame=="") {
 		return showBalloonFrame(html);
 	}
-          	
+
 	//put the frame there
 	$("#"+tooltip_destinationFrame).each(function(){
 	    var oDoc = this.contentWindow || this.contentDocument;
@@ -219,32 +231,32 @@
 		oDoc.write(html);
 		if(isLastResult())
 			oDoc.close();
-	});	
+	});
 	visibleRequest++;
 }
 
 function showBalloonFrame(html){
 	if(isFirstResult()){
 		//calculate Position
-		
+
 		x=point.x+parseInt(document.getElementById(tooltipTarget).style.left, 10);
 		y=point.y+parseInt(document.getElementById(tooltipTarget).style.top, 10);
-		
+
 		//hide old Popup
 		if(tooltipWin&&tooltipWin.isVisible())
 			tooltipWin.destroy();
-	
+
 		//create Popup and append document
 		tooltipWin = new mb_popup({html:'<iframe id="tooltipWin" name="tooltipWin" src="about:blank"/>',title:tooltipMsg.title,width:tooltip_width,height:tooltip_height,balloon:true,left:x,top:y});
 		//open document
 		tooltipWin.open();
 	}
 	tooltipWin.write(html);
-	
+
 	if(isLastResult()){
 		tooltipWin.close();
 	}
-		
+
 	//finally display popup
 	tooltipWin.show();
 	visibleRequest++;
@@ -261,7 +273,7 @@
 	var ind = getMapObjIndexByName(target);
 	var db_wfs_conf_id = [];
 	var js_wfs_conf_id = [];
-	
+
 	//search configurations that are selected (and in scale)
 	for (var i=0; i < mb_mapObj[ind].wms.length; i++){
 		for(var ii=0; ii < mb_mapObj[ind].wms[i].objLayer.length; ii++){
@@ -283,7 +295,7 @@
 
 	//build requests
 	var requests = [];
-	
+
 	for(var i=0;i < js_wfs_conf_id.length; i++){
 		//build url
 		var url = wfs_config[js_wfs_conf_id[i]]['wfs_getfeature'];
@@ -291,7 +303,7 @@
 		url += "service=wfs&request=getFeature&version=1.0.0";
 		url += "&typename="+ wfs_config[js_wfs_conf_id[i]]['featuretype_name'];
 		url += "&filter=";
-	
+
 		//search for geometry column
 		var geometryCol;
 		for(var j=0; j < wfs_config[js_wfs_conf_id[i]]['element'].length; j++){
@@ -299,14 +311,14 @@
 				geometryCol = wfs_config[js_wfs_conf_id[i]]['element'][j]['element_name'];
 			}
 		}
-		
+
 		//get filter
 		var filter = new WfsFilter();
 		filter.addSpatial(geom, geometryCol, filteroption, wfs_config[js_wfs_conf_id[i]]['featuretype_srs'], target);
 
 		requests.push({'url':url,'filter':filter.toString(), 'typename':wfs_config[js_wfs_conf_id[i]]['featuretype_name'],'js_wfs_conf_id':js_wfs_conf_id[i], 'db_wfs_conf_id':db_wfs_conf_id[i]});
 	}
-	
+
 	return requests;
 }
 
@@ -323,9 +335,9 @@
 			html += "\t\t\t onmouseover='parent.setResult(\"over\","+i+");' ";
 			html += " onmouseout='parent.setResult(\"out\","+i+")' ";
 			html += " onclick='parent.setResult(\"click\","+i+");' ";
-			var geomName = getWfsListEntry(_geomArray.get(i)); 
+			var geomName = getWfsListEntry(_geomArray.get(i));
 			html += ">" + geomName +"</td>";
-			html += "\t\t</tr>\n"; 
+			html += "\t\t</tr>\n";
 		}
 	}
 
@@ -339,18 +351,18 @@
 	wfsConf = get_complete_wfs_conf();
 	var html = '<html><head><style type="text/css">';
 	html += tooltip_styles_detail;
-	html += "</style></head><body><table>\n";	
-		
+	html += "</style></head><body><table>\n";
+
 	var wfsConfIndex = _geomArray.get(geometryIndex).wfs_conf;
 	var currentWfsConf = wfsConf[wfsConfIndex];
 	for (var i = 0 ; i <currentWfsConf.element.length; i ++) {
 	    if(currentWfsConf.element[i].f_show_detail==1){
 	    	if( _geomArray.get(geometryIndex).e.getElementValueByName(currentWfsConf.element[i].element_name)!=false){
-				html +="<tr class='list_"+(cnt%2?"uneven":"even")+"'><td>\n"; 
+				html +="<tr class='list_"+(cnt%2?"uneven":"even")+"'><td>\n";
 				html += currentWfsConf.element[i].f_label;
-				html +="</td>\n"; 
+				html +="</td>\n";
 				html += "<td>\n";
-				var elementVal = _geomArray.get(geometryIndex).e.getElementValueByName(currentWfsConf.element[i].element_name); 
+				var elementVal = _geomArray.get(geometryIndex).e.getElementValueByName(currentWfsConf.element[i].element_name);
 				if(currentWfsConf.element[i].f_form_element_html.indexOf("href")!=-1){
 					var setUrl = currentWfsConf.element[i].f_form_element_html.replace(/href\s*=\s*['|"]\s*['|"]/, "href='"+elementVal+"' target='_blank'");
 					if(setUrl.match(/><\/a>/)){
@@ -369,7 +381,7 @@
 			}
 		}
 	}
-	
+
 	html += "</table></body>\n";
 	return html;
 }
@@ -388,7 +400,7 @@
 				}
 				else {
 					resultArray[pos] = geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']);
-				} 
+				}
 			}
 		}
 		var resultName = resultArray.join(" ");
@@ -410,7 +422,7 @@
 	var currentGeom = resultGeomArray.get(index);
 	var resultHighlight = new parent.Highlight(targetArray, "tooltipHighlight", {"position":"absolute", "top":"0px", "left":"0px", "z-index":100}, 2);
 	var cw_fillcolor = "#cc33cc";
-	
+
 	if (event == "over") {
 		resultHighlight.add(currentGeom, cw_fillcolor);
 		resultHighlight.paint();



More information about the Mapbender_commits mailing list