[OpenLayers-Commits] r7507 - sandbox/architect/scripts
commits at openlayers.org
commits at openlayers.org
Mon Jul 14 16:25:00 EDT 2008
Author: architect
Date: 2008-07-14 16:25:00 -0400 (Mon, 14 Jul 2008)
New Revision: 7507
Modified:
sandbox/architect/scripts/controlConfig.js
Log:
Modified: sandbox/architect/scripts/controlConfig.js
===================================================================
--- sandbox/architect/scripts/controlConfig.js 2008-07-14 19:13:44 UTC (rev 7506)
+++ sandbox/architect/scripts/controlConfig.js 2008-07-14 20:25:00 UTC (rev 7507)
@@ -88,7 +88,39 @@
});
});
+/*=======================
+| addDelEditOptionsToLayerListItem
+=========================*/
+function addDelEditOptionsToControlListItem(ID){
+ /*edit function*/
+ $('tb1Control' + ID).innerHTML += "<div id='tbControlOptionContainer'>"
+ +" <div id='tbControlEditDiv" + ID + "Edit' class='tbControlEditDiv' >Edit</div>"
+ +" <div class='tbControlDeleteDiv' ><img id='tb1Control" + ID + "Delete' src='images/close.png' alt='Delete control'/></div>"
+ +" </div>";
+ var curEdit = 'tbControlEditDiv' + ID + 'Edit';
+ var curListItem = "tb1Control" + ID;
+ console.log(curEdit)
+ $(curEdit).addEvent('click', function(e) {
+ $('tb1Control' + ID).highlight('#bcb8ad');
+ editControl(ID); //The title contains the value of controlsLength, i.e. the number used in the Element's ID to uniquly identify it
+ });
+
+ /*delete function*/
+ var curDelete = 'tb1Control' + ID + 'Delete';
+ var curListItem = "tb1Control" + ID;
+ $(curDelete).addEvent('click', function(e) {
+ var elName = $('controlListItems').get('title')
+ if(elName == "editMode")
+ $('toolBox2Content').innerHTML = getEmptyToolBox2HTML("none", "Control"); //hide the toolbox
+ $(curListItem).dispose(); //Remove the current LI element
+ numActiveControls--; //Decrease the number of active controls by 1
+ map.controls[ID] = null; // empty the current control object
+ controlToggle.show(); //update the height
+ });
+}
+
+
/*=======================
| createBaseControlConfig
|
@@ -130,10 +162,51 @@
/*set the Delete div's name to newMode, which means don't delete toolbox 2's content if the layer delete button has been pressed*/
$('controlListItems').set('title', 'newMode');
-
+}
+
+
+/*=======================
+| editControl
+|
+|called when the dom is ready and the new layer button is clicked
+|
+|sets up a new layer in the global map object and populates toolbox 2 with empty input boxes
+=========================*/
+function editControl(ID){
+/*store the toolbox div in tbid (toolboxid)*/
+ var tbid = $('toolBox2Content');
+ var tb1SelectedControl = $('tb1ControlListDropdown');
+ var tb1SelectedPanel = $('tb1ControlListPanelDropdown');
+
+/*get title*/
+ var controlTitle = map.controls[ID].CLASS_NAME;
+ controlTitle = controlTitle.replace("OpenLayers.Control.", "");
+
+/*add the html to the toolbox*/
+ tbid.innerHTML = getEmptyToolBox2HTML("block", "Control");
+
+/*Create the control list dropdown in Toolbox 2, called tb2controlListDropdown'*/
+ $('tb2blcBase').innerHTML += "Control Selected " + createSelectList('tb2ControlListDropdown', 'Control Picklist', 'changeControl(this, ' + ID + ',\"' + tb1SelectedControl.value + '\", true );', getControlListMenu()); //Layer List Dropdown
+ /*Set the value of the controlList dropdown in toolbox2 to the value of the dropdown in toolbox1*/
+ $('tb2ControlListDropdown').value = tb1SelectedControl.value;
+
+
+ console.log(controlTitle);
+ eval("loadControl" + controlTitle + "();"); //Call the loadLayerConfig function;
+//pass in the ID and false (don't get values from openlayers)
+ populateControlValues(ID, controlTitle, false); //get data from the map object and fill in the inp
+
+
+ /*Create the save and reset buttons*/
+ $('tb2blcButtons').innerHTML += "<br /><br /><input id='resetButton' onclick='populateControlValues( " + ID + ", \"" + tb1SelectedControl.value + "\", true);'type='button' value='Reset'/><input id='saveButton' type='button' class='" + ID + "' value='Save' onclick='saveControlConfig(" + ID + ", false);'><br />"; //Save Button
+
+ /*Set the the name to "editMode", this allows us to determine if we should clear toolbox2's content or not. If the name = editMode, then we should clear toolbox2 once the layer delete button has been pressed*/
+ $('layerListItems').set('title', 'editMode');
}
+
+
/*=======================
| saveControlConfig(ID, isControlNew)
|
@@ -210,14 +283,258 @@
}
/*Create the delete text and edit button*/
-// addDelEditOptionsToLayerListItem(ID);
+ addDelEditOptionsToControlListItem(ID);
/*Update the height*/
layerToggle.show();
}
+
+
+
/*=======================
+| populateControlValues(ID, controlName, isControlNew)
+|
+|used to fill in default values from OpenLayers.prototype or values stored in the map object, if the layer already exists
+|
+|ID is the id of the current layer - an integer
+|controlName is the name of the layer service which coresponds with OpenLayers.Control.controlName.prototype
+|isControlNew determines if the layer is a newly created one or already exists
+=========================*/
+/*Warning:Confusion follows*/
+/*Because some values in OL are set as 'false' by default we check to see if the prototype != null*/
+function populateControlValues(ID, controlName, isControlNew,type){
+ /*by default, we assuse the isControlNew is "new"*/
+ if(isControlNew == undefined || isControlNew == null)
+ isControlNew = true;
+
+
+ var elName = $('layerListItems').get('title')
+ if(elName == "editMode"){
+ if($('tb2ControlListDropdown').value == controlName)
+ isControlNew = false;
+ }
+ /*pull values from OpenLayers*/
+ if(isControlNew == true){
+ /*Loop through the common values*/
+ var curDropDownVal = $('tb2ControlListDropdown').value;
+ for (var i = 0; i < $('tb2blcCommon').childNodes.length; i++){
+ /*set a variable equal to the current node*/
+ var tempNode = $('tb2blcCommon').childNodes[i];
+ /*if the childnode has an ID, then it is an input which we will get a value from to put in the map object*/
+ if (tempNode.type == "text"){
+ //By default, set the value to nothing. If something exists, override the null value
+ tempNode.value = '';
+ /*Get the map name value*/
+ /*Check the DEFAULT_PARAMS and everything else*/
+ if (OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS != null){
+ if(OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS[tempNode.name] != null)
+ tempNode.value = OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS[tempNode.name];
+ }
+ if(OpenLayers.Control[curDropDownVal].prototype[tempNode.name] != null){
+ tempNode.value = OpenLayers.Control[curDropDownVal].prototype[tempNode.name];
+ }
+ $(tempNode).erase('class'); //clear the ValueUpdated class - it won't think the value is updated
+ }
+ /* SELECT LIST*/
+ else if(tempNode.type == "select-one" ){
+ //By default, set the value to 0. Override the value is necessary
+ tempNode.selectedIndex = 0;
+ if (OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS != null || OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS != undefined){
+ if(OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS[tempNode.name] != null){
+ var olVal = OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS[tempNode.name];
+ /*check for True / False lists*/
+ if(tempNode.options[0].value == "True" || tempNode.options[0].value == "False"){
+ if( Boolean(tempNode.options[0].name) == olVal)
+ tempNode.selectedIndex = 0;
+ if( Boolean(tempNode.options[1].name) == olVal)
+ tempNode.selectedIndex = 1;
+ }
+ /*check for Jpg / Gif / Png, and other type of lists*/
+ else{
+ if(tempNode.options[0].value == olVal)
+ tempNode.selectedIndex = 0;
+ if(tempNode.options[1].value == olVal)
+ tempNode.selectedIndex = 1;
+ if(tempNode.options[2]){
+ if(tempNode.options[2].value == olVal)
+ tempNode.selectedIndex = 2;
+ }
+ if(tempNode.options[3]){
+ if(tempNode.options[3].value == olVal)
+ tempNode.selectedIndex = 3;
+ }
+ }
+ }
+ }
+ if(OpenLayers.Control[curDropDownVal].prototype[tempNode.name] != null){
+ var olVal = OpenLayers.Control[curDropDownVal].prototype[tempNode.name];
+ /*check for True / False lists*/
+ if(tempNode.options[0].value == "True" || tempNode.options[0].value == ''){
+ if( Boolean(tempNode.options[0].name) == olVal){
+ tempNode.selectedIndex = 0;
+ }
+ if( Boolean(tempNode.options[1].name) == olVal){
+ tempNode.selectedIndex = 1;
+ }
+ }
+ /*check for Jpg / Gif / Png, and other type of lists*/
+ else{
+ if(tempNode.options[0].value == olVal)
+ tempNode.selectedIndex = 0;
+ if(tempNode.options[1].value == olVal)
+ tempNode.selectedIndex = 1;
+ if(tempNode.options[2]){
+ if(tempNode.options[2].value == olVal)
+ tempNode.selectedIndex = 2;
+ }
+ if(tempNode.options[3]){
+ if(tempNode.options[3].value == olVal)
+ tempNode.selectedIndex = 3;
+ }
+ }
+ $(tempNode).erase('class'); //clear the ValueUpdated class - it won't think the value is updated
+ }
+ }
+ }
+
+ /*CHECK ADVANCED*/
+ for (var i = 0; i < $('tb2blcAdvanced').childNodes.length; i++){
+ /*set a variable equal to the current node*/
+ var tempNode = $('tb2blcAdvanced').childNodes[i];
+ /*if the childnode has an ID, then it is an input which we will get a value from to put in the map object*/
+ if (tempNode.type == "text"){
+ //By default, set the value to nothing. If something exists, override the null value
+ tempNode.value = '';
+ /*Get the map name value*/
+ /*Check the DEFAULT_PARAMS and everything else*/
+ if (OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS != null){
+ if(OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS[tempNode.name] != null)
+ tempNode.value = OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS[tempNode.name];
+ }
+ if(OpenLayers.Control[curDropDownVal].prototype[tempNode.name] != null){
+ tempNode.value = OpenLayers.Control[curDropDownVal].prototype[tempNode.name];
+
+ }
+ $(tempNode).erase('class'); //clear the ValueUpdated class - it won't think the value is updated
+ }
+
+ /* SELECT LIST*/
+ else if(tempNode.type == "select-one" ){
+ //By default, set the value to 0. Override the value is necessary
+ tempNode.selectedIndex = 0;
+ if (OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS != null || OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS != undefined){
+ if(OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS[tempNode.name] != null){
+ var olVal = OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS[tempNode.name];
+ /*check for True / False lists*/
+ if(tempNode.options[0].value == "True" || tempNode.options[0].value == "False"){
+ if( Boolean(tempNode.options[0].name) == olVal)
+ tempNode.selectedIndex = 0;
+ if( Boolean(tempNode.options[1].name) == olVal)
+ tempNode.selectedIndex = 1;
+ }
+ /*check for Jpg / Gif / Png, and other type of lists*/
+ else{
+ if(tempNode.options[0].value == olVal)
+ tempNode.selectedIndex = 0;
+ if(tempNode.options[1].value == olVal)
+ tempNode.selectedIndex = 1;
+ if(tempNode.options[2]){
+ if(tempNode.options[2].value == olVal)
+ tempNode.selectedIndex = 2;
+ }
+ if(tempNode.options[3]){
+ if(tempNode.options[3].value == olVal)
+ tempNode.selectedIndex = 3;
+ }
+ }
+ }
+ }
+ if(OpenLayers.Control[curDropDownVal].prototype[tempNode.name] != null){
+ var olVal = OpenLayers.Control[curDropDownVal].prototype[tempNode.name];
+ /*check for True / False lists*/
+ if(tempNode.options[0].value == "True" || tempNode.options[0].value == ''){
+ if( Boolean(tempNode.options[0].name) == olVal){
+ tempNode.selectedIndex = 0;
+ }
+ if( Boolean(tempNode.options[1].name) == olVal){
+ tempNode.selectedIndex = 1;
+ }
+ }
+ /*check for Jpg / Gif / Png, and other type of lists*/
+ else{
+ if(tempNode.options[0].value == olVal)
+ tempNode.selectedIndex = 0;
+ if(tempNode.options[1].value == olVal)
+ tempNode.selectedIndex = 1;
+ if(tempNode.options[2]){
+ if(tempNode.options[2].value == olVal)
+ tempNode.selectedIndex = 2;
+ }
+ if(tempNode.options[3]){
+ if(tempNode.options[3].value == olVal)
+ tempNode.selectedIndex = 3;
+ }
+ }
+ $(tempNode).erase('class'); //clear the ValueUpdated class - it won't think the value is updated
+ }
+ }
+ }
+
+
+
+ }
+
+ /*If the layer is not new, grab values from the map object*/
+ if(isControlNew == false){
+ /*Loop through the common values*/
+ for (var i = 0; i < $('tb2blcCommon').childNodes.length; i++){
+ /*set a variable equal to the current node*/
+ var tempNode = $('tb2blcCommon').childNodes[i];
+ /*if the childnode has an ID, then it is an input which we will get a value from to put in the map object*/
+ if (tempNode.type == "text" || tempNode.type == "select-one" ){
+ /*Get the map name value*/
+ var mapLayerVal = map.controls[ID][tempNode.name];
+ /*If there is valid data, fill in the current form*/
+ if(mapLayerVal != undefined || mapLayerVal != null){
+ tempNode.value = map.controls[ID][tempNode.name];
+ }
+ else{
+ tempNode.value = '';
+ if(tempNode.type == "select-one" )
+ tempNode.selectedIndex = 0;
+ $(tempNode).erase('class'); //clear the class - it won't think the value is updated
+ }
+ }
+ }
+ /*Loop through the advanced values*/
+ for (var i = 0; i < $('tb2blcAdvanced').childNodes.length; i++){
+ /*set a variable equal to the current node*/
+ var tempNode = $('tb2blcAdvanced').childNodes[i];
+ /*if the childnode has an ID, then it is an input which we will get a value from to put in the map object*/
+ if (tempNode.type == "text" || tempNode.type == "select-one"){
+ /*Get the map name value*/
+ var mapLayerVal = map.controls[ID][tempNode.name];
+ /*If there is valid data, fill in the current form*/
+ if(mapLayerVal != undefined || mapLayerVal != null){
+ tempNode.value = map.controls[ID][tempNode.name];
+ }
+ else{
+ tempNode.value = '';
+ if(tempNode.type == "select-one" )
+ tempNode.selectedIndex = 0;
+ $(tempNode).erase('class'); //clear the class - it won't think the value is updated
+ }
+ }
+ }
+ }
+}
+
+
+
+
+/*=======================
| changeLayer(controlList, ID, controlName, isControlNew)
|
|Called when the layer list drop down menu is changed and also when a new layer is created to populate toolbox2
@@ -246,16 +563,16 @@
$('tb2blcAdvanced').innerHTML = "";
if($(controlList).selectedIndex == 1){
- loadControlButtonConfig();
+ loadControlButton();
}
if($(controlList).selectedIndex == 2){
loadControlEditingToolbar();
}
if($(controlList).selectedIndex == 3){
- loadControlLayerSwitcherConfig();
+ loadControlLayerSwitcher();
}
if($(controlList).selectedIndex == 4){
- loadControlMousePositionConfig();
+ loadControlMousePosition();
}
if($(controlList).selectedIndex == 5){
loadControlNavigationHistory();
@@ -283,7 +600,7 @@
}
/*Fill in default values*/
- //populateControlValues(ID, controlName, isControlNew);
+ populateControlValues(ID, controlName, isControlNew);
/*if the layer service in the drop down matches the passed in name, do not populate the fields with the default values
if($('tb2controlListDropdown').value == controlName){
@@ -295,7 +612,7 @@
-Belongs to a panel
-Has a trigger...provide the ability to input a function?
*/
-function loadControlButtonConfig(){
+function loadControlButton(){
/*Check to see if the control has a panel*/
var selTitle = $('tb2ControlListDropdown').options[$('tb2ControlListDropdown').selectedIndex].title
@@ -334,7 +651,7 @@
TODO - controls
*/
-function loadControlLayerSwitcherConfig(){
+function loadControlLayerSwitcher(){
/*Check to see if the control has a panel*/
var selTitle = $('tb2ControlListDropdown').options[$('tb2ControlListDropdown').selectedIndex].title
@@ -354,7 +671,7 @@
TODO - Change Color?
*/
-function loadControlMousePositionConfig(){
+function loadControlMousePosition(){
/*Check to see if the control has a panel*/
var selTitle = $('tb2ControlListDropdown').options[$('tb2ControlListDropdown').selectedIndex].title
More information about the Commits
mailing list