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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu May 30 05:47:12 PDT 2013


Author: armin11
Date: 2013-05-30 05:47:12 -0700 (Thu, 30 May 2013)
New Revision: 8633

Modified:
   trunk/mapbender/http/javascripts/mod_loadwmc.js
Log:
Change loadwmc table - reduce number of rows - one row for api now!

Modified: trunk/mapbender/http/javascripts/mod_loadwmc.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_loadwmc.js	2013-05-29 13:33:15 UTC (rev 8632)
+++ trunk/mapbender/http/javascripts/mod_loadwmc.js	2013-05-30 12:47:12 UTC (rev 8633)
@@ -18,6 +18,7 @@
 options.showPublic = typeof options.showPublic === "number" ? options.showPublic : 0;
 options.mobileUrl = typeof options.mobileUrl === "number" ? options.mobileUrl : 0;
 options.mobileUrlNewWindow = typeof options.mobileUrlNewWindow === "number" ? options.mobileUrlNewWindow : 0;
+options.showApi = typeof options.showApi === "number" ? options.showApi : 1;
 
 Mapbender.events.init.register(function () {
 	if(Mapbender.modules[options.saveWmcTarget] && Mapbender.modules[options.saveWmcTarget].overwrite === 1 && options.editWmc == 1) {
@@ -54,6 +55,7 @@
 	"labelOpenLayers": "OpenLayers",
 	"labelOpenLayersUrl": "Link",
 	"labelMobileUrl": "Mobile client",
+	"labelApi": "APIs",
 	"labelCurrentState": "currentState",
 	"labelDeleteWmc": "delete this WMC",
 	"confirmDelete": "Do you really want to delete WMC",
@@ -92,6 +94,7 @@
 	var $wmcOpenLayersPopup = null;
 	var $wmcOpenLayersUrlPopup = null;
 	var $wmcMobilePopup = null;
+	var $wmcApiDialog = null;
 	var wmcPopupHtml = null;
 	var wmcListTableInitialized = false;
 
@@ -131,6 +134,11 @@
 		title: translatedI18nObject.labelOpenLayersUrl
 	};
 
+	var API_WMC_OPTIONS = {
+		src: "../img/osgeo_graphics/geosilk/link.png",
+		title: translatedI18nObject.labelApi
+	};
+	
 	var DELETE_WMC_OPTIONS = {
 		src: "../img/button_gray/del_disabled.png",
 		title: translatedI18nObject.labelDeleteWmc,
@@ -184,7 +192,10 @@
 				modal: false,
 				width: 750,
 				height: 500,
-				pos: [100,50]
+				pos: [100,50],
+				close: function (){
+					that.hideDependendWindows();
+				}
 			}).parent().css({position:"absolute"});
 		}
 		else {
@@ -199,12 +210,18 @@
 			$wmcPopup.dialog('destroy');
 			$wmcPopup.remove();
 		}
-		this.hideWmcXml();
-		this.hideOpenLayers();
+		that.hideDependenWindows();
 	};
+
+	this.hideDependendWindows = function () {
+		that.hideWmcXml();
+		that.hideOpenLayers();
+		that.hideApiList();
+		that.hideApiUrl();
+	};
 	
 	this.showWmcXml = function (id) {
-		this.hideWmcXml();
+		that.hideDependendWindows();
 		var url = "../javascripts/mod_displayWmc.php?wmc_id=" + id + "&" + mb_session_name + "=" + mb_nr;
 		var $wmcDisplayPopup = $('<div class="wmcDisplayPopup"><a href="'+ url + '&download=true' +'"><h3>Download</h3><img src="../img/gnome/document-save.png"/></a><br><br><iframe style="width:99%;height:99%;" src="' + url + '"></iframe></div>');
 		$wmcDisplayPopup.dialog({
@@ -223,9 +240,9 @@
 			$('.wmcDisplayPopup').dialog('destroy');
 		}
 	};
-	
+	//next function is obsolete
 	this.showOpenLayers = function (id) {
-		this.hideOpenLayers();
+		that.hideDependendWindows();
 		var url = "../php/mod_wmc2ol.php?wmc_id=" + id + "&" + mb_session_name + "=" + mb_nr;
 		var $wmcOpenLayersPopup = $('<div class="wmcOpenLayersPopup"><iframe style="width:99%;height:99%;" src="' + url + '" frameborder="0"></iframe></div>');
 		$wmcOpenLayersPopup.dialog({
@@ -244,15 +261,11 @@
 			$('.wmcOpenLayersPopup').dialog('destroy');
 		}
 	};
-	//following is added to give a window with an interated link which can be included in external applications
-	this.showOpenLayersUrl = function (id) {
-		this.hideOpenLayersUrl();
-		var url = Mapbender.loginUrl;
-		url = url.replace("frames/login.php", "");
-		url = Mapbender.baseUrl + "/mapbender/";
-		url = url + "php/mod_wmc2ol.php?wmc_id=" + id ;
-		var $wmcOpenLayersUrlPopup = $('<div><input size="35" type="text" value="' + url + '"/></div>');
-		$wmcOpenLayersUrlPopup.dialog({
+	//following is added to give a window with an integrated link which can be included in external applications
+	this.showApiUrl = function (url) {
+		this.hideApiUrl();
+		var $wmcApiUrlPopup = $('<div id="api_url"><input size="35" type="text" value="' + url + '"/></div>');
+		$wmcApiUrlPopup.dialog({
 			title: translatedI18nObject.labelOpenLayersUrl,
 			bgiframe: true,
 			autoOpen: true,
@@ -263,42 +276,25 @@
 		});
 	};
 	
-	this.hideOpenLayersUrl = function () {
-		if($('.wmcOpenLayersUrlPopup').size() > 0) {
-			$('.wmcOpenLayersUrlPopup').dialog('destroy');
+	this.hideApiUrl = function () {
+		if($('.wmcApiUrlPopup').size() > 0) {
+			$('.wmcApiUrlUrlPopup').dialog('destroy');
+			$('#api_url').remove();
 		}
 	};
 
-	this.showMobileUrl = function (id) {
-		this.hideMobileUrl();
-		var url = Mapbender.loginUrl;
-		url = url.replace("frames/login.php", "");
-		url = Mapbender.baseUrl + "/mapbender/";
-		url = url + "extensions/mobilemap/map.php?wmcid=" + id ;
-		//get qr code via ajax request - sync - not async!
-		var req = new Mapbender.Ajax.Request({
-			url: serverSideFileName,
-			method: "getQrCode",
-			parameters: {
-				"wmcid": id,
-				"newWindow": options.mobileUrlNewWindow
-			},
-			callback: function(obj, result, message){
-				if (!result) {
-					new Mapbender.Exception(obj.message);
-					return;
-				} else {
-					$("#mobile_url_popup").append(obj.qrCode);
-					$("#mobile_url_popup").dialog({height:200});
-				}
-			}
-		});
-		req.send();
-
-
-		var $wmcMobilePopup = $('<div id="mobile_url_popup"><input size="35" type="text" value="' + url + '"/></div>');
-		$wmcMobilePopup.dialog({
-			title: translatedI18nObject.labelMobileUrl,
+	this.showApiList = function (id) {
+		that.hideDependendWindows();
+		var mobileUrl = Mapbender.loginUrl;
+		mobileUrl = mobileUrl.replace("frames/login.php", "");
+		mobileUrl = Mapbender.baseUrl + "/mapbender/";
+		var olUrl = "";
+		olUrl = mobileUrl + "php/mod_wmc2ol.php?wmc_id=" + id ;
+		mobileUrl = mobileUrl + "extensions/mobilemap/map.php?wmcid=" + id ;
+		//initialize dialog
+		var $wmcApiDialog = $('<div id="api_dialog"></div>');
+		$wmcApiDialog.dialog({
+			title: translatedI18nObject.labelApi,
 			bgiframe: true,
 			autoOpen: true,
 			modal: false,
@@ -306,17 +302,69 @@
 			height: 90,
 			pos: [600,40]
 		});
+		//generate API options
+		$apiTable = $('<table>');
+		if (options.openLayers) {
+			//openlayers client
+			$trOl = $('<tr>');
+			$trOl.append('<td>OpenLayers:</td>');
+			$trOl.append('<td><a href="'+olUrl+'" target="_blank"><img src="../img/OpenLayers.trac.png"></a></td>');
+			if (options.openLayersUrl) {
+				//add ol link input field
+				var $olLinkImg = $('<img src="../img/osgeo_graphics/geosilk/link.png" title="' + "Link" + '">');
+				$olLinkImg.click(function() {
+					that.showApiUrl(olUrl);
+				});
+				$td2Ol = $('<td>');
+				$td2Ol.append($olLinkImg);
+				$trOl.append($td2Ol);
+			}
+			$apiTable.append($trOl);
+		}
+		if (options.mobileUrl) {
+			//mobile client 
+			//get qr code for mobile client via ajax request
+			var req = new Mapbender.Ajax.Request({
+				url: serverSideFileName,
+				method: "getQrCode",
+				parameters: {
+					"wmcid": id,
+					"newWindow": options.mobileUrlNewWindow
+				},
+				callback: function(obj, result, message){
+					if (!result) {
+						new Mapbender.Exception(obj.message);
+						return;
+					} else {
+						//extent dialog
+						$("#api_dialog").dialog({height:220});
+						$trMobile = $('<tr>');
+						$trMobile.append("<td>Mobile Client:</td>");
+						$trMobile.append("<td>" + obj.qrCode + "</td>");
+						var $mobileLinkImg = $('<img src="../img/osgeo_graphics/geosilk/link.png" title="' + "Link" + '">');
+						$mobileLinkImg.click(function() {
+							that.showApiUrl(mobileUrl);
+						});
+						$td2Mobile = $('<td>');
+						$td2Mobile.append($mobileLinkImg);
+						$trMobile.append($td2Mobile);
+						$apiTable.append($trMobile);
+					}
+				}
+			});
+			req.send();
+			}
+		$("#api_dialog").append($apiTable);
 	};
 	
-	this.hideMobileUrl = function () {
-		if($('.wmcMobilePopup').size() > 0) {
-			$('.wmcMobilePopup').dialog('destroy');
+	this.hideApiList = function () {
+		if($('.wmcApiDialog').size() > 0) {
+			$('.wmcApiDialog').dialog('destroy');
 		}
-		$('#mobile_url_popup').remove();
+		$('#api_dialog').remove();//link to url
+		this.hideApiUrl();
 	};
 
-
-
 	//end of the link-handle popup	
 	this.refreshList = function () {
 		//alert("Options showPublic: "+options.showPublic);
@@ -393,9 +441,7 @@
 				(options.appendWmc ? "<th>" + t.labelAppend + "</td>" : "") + 
 				(options.publishWmc ? "<th>" + t.labelPublic + "</td>" : "") + 
 				(options.showWmc ? "<th>" + t.labelShow + "</td>" : "") +
-				(options.openLayers ? "<th>" + t.labelOpenLayers + "</td>" : "") + 
-				(options.openLayersUrl ? "<th>" + t.labelOpenLayersUrl + "</td>" : "") + 
-				(options.mobileUrl ? "<th>" + t.labelMobileUrl + "</td>" : "") + 
+				(options.showApi ? "<th>" + t.labelApi + "</td>" : "") + 
 				(options.editWmc ? "<th>" + t.labelEditWmc + "</td>" : "") + 
 				(options.deleteWmc ? "<th>" + t.labelDelete + "</td>" : "") + 
 				"</tr></thead></table>";
@@ -601,6 +647,14 @@
 		);	
 	};
 
+	var createApiWmcCell = function (wmc) {
+		return createTableCell(
+			API_WMC_OPTIONS, function(){
+				that.showApiList(wmc.id);
+			}
+		);	
+	};
+
 	var createDisplayWmcCell = function (wmc) {
 		return createTableCell(
 			DISPLAY_WMC_OPTIONS,
@@ -708,15 +762,9 @@
 				if (options.showWmc) {
 					$tr.append(createDisplayWmcCell(currentWmc));
 				}
-				if (options.openLayers) {
-					$tr.append(createOpenLayersWmcCell(currentWmc));
+				if (options.showApi) {
+					$tr.append(createApiWmcCell(currentWmc));
 				}
-				if (options.openLayersUrl) {
-					$tr.append(createOpenLayersUrlWmcCell(currentWmc));
-				}
-				if (options.mobileUrl) {
-					$tr.append(createMobileUrlWmcCell(currentWmc));
-				}
 				if (options.editWmc) {
 					$tr.append(createEditWmcCell(currentWmc));
 				}



More information about the Mapbender_commits mailing list