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: perry $'
12
  *      '$Date: 2006-08-31 16:37:13 -0700 (Thu, 31 Aug 2006) $'
13
  *  '$Revision: 3034 $'
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

    
84

    
85
/**
86
 *  inserts the first half of the template table that surrounds the page's'
87
 *  content, including the the optional header and left column areas
88
 *  referenced by the HEADER_URL and LEFTCOL_URL settings
89
 */
90
function insertTemplateOpening() {
91

    
92
  //table opening tag
93
  document.write("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" "
94
                                  +" class=\""+TEMPLATE_TABLE_CLASS+"\">");
95
  //first row is header
96
  document.write("<tr><td "+_getColSpanString()+" class=\""+TEMPLATE_HEADERROW_CLASS+"\">");
97

    
98
  //content for the header (if any)
99
  _createIFrameWithURL(HEADER_URL, IFRAME_HEADER_CLASS);
100

    
101
  document.write("</td></tr><tr>");
102

    
103
  //content for the left column (if any)
104
  if (!_isBlank(LEFTCOL_URL)) {
105

    
106
    document.write("<td class=\""+TEMPLATE_LEFTCOL_CLASS+"\">");
107

    
108
    _createIFrameWithURL(LEFTCOL_URL, IFRAME_LEFTCOL_CLASS);
109

    
110
    document.write("</td>");
111
  }
112

    
113
  //main content area
114
  document.write("<td class=\""+TEMPLATE_CONTENTAREA_CLASS+"\">");
115
}
116

    
117
/**
118
 *  inserts the last half of the template table that surrounds the page's'
119
 *  content, including the optional right column and footer areas
120
 *  referenced by the RIGHTCOL_URL and FOOTER_URL settings
121
 */
122
function insertTemplateClosing() {
123

    
124
  //right column
125
  document.write("</td>");
126

    
127
  //content for the right column (if any)
128
  if (!_isBlank(RIGHTCOL_URL)) {
129

    
130
    document.write("<td class=\""+TEMPLATE_RIGHTCOL_CLASS+"\">");
131

    
132
    _createIFrameWithURL(RIGHTCOL_URL, IFRAME_RIGHTCOL_CLASS);
133

    
134
    document.write("</td>");
135
  }
136

    
137
  //last row is footer
138
  document.write("</tr><tr><td "+_getColSpanString()+" class=\""
139
                                              +TEMPLATE_FOOTERROW_CLASS+"\">");
140

    
141
  //content for the footer (if any)
142
  _createIFrameWithURL(FOOTER_URL, IFRAME_FOOTER_CLASS);
143

    
144
  //close table
145
  document.write("</td></tr></table>");
146

    
147
}
148

    
149

    
150
/**
151
 *  inserts the header referenced by the SEARCHBOX_URL setting
152
 */
153
function insertSearchBox() { 
154

    
155
  if (!_isBlank(SEARCHBOX_URL)) {
156

    
157
    _createIFrameWithURL(SEARCHBOX_URL, IFRAME_SEARCHBOX_CLASS);
158
  }
159

    
160
}
161

    
162

    
163
/**
164
 *  inserts the header referenced by the SEARCHBOX_URL setting
165
 */
166
function insertMap() { 
167

    
168
  if (!_isBlank(MAP_URL)) {
169

    
170
    _createIFrameWithURL(MAP_URL, IFRAME_MAP_CLASS);
171
  }
172

    
173
}
174

    
175
/**
176
 *  inserts the header referenced by the ADVANCED_SEARCHBOX_URL setting
177
 */
178
function insertAdvancedSearchBox() { 
179

    
180
  if (!_isBlank(ADVANCED_SEARCHBOX_URL)) {
181

    
182
    _createIFrameWithURL(ADVANCED_SEARCHBOX_URL, IFRAME_ADVANCED_SEARCHBOX_CLASS);
183
  }
184

    
185
}
186

    
187
/**
188
 *  inserts the header referenced by the LOGINBOX_URL setting
189
 */
190
function insertLoginBox() { 
191

    
192
  if (!_isBlank(LOGINBOX_URL)) {
193

    
194
    _createIFrameWithURL(LOGINBOX_URL, IFRAME_LOGINBOX_CLASS);
195
  }
196

    
197
}
198

    
199

    
200
/**
201
 *  inserts an iframe into the document and assigns it the passed source URL
202
 *  and class attribute
203
 */
204
function _createIFrameWithURL(targetURL, cssClass) {
205

    
206

    
207
  if (_isBlank(targetURL)) {
208

    
209
    document.write("&nbsp;");
210

    
211
  } else {
212

    
213
    document.write("<iframe src=\""+targetURL+"\" class=\""+cssClass+"\" "
214
                  +" id=\"" + cssClass + "\""
215
                  +" name=\"" + cssClass + "\""
216
				  + "\" marginwidth=\"0\" scrolling=\"no\" "
217
                  +" marginheight=\"0\" marginwidth=\"0\" scrolling=\"no\" "
218
                  +" border=\"0\" frameborder=\"0\" framespacing=\"0\" "
219
                  +" hspace=\"0\" vspace=\"0\">Your browser does not support"
220
                  +" the iframe tag. <a href=\""+targetURL+"\" "
221
                  +"target=\"_blank\">This content</a>"
222
                  +" should have been displayed at this location</iframe>");
223
  }
224
}
225

    
226

    
227

    
228
function _isBlank(testString) {
229

    
230
  return (  !testString
231
          || testString==null
232
          || (testString.replace(/^\s*/, '').replace(/\s*$/,'')==""));
233
}
234

    
235

    
236
function _getColSpanString() {
237

    
238
  var colspan = 1;
239
  if (!_isBlank(LEFTCOL_URL))  colspan++;
240
  if (!_isBlank(RIGHTCOL_URL)) colspan++;
241
  if (colspan==1) return "";
242
  else return " colspan=\""+colspan+"\" ";
243
} 
244

    
245
function submitbrowseform(action,form_ref) {
246
  form_ref.action.value=action;
247
  form_ref.submit();
248
}
(4-4/20)