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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Feb 24 08:09:26 EST 2010


Author: kmq
Date: 2010-02-24 08:09:25 -0500 (Wed, 24 Feb 2010)
New Revision: 5629

Modified:
   trunk/mapbender/http/javascripts/mod_ResultList.js
Log:
cleaning up that code a little

Modified: trunk/mapbender/http/javascripts/mod_ResultList.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_ResultList.js	2010-02-24 11:51:04 UTC (rev 5628)
+++ trunk/mapbender/http/javascripts/mod_ResultList.js	2010-02-24 13:09:25 UTC (rev 5629)
@@ -54,27 +54,13 @@
 	me.options = options;
 	me.rowclick = new Mapbender.Event();
 
-	this.addRowcallback = function(callback){
-		//disaabled
-		// the signature of the callback function (columns)
-		// where columns is an object containiing pairs of column:value
-		//row_callback = callback;
-		
-	};
-
-	this.row_click_callback = function(){
-		// Fixme get from row
-		// If we were dynamic, this is what we would do
-		//row_callback.call(null,{"firstname":"gonzales"});	
-		//but for now we just open a popup with infos abotut the table
-		// we have:
-		// DOMTableRow
-		// DOMTableRow.data("modelindex")
-		// model.getFeatureProperty(modelIndex) - but we need all of them :-(
-		//alert($(this).data("modelindex"));
-	};
-
-
+	/*
+	 * Method: addGlobalButton
+	 * Descriptions: adds a Button to the bottom of the resultList
+	 * Parameters:
+	 * buttondef: {Object} an object with five properties, "title", "type" (either button or select)  "classes" (the classes the button should have), "selectoptions" (an array in case the type is select), "callback"
+	 *
+  	*/
 	this.addGlobalButton =  function(buttondef){
 			//buttondef format:
 			//{"title":<if no image is given then this is displayed>, callback: <function( ))
@@ -88,7 +74,7 @@
 			bd.title = bd.title || "no title";
 			bd.type = bd.type || "button";
 			bd.classes = bd.classes || "";
-			bd.selectoptions = bd.selectoptions || []
+			bd.selectoptions = bd.selectoptions || [];
 			bd.callback = bd.callback || function(){};
 
 			var result = function(){
@@ -121,25 +107,14 @@
 				alert("invalid buttondefintion");
 			}
 		};
-	
 
-	this.addRowButton = function(buttondef){
-	// buttondef format:
-	//  title:
-	//  src:
-	//  callback = function(feature) {}
-	//  index: ( 0=> in front, 1, after first, -1 end, -2 second to last...
-	//  modify buttoncolumns
-	// and reinitialize
-		me.buttoncolumns.push(buttondef);
-//		me.reinitialize();
-
-	};
-	
+	/*
+	 * Method: addPopupButton
+	 * Description: adds a Button to the Popupmenu that is displayed when the user clicks an entry in the result list
+	 * Parameters:
+	 * buttondef: {Object} an object with two properties: "title" and  "callback", a function that gets the  feature that corresponds to the popup as it's argument
+  */
 	this.addPopupButton = function(buttondef){
-	// buttondef format:
-	//  title:
-	//  callback = function(feature) {}
 		popupButtons.push(buttondef);
 	};
 	
@@ -152,7 +127,7 @@
 	*/
 	this.setTitle = function(title){
 		$('#'+options.id).data("title.dialog",title);
-	}
+	};
 
 	/*
 	 * Method: getSelected
@@ -170,7 +145,7 @@
 			}
 		}
 		return selected;
-	}
+	};
 	
 	this.show = function(){
 	
@@ -178,68 +153,62 @@
 			options.target, 
 			"resultListHighlight", 
 			{"position":"absolute", "top":"0px", "left":"0px", "z-index":options.resultHighlightZIndex}, 
-			options.resultHighlightLineWidth
-		);
+			options.resultHighlightLineWidth);
 		if(display_popup){
 			$('#'+options.id).dialog("open");
 		}else{
 			$('#'+options.id).css("display","block");
 		}
 	
-
-
 		me.resultHighlight = new Highlight(
 			options.target, 
 			"resultListHighlight", 
 			{"position":"absolute", "top":"0px", "left":"0px", "z-index":options.resultHighlightZIndex}, 
-			options.resultHighlightLineWidth
-		);
+			options.resultHighlightLineWidth);
 		var rowNodes = me.datatable.fnGetNodes();
 		for (rowNodeIndex in rowNodes){
 			(function() {
-			var row = rowNodes[rowNodeIndex];
-			$(".wfsFproperty", row).click(function(){
-				me.rowclick.trigger((function(){return row;})());
-			})		
+				var row = rowNodes[rowNodeIndex];
+				$(".wfsFproperty", row).click(function(){
+					me.rowclick.trigger((function(){return row;})());
+				});		
 
 
-			$(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();
-				}
-				
-				me.resultHighlight.add(feature, options.resultHighlightColor);
-				me.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();
-				}
-				
-				me.resultHighlight.del(feature, options.resultHighlightColor);
-				me.resultHighlight.paint();
-			});
-		
-			// make rows selectable only when there are Global Buttons that could actually do womething with that selection
-			if($('#'+options.id+"buttonrow").length >  0){
-				$(row).click((function(){
-					if($(this).hasClass('row_selected')){
-						$(this).removeClass('row_selected');
+				$(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();
 					}
-					else{
-						$(this).addClass('row_selected');
+					
+					me.resultHighlight.add(feature, options.resultHighlightColor);
+					me.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();
 					}
-					return true;
-				}));
-			}
-
-			// set style of cursor to pointer for the result table
-			if(me.rowclick.getProperties().count > 0) {$(".wfsFproperty", row).css("cursor","pointer")};
+					
+					me.resultHighlight.del(feature, options.resultHighlightColor);
+					me.resultHighlight.paint();
+				});
+				// make rows selectable only when there are Global Buttons that could actually do womething with that selection
+				if($('#'+options.id+"buttonrow").length >  0){
+					$(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
+				if(me.rowclick.getProperties().count > 0) {$(".wfsFproperty", row).css("cursor","pointer");} 
 			})();
 
 		}
@@ -266,8 +235,6 @@
 };
 
 
-//var table = $('<table class="display" id="'+ options.id +'_table"><thead><tr></tr></thead><tbody></tbody></table>');
-//$('#'+options.id).append(table);
 ResultGeometryList.prototype = new ResultGeometryListController(options);
 ResultGeometryList.prototype.constructor = ResultGeometryList;
 



More information about the Mapbender_commits mailing list