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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Nov 5 07:55:47 EST 2009


Author: christoph
Date: 2009-11-05 07:55:46 -0500 (Thu, 05 Nov 2009)
New Revision: 4931

Modified:
   trunk/mapbender/http/javascripts/mod_loadwmc.js
   trunk/mapbender/http/javascripts/mod_loadwmc.php
Log:


Modified: trunk/mapbender/http/javascripts/mod_loadwmc.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_loadwmc.js	2009-11-05 12:53:35 UTC (rev 4930)
+++ trunk/mapbender/http/javascripts/mod_loadwmc.js	2009-11-05 12:55:46 UTC (rev 4931)
@@ -1,14 +1,3 @@
-// checks if element var loadFromSession exists
-if (typeof options.loadFromSession === undefined) {
-	var loadFromSession = 0;
-}
-
-if (loadFromSession) {
-	// function load_wmc_session() is generated by mod_loadwmc.php
-	Mapbender.events.init.register(function () {
-		load_wmc_session();
-	});
-}
 var wmcPopup = null;
 var wmcDisplayPopup = null;
 var wmcOpenlayersPopup = null;
@@ -21,7 +10,9 @@
 }
 
 $(this).click(function () {
-	mod_loadwmc();
+	if (wmcPopup === null || !wmcPopup.isVisible()) {
+		mod_loadwmc();
+	}
 }).mouseover(function () {
 	if (options.src) {
 		this.src = options.src.replace(/_off/, "_over");
@@ -79,15 +70,7 @@
 		wmcPopup.setHtml(initialHtml);
 		wmcPopup.show();
 	}
-/*
-	$(initialHtml).appendTo("body");
-	Mapbender.modules.ui_widget.create({
-		target: options.id + "_wmclist",
-		title: "load WMC from list"
-	});
-*/
 
-
 	// get WMC data from server
 	var req = new Mapbender.Ajax.Request({
 		url: serverSideFileName,
@@ -113,6 +96,7 @@
 	for (var i=0; i < wmcObj.wmc.length; i++) {
 		(function () {
 			var currentId = wmcObj.wmc[i].id;
+			var currentName = wmcObj.wmc[i].title;
 			var $tr = $("<tr></tr>").appendTo($("#" + options.id + "_wmclist_table"));
 			var $td;
 			$tr.append($("<td>" + wmcObj.wmc[i].title + "</td>"));
@@ -173,16 +157,15 @@
 					// create Popup
 					if (wmcDisplayPopup === null) {
 						wmcDisplayPopup = new mb_popup({
-							title:"WMC Document",
+							title:currentName + " - WMC Document",
 							width:600,
 							height:500,
-							top:100,
-							left:300,
+							top:50,
+							left:700,
 							url:"../javascripts/mod_displayWmc.php?wmc_id=" + currentId
 						});
 					}
-					// set correct URL
-					if (wmcDisplayPopup.isVisible()) {
+					else {
 						wmcDisplayPopup.setUrl("../javascripts/mod_displayWmc.php?wmc_id=" + currentId + "&" + mb_session_name + "=" + mb_nr);
 					}
 					// display the pop up
@@ -199,17 +182,17 @@
 					// create Popup
 					if (wmcOpenlayersPopup === null) {
 						wmcOpenlayersPopup = new mb_popup({
-							title: "WMC Document",
+							title: currentName + " - OpenLayers",
 							width: 600,
 							height: 500,
-							top: 100,
-							left: 300,
+							top: 40,
+							left: 600,
 							url: "../php/mod_wmc2ol.php?wmc_id=" + currentId + 
 								"&" + mb_session_name + "=" + mb_nr
 						});
 					}
-					// set correct URL
-					if (wmcOpenlayersPopup.isVisible()) {
+					else {
+						// set correct URL
 						wmcOpenlayersPopup.setUrl("../php/mod_wmc2ol.php?wmc_id=" + currentId + "&" + mb_session_name + "=" + mb_nr);
 					}
 					// display the pop up
@@ -225,9 +208,11 @@
 					title: "delete this WMC",
 					method: "deleteWmc",
 					callback: function (args) {
-						executeJavaScript(args);
-						var aPos = wmcTable.fnGetPosition($deleteTd.get(0));
-						wmcTable.fnDeleteRow(aPos[0]);
+						if (confirm("Do you really want to delete WMC '" + currentName + "'?")) {
+							executeJavaScript(args);
+							var aPos = wmcTable.fnGetPosition($deleteTd.get(0));
+							wmcTable.fnDeleteRow(aPos[0]);
+						}
 					},
 					parameters:{
 						id:currentId
@@ -235,7 +220,7 @@
 				});
 				$tr.append($deleteTd);	
 			})();
-		}());
+		})();
 	}
 
 	$("#" + options.id + "_tabs").tabs();
@@ -245,10 +230,11 @@
 			prompt((success ? "Success." : "Failed!") + " " + message, filename);
 		}
 	});
-	wmcTable = $("#" + options.id + "_wmclist_table").jq_datatables({
+	wmcTable = $("#" + options.id + "_wmclist_table").dataTable({
 		"bPaginate": true,
 		"bJQueryUI": true
 	});
+	console.log(wmcTable);
 
 }
 
@@ -298,5 +284,4 @@
 		args.callback(args);
 	});
 	return $("<td></td>").append($img);
-	
 }

Modified: trunk/mapbender/http/javascripts/mod_loadwmc.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_loadwmc.php	2009-11-05 12:53:35 UTC (rev 4930)
+++ trunk/mapbender/http/javascripts/mod_loadwmc.php	2009-11-05 12:55:46 UTC (rev 4931)
@@ -20,7 +20,8 @@
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
 require_once(dirname(__FILE__)."/../classes/class_wmc.php");
 
-include(dirname(__FILE__) . "/../include/dyn_js.php");
+$loadFromSession = false;
+include(dirname(__FILE__) . "/../include/dyn_php.php");
 
 function createJs ($mergeWms) {
 	$jsString = "";
@@ -81,25 +82,24 @@
 // This function loads a WMC from the session, if the element var
 // "loadFromSession" is set to true.
 //
-?>
-function load_wmc_session() {
-<?php
-if (Mapbender::session()->get("command") && Mapbender::session()->get("command") == "ADDWMS") {
-	$e = new mb_notice("merging with WMS in Session...");
-	$output = createJs(true);
+$output = "";
+if ($loadFromSession) {
+	if (Mapbender::session()->get("command") && Mapbender::session()->get("command") == "ADDWMS") {
+		$e = new mb_notice("merging with WMS in Session...");
+		$output = createJs(true);
+	}
+	else {
+		$e = new mb_notice("NOT merging with WMS in Session...");
+		$output = createJs(false);
+	}
+	echo "\nvar loadFromSession = " . $loadFromSession . ";";
 }
-else {
-	$e = new mb_notice("NOT merging with WMS in Session...");
-	$output = createJs(false);
-}
 
 $output = administration::convertOutgoingString($output);
+echo "function load_wmc_session() {";
 echo $output;
+echo "}\n";
 
-?>
-}
-
-<?php 
 if ($e_src) {
 	sprintf("var mod_loadwmc_img = new Image(); 
 			mod_loadwmc_img.src = '%s'", $e_src);
@@ -111,3 +111,14 @@
 //
 include("mod_loadwmc.js");
 ?>
+
+// checks if element var loadFromSession exists
+if (typeof loadFromSession === undefined) {
+	var loadFromSession = 0;
+}
+
+if (loadFromSession) {
+	Mapbender.events.init.register(function () {
+		load_wmc_session();
+	});
+}
\ No newline at end of file



More information about the Mapbender_commits mailing list