[Mapbender-commits] r5874 - trunk/mapbender/http/plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Apr 8 02:54:24 EDT 2010


Author: christoph
Date: 2010-04-08 02:54:23 -0400 (Thu, 08 Apr 2010)
New Revision: 5874

Modified:
   trunk/mapbender/http/plugins/mb_background.js
Log:


Modified: trunk/mapbender/http/plugins/mb_background.js
===================================================================
--- trunk/mapbender/http/plugins/mb_background.js	2010-04-07 15:33:34 UTC (rev 5873)
+++ trunk/mapbender/http/plugins/mb_background.js	2010-04-08 06:54:23 UTC (rev 5874)
@@ -1,42 +1,97 @@
+/**
+ * Package: mb_background
+ *
+ * Description:
+ * A GoogleMaps like button set to select the current background map.
+ * 
+ * Files:
+ *  - http/plugins/mb_background.js
+ *
+ * SQL:
+ * > INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, 
+ * > e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, 
+ * > e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, 
+ * > e_mb_mod, e_target, e_requires, e_url) VALUES ('<appId>',
+ * > 'mb_background',1,1,'Set background WMS','Set background WMS','div','',
+ * > '',NULL ,NULL ,NULL ,NULL ,NULL ,'','','div',
+ * > '../plugins/mb_background.js','','mapframe1','','');
+ * > 
+ * > INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, 
+ * > context, var_type) VALUES('test_background', 'body', 
+ * > 'setBackgroundWmsCss', '.label-background-wms {
+ * > border: 1px solid black;
+ * > padding: 2px 10px 2px 10px;
+ * > background-color: #fff;
+ * > cursor: pointer;
+ * > white-space: nowrap;
+ * > }
+ * > .label-background-wms-active {
+ * > font-weight: bold;
+ * > padding: 1px 9px 1px 9px;
+ * > border: 2px solid black;
+ * > }
+ * > .container-background-wms {
+ * > position: relative;
+ * > z-index: 300;
+ * > margin: 7px;
+ * > text-align:right;
+ * > }', '' ,'text/css');
+ *
+ * Help:
+ * http://www.mapbender.org/<wiki site name>
+ *
+ * Maintainer:
+ * http://www.mapbender.org/User:Christoph_Baudson
+ * 
+ * License:
+ * Copyright (c) 2009, Open Source Geospatial Foundation
+ * This program is dual licensed under the GNU General Public License 
+ * and Simplified BSD license.  
+ * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
+ */
+
 var $background = $(this);
 
 var BackgroundApi = function (o) {
-	var isVisibleBackgroundWms = function (wms) {
-		if (wms.gui_wms_visible === 2) {
-			return true;
-		}
-		return false;
-	};
-	
-	var isHiddenBackgroundWms = function (wms) {
-		if (wms.gui_wms_visible === 0) {
-			return true;
-		}
-		return false;
-	};
+
 	Mapbender.events.init.register(function () {
 		o.$target.each(function () {
 			var $map = $(this);
-			var $bgRadio = $("<div />").attr({
-				"id": this.id + "_" + o.id
-			}).addClass("container-background-wms");
 			var map = $map.mapbender();
+
+			var $bgRadio = $("<div />")
+				.addClass("container-background-wms");
+
+			var firstBackgroundWmsIsActivated = false;
+
 			$(map.wms).each(function () {
 				var wms = this;
-				var isVisible = isVisibleBackgroundWms(wms);
-				var isHidden = isHiddenBackgroundWms(wms);
+				if (!firstBackgroundWmsIsActivated) {
+					wms.gui_wms_visible = 2;
+					firstBackgroundWmsIsActivated = true;
+				}
+				var isVisible = (wms.gui_wms_visible === 2) ? true : false;
+				var isHidden = (wms.gui_wms_visible === 0) ? true : false;
 				if (!isHidden && !isVisible) {
 					return;
 				}
-				var html = "<span class='label-background-wms" + (isVisible ? " label-background-wms-active" : "") + "'>" + wms.wms_title + "</span>";
-				var $bgWms = $(html).data("wms", wms).click(function () {
-						// set as background WMS
+				$("<span />")
+					.addClass("label-background-wms")
+					.addClass(isVisible ? " label-background-wms-active" : "")
+					.text(wms.wms_title)
+					.data("wms", wms)
+					.mousedown(function (e) {
 						wms.gui_wms_visible = 2;
-						$(this).addClass("label-background-wms-active").siblings().removeClass("label-background-wms-active").each(function () {
-							var wms = $(this).data("wms");
-							wms.gui_wms_visible = 0;
-						});
+						$(this)
+							.addClass("label-background-wms-active")
+							.siblings()
+								.removeClass("label-background-wms-active")
+								.each(function () {
+									var wms = $(this).data("wms");
+									wms.gui_wms_visible = 0;
+								});
 						map.zoom(true, 0.999);
+						return false;
 					}).appendTo($bgRadio);
 			});
 			$bgRadio.appendTo($map);



More information about the Mapbender_commits mailing list