[OpenLayers-Commits] r7505 - sandbox/architect/scripts

commits at openlayers.org commits at openlayers.org
Mon Jul 14 13:46:20 EDT 2008


Author: architect
Date: 2008-07-14 13:46:20 -0400 (Mon, 14 Jul 2008)
New Revision: 7505

Modified:
   sandbox/architect/scripts/controlConfig.js
Log:


Modified: sandbox/architect/scripts/controlConfig.js
===================================================================
--- sandbox/architect/scripts/controlConfig.js	2008-07-14 14:59:39 UTC (rev 7504)
+++ sandbox/architect/scripts/controlConfig.js	2008-07-14 17:46:20 UTC (rev 7505)
@@ -79,8 +79,10 @@
 		}
 		//populate toolbox2
 		createBaseControlConfig();
-		
-		
+		$('saveButton').addEvent('click', function(e) {
+			e.stop();
+			saveControlConfig(controlsLength,true); //Only used when first created.  When in edit mode, this function is attached to the save button in the editLayer function
+		})
 		/*When the save button is clicked when the layer is first added, add a list item to the layer list in toolbox1*/
 		
 	});
@@ -132,7 +134,89 @@
 
 }
 
+/*=======================
+|  saveControlConfig(ID, isControlNew)
+|
+|called when the save button is pressed
+|
+|ID is the id of the current layer - an integer - an integer
+|isControlNew is either "new" or "edit" - new, if the new layer button has been clicked; edit, if a layer is going to be modified
+=========================*/
+function saveControlConfig(ID, isControlNew){
+	if ($('tb2ControlListDropdown').selectedIndex == 0)
+		return; //If the layer type is empty, return.  We can't have an empty layer service
+		
+	/*if no isControlNew is defined, assume it is a new layer*/
+	if ( isControlNew == null || isControlNew == undefined)
+		isControlNew = true;
+		
+		
+	//Get the value of the text input.
+	var valName = $('layoutControlConfigTitle').value;
+	console.log(valName);
+	/*The code here will execute if the input is empty.
+	Create a new <li> to hold all our content.
+	Set the title of the LI to the current layersLength value*/ 
+	if(isControlNew == true){
+		var li = new Element('li', {id: 'tb1Control'+ID, title:'Control ' + valName,'class':'drag'}); //onclick=\"editLayer('" + ID + "')\"
+		
+		//Add the <li> to our list.
+		$('controlListItems').adopt(li);
+		//We have to add the list item to our Sortable object so it's sortable.
+		sort.addItems(li);
+		//We put the new order inside of the data div. Function defined in sortable.js
+		showNewOrder();	
+	}
+	/*loop through options, get by class listValueUpdated and valueUpdated
+	saved all the changed class options*/
+	map.controls[ID].title = valName; //Set the name in the map object to the value of toolbox 2's name form
+	var updatedLists = $$('.listValueUpdated, .valueUpdated') //Get all the elements that have been updated
+	for (var i = 0; i < updatedLists.length; i++){
+		var list = updatedLists[i].name; //The name attribute of the element
+		if(updatedLists[i].selectedIndex != undefined) //If the current item is a select list
+			var val = updatedLists[i].options[updatedLists[i].selectedIndex].value; //The value attribute of the element
+		else if(updatedLists[i].value != undefined)
+			var val = updatedLists[i].value; //The current item is a text box
+		map.controls[ID][list] = val //Add the properties to the current map layer
+	}
+	
+	/*Update the name and layer type*/
+	map.controls[ID].title = valName
+	map.controls[ID].CLASS_NAME = 'OpenLayers.Control.' + $('tb2ControlListDropdown').value	
+	
+		
+	/*Clear the layer editing options*/
+	//add the empty html to the toolbox
+	$('toolBox2Content').innerHTML = getEmptyToolBox2HTML("none", "Control"); 
+	
+	/*Highlist the layer in the layer list that was saved*/
+	$('tb1Control' + ID).highlight('#bcb8ad');
+	
+	/*Update the layer name in the layer list*/
+	var controlName = map.controls[ID].CLASS_NAME;
+	controlName = controlName.replace("OpenLayers.Control.", "");
+	if(map.controls[ID].title == "" || map.controls[ID].title == null)
+		var controlTitle = "";
+	else
+		var controlTitle = " - " + map.controls[ID].title;
+	
+	$('tb1Control' + ID).set('text',controlName + controlTitle);
+	$('tb1Control' + ID).set('title','Control - ' + map.controls[ID].title);
+	
+	if(isControlNew == true){
+	/*If a new layer is being added, do not clear the HTML when the delete button is pressed*/		
+		controlsLength++; //A layer has been created, so add 1 to the layersLength (global var to keep track of number of layers
+		numActiveLayers++; //Add one to the number of active layers
+	}
+	
+	/*Create the delete text and edit button*/
+//	addDelEditOptionsToLayerListItem(ID);	
+	
+	/*Update the height*/
+	layerToggle.show();
+}
 
+
 /*=======================
 |  changeLayer(controlList, ID, controlName, isControlNew)
 |



More information about the Commits mailing list