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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Dec 16 05:42:30 EST 2009


Author: kmq
Date: 2009-12-16 05:42:29 -0500 (Wed, 16 Dec 2009)
New Revision: 5197

Modified:
   trunk/mapbender/http/javascripts/mod_ResultList.js
   trunk/mapbender/lib/resultGeometryListController.js
Log:
selecting, shopwing popups for all datatable entries - final(hopefully)

Modified: trunk/mapbender/http/javascripts/mod_ResultList.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_ResultList.js	2009-12-16 09:35:34 UTC (rev 5196)
+++ trunk/mapbender/http/javascripts/mod_ResultList.js	2009-12-16 10:42:29 UTC (rev 5197)
@@ -36,8 +36,21 @@
 	this.addGlobalButton = function(buttondef){
 		//buttondef format:
 		//{"title":<if no image is given then this is displayed>, callback: <function( ))
+		//type: <type> // either "select" or "button", defaults to "button"
+		//  if type is "select", add options like this:
+		// selectoptions : [{label :<label>,value : <value>},...   ]
 		//
 		// this is the domelement
+			
+		var bd = buttondef|| {};
+		bd.title = bd.title || "no title";
+		bd.type = bd.type || "button";
+		bd.selectoptions = bd.selectoptions || []
+		bd.callback = bd.callback || function(){};
+
+		return;
+		
+
 		var result = function(){
 			var  args =  { 
 				WFSConf: me.WFSConf,
@@ -47,12 +60,26 @@
 			};
 			buttondef.callback.call(this,args);
 		};
-		var button = $("<span><button type='button' class='ui-state-default ui-corner-all'>"+buttondef.title+"</button></span>").click(result);
+		
 		if($('#'+options.id+"buttonrow").length < 1){
 			$('#'+options.id).append('<div id="'+options.id +'buttonrow"></div>');
 			$('#'+options.id+'buttonrow').css("clear","both");
 		}
-		$('#'+options.id +'buttonrow').append(button);
+	
+		if (bd.type == "button")
+		{
+			var button = $("<span><button type='button' class='ui-state-default ui-corner-all'>"+buttondef.title+"</button></span>").click(result);
+			$('#'+options.id +'buttonrow').append(button);
+		}else if (bd.type == "select"){
+			var options = "";
+			for (c in bd.selectoptions){	
+				options += '<option value="'+ bd.selectoptions[c].value +'">'+bd.selectoptions[c].label +'</options>';
+			}	
+			var selectbox = '<select>'+ options  +'</select>';
+			$('#'+options.id +'buttonrow').append(selectbox);
+		}else{
+			alert("invalid buttondefintion");
+		}
 	};
 
 	
@@ -109,73 +136,124 @@
 			$('#'+options.id).css("display","block");
 		}
 
-		$("tr td span.wfsFproperty",me.table).click(function(){
-			// go up to the row, which has the "modelindex" set
-			var i = $(this.parentNode.parentNode).data("modelindex");
-			var feature = me.model.getFeature(i);
 
-			var infoPopupHtml = "<table>";
-			for (index in me.detailColumns) {
-				infoPopupHtml += "<tr>";
-				infoPopupHtml += "<td>" + me.detailColumns[index].label + "</td>";
-				infoPopupHtml += "<td>" + me.model.getFeatureProperty(i, me.detailColumns[index].name)+ "</td>";
-				infoPopupHtml += "</tr>";
-			}
-			infoPopupHtml += "</table>";
-			
-			var infoPopup = $("<div> </div>");
-			infoPopup.append(infoPopupHtml);
-			
-			buttonList = $("<ul></ul>").css("list-style-type","none");
-			for (c in popupButtons){
-				var callback = function() {
-					var  args =  { 
-						WFSConf: me.WFSConf,
-						geoJSON: feature,
-						selectedRows: me.getSelected()
+		var resultHighlight = new Highlight(
+			options.target, 
+			"resultListHighlight", 
+			{"position":"absolute", "top":"0px", "left":"0px", "z-index":options.resultHighlightZIndex}, 
+			options.resultHighlightLineWidth
+		);
+		var rowNodes = me.datatable.fnGetNodes();
+		for (rowNodeIndex in rowNodes){
+			(function() {
+			var row = rowNodes[rowNodeIndex];
+			$(".wfsFproperty", row).click(function(){
+				// go up to the row, which has the "modelindex" set
+				var modelIndex = $(row).data("modelindex");
+				var feature = me.model.getFeature(i);
+
+				var infoPopupHtml = "<table>";
+				for (var columnIndex in me.detailColumns) {
+					infoPopupHtml += "<tr>";
+					infoPopupHtml += "<td>" + me.detailColumns[columnIndex].label + "</td>";
+					infoPopupHtml += "<td>" + me.model.getFeatureProperty(modelIndex, me.detailColumns[columnIndex].name)+ "</td>";
+					infoPopupHtml += "</tr>";
+				}
+				infoPopupHtml += "</table>";
+				
+				var infoPopup = $("<div> </div>");
+				infoPopup.append(infoPopupHtml);
+				
+				buttonList = $("<ul></ul>").css("list-style-type","none");
+				for (var c in popupButtons){
+					var callback = function() {
+						var  args =  { 
+							WFSConf: me.WFSConf,
+							geoJSON: feature,
+							selectedRows: me.getSelected()
+						};
+						popupButtons[c].callback.call(this,args);
 					};
-					popupButtons[c].callback.call(this,args);
-				};
-				var button = $("<li><button type='button' class='ui-state-default ui-corner-all'>"+popupButtons[c].title+"</button></li>").click(callback);
-				button.css("display","inline");
-				buttonList.append(button);
-			}
-			infoPopup.append(buttonList);
-			infoPopup.dialog({
-				title : "Details", 
-				autoOpen : false, 
-				draggable : true,
-				width : options.infoPopupWidth,
-				height : options.infoPopupHeight
+					var button = $("<li><button type='button' class='ui-state-default ui-corner-all'>"+popupButtons[c].title+"</button></li>").click(callback);
+					button.css("display","inline");
+					buttonList.append(button);
+				}
+				infoPopup.append(buttonList);
+				infoPopup.dialog({
+					title : "Details", 
+					autoOpen : false, 
+					draggable : true,
+					width : options.infoPopupWidth,
+					height : options.infoPopupHeight
+				});
+				infoPopup.dialog("open");
+				
+				if (options.maxHighlightedPoints > 0 && feature.getTotalPointCount() > options.maxHighlightedPoints) {
+					feature = feature.getBBox4();
+				}
+				
+				resultHighlight.del(feature, options.resultHighlightColor);
+				var bbox = feature.getBBox();
+				var bufferFloat = parseFloat(me.WFSConf.g_buffer);
+				var buffer = new Point(bufferFloat,bufferFloat);
+				bbox[0] = bbox[0].minus(buffer);
+				bbox[1] = bbox[1].plus(buffer);
+				//mb_calculateExtent(targetArray[0], bbox[0].x, bbox[0].y, bbox[1].x, bbox[1].y);
+				//zoom(targetArray[0], 'true', 1.0);
+				var map = Mapbender.modules[options.target[0]];
+				map.calculateExtent(
+					new Mapbender.Extent(bbox[0], bbox[1])
+				);
+				map.setMapRequest();
+				
+				resultHighlight.add(feature, options.resultHighlightColor);
+				resultHighlight.paint();
+				
+			})		
+
+
+			$(row).mouseover(function () {
+				var i = $(this).data("modelindex");
+				var feature = me.model.getFeature(i);
+				
+				if (options.maxHighlightedPoints > 0 && feature.getTotalPointCount() > options.maxHighlightedPoints) {
+					feature = feature.getBBox4();
+				}
+				
+				resultHighlight.add(feature, options.resultHighlightColor);
+				resultHighlight.paint();
+			}).mouseout(function () {
+				var i = $(this).data("modelindex");
+				var feature = me.model.getFeature(i);
+				
+				if (options.maxHighlightedPoints > 0 && feature.getTotalPointCount() > options.maxHighlightedPoints) {
+					feature = feature.getBBox4();
+				}
+				
+				resultHighlight.del(feature, options.resultHighlightColor);
+				resultHighlight.paint();
 			});
-			infoPopup.dialog("open");
-			
-			if (options.maxHighlightedPoints > 0 && feature.getTotalPointCount() > options.maxHighlightedPoints) {
-				feature = feature.getBBox4();
-			}
-			
-			resultHighlight.del(feature, options.resultHighlightColor);
-			var bbox = feature.getBBox();
-			var bufferFloat = parseFloat(me.WFSConf.g_buffer);
-			var buffer = new Point(bufferFloat,bufferFloat);
-			bbox[0] = bbox[0].minus(buffer);
-			bbox[1] = bbox[1].plus(buffer);
-			//mb_calculateExtent(targetArray[0], bbox[0].x, bbox[0].y, bbox[1].x, bbox[1].y);
-			//zoom(targetArray[0], 'true', 1.0);
-			var map = Mapbender.modules[options.target[0]];
-			map.calculateExtent(
-				new Mapbender.Extent(bbox[0], bbox[1])
-			);
-			map.setMapRequest();
-			
-			resultHighlight.add(feature, options.resultHighlightColor);
-			resultHighlight.paint();
-			
-		})		
-		// set style of cursor to pointer for the result table
-		$("tr td span.wfsFproperty",me.table).css("cursor","pointer");
+		
+			// make rows selectable
+			$(row).click((function(){
+				if($(this).hasClass('row_selected')){
+					$(this).removeClass('row_selected');
+				}
+				else{
+					$(this).addClass('row_selected');
+				}
+				return true;
+			}));
 
+			// set style of cursor to pointer for the result table
+			$(".wfsFproperty", row).css("cursor","pointer");
 
+
+			})();
+
+		}
+
+
 	};
 
 	this.hide = function(){

Modified: trunk/mapbender/lib/resultGeometryListController.js
===================================================================
--- trunk/mapbender/lib/resultGeometryListController.js	2009-12-16 09:35:34 UTC (rev 5196)
+++ trunk/mapbender/lib/resultGeometryListController.js	2009-12-16 10:42:29 UTC (rev 5197)
@@ -23,8 +23,6 @@
 	// array of buttondef objects
 	this.buttoncolumns = []
 
-	var me = this;
-
 	this.options = options;
 
 
@@ -79,50 +77,11 @@
 
 			// fnAddData returns an array of indices
 			var index = me.datatable.fnAddData(rowData);
-
+			
 			// this is ok because we only added a single row
 			var rowNode = me.datatable.fnGetNodes(index[0]);
 			$(rowNode).data("modelindex",modelIndex);
 
-			var resultHighlight = new Highlight(
-				me.options.target, 
-				"resultListHighlight", 
-				{"position":"absolute", "top":"0px", "left":"0px", "z-index":me.options.resultHighlightZIndex}, 
-				me.options.resultHighlightLineWidth
-			);
-			$(rowNode).mouseover(function () {
-			var i = $(this).data("modelindex");
-			var feature = me.model.getFeature(i);
-			
-			if (me.options.maxHighlightedPoints > 0 && feature.getTotalPointCount() > me.options.maxHighlightedPoints) {
-				feature = feature.getBBox4();
-			}
-			
-			resultHighlight.add(feature, me.options.resultHighlightColor);
-			resultHighlight.paint();
-		}).mouseout(function () {
-			var i = $(this).data("modelindex");
-			var feature = me.model.getFeature(i);
-			
-			if (me.options.maxHighlightedPoints > 0 && feature.getTotalPointCount() > me.options.maxHighlightedPoints) {
-				feature = feature.getBBox4();
-			}
-			
-			resultHighlight.del(feature, me.options.resultHighlightColor);
-			resultHighlight.paint();
-		});
-		
-			// make rows selectable
-			$(rowNode).click((function(){
-				if($(this).hasClass('row_selected')){
-					$(this).removeClass('row_selected');
-				}
-				else{
-					$(this).addClass('row_selected');
-				}
-				return true;
-			}));
-
 		}
 	};
 	



More information about the Mapbender_commits mailing list