| | 135 | } |
|---|
| | 136 | |
|---|
| | 137 | /*======================= |
|---|
| | 138 | | saveControlConfig(ID, isControlNew) |
|---|
| | 139 | | |
|---|
| | 140 | |called when the save button is pressed |
|---|
| | 141 | | |
|---|
| | 142 | |ID is the id of the current layer - an integer - an integer |
|---|
| | 143 | |isControlNew is either "new" or "edit" - new, if the new layer button has been clicked; edit, if a layer is going to be modified |
|---|
| | 144 | =========================*/ |
|---|
| | 145 | function saveControlConfig(ID, isControlNew){ |
|---|
| | 146 | if ($('tb2ControlListDropdown').selectedIndex == 0) |
|---|
| | 147 | return; //If the layer type is empty, return. We can't have an empty layer service |
|---|
| | 148 | |
|---|
| | 149 | /*if no isControlNew is defined, assume it is a new layer*/ |
|---|
| | 150 | if ( isControlNew == null || isControlNew == undefined) |
|---|
| | 151 | isControlNew = true; |
|---|
| | 152 | |
|---|
| | 153 | |
|---|
| | 154 | //Get the value of the text input. |
|---|
| | 155 | var valName = $('layoutControlConfigTitle').value; |
|---|
| | 156 | console.log(valName); |
|---|
| | 157 | /*The code here will execute if the input is empty. |
|---|
| | 158 | Create a new <li> to hold all our content. |
|---|
| | 159 | Set the title of the LI to the current layersLength value*/ |
|---|
| | 160 | if(isControlNew == true){ |
|---|
| | 161 | var li = new Element('li', {id: 'tb1Control'+ID, title:'Control ' + valName,'class':'drag'}); //onclick=\"editLayer('" + ID + "')\" |
|---|
| | 162 | |
|---|
| | 163 | //Add the <li> to our list. |
|---|
| | 164 | $('controlListItems').adopt(li); |
|---|
| | 165 | //We have to add the list item to our Sortable object so it's sortable. |
|---|
| | 166 | sort.addItems(li); |
|---|
| | 167 | //We put the new order inside of the data div. Function defined in sortable.js |
|---|
| | 168 | showNewOrder(); |
|---|
| | 169 | } |
|---|
| | 170 | /*loop through options, get by class listValueUpdated and valueUpdated |
|---|
| | 171 | saved all the changed class options*/ |
|---|
| | 172 | map.controls[ID].title = valName; //Set the name in the map object to the value of toolbox 2's name form |
|---|
| | 173 | var updatedLists = $$('.listValueUpdated, .valueUpdated') //Get all the elements that have been updated |
|---|
| | 174 | for (var i = 0; i < updatedLists.length; i++){ |
|---|
| | 175 | var list = updatedLists[i].name; //The name attribute of the element |
|---|
| | 176 | if(updatedLists[i].selectedIndex != undefined) //If the current item is a select list |
|---|
| | 177 | var val = updatedLists[i].options[updatedLists[i].selectedIndex].value; //The value attribute of the element |
|---|
| | 178 | else if(updatedLists[i].value != undefined) |
|---|
| | 179 | var val = updatedLists[i].value; //The current item is a text box |
|---|
| | 180 | map.controls[ID][list] = val //Add the properties to the current map layer |
|---|
| | 181 | } |
|---|
| | 182 | |
|---|
| | 183 | /*Update the name and layer type*/ |
|---|
| | 184 | map.controls[ID].title = valName |
|---|
| | 185 | map.controls[ID].CLASS_NAME = 'OpenLayers.Control.' + $('tb2ControlListDropdown').value |
|---|
| | 186 | |
|---|
| | 187 | |
|---|
| | 188 | /*Clear the layer editing options*/ |
|---|
| | 189 | //add the empty html to the toolbox |
|---|
| | 190 | $('toolBox2Content').innerHTML = getEmptyToolBox2HTML("none", "Control"); |
|---|
| | 191 | |
|---|
| | 192 | /*Highlist the layer in the layer list that was saved*/ |
|---|
| | 193 | $('tb1Control' + ID).highlight('#bcb8ad'); |
|---|
| | 194 | |
|---|
| | 195 | /*Update the layer name in the layer list*/ |
|---|
| | 196 | var controlName = map.controls[ID].CLASS_NAME; |
|---|
| | 197 | controlName = controlName.replace("OpenLayers.Control.", ""); |
|---|
| | 198 | if(map.controls[ID].title == "" || map.controls[ID].title == null) |
|---|
| | 199 | var controlTitle = ""; |
|---|
| | 200 | else |
|---|
| | 201 | var controlTitle = " - " + map.controls[ID].title; |
|---|
| | 202 | |
|---|
| | 203 | $('tb1Control' + ID).set('text',controlName + controlTitle); |
|---|
| | 204 | $('tb1Control' + ID).set('title','Control - ' + map.controls[ID].title); |
|---|
| | 205 | |
|---|
| | 206 | if(isControlNew == true){ |
|---|
| | 207 | /*If a new layer is being added, do not clear the HTML when the delete button is pressed*/ |
|---|
| | 208 | controlsLength++; //A layer has been created, so add 1 to the layersLength (global var to keep track of number of layers |
|---|
| | 209 | numActiveLayers++; //Add one to the number of active layers |
|---|
| | 210 | } |
|---|
| | 211 | |
|---|
| | 212 | /*Create the delete text and edit button*/ |
|---|
| | 213 | // addDelEditOptionsToLayerListItem(ID); |
|---|
| | 214 | |
|---|
| | 215 | /*Update the height*/ |
|---|
| | 216 | layerToggle.show(); |
|---|