[Mapbender-commits] r1691 - in trunk/mapbender/http: html javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Sep 26 09:39:38 EDT 2007


Author: nimix
Date: 2007-09-26 09:39:38 -0400 (Wed, 26 Sep 2007)
New Revision: 1691

Modified:
   trunk/mapbender/http/html/mod_treefolder2.php
   trunk/mapbender/http/javascripts/jsTree.js
Log:
Sublayer and reverse support for Treefolder2

Modified: trunk/mapbender/http/html/mod_treefolder2.php
===================================================================
--- trunk/mapbender/http/html/mod_treefolder2.php	2007-09-26 13:38:29 UTC (rev 1690)
+++ trunk/mapbender/http/html/mod_treefolder2.php	2007-09-26 13:39:38 UTC (rev 1691)
@@ -58,6 +58,8 @@
 var jst_display_root = false;
 var defaultTarget = 'examplemain';
 var lock=false;
+var lock_update=false;
+var lock_check=false;
 var selectedMap=-1;
 var selectedWMS=-1;
 var selectedLayer=-1;
@@ -74,6 +76,7 @@
 function _foo(){}
 
 // some defaults
+try{if (reverse){}}catch(e){reverse = 'false';}
 try{if (switchwms){}}catch(e){switchwms = 'true';}
 try{if (ficheckbox){}}catch(e){ficheckbox = 'false';}
 try{if (metadatalink){}}catch(e){metadatalink = 'false';}
@@ -81,6 +84,7 @@
 try{if (showstatus){}}catch(e){showstatus = 'false';}
 try{if (alerterror){}}catch(e){alerterror = 'false';}
 try{if (openfolder){}}catch(e){openfolder = 'false';}
+try{if (handlesublayer){}}catch(e){handlesublayer = 'false';}
 try{if (menu){}}catch(e){menu = '';}
 
 //menu elements
@@ -121,19 +125,19 @@
 		if(selectedLayer==0)
 		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id, '#999999');
 		else
-		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_name, '#999999');
+		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_id, '#999999');
 	}
 	else if(scale > parseInt(parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].gui_layer_maxscale) && parseInt(parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].gui_layer_maxscale) != 0){
 		if(selectedLayer==0)
 		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id, '#999999');
 		else
-		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_name, '#999999');
+		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_id, '#999999');
 	}
 	else{
 		if(selectedLayer==0)
 		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id, '');
 		else
-		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_name, '');
+		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_id, '');
 	}
 
 	selectedMap=i;
@@ -152,19 +156,19 @@
 						if(iii==0)
 						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id, '#999999');
 						else
-						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id+"|"+parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_name, '#999999');
+						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id+"|"+parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_id, '#999999');
 					}
 					else if(scale > parseInt(parent.mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_maxscale) && parseInt(parent.mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_maxscale) != 0){
 						if(iii==0)
 						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id, '#999999');
 						else
-						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id+"|"+parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_name, '#999999');
+						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id+"|"+parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_id, '#999999');
 					}
 					else{
 						if(iii==0)
 						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id, '');
 						else
-						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id+"|"+parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_name, '');
+						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id+"|"+parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_id, '');
 					}
 				}
 			}
@@ -254,6 +258,8 @@
 	}
 }
 
+//parent.mb_registerWmsLoadErrorFunctions("window.frames['treeGDE'].imgerror();");
+
 function init_mapcheck(){
 	if(!init)return;
 	errors = 0;
@@ -271,11 +277,14 @@
 }
 
 function handleSelectedLayer(mapObj,wms_id,layername,type,status){
-	var mywms = new Array();
-	mywms[0] = wms_id;
-	var mylayername = new Array();
-	mylayername[0] = layername;
-	parent.handleSelectedLayer_array(mapObj, mywms, mylayername, type, status);
+	if(lock_update||lock_check)return;
+	var ind = parent.getMapObjIndexByName(mapObj);
+	for(var i=0; i<parent.mb_mapObj[ind].wms.length; i++){
+		if(parent.mb_mapObj[ind].wms[i].wms_id == wms_id){
+			parent.mb_mapObj[ind].wms[i].handleLayer(layername, type, status);
+			break;
+		}
+	}
 }
 
 function zoomToLayer(j,k,l){
@@ -326,7 +335,7 @@
 	if (parent.mb_mapObj[mapObj_id].wms[wms_id].gui_wms_visible > 0) {
 		var divId = 'div_'+wms_id;
 		wmsImage = parent.mapframe1.document.getElementById(divId);
-		if (wmsImage != null && !isNaN(opacity) && opacity != 100) {
+		if (wmsImage != null && !isNaN(opacity)) {
 			wmsImage.style.opacity = (opacity / 100);
 			wmsImage.style.MozOpacity = (opacity / 100);
 			wmsImage.style.KhtmlOpacity = (opacity / 100);
@@ -348,7 +357,7 @@
 //---end------------- opacity --------------------
 
 function move_up(j,k,l){
-	if(!j&&!k&&!l){
+	if(isNaN(j)&&isNaN(k)&&isNaN(l)){
 		j=selectedMap;
 		k=selectedWMS;
 		l=selectedLayer;
@@ -357,95 +366,62 @@
 		alert("You have to select the WMS you want to move up!")		
 		return;
 	}
-	if(l!=0){
-		if(l==1){
-			alert("The Layer you selected is already on top of the WMS");
-			return;
-		}
-			
-		var my = parent.mb_mapObj[j];
-		var upperLayers = my.wms[k].objLayer[l-1];
-		my.wms[k].objLayer[l-1] = my.wms[k].objLayer[l];
-		my.wms[k].objLayer[l] = upperLayers;
-
-		//Reload the mapframe by calling zoom function with factor one
-		treeState = getState();
-		parent.zoom(my.frameName, true, 1.0);
-		parent.mb_execloadWmsSubFunctions();	
-		select(j, k, l-1);
-		selectNode(arrNodes[0][0]+"|"+my.wms[k].wms_id+"|"+my.wms[k].objLayer[l-1].layer_name);
+	var lid=parent.mb_mapObj[j].wms[k].objLayer[l].layer_id;
+	if(!parent.mb_mapObj[j].move(parent.mb_mapObj[j].wms[k].wms_id,lid,(reverse=="true")?false:true)){
+		alert("Illegal move operation");
 		return;
 	}
-	var previousWMS=-1;
-	for(var i=k-1;i>=0;i--)
-		if(parent.mb_mapObj[j].wms[i].gui_wms_visible=='1'||parent.mb_mapObj[j].wms[i].gui_wms_visible==1){
-			previousWMS=i;
-			break;
+	treeState = getState();
+	parent.zoom(parent.mb_mapObj[j].frameName, true, 1.0);
+	parent.mb_execloadWmsSubFunctions();
+	//find layer and select
+	for(k=0;k<parent.mb_mapObj[j].wms.length;k++){
+		for(l=0;l<parent.mb_mapObj[j].wms[k].objLayer.length;l++){
+			if(parent.mb_mapObj[j].wms[k].objLayer[l].layer_id==lid){
+				select(j,k,l);
+				if(l!=0)
+					selectNode(String(lid));
+				else
+					selectNode(String(parent.mb_mapObj[j].wms[k].wms_id));
+			}
 		}
-	if(previousWMS==-1){
-		alert("The selected WMS is already on top!")
-		return;
 	}
-	if (parent.mb_swapWmsByIndex(j, previousWMS, k) == true){
-		treeState = getState();
-		parent.zoom(parent.mb_mapObj[j].frameName, true, 1.0);
-		parent.mb_execloadWmsSubFunctions();	
-		select(j, previousWMS, 0);
-		selectNode(arrNodes[0][0]+"|"+parent.mb_mapObj[j].wms[previousWMS].wms_id);
-	}
 }
 
 function move_down(j,k,l){
-	if(!j&&!k&&!l){
+	if(isNaN(j)&&isNaN(k)&&isNaN(l)){
 		j=selectedMap;
 		k=selectedWMS;
 		l=selectedLayer;
-	}	
+	}
 	if(j==-1||k==-1||l==-1){
 		alert("You have to select the WMS you want to move down!")		
 		return;
 	}
-	if(l!=0){
-		var my = parent.mb_mapObj[j];
-		if(selectedLayer==my.wms[k].objLayer.length-1){
-			alert("The Layer you selected is already on bottom of the WMS");
-			return;
-		}
-			
-		var nextLayers = my.wms[k].objLayer[l+1];
-		my.wms[k].objLayer[l+1] = my.wms[k].objLayer[l];
-		my.wms[k].objLayer[l] = nextLayers;
-
-		//Reload the mapframe by calling zoom function with factor one
-		treeState = getState();
-		parent.zoom(my.frameName, true, 1.0);
-		parent.mb_execloadWmsSubFunctions();
-		select(j, k, l+1);
-		selectNode(arrNodes[0][0]+"|"+my.wms[k].wms_id+"|"+my.wms[k].objLayer[l+1].layer_name);
+	var lid=parent.mb_mapObj[j].wms[k].objLayer[l].layer_id;
+	if(!parent.mb_mapObj[j].move(parent.mb_mapObj[j].wms[k].wms_id,lid,(reverse=="true")?true:false)){
+		alert("Illegal move operation");
 		return;
 	}
-	var nextWMS=-1;
-	for(var i=k+1;i<parent.mb_mapObj[j].wms.length;i++){
-		if(parent.mb_mapObj[j].wms[i].gui_wms_visible=='1'||parent.mb_mapObj[j].wms[i].gui_wms_visible==1){
-			nextWMS=i;
-			break;
+	treeState = getState();
+	parent.zoom(parent.mb_mapObj[j].frameName, true, 1.0);
+	parent.mb_execloadWmsSubFunctions();	
+	//find layer and select
+	for(k=0;k<parent.mb_mapObj[j].wms.length;k++){
+		for(l=0;l<parent.mb_mapObj[j].wms[k].objLayer.length;l++){
+			if(parent.mb_mapObj[j].wms[k].objLayer[l].layer_id==lid){
+				select(j,k,l);
+				if(l!=0)
+					selectNode(String(lid));
+				else
+					selectNode(String(parent.mb_mapObj[j].wms[k].wms_id));
+			}
 		}
 	}
-	if(nextWMS==-1){
-		alert("The selected WMS is already on bottom!")
-		return;
-	}
-	if (parent.mb_swapWmsByIndex(j, k, nextWMS) == true){
-		treeState = getState();
-		parent.zoom(parent.mb_mapObj[j].frameName, true, 1.0);
-		parent.mb_execloadWmsSubFunctions();	
-		select(j, nextWMS, 0);	
-		selectNode(arrNodes[0][0]+"|"+parent.mb_mapObj[j].wms[nextWMS].wms_id);
-	}
 }
 
 function remove_wms(j,k,l){
-	if(!j&&!k&&!l){
+	if(isNaN(j)&&isNaN(k)&&isNaN(l)){
 		j=selectedMap;
 		k=selectedWMS;
 		l=selectedLayer;
@@ -474,37 +450,55 @@
 }
 
 function updateParent(path){
-	if(lock)return;
-	lock=true;
+	if(lock_check)return;
+	var reset_lock=!lock_update; 
+	lock_update=true;
 	var state=getChildrenCheckState(path, 0);
 	//enableCheckbox(path, (state!=-1)); //3rd state
 	checkNode(path, 0, (state==1));
-	if(state==0 && showstatus=='true'){
-/*		var arrPath = path.split(jst_delimiter[0])
-		var ind = parent.getMapObjIndexByName(mod_treeGDE_map);
-		for(var wms=0;wms<parent.mb_mapObj[ind].wms.length;wms++)
-		{
-			if(parent.mb_mapObj[ind].wms[wms].wms_id==arrPath[arrPath.length-1])
-				break;
-		}
-*/		setTimeout('setNodeImage("'+path+'", "error_folder.png");', 100);
-//		state[wms]=-1;
-	}	
-	lock=false;
+	if(state==0 && showstatus=='true' && path.split(jst_delimiter[0]).length == 2){
+		setTimeout('setNodeImage("'+path+'", "error_folder.png");', 100);
+	}
+	if(reset_lock)
+		lock_update=false;
 }
 
 function handleSelectedWMS(path){
-	if(lock)return;
-	lock=true;
+	if(lock_update)return;
+	var t = path.split("|");
+	var reset_lock=!lock_check; 
+	var ind = parent.getMapObjIndexByName(mod_treeGDE_map);
+	var layername = parent.mb_mapObj[ind].wms[parent.getWMSIndexById(mod_treeGDE_map,t[t.length-1])].objLayer[0].layer_name;
 	var bChk = IsChecked(path, 0);	
-	enableCheckbox(path, 0, true);
+	handleSelectedLayer(mod_treeGDE_map,t[t.length-1],layername,"visible",bChk?"1":"0");
+	lock_check=true;
 	checkChildren(path, 0, bChk);
 	if(ficheckbox)checkChildren(path, 1, bChk);
 	if(bChk==false && showstatus=='true')
 		setTimeout('setNodeImage("'+path+'", "error_folder.png");', 100);
-	lock=false;
+	if(reset_lock)
+	{
+		lock_check=false;
+		parent.mb_restateLayers(mod_treeGDE_map,t[t.length-1]);
+		parent.setSingleMapRequest(mod_treeGDE_map,t[t.length-1]);
+	}
 }
 
+function handleSelection(path){
+	if(lock_update)return;
+	var reset_lock=!lock_check; 
+	lock_check=true;
+	var bChk = IsChecked(path, 0);	
+//	enableCheckbox(path, 0, true);
+	checkChildren(path, 0, bChk);
+	if(reset_lock){
+		var t = path.split("|");
+		lock_check=false;
+		parent.mb_restateLayers(mod_treeGDE_map,t[1]);
+		parent.setSingleMapRequest(mod_treeGDE_map,t[1]);
+	}
+}
+
 function initArray(){
 	var parentObj = "";
 	var controls="";
@@ -517,27 +511,49 @@
 							var temp = parent.mb_mapObj[i].wms[ii].objLayer[iii];     
 							if(parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_parent == ""){  
 								var c_menu="[";
-								if(menu.indexOf("wms_up")!=-1 && parentObj!="")c_menu+="menu_move_up,";
-								if(menu.indexOf("wms_down")!=-1 && ii!=parent.mb_mapObj[i].wms.length-1)c_menu+="menu_move_down,";
+								if(reverse=="true"){
+									if(menu.indexOf("wms_down")!=-1 && ii!=parent.mb_mapObj[i].wms.length-1)c_menu+="menu_move_up,";
+									if(menu.indexOf("wms_up")!=-1 && parentObj!="")c_menu+="menu_move_down,";
+								}
+								else{
+									if(menu.indexOf("wms_up")!=-1 && parentObj!="")c_menu+="menu_move_up,";
+									if(menu.indexOf("wms_down")!=-1 && ii!=parent.mb_mapObj[i].wms.length-1)c_menu+="menu_move_down,";
+								}
 								if(menu.indexOf("remove")!=-1)c_menu+="menu_delete,";
 //								if(menu.indexOf("wms_switch")!=-1)c_menu+="menu_wms_switch,";
 								if(menu.indexOf("opacity_up")!=-1 && parseFloat(parent.mb_mapObj[i].wms[ii].gui_wms_mapopacity) < 1)c_menu+="menu_opacity_up,";
 								if(menu.indexOf("opacity_down")!=-1 && parseFloat(parent.mb_mapObj[i].wms[ii].gui_wms_mapopacity) > 0)c_menu+="menu_opacity_down,";
 								if(menu.indexOf("hide")!=-1)c_menu+="menu_hide";
 								c_menu+="]";
-								if(switchwms=='true') {
-									addNode(arrNodes[0][0],[parent.mb_mapObj[i].wms[ii].wms_id,[temp.layer_title,"javascript:select("+i+","+ii+","+iii+");",,,,eval(c_menu),'<INPUT type="checkbox" checked onclick="handleSelectedWMS(\''+arrNodes[0][0]+'|'+parent.mb_mapObj[i].wms[ii].wms_id+'\');" />',[i,ii,iii]]],false,false);
-								}
-								else {
-									addNode(arrNodes[0][0],[parent.mb_mapObj[i].wms[ii].wms_id,[temp.layer_title,"javascript:select("+i+","+ii+","+iii+");",,,,eval(c_menu),,[i,ii,iii]]],false,false);
-								}
+								controls=null;
+								if(switchwms=='true')controls='<INPUT type="checkbox" checked onclick="handleSelectedWMS(\''+arrNodes[0][0]+'|'+parent.mb_mapObj[i].wms[ii].wms_id+'\');" />';
+								if(wmsbuttons == 'true'&&metadatalink == 'true')controls+='<a href="'+'javascript:openwindow(\'../php/mod_layerMetadata.php?id='+temp.layer_uid+'\');'+'"><img src="'+imagedir+'/info.png" /></a>';
+								addNode(arrNodes[0][0],[parent.mb_mapObj[i].wms[ii].wms_id,[temp.layer_title,((metadatalink=='true'&&wmsbuttons != 'true')?('javascript:openwindow(\"../php/mod_layerMetadata.php?id='+temp.layer_uid+'\");'):"javascript:select("+i+","+ii+","+iii+");"),,,,eval(c_menu),controls,[i,ii,iii]]],false,false,reverse=="true");
 								parentObj = arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id;              
 							}
-							if(parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_parent == "0"){
+							if(parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_parent && (handlesublayer=="true"||parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_parent=="0")){
+								var parentLayer = "";
+								var j = iii;
+								while(parent.mb_mapObj[i].wms[ii].objLayer[j].layer_parent!="0"){
+									//find parent
+									for(var jj=0; jj < parent.mb_mapObj[i].wms[ii].objLayer.length; jj++){
+										if(parent.mb_mapObj[i].wms[ii].objLayer[jj].layer_pos==parseInt(parent.mb_mapObj[i].wms[ii].objLayer[j].layer_parent)){
+											j=jj;
+											break;
+										}										
+									}									
+									parentLayer = "|" + parent.mb_mapObj[i].wms[ii].objLayer[j].layer_id + parentLayer;
+								}
 								if(temp.gui_layer_selectable == '1' || temp.gui_layer_queryable == '1'){
 									var c_menu="[";
-									if(menu.indexOf("layer_up")!=-1 && iii!=1)c_menu+="menu_move_up,";
-									if(menu.indexOf("layer_down")!=-1 && iii!=parent.mb_mapObj[i].wms[ii].objLayer.length-1)c_menu+="menu_move_down,";
+									if(reverse=="true"){
+										if(menu.indexOf("layer_down")!=-1 && iii!=parent.mb_mapObj[i].wms[ii].objLayer.length-1)c_menu+="menu_move_up,";
+										if(menu.indexOf("layer_up")!=-1 && iii!=1)c_menu+="menu_move_down,";
+									}
+									else{
+										if(menu.indexOf("layer_up")!=-1 && iii!=1)c_menu+="menu_move_up,";
+										if(menu.indexOf("layer_down")!=-1 && iii!=parent.mb_mapObj[i].wms[ii].objLayer.length-1)c_menu+="menu_move_down,";
+									}
 									if(menu.indexOf("metainfo")!=-1)c_menu+="menu_metalink,";
 									if(menu.indexOf("zoom")!=-1 && temp.layer_epsg.length>0)c_menu+="menu_zoom,";
 //									if(menu.indexOf("layer_switch")!=-1)c_menu+="menu_layer_switch,";
@@ -545,10 +561,10 @@
 									if(menu.indexOf("hide")!=-1)c_menu+="menu_hide";
 									c_menu+="]";
 									
-									controls='<input type="checkbox" '+((temp.gui_layer_visible=='1')?'checked ':'')+(temp.gui_layer_selectable!='1'?'disabled ':'')+"onclick=\"handleSelectedLayer('"+mod_treeGDE_map+"','"+parent.mb_mapObj[i].wms[ii].wms_id+"','"+temp.layer_name+"','visible',this.checked?1:0);updateParent('"+parentObj+"');"+((ficheckbox == 'false')?"handleSelectedLayer('"+mod_treeGDE_map+"','"+parent.mb_mapObj[i].wms[ii].wms_id+"','"+temp.layer_name+"','querylayer',this.checked?1:0)":"")+"\" />";
-									if(ficheckbox == 'true')controls+='<input type="checkbox" '+(temp.gui_layer_querylayer=='1'?'checked ':'')+(temp.gui_layer_queryable!='1'?'disabled ':'')+"onclick=\"handleSelectedLayer('"+mod_treeGDE_map+"','"+parent.mb_mapObj[i].wms[ii].wms_id+"','"+temp.layer_name+"','querylayer',this.checked?1:0)\" />";
+									controls='<input type="checkbox" '+(temp.layer_name==""?'style="display:none;" ':"")+((temp.gui_layer_visible=='1')?'checked ':'')+(temp.gui_layer_selectable!='1'?'disabled ':'')+"onclick=\"handleSelectedLayer('"+mod_treeGDE_map+"','"+parent.mb_mapObj[i].wms[ii].wms_id+"','"+temp.layer_name+"','visible',this.checked?1:0);handleSelection('"+parentObj+parentLayer+"|"+temp.layer_id+"');updateParent('"+parentObj+parentLayer+"');"+((ficheckbox == 'false')?"handleSelectedLayer('"+mod_treeGDE_map+"','"+parent.mb_mapObj[i].wms[ii].wms_id+"','"+temp.layer_name+"','querylayer',this.checked?1:0)":"")+"\" />";
+									if(ficheckbox == 'true')controls+='<input type="checkbox" '+(temp.gui_layer_querylayer=='1'?'checked ':'')+(temp.gui_layer_queryable!='1'?'disabled ':'')+"onclick=\"handleSelectedLayer('"+mod_treeGDE_map+"','"+parent.mb_mapObj[i].wms[ii].wms_id+"','"+temp.layer_name+"','querylayer',this.checked?1:0);checkChildren('"+parentObj+parentLayer+"|"+temp.layer_id+"', 1, this.checked?1:0)\" />";
 									if(wmsbuttons == 'true'&&metadatalink == 'true')controls+='<a href="'+'javascript:openwindow(\'../php/mod_layerMetadata.php?id='+temp.layer_uid+'\');'+'"><img src="'+imagedir+'/info.png" /></a>';
-									addNode(parentObj, [temp.layer_name,[temp.layer_title,((metadatalink=='true'&&wmsbuttons != 'true')?('javascript:openwindow(\"../php/mod_layerMetadata.php?id='+temp.layer_uid+'\");'):"javascript:select("+i+","+ii+","+iii+");"),,(c_menu!='[]'?'menu.png':null),,eval(c_menu),controls,[i,ii,iii]]],false,false);
+									addNode(parentObj + parentLayer, [temp.layer_id,[temp.layer_title,((metadatalink=='true'&&wmsbuttons != 'true')?('javascript:openwindow(\"../php/mod_layerMetadata.php?id='+temp.layer_uid+'\");'):"javascript:select("+i+","+ii+","+iii+");"),,((c_menu!='[]'&&temp.layer_name!="")?'menu.png':null),,eval(c_menu),controls,[i,ii,iii]]],false,false,reverse=="true");
 								}
 							}
 						}

Modified: trunk/mapbender/http/javascripts/jsTree.js
===================================================================
--- trunk/mapbender/http/javascripts/jsTree.js	2007-09-26 13:38:29 UTC (rev 1690)
+++ trunk/mapbender/http/javascripts/jsTree.js	2007-09-26 13:39:38 UTC (rev 1691)
@@ -187,6 +187,11 @@
 								eval(ps)[d].push(new Array())
 							eval(ps)[d][2].push(nd)
 						break;
+						case "u":
+							if(!eval(ps)[d][2])
+								eval(ps)[d].push(new Array())
+							eval(ps)[d][2].unshift(nd)
+						break;
 					}
 					return true
 					
@@ -201,8 +206,8 @@
 	return false
 }
 
-function addNode(path, nd, sel, refresh){
-	if(_editDataNode("a", path, nd)){
+function addNode(path, nd, sel, refresh, begining){
+	if(_editDataNode((begining?"u":"a"), path, nd)){
 		if(refresh){	
 			rebuildNode(path, true)
 			rebuildNode(path)
@@ -242,16 +247,22 @@
 function setState(data){
 	jst_state_paths = data.split(jst_delimiter[1])
 	for(var p in jst_state_paths){
-		var tr = getDomNode(jst_state_paths[p])
-		
-		if(tr){
-			var f1 = tr.firstChild
-			if(f1){
-				var f2 = f1.firstChild
-				if(!isExpanded(tr) && f2)
-					if(f2.onclick)
-						f2.onclick()
+		var path="";
+		var pathElements = jst_state_paths[p].split(jst_delimiter[0]);
+		for(i in pathElements){
+			path += pathElements[i];
+			var tr = getDomNode(path)
+			
+			if(tr){
+				var f1 = tr.firstChild
+				if(f1){
+					var f2 = f1.firstChild
+					if(!isExpanded(tr) && f2)
+						if(f2.onclick)
+							f2.onclick()
+				}
 			}
+			path+=jst_delimiter[0];
 		}
 	}
 }
@@ -395,7 +406,7 @@
 	var plus;
 	
 	if(!nd)return false;
-	if(!childExists(nd))nd.firstChild.firstChild.onclick();
+	if(!childExists(nd))return false;
 	var tBody = nd.nextSibling.childNodes[1].firstChild.firstChild;
 	if(!tBody)return false;
 	for(var i = 0;i < tBody.childNodes.length; i++){
@@ -405,8 +416,7 @@
 		var cb = tBody.childNodes[i].childNodes[1].childNodes[ctrlNr+plus];
 		if(cb && cb.nodeName=="INPUT"&&!cb.disabled){
 			cb.checked = bChk;	
-			if(cb.onclick){cb.onclick();}	
-//TODO DataNode anpassen
+			if(cb.onclick){cb.onclick();}
 		}		
 	}
 	return true;
@@ -588,16 +598,20 @@
 			}
 			return
 		}else{
-			ctlImg.src = jst_image_folder + "/" + (tr.nextSibling ? "" : "last_") + "expanded.png"
+			ctlImg.src = jst_image_folder + "/" + (tr.nextSibling ? "" : "last_") + "closed.png"
 			if(eval(strData.substr(0, strData.length-3)+"[1][3]"))
 				fldImg.src = jst_image_folder + "/" + eval(strData.substr(0, strData.length-3)+"[1][3]");
 			else
-				fldImg.src = jst_image_folder + "/expanded_folder.png";
+				fldImg.src = jst_image_folder + "/closed_folder.png";
 		}
 	}
 
 	var newTr = tr.parentNode.insertRow((tr.rowIndex?tr.rowIndex:0) + 1)
 
+	if(ctlImg.id != "rootFolder"){
+		newTr.style.display = "none";
+	}
+
 	newTr.appendChild(document.createElement('td'))
 	newTr.appendChild(document.createElement('td'))
 		
@@ -605,7 +619,20 @@
 		newTr.firstChild.setAttribute("background", jst_image_folder + "/branch.png", "false")
 	
 	newTr.childNodes[1].innerHTML = renderChildren(strData)
+	
+	var nodes = eval(strData)
 
+	var ndWithChildren = 0;
+	for(var n in nodes){
+		var n0 = nodes[n]
+		var n1 = n0[2]
+
+		if(n1){
+			renderNode(strData + "[" + n + "][2]" ,newTr.childNodes[1].firstChild.firstChild.childNodes[parseInt(n)+ndWithChildren].firstChild.firstChild);
+			ndWithChildren++;
+		}
+	}
+	
 	jst_loaded = true
 }
 



More information about the Mapbender_commits mailing list