Project

General

Profile

1 1929 brooke
 /*
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$'
12
  *      '$Date$'
13
  *  '$Revision$'
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
 *  inserts the header referenced by the LOGINBOX_URL setting
164
 */
165
function insertLoginBox() {
166
167
  if (!_isBlank(LOGINBOX_URL)) {
168
169
    _createIFrameWithURL(LOGINBOX_URL, IFRAME_LOGINBOX_CLASS);
170
  }
171
172
}
173
174
175
/**
176
 *  inserts an iframe into the document and assigns it the passed source URL
177
 *  and class attribute
178
 */
179
function _createIFrameWithURL(targetURL, cssClass) {
180
181
182
  if (_isBlank(targetURL)) {
183
184
    document.write("&nbsp;");
185
186
  } else {
187
188
    document.write("<iframe src=\""+targetURL+"\" class=\""+cssClass+"\" "
189 1937 brooke
                  +" marginheight=\"0\" marginwidth=\"0\" scrolling=\"no\" "
190
                  +" border=\"0\" frameborder=\"0\" framespacing=\"0\" "
191
                  +" hspace=\"0\" vspace=\"0\">Your browser does not support"
192
                  +" the iframe tag. <a href=\""+targetURL+"\" "
193
                  +"target=\"_blank\">This content</a>"
194
                  +" should have been displayed at this location</iframe>");
195 1929 brooke
  }
196
}
197
198
199
200
function _isBlank(testString) {
201
202
  return (  !testString
203
          || testString==null
204
          || (testString.replace(/^\s*/, '').replace(/\s*$/,'')==""));
205
}
206
207
208
function _getColSpanString() {
209
210
  var colspan = 1;
211
  if (!_isBlank(LEFTCOL_URL))  colspan++;
212
  if (!_isBlank(RIGHTCOL_URL)) colspan++;
213
  if (colspan==1) return "";
214
  else return " colspan=\""+colspan+"\" ";
215
}