Project

General

Profile

1
 /*
2
  *   '$RCSfile$'
3
  *     Purpose: Default style sheet for KNB project web pages 
4
  *              Using this stylesheet rather than placing styles directly in 
5
  *              the KNB web documents allows us to globally change the 
6
  *              formatting styles of the entire site in one easy place.
7
  *   Copyright: 2000 Regents of the University of California and the
8
  *               National Center for Ecological Analysis and Synthesis
9
  *     Authors: Matt Jones
10
  *
11
  *    '$Author: leinfelder $'
12
  *      '$Date: 2008-02-21 10:01:50 -0800 (Thu, 21 Feb 2008) $'
13
  *  '$Revision: 3728 $'
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

    
31
/**
32
 *  NOTE: THIS SCRIPT EXPECTS YOU ALREADY TO HAVE IMPORTED THE FOLLOWING 
33
 *  VARIABLES, WHICH ARE TYPICALLY DEFINED IN style/skins/qformat/qformat.js:
34
 *
35
 *   Location of the header that will be displayed at the top of the page
36
 *  HEADER_URL 
37
 *
38
 *   Location of the header that will be displayed at the top of the page
39
 *  LEFTCOL_URL 
40
 *
41
 *   Location of the header that will be displayed at the top of the page
42
 *  RIGHTCOL_URL 
43
 *
44
 *   Location of the header that will be displayed at the top of the page
45
 *  FOOTER_URL 
46
 *
47
 * header iframe class
48
 *  IFRAME_HEADER_CLASS
49
 *
50
 * left column iframe class
51
 *  IFRAME_LEFTCOL_CLASS
52
 *
53
 * right column iframe class
54
 *  IFRAME_RIGHTCOL_CLASS
55
 *
56
 * footer iframe class
57
 *  IFRAME_FOOTER_CLASS
58
 *
59
 * entire table class
60
 *  TEMPLATE_TABLE_CLASS
61
 *
62
 * header table-cell class. Note you should not set css "width" on this, since it 
63
 * includes a colspan
64
 *  TEMPLATE_HEADERROW_CLASS
65
 *
66
 * left column table-cell class. Note that restricting css "height" on this may 
67
 * affect visibility of the main content, since it's in the same table row 
68
 *  TEMPLATE_LEFTCOL_CLASS
69
 *
70
 * main central content table-cell class. Note that css attributes set here may 
71
 * apply to the content nested inside this cell
72
 *  TEMPLATE_CONTENTAREA_CLASS
73
 *
74
 * rigth column table-cell class. Note that restricting css "height" on this may 
75
 * affect visibility of the main content, since it's in the same table row 
76
 *  TEMPLATE_RIGHTCOL_CLASS
77
 *
78
 * footer table-cell class. Note you should not set "width" on this, since it 
79
 * includes a colspan
80
 *  TEMPLATE_FOOTERROW_CLASS
81
 */
82
 
83
function prependUrl(prefix, path) {
84

    
85
	var retUrl = path;
86
	if ( !_isBlank(path) ) {
87
		if ( !_isBlank(prefix) ) {
88
			if (path.indexOf("http") < 0) {
89
				retUrl = prefix + "/" + path;
90
			}
91
		}
92
	}
93
	return retUrl;
94
}
95

    
96

    
97
/**
98
 *  inserts the first half of the template table that surrounds the page's'
99
 *  content, including the the optional header and left column areas
100
 *  referenced by the HEADER_URL and LEFTCOL_URL settings
101
 */
102
function insertTemplateOpening(serverContextUrl) {
103

    
104
  //table opening tag
105
  document.write("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" "
106
                                  +" class=\""+TEMPLATE_TABLE_CLASS+"\">");
107
  //first row is header
108
  document.write("<tr><td "+_getColSpanString()+" class=\""+TEMPLATE_HEADERROW_CLASS+"\">");
109

    
110
  //make any relative paths into absolute paths
111
  HEADER_URL = prependUrl(serverContextUrl, HEADER_URL);
112
	
113
  //content for the header (if any)
114
  _createIFrameWithURL(HEADER_URL, IFRAME_HEADER_CLASS);
115

    
116
  document.write("</td></tr><tr>");
117

    
118
  //content for the left column (if any)
119
  if (!_isBlank(LEFTCOL_URL)) {
120

    
121
    document.write("<td class=\""+TEMPLATE_LEFTCOL_CLASS+"\">");
122

    
123
	//make any relative paths into absolute paths
124
	LEFTCOL_URL = prependUrl(serverContextUrl, LEFTCOL_URL);
125
  
126
    _createIFrameWithURL(LEFTCOL_URL, IFRAME_LEFTCOL_CLASS);
127

    
128
    document.write("</td>");
129
  }
130

    
131
  //main content area
132
  document.write("<td class=\""+TEMPLATE_CONTENTAREA_CLASS+"\">");
133
}
134

    
135
/**
136
 *  inserts the last half of the template table that surrounds the page's'
137
 *  content, including the optional right column and footer areas
138
 *  referenced by the RIGHTCOL_URL and FOOTER_URL settings
139
 */
140
function insertTemplateClosing(serverContextUrl) {
141

    
142
  //right column
143
  document.write("</td>");
144

    
145
  //content for the right column (if any)
146
  if (!_isBlank(RIGHTCOL_URL)) {
147

    
148
    document.write("<td class=\""+TEMPLATE_RIGHTCOL_CLASS+"\">");
149

    
150
	//make any relative paths into absolute paths
151
	RIGHTCOL_URL = prependUrl(serverContextUrl, RIGHTCOL_URL);
152
	
153
    _createIFrameWithURL(RIGHTCOL_URL, IFRAME_RIGHTCOL_CLASS);
154

    
155
    document.write("</td>");
156
  }
157

    
158
  //last row is footer
159
  document.write("</tr><tr><td "+_getColSpanString()+" class=\""
160
                                              +TEMPLATE_FOOTERROW_CLASS+"\">");
161

    
162
  //make any relative paths into absolute paths
163
  FOOTER_URL = prependUrl(serverContextUrl, FOOTER_URL);
164
	
165
  //content for the footer (if any)
166
  _createIFrameWithURL(FOOTER_URL, IFRAME_FOOTER_CLASS);
167

    
168
  //close table
169
  document.write("</td></tr></table>");
170

    
171
}
172

    
173

    
174
/**
175
 *  inserts the header referenced by the SEARCHBOX_URL setting
176
 */
177
function insertSearchBox(serverContextUrl) { 
178

    
179
  if (!_isBlank(SEARCHBOX_URL)) {
180
  
181
	//make any relative paths into absolute paths
182
	SEARCHBOX_URL = prependUrl(serverContextUrl, SEARCHBOX_URL);
183

    
184
    _createIFrameWithURL(SEARCHBOX_URL, IFRAME_SEARCHBOX_CLASS);
185
  }
186

    
187
}
188

    
189

    
190
/**
191
 *  inserts the header referenced by the SEARCHBOX_URL setting
192
 */
193
function insertMap(serverContextUrl) { 
194

    
195
  if (!_isBlank(MAP_URL)) {
196
  	//make any relative paths into absolute paths
197
	MAP_URL = prependUrl(serverContextUrl, MAP_URL);
198

    
199
    _createIFrameWithURL(MAP_URL, IFRAME_MAP_CLASS);
200
  }
201

    
202
}
203

    
204
/**
205
 *  inserts the header referenced by the ADVANCED_SEARCHBOX_URL setting
206
 */
207
function insertAdvancedSearchBox(serverContextUrl) { 
208

    
209
  if (!_isBlank(ADVANCED_SEARCHBOX_URL)) {
210
	//make any relative paths into absolute paths
211
	ADVANCED_SEARCHBOX_URL = prependUrl(serverContextUrl, ADVANCED_SEARCHBOX_URL);
212
	
213
    _createIFrameWithURL(ADVANCED_SEARCHBOX_URL, IFRAME_ADVANCED_SEARCHBOX_CLASS);
214
  }
215

    
216
}
217

    
218
/**
219
 *  inserts the header referenced by the LOGINBOX_URL setting
220
 */
221
function insertLoginBox(serverContextUrl) { 
222

    
223
  if (!_isBlank(LOGINBOX_URL)) {
224
  
225
  	//make any relative paths into absolute paths
226
	LOGINBOX_URL = prependUrl(serverContextUrl, LOGINBOX_URL);
227

    
228
    _createIFrameWithURL(LOGINBOX_URL, IFRAME_LOGINBOX_CLASS);
229
  }
230

    
231
}
232

    
233

    
234
/**
235
 *  inserts an iframe into the document and assigns it the passed source URL
236
 *  and class attribute
237
 */
238
function _createIFrameWithURL(targetURL, cssClass) {
239

    
240

    
241
  if (_isBlank(targetURL)) {
242

    
243
    document.write("&nbsp;");
244

    
245
  } else {
246

    
247
    document.write("<iframe src=\""+targetURL+"\" class=\""+cssClass+"\" "
248
                  +" id=\"" + cssClass + "\""
249
                  +" name=\"" + cssClass + "\""
250
				  + "\" marginwidth=\"0\" scrolling=\"no\" "
251
                  +" marginheight=\"0\" marginwidth=\"0\" scrolling=\"no\" "
252
                  +" border=\"0\" frameborder=\"0\" framespacing=\"0\" "
253
                  +" hspace=\"0\" vspace=\"0\">Your browser does not support"
254
                  +" the iframe tag. <a href=\""+targetURL+"\" "
255
                  +"target=\"_blank\">This content</a>"
256
                  +" should have been displayed at this location</iframe>");
257
  }
258
}
259

    
260

    
261

    
262
function _isBlank(testString) {
263

    
264
  return (  !testString
265
          || testString==null
266
          || (testString.replace(/^\s*/, '').replace(/\s*$/,'')==""));
267
}
268

    
269

    
270
function _getColSpanString() {
271

    
272
  var colspan = 1;
273
  if (!_isBlank(LEFTCOL_URL))  colspan++;
274
  if (!_isBlank(RIGHTCOL_URL)) colspan++;
275
  if (colspan==1) return "";
276
  else return " colspan=\""+colspan+"\" ";
277
} 
278

    
279
function submitbrowseform(action,form_ref) {
280
  form_ref.action.value=action;
281
  form_ref.submit();
282
}
(4-4/20)