[Mapbender-commits] r4253 - trunk/mapbender/lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Jun 26 10:12:08 EDT 2009


Author: christoph
Date: 2009-06-26 10:12:08 -0400 (Fri, 26 Jun 2009)
New Revision: 4253

Modified:
   trunk/mapbender/lib/button.js
Log:
new button class

Mapbender.Button

Modified: trunk/mapbender/lib/button.js
===================================================================
--- trunk/mapbender/lib/button.js	2009-06-26 14:09:50 UTC (rev 4252)
+++ trunk/mapbender/lib/button.js	2009-06-26 14:12:08 UTC (rev 4253)
@@ -3,42 +3,63 @@
  *   button handling
  ***************************************************************************************
  */
+
+Mapbender.Button = function (options) {
+	mb_regButton(options);
+};
  
 var mb_button = [];
 
 function mb_regButton_frame(wii, frameName, param){
-
 	var ind = mb_button.length;
 	mb_button[ind] = new mb_conButton(wii, ind);
-	if (frameName === null) {
-		if (param === null) {
-			if (typeof(wii) == "string") {
-				eval(wii+"("+ind+")");
-			}
-			else {
-				wii(ind);
-			}
+
+	if (typeof wii === "object") {
+		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_off = options.off ? options.off : "";
+		mb_button[ind].status = options.status ? options.status : 0;
+		mb_button[ind].elName = options.name ? options.name : "";
+		mb_button[ind].fName = options.frameName ? options.frameName : "";
+		if (options.go && typeof options.go === "function") {
+			mb_button[ind].go = options.go;
 		}
 		else {
-			if (typeof(wii) == "string") {
-				eval(wii + "(" + ind + ", " + param + ")");
-			}
-			else {
-				wii(ind, param);
-			}
+			mb_button[ind].go = function () {
+			};
 		}
+		if (options.stop && typeof options.stop === "function") {
+			mb_button[ind].stop = options.stop;
+		}
+		else {
+			mb_button[ind].stop = function () {
+			};
+		}
 	}
-	else if (param === null) {
-		eval("window.frames['" + frameName + "']."+wii+"("+ind+")");
+	else if (typeof wii === "string") {
+		var str = "";
+		if (frameName !== null) {
+			str += "window.frames.['" + frameName + "'].";
+		}
+		str += wii + "(" + ind;
+		if (param !== null) {
+			str += "," + param;
+		}
+		str += ");";
+		console.log(str);
+		eval(str);
 	}
-	else {
-		if (typeof(wii) == "string") {
-			eval("window.frames['" + frameName + "']."+ wii + "(" + ind + ", " + param + ")");
+	else if (typeof wii == "function") {
+		if (param === null) {
+			wii(ind);
 		}
 		else {
 			wii(ind, param);
 		}
 	}
+
 	mb_button[ind].prev = mb_button[ind].src;
 	mb_button[ind].src = mb_button[ind].img_off;
 	mb_button[ind].onmouseover = function () {
@@ -63,7 +84,6 @@
 }
 
 function mb_conButton(wii, ind){
-   this.wii = wii;
    return true;
 }
 function mb_button_over(ind){
@@ -156,8 +176,11 @@
 }
 
 function mb_localizeButtons(){
-	var req = new Mapbender.Ajax.Request();
-	req.send("../php/mod_button_tooltips.php", updateButtonTooltips);
+	var req = new Mapbender.Ajax.Request({
+		url: "../php/mod_button_tooltips.php",
+		callback: updateButtonTooltips
+	});
+	req.send();
 };
 
 eventLocalize.register(function () {



More information about the Mapbender_commits mailing list