Project

General

Profile

1
 /*
2
  *   '$RCSfile$'
3
  *     Purpose: Default style sheet for KNP project web pages 
4
  *              Using this stylesheet rather than placing styles directly in 
5
  *              the KNP web documents allows us to globally change the 
6
  *              formatting styles of the entire site in one easy place.
7
  *   Copyright: 2009 Regents of the University of California and the
8
  *               National Center for Ecological Analysis and Synthesis
9
  *     Authors: Matt Jones
10
  *
11
  *    '$Author: daigle $'
12
  *      '$Date: 2008-07-06 21:25:34 -0700 (Sun, 06 Jul 2008) $'
13
  *  '$Revision: 4080 $'
14
  *
15
  * This program is free software; you can redistribute it and/or modify
16
  * it under the terms of the GNU General Public License as published by
17
  * the Free Software Foundation; either version 2 of the License, or
18
  * (at your option) any later version.
19
  *
20
  * This program is distributed in the hope that it will be useful,
21
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
  * GNU General Public License for more details.
24
  *
25
  * You should have received a copy of the GNU General Public License
26
  * along with this program; if not, write to the Free Software
27
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
  */
29

    
30
var lastInputIndex = 0;
31
 
32
function submitFormIntoDiv(url, formId, divId) {
33
	//alert('Sending form: ' + formId + " to url: " + url);
34
	var formObj = document.getElementById(formId);
35

    
36
	var myRequest = new Ajax.Updater(divId, url,
37
		{	method: 'post',
38
			parameters: Form.serialize(formObj),
39
		});
40
}
41
 
42
function getSearchModeList(searchModeString) {
43
	var abbrevArray = searchModeString.split('|');
44
	var smArray = new Array();
45
	
46
	for (i = 0; i < abbrevArray.length; i++) {
47
		if (abbrevArray[i] == 'co') {
48
			smArray.push(new Array('contains', 'contains','Contains'));
49
		} else if (abbrevArray[i] == 'sw') {
50
			smArray.push(new Array('starts-with', 'starts with', 'Starts With'));
51
		} else if (abbrevArray[i] == 'ew') {
52
			smArray.push(new Array('ends-with', 'ends with', 'Ends With'));
53
		} else if (abbrevArray[i] == 'eq') {
54
			smArray.push(new Array('equals', 'equals', 'Equals'));
55
		} else if (abbrevArray[i] == 'ne') {
56
			smArray.push(new Array('isnot-equal', 'is not equal', 'Is Not Equal'));
57
		} else if (abbrevArray[i] == 'gt') {
58
			smArray.push(new Array('greater-than', 'is greater than', 'Is Greater Than'));
59
		} else if (abbrevArray[i] == 'lt') {
60
			smArray.push(new Array('less-than', 'is less than', 'Is Less Than'));
61
		} else if (abbrevArray[i] == 'ge') {
62
			smArray.push(new Array('greater-than-equals', 'is greater than or equal to', 'Is Greater Than Or Equal To'));
63
		} else if (abbrevArray[i] == 'le') {
64
			smArray.push(new Array('less-than-equals', 'is less than or equal to', 'Is Less Than Or Equal To'));
65
		} else if (abbrevArray[i] == 'af') {
66
			smArray.push(new Array('greater-than', 'is after', 'Is After'));
67
		} else if (abbrevArray[i] == 'be') {
68
			smArray.push(new Array('less-than', 'is before', 'Is Before'));
69
		} else if (abbrevArray[i] == 'is') {
70
			smArray.push(new Array('equals', 'is', 'Is'));
71
		} else if (abbrevArray[i] == 'in') {
72
			smArray.push(new Array('isnot-equal', 'is not', 'Is Not'));
73
		}
74
	}
75
	
76
	return smArray;	
77
}
78
   
79
function addSearchDropdown(formName, inputLabel, inputIdBase, inputName, searchModes) {
80
	
81
	var formObj = document.getElementById(formName);
82
	var newdiv = document.createElement('div');
83
	var searchModeArray = getSearchModeList(searchModes);
84
  
85
  	var innerHtml = "";
86
	innerHtml += '    <div class="field-label dropdown-field-label">' + inputLabel + '</div>';
87
	innerHtml += '    <select class="dropdown-input" name="dd-' + inputIdBase + lastInputIndex + '">';
88
	for (i = 0; i < searchModeArray.length; i++ ) {
89
		innerHtml += '      <option value="' + searchModeArray[i][0] + '">' + searchModeArray[i][1] + '</option>';
90
	}
91
	innerHtml += '    </select>';
92
	innerHtml += '    <input class="text-input" id="tx-' + inputIdBase + lastInputIndex + '" name="' + inputName + '" type="text"/>';
93
	innerHtml += '  </div>' 
94

    
95
	newdiv.setAttribute('class','content-subsection');
96
	newdiv.innerHTML = innerHtml;
97
	formObj.appendChild(newdiv);
98
  
99
  	lastInputIndex++;
100
}
101

    
102
function addSearchDropdownBefore(formId, inputLabel, inputName,  searchModes, beforeElementId) {
103
	// alert('in addDropdownInputBefore - formId: ' + formId + ' inputLabel: ' + inputLabel + ' inputName: ' + inputName + ' searchModes: ' + searchModes + ' beforeElementId: ' + beforeElementId);
104
	var formObj = document.getElementById(formId);
105
	var beforeObj = document.getElementById(beforeElementId);
106
	var newDiv = document.createElement('div');
107
	var searchModeArray = getSearchModeList(searchModes);
108
  
109
  	var innerHtml = '';
110
	innerHtml += '    <div class="field-label dropdown-field-label">' + inputLabel + '</div>';
111
	innerHtml += '    <select class="dropdown-input" id="sm-' + inputName + lastInputIndex + '">';
112
	for (i = 0; i < searchModeArray.length; i++ ) {
113
		innerHtml += '      <option value="' + searchModeArray[i][0] + '">' + searchModeArray[i][1] + '</option>';
114
	}
115
	innerHtml += '    </select>';
116
	innerHtml += '    <input class="text-input" id="sf-' + inputName + lastInputIndex + '" name="' + inputName + '" type="text"/>';
117
	innerHtml += '    <input class="field-remove-button" type="button" value="-" onclick="removeInput(\''+ formId + '\',\'cs-' + inputName + lastInputIndex + '\')"/>';     
118
	innerHtml += '</div>';   
119
	//alert('innerHtml: ' + innerHtml); 								
120

    
121
	// alert('formObj:' + formObj);
122
	newDiv.setAttribute('id', 'cs-' + inputName + lastInputIndex);
123
	newDiv.setAttribute('class', 'form-input-row');
124
	newDiv.innerHTML = innerHtml;
125
	// alert('newDiv:' + newDiv);
126
	formObj.insertBefore(newDiv, beforeObj);
127
		
128
	lastInputIndex++;
129
}
130

    
131
function removeInput(formId, inputId) {
132
	//alert('in remove input - formname: ' + formId + ' inputid: ' + inputId);
133
	var formObj = document.getElementById(formId);
134
	var inputObj = document.getElementById(inputId);
135

    
136
	if ((formObj != null) && (inputObj != null)) { 
137
		// alert('removing child: ' + inputObj.toString());
138
		formObj.removeChild(inputObj);
139
	}
140
}
141
  
(2-2/4)