[Mapbender-commits] r4899 - in branches/jqMapbender/mapstraction/http: javascripts plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Sun Nov 1 12:53:16 EST 2009


Author: christoph
Date: 2009-11-01 12:53:15 -0500 (Sun, 01 Nov 2009)
New Revision: 4899

Added:
   branches/jqMapbender/mapstraction/http/plugins/mb_legend.js
   branches/jqMapbender/mapstraction/http/plugins/ui_portlet.js
Modified:
   branches/jqMapbender/mapstraction/http/javascripts/map.php
   branches/jqMapbender/mapstraction/http/javascripts/mod_legend.php
   branches/jqMapbender/mapstraction/http/plugins/ui_accordion.js
Log:


Modified: branches/jqMapbender/mapstraction/http/javascripts/map.php
===================================================================
--- branches/jqMapbender/mapstraction/http/javascripts/map.php	2009-11-01 12:41:27 UTC (rev 4898)
+++ branches/jqMapbender/mapstraction/http/javascripts/map.php	2009-11-01 17:53:15 UTC (rev 4899)
@@ -78,7 +78,7 @@
 $extFileArray = array(  "jquery-1.3.2.min.js", 
 						"jqjson.js", 
 						"jquery.form.js",
-						"jquery-ui-1.7.2.custom/js/jquery-ui-1.7.2.custom.min.js"
+						"jquery-ui-1.7.2.custom/development-bundle/ui/ui.core.js"
 						);
 
 for ($i = 0; $i < count($extFileArray); $i++) {

Modified: branches/jqMapbender/mapstraction/http/javascripts/mod_legend.php
===================================================================
--- branches/jqMapbender/mapstraction/http/javascripts/mod_legend.php	2009-11-01 12:41:27 UTC (rev 4898)
+++ branches/jqMapbender/mapstraction/http/javascripts/mod_legend.php	2009-11-01 17:53:15 UTC (rev 4899)
@@ -1,95 +1,41 @@
-<?php
-# $Id: mod_legend.php 4879 2009-10-29 17:28:53Z christoph $
-# http://www.mapbender.org/index.php/Legend
-# Copyright (C) 2005 CCGIS / terrestris 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- 
-require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+var target = Mapbender.modules[options.target];
+var $this = $(this);
 
-<html>
-<head>
-<meta http-equiv="cache-control" content="no-cache">
-<meta http-equiv="pragma" content="no-cache">
-<meta http-equiv="expires" content="0">
-<?php
-echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';	
-?>
-<title>Legend</title>
-<?php
-include '../include/dyn_css.php';
+var mod_legend_offsetLeft = 25;
+var mod_legend_offsetTop = -10;
 
-$sql = "SELECT DISTINCT e_target, e_width, e_height FROM gui_element WHERE e_id = '".$_REQUEST["e_id_css"]."' AND fkey_gui_id = $1";
-$v = array($gui_id);
-$t = array('s');
-$res = db_prep_query($sql, $v, $t);
-$cnt = 0;
-while($row = db_fetch_array($res)){    
-	$e_target = $row["e_target"];
-	$cnt++;
+var checkbox_on_off = false;
+if (typeof options.checkbox_on_off !== "undefined") {
+	checkbox_on_off = options.checkbox_on_off;
 }
-if($cnt > 1){
-	echo "alert('legend: ID not unique!');";
-}
 
-$sql2 = "SELECT e_left,e_top,e_width,e_height FROM gui_element WHERE e_id = '".$e_target."' AND fkey_gui_id = $1";
-$v = array($gui_id);
-$t = array('s');
-$res2 = db_prep_query($sql2, $v, $t);
-echo "<script type='text/javascript'>\n";
-echo "var mod_legend_target = '".$e_target."';\n";
-echo "var mod_legend_target_left = ".db_result($res2,0,"e_left").";\n";
-echo "var mod_legend_target_top = ".db_result($res2,0,"e_top").";\n";
-echo "var mod_legend_target_width = ".db_result($res2,0,"e_width").";\n";
-echo "var mod_legend_target_height = ".db_result($res2,0,"e_height").";\n";
-echo "</script>\n";
-?>
-
-<script type="text/javascript">
-<!--
-
-mod_legend_offsetLeft = 25;
-mod_legend_offsetTop = -10;
-
-try{
-	if (checkbox_on_off){}
+var stickylegend = false;
+if (typeof options.stickylegend !== "undefined") {
+	stickylegend = options.stickylegend;
 }
-catch(e){
-	checkbox_on_off = 'false';
-}
 
-try{
-	if (stickylegend){}
-}
-catch(e){
-	stickylegend = 'false';
-}
-// Todo: return-value may change in the next version....
-parent.eventAfterMapRequest.register(function (obj) {
+Mapbender.eventAfterMapRequest.register(function (obj) {
 	mod_legend_pos(obj.map.elementName)
 });
 
+$this.append($(
+	"<form><span class='switch'><div id='" + options.id + "_checkboxstyle' " + 
+	"style='display:block;'>on/off" + 
+	"<input type='checkbox' name='sw' checked='true'></div></span>" + 
+	"<div name='leg' id='" + options.id + "_leg' ></div></form>"
+));
 
-function mod_legend_init(){
-	var obj = parent.document.getElementById("legend");
-	obj.style.top = mod_legend_target_top  + mod_legend_offsetTop;
-	obj.style.left = mod_legend_target_left + mod_legend_target_width + mod_legend_offsetLeft; 
-	var checkobj = document.getElementById("checkboxstyle");
-	if (checkbox_on_off == 'false'){
+$("#" +  options.id + "_checkboxstyle > input").click(function () {
+	mod_legend_repaint(this);
+});
+
+Mapbender.events.init.register(function (){
+	$this.css(
+		top:  mod_legend_target_top  + mod_legend_offsetTop,
+		left: mod_legend_target_left + mod_legend_target_width + mod_legend_offsetLeft
+	); 
+	if (!checkbox_on_off){
+		var checkobj = document.getElementById(options.id + "_checkboxstyle");
 		checkobj.style.display = "none";
 		checkobj.style.width = 0;
 		checkobj.style.height = 0;
@@ -122,69 +68,53 @@
 						
 		for(var i=0; i<parent.mb_mapObj[ind].wms.length; i++){
 			
-			 	var layerNames = parent.mb_mapObj[ind].wms[i].getLayers(parent.mb_mapObj[ind]);
-				for(var j=0; j<layerNames.length; j++){
-					var layerParent = parent.mb_mapObj[ind].wms[i].checkLayerParentByLayerName(layerNames[j]); 
-					var layerTitle = parent.mb_mapObj[ind].wms[i].getTitleByLayerName(layerNames[j]);
-					var layerStyle = parent.mb_mapObj[ind].wms[i].getCurrentStyleByLayerName(layerNames[j]);
-					var legendUrl = false;
-					if(layerStyle == false){
-						legendUrl = parent.mb_mapObj[ind].wms[i].getLegendUrlByGuiLayerStyle(layerNames[j],"");	
-					}
-					else{
-						legendUrl = parent.mb_mapObj[ind].wms[i].getLegendUrlByGuiLayerStyle(layerNames[j],layerStyle);
-					}
-			         
-					if (legendUrl !== false){
-						
-//	 					if(layerParent == 0){
-		 					if(showlayertitle == 'true'){
-								str_tmp += "<div><span class='titles'>" + layerTitle+ "</span></div>";
-							}
-							str_tmp += "<div>";
-		                    if(legendlink == 'true'){
-		                    	str_tmp += "<a href='../php/result.php?lingo=deutsch&layer="+layerNames[j]+"' class='link_metadata' title='Zeigt Liste zum Thema: "+layerTitle+"' target='result'>";
-		                    }
-		                    str_tmp += "<img border=0 src = '";			
-							str_tmp += legendUrl;
-							str_tmp += "'></img>";
-							if (legendlink == 'true'){
-		                    	str_tmp += "</a>";
-		                    }
-		                    str_tmp += "</div>";
-//	                	}
-					} 
+		 	var layerNames = parent.mb_mapObj[ind].wms[i].getLayers(parent.mb_mapObj[ind]);
+			for(var j=0; j<layerNames.length; j++){
+				var layerParent = parent.mb_mapObj[ind].wms[i].checkLayerParentByLayerName(layerNames[j]); 
+				var layerTitle = parent.mb_mapObj[ind].wms[i].getTitleByLayerName(layerNames[j]);
+				var layerStyle = parent.mb_mapObj[ind].wms[i].getCurrentStyleByLayerName(layerNames[j]);
+				var legendUrl = false;
+				if(layerStyle == false){
+					legendUrl = parent.mb_mapObj[ind].wms[i].getLegendUrlByGuiLayerStyle(layerNames[j],"");	
 				}
+				else{
+					legendUrl = parent.mb_mapObj[ind].wms[i].getLegendUrlByGuiLayerStyle(layerNames[j],layerStyle);
+				}
+		         
+				if (legendUrl !== false){
+					
+ 					if(showlayertitle == 'true'){
+						str_tmp += "<div><span class='titles'>" + layerTitle+ "</span></div>";
+					}
+					str_tmp += "<div>";
+                    if(legendlink == 'true'){
+                    	str_tmp += "<a href='../php/result.php?lingo=deutsch&layer="+layerNames[j]+"' class='link_metadata' title='Zeigt Liste zum Thema: "+layerTitle+"' target='result'>";
+                    }
+                    str_tmp += "<img border=0 src = '";			
+					str_tmp += legendUrl;
+					str_tmp += "'></img>";
+					if (legendlink == 'true'){
+                    	str_tmp += "</a>";
+                    }
+                    str_tmp += "</div>";
+				} 
+			}
 			if(str_tmp !=''){
 				if (showwmstitle == 'true'){
-					str += "<div><span class='header'>" +parent.mb_mapObj[ind].wms[i].wms_title+ "</span></div>";
+					str += "<div><span class='header'>" + 
+						mb_mapObj[ind].wms[i].wms_currentTitle + 
+						"</span></div>";
 				}
 				str += str_tmp;
 				str_tmp ='';
 			}		
 		}
 	    if(str != ""){
-			parent.writeTag("legend", "leg", str);
+			$(options.id + "_leg").html(str);
 		}
 		else{
-			parent.writeTag("legend", "leg", "");
+			$(options.id + "_leg").empty();
 		}
 		return true;
 	}
 } 
-
-// -->
-</script>
-
-</head>
-<body onload='mod_legend_init()'>
-<form>
-
-<span class='switch'>
-<div id="checkboxstyle" style="display:block;">on/off<input type='checkbox' name='sw' checked='true' onclick='mod_legend_repaint(this)'></div>
-</span>
-<div name='leg' id='leg' ></div>
-
-</form>
-</body>
-</html>

Added: branches/jqMapbender/mapstraction/http/plugins/mb_legend.js
===================================================================
--- branches/jqMapbender/mapstraction/http/plugins/mb_legend.js	                        (rev 0)
+++ branches/jqMapbender/mapstraction/http/plugins/mb_legend.js	2009-11-01 17:53:15 UTC (rev 4899)
@@ -0,0 +1,142 @@
+var target = Mapbender.modules[options.target[0]];
+var $this = $(this);
+
+var mod_legend_offsetLeft = 25;
+var mod_legend_offsetTop = -10;
+
+var checkbox_on_off = false;
+if (typeof options.checkbox_on_off !== "undefined") {
+	checkbox_on_off = options.checkbox_on_off;
+}
+
+var stickylegend = false;
+if (typeof options.stickylegend !== "undefined") {
+	stickylegend = options.stickylegend;
+}
+
+var showlayertitle = false;
+if (typeof options.showlayertitle !== "undefined") {
+	showlayertitle = options.showlayertitle;
+}
+
+var legendlink = false;
+if (typeof options.legendlink !== "undefined") {
+	legendlink = options.legendlink;
+}
+
+var showwmstitle = false;
+if (typeof options.showwmstitle !== "undefined") {
+	showwmstitle = options.showwmstitle;
+}
+
+Mapbender.events.afterMapRequest.register(function (obj) {
+	mod_legend_pos(obj.map.elementName)
+});
+
+$this.append($(
+	"<form><span class='switch'><div id='" + options.id + "_checkboxstyle' " + 
+	"style='display:block;'>on/off" + 
+	"<input type='checkbox' name='sw' checked='true'></div></span>" + 
+	"<div name='leg' id='" + options.id + "_leg' ></div></form>"
+));
+
+$("#" +  options.id + "_checkboxstyle > input").click(function () {
+	mod_legend_repaint(this);
+});
+
+Mapbender.events.init.register(function (){
+	$this.css({
+		top:  options.top  + mod_legend_offsetTop,
+		left: options.left + options.width + mod_legend_offsetLeft
+	}); 
+	if (!checkbox_on_off){
+		var checkobj = document.getElementById(options.id + "_checkboxstyle");
+		checkobj.style.display = "none";
+		checkobj.style.width = 0;
+		checkobj.style.height = 0;
+	}
+});
+
+function mod_legend_repaint(obj) {
+	var checkobj = document.getElementById(options.id + "_checkboxstyle");
+	if (checkobj.style.display == "block") {
+		mod_legend_pos();     
+	}
+}
+
+function mod_legend_pos(frameName){
+	if (frameName !== options.target[0]) {
+		return;
+	}
+
+	var ind = getMapObjIndexByName(options.target[0]);
+	var obj = document.getElementById(options.id + "_leg");
+
+	if (stickylegend) {
+		obj.style.left = parseInt(
+			mb_mapObj[ind].getWidth() + 
+			options.left + 
+			mod_legend_offsetLeft, 
+			10
+		);
+	}
+
+	if (!$("#" +  options.id + "_checkboxstyle > input").attr("checked")){
+		$("#" + options.id + "_leg").empty();
+		return;
+	}
+	
+	var str = "";
+	var str_tmp = "";
+					
+	for(var i=0; i<mb_mapObj[ind].wms.length; i++){
+		
+	 	var layerNames = mb_mapObj[ind].wms[i].getLayers(mb_mapObj[ind]);
+		for(var j=0; j<layerNames.length; j++){
+			var layerParent = mb_mapObj[ind].wms[i].checkLayerParentByLayerName(layerNames[j]); 
+			var layerTitle = mb_mapObj[ind].wms[i].getTitleByLayerName(layerNames[j]);
+			var layerStyle = mb_mapObj[ind].wms[i].getCurrentStyleByLayerName(layerNames[j]);
+			var legendUrl = false;
+			if(layerStyle == false){
+				legendUrl = mb_mapObj[ind].wms[i].getLegendUrlByGuiLayerStyle(layerNames[j],"");	
+			}
+			else{
+				legendUrl = mb_mapObj[ind].wms[i].getLegendUrlByGuiLayerStyle(layerNames[j],layerStyle);
+			}
+	         
+			if (legendUrl !== false){
+				
+					if (showlayertitle) {
+					str_tmp += "<div><span class='titles'>" + layerTitle+ "</span></div>";
+				}
+				str_tmp += "<div>";
+                if(legendlink){
+                	str_tmp += "<a href='../php/result.php?lingo=deutsch&layer="+layerNames[j]+"' class='link_metadata' title='Zeigt Liste zum Thema: "+layerTitle+"' target='result'>";
+                }
+                str_tmp += "<img border=0 src = '";			
+				str_tmp += legendUrl;
+				str_tmp += "'></img>";
+				if (legendlink){
+                	str_tmp += "</a>";
+                }
+                str_tmp += "</div>";
+			} 
+		}
+		if(str_tmp !=''){
+			if (showwmstitle){
+				str += "<div><span class='header'>" + 
+					mb_mapObj[ind].wms[i].wms_currentTitle + 
+					"</span></div>";
+			}
+			str += str_tmp;
+			str_tmp ='';
+		}		
+	}
+    if (str !== "") {
+		$("#" + options.id + "_leg").html(str);
+	}
+	else{
+		$("#" + options.id + "_leg").empty();
+	}
+	return true;
+} 

Modified: branches/jqMapbender/mapstraction/http/plugins/ui_accordion.js
===================================================================
--- branches/jqMapbender/mapstraction/http/plugins/ui_accordion.js	2009-11-01 12:41:27 UTC (rev 4898)
+++ branches/jqMapbender/mapstraction/http/plugins/ui_accordion.js	2009-11-01 17:53:15 UTC (rev 4899)
@@ -1,10 +1,56 @@
+/**
+ * Package: ui_accordion
+ *
+ * Description:
+ * An accordion decorator, replaces the deprecated element "tabs"
+ * 
+ * Enter the elements to be put in the accordion in its target field 
+ * (comma-separated list of element ids).
+ * 
+ * Avoid styles in elements within the accordion. 
+ * 
+ * The overview won't work in the accordion, as it cannot be positioned 
+ * absolutely.
+ * 
+ * The width of this module determines the accordion width, but the height
+ * of the individual elements determines the height. 
+ *  
+ * 
+ * Files:
+ *  - http/plugins/ui_accordion.js
+ *  - http/extensions/jquery-ui-1.7.2.custom/development-bundle/ui/ui.accordion.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('gui','ui_accordion',2,1,
+ * > 'An accordion decorator, replaces the deprecated element tabs','','div',
+ * > '','',10,240,300,NULL ,2,'','','div','../plugins/ui_accordion.js',
+ * > '../extensions/jquery-ui-1.7.2.custom/development-bundle/ui/ui.accordion.js',
+ * > '','','http://docs.jquery.com/UI/Accordion');
+ *
+ * Help:
+ * http://docs.jquery.com/UI/Accordion
+ *
+ * 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
+ */
+
 $this = $(this);
 
-var selectorArray = [];
+// tab to open onload
+var active = typeof options.active !== "number" ? 
+	false : options.active - 1;
+
 for (var i = 0; i < options.target.length; i++) {
-	var selector = "#" + options.target[i];
-	
-	$c = $(selector);
+	$c = $("#" + options.target[i]);
 	$this.append(
 		$(
 			"<h3><a id='header_" + options.id + "_" +	$c.attr("id") +	
@@ -22,13 +68,8 @@
 	);
 }
 
-//Mapbender.events.localize.register(function () {
-//	$(".ui-" + options.id).each(function () {
-//		$("#header_" + options.id + "_" + this.id)
-//	}) 
-//});
-
 $("#" + options.id).accordion({
 	collapsible: true,
-	autoHeight: false
+	autoHeight: false,
+	active: active
 });

Added: branches/jqMapbender/mapstraction/http/plugins/ui_portlet.js
===================================================================
--- branches/jqMapbender/mapstraction/http/plugins/ui_portlet.js	                        (rev 0)
+++ branches/jqMapbender/mapstraction/http/plugins/ui_portlet.js	2009-11-01 17:53:15 UTC (rev 4899)
@@ -0,0 +1,75 @@
+/**
+ * Package: ui_accordion
+ *
+ * Description:
+ * An accordion decorator, replaces the deprecated element "tabs"
+ * 
+ * Enter the elements to be put in the accordion in its target field 
+ * (comma-separated list of element ids).
+ * 
+ * Avoid styles in elements within the accordion. 
+ * 
+ * The overview won't work in the accordion, as it cannot be positioned 
+ * absolutely.
+ * 
+ * The width of this module determines the accordion width, but the height
+ * of the individual elements determines the height. 
+ *  
+ * 
+ * Files:
+ *  - http/plugins/ui_accordion.js
+ *  - http/extensions/jquery-ui-1.7.2.custom/development-bundle/ui/ui.accordion.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('gui','ui_accordion',2,1,
+ * > 'An accordion decorator, replaces the deprecated element tabs','','div',
+ * > '','',10,240,300,NULL ,2,'','','div','../plugins/ui_accordion.js',
+ * > '../extensions/jquery-ui-1.7.2.custom/development-bundle/ui/ui.accordion.js',
+ * > '','','http://docs.jquery.com/UI/Accordion');
+ *
+ * Help:
+ * http://docs.jquery.com/UI/Accordion
+ *
+ * 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
+ */
+
+$this = $(this);
+
+// tab to open onload
+var active = typeof options.active !== "number" ? 
+	false : options.active - 1;
+
+for (var i = 0; i < options.target.length; i++) {
+	$c = $("#" + options.target[i]);
+	$this.append(
+		$(
+			"<h3><a id='header_" + options.id + "_" +	$c.attr("id") +	
+			"' href='#'>" +	Mapbender.modules[$c.attr("id")].currentTitle +	
+			"</a></h3>"
+		)
+	).append(
+		$(
+			"<div></div>"
+		).append(
+			$(
+				"<div style='height:" + $c.css("height") +	"'></div>"
+			).append($c)
+		)
+	);
+}
+
+$("#" + options.id).accordion({
+	collapsible: true,
+	autoHeight: false,
+	active: active
+});



More information about the Mapbender_commits mailing list