source: main/trunk/greenstone3/web/interfaces/default/transform/layouts/toc.xsl@ 26307

Last change on this file since 26307 was 26307, checked in by sjm84, 8 years ago

The view option images can now be clicked as well as the checkboxes

  • Property svn:executable set to *
File size: 15.0 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:java="http://xml.apache.org/xslt/java"
5 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
6 xmlns:gslib="http://www.greenstone.org/skinning"
7 xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
8 extension-element-prefixes="java util"
9 exclude-result-prefixes="java util gsf">
10
11 <xsl:template name="rightSidebar">
12 <div id="rightSidebar">
13 <xsl:call-template name="displayCoverImage"/>
14 <xsl:call-template name="viewOptions"/>
15
16 <xsl:if test="@docType != 'simple'">
17 <xsl:call-template name="displayTOC"/>
18 </xsl:if>
19 </div>
20 </xsl:template>
21
22 <xsl:template name="displayCoverImage">
23 <!-- Need to be in the context of the top-level documentNode rather than the document for the gsf:metadata call to work -->
24 <xsl:for-each select="documentNode">
25 <xsl:variable name="hasCover"><gsf:metadata name="hascover"/></xsl:variable>
26 <xsl:if test="$hasCover = '1' and (not(/page/pageResponse/format[@type='display']/gsf:option[@name='coverImage']) or /page/pageResponse/format[@type='display']/gsf:option[@name='coverImage']/@value='true')">
27 <!-- the book's cover image -->
28 <div id="coverImage">
29 <img>
30 <xsl:attribute name="src"><xsl:value-of select="$httpPath"/>/index/assoc/<gsf:metadata name="assocfilepath"/>/cover.jpg</xsl:attribute>
31 </img><xsl:text> </xsl:text>
32 </div>
33 </xsl:if>
34 </xsl:for-each>
35 </xsl:template>
36
37 <xsl:template name="displayTOC">
38 <div class="tableOfContentsContainer ui-state-default">
39 <table class="tocTable ui-widget-content">
40 <tr>
41 <td id="unfloatTOCButton" style="display:none;">
42 <a href="javascript:floatMenu(false);">
43 <img class="icon" style="padding-top:3px;">
44 <xsl:attribute name="src">
45 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'left_arrow_image')"/>
46 </xsl:attribute>
47 </img>
48 </a>
49 </td>
50 <td style="vertical-align:top; text-align:right;">
51 <a id="sidebarMinimizeButton" href="javascript:minimizeSidebar();" style="float: right; font-size:0.6em;">
52 <img class="icon" style="padding-top:3px;">
53 <xsl:attribute name="src">
54 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
55 </xsl:attribute>
56 </img>
57 </a>
58 <a id="sidebarMaximizeButton" href="javascript:maximizeSidebar();" style="float: right; font-size:0.6em; display:none;">
59 <img class="icon" style="padding-top:3px;">
60 <xsl:attribute name="src">
61 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/>
62 </xsl:attribute>
63 </img>
64 </a>
65 </td>
66 </tr>
67 <tr><td>
68 <div id="contentsArea">
69 <!-- show the berry basket if it's turned on -->
70 <gslib:berryBasket/>
71
72 <!-- the contents (if enabled) -->
73 <xsl:choose>
74 <xsl:when test="/page/pageResponse/document/@docType = 'paged' or /page/pageResponse/document/@docType = 'pagedhierarchy'">
75 <gsf:image type="Thumb"/>
76 <!-- Table of contents will be dynamically retrieved when viewing a paged document -->
77 <script type="text/javascript">
78 <xsl:text disable-output-escaping="yes">
79 $(window).load(function()
80 {
81 retrieveTableOfContentsAndTitles();
82 });
83 </xsl:text>
84 </script>
85 <div id="tableOfContents"><xsl:text> </xsl:text></div>
86 <div id="tocLoadingImage" style="text-align:center;">
87 <img src="{util:getInterfaceText($interface_name, /page/@lang, 'loading_image')}"/><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.loading')"/><xsl:text>...</xsl:text>
88 </div>
89 <table style="width:100%;"><tbody><tr>
90 <td><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.filter_pages')"/><xsl:text>: </xsl:text><input id="filterText" type="text" size="27"/></td>
91 </tr></tbody></table>
92 </xsl:when>
93 <xsl:when test="not(/page/pageRequest/paramList/param[@name = 'ed']/@value = '1')">
94 <div id="tableOfContents">
95 <div id="tocLoadingImage" style="text-align:center;">
96 <img src="{util:getInterfaceText($interface_name, /page/@lang, 'loading_image')}"/><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.loading')"/><xsl:text>...</xsl:text>
97 </div>
98 </div>
99 <script type="text/javascript">
100 <xsl:text disable-output-escaping="yes">
101 $(window).load(function()
102 {
103 retrieveFullTableOfContents();
104 });
105 </xsl:text>
106 </script>
107 </xsl:when>
108 <xsl:otherwise>
109 <div id="tableOfContents">
110 <xsl:attribute name="class">
111 <xsl:choose>
112 <xsl:when test="count(//documentNode) > 1 and not(/page/pageResponse/format[@type='display']/gsf:option[@name='TOC']) or /page/pageResponse/format[@type='display']/gsf:option[@name='TOC']/@value='true'">visible</xsl:when>
113 <xsl:otherwise>hidden</xsl:otherwise>
114 </xsl:choose>
115 </xsl:attribute>
116 <xsl:for-each select="documentNode">
117 <xsl:call-template name="documentNodeTOC"/>
118 </xsl:for-each>
119 </div>
120 </xsl:otherwise>
121 </xsl:choose>
122 </div>
123 </td></tr>
124 </table>
125 </div>
126 </xsl:template>
127
128 <!-- This template is used to display the table of contents -->
129 <xsl:template name="documentNodeTOC">
130
131 <!-- check if this is the currently selected table of contents item -->
132 <xsl:variable name="isCurrent" select="nodeContent"/>
133
134 <!-- formulate the link -->
135 <xsl:variable name="contentsLink">
136 <xsl:value-of select='$library_name'/>?a=d&amp;c=<gslib:collectionNameShort/>&amp;d=<xsl:value-of select='@nodeID'/><xsl:if test="documentNode">.pr</xsl:if>&amp;sib=1
137 </xsl:variable>
138
139 <ul>
140 <table><tr>
141 <!-- The expand/collapse button (not displayed for the top level node) -->
142 <xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle'">
143 <td>
144 <xsl:choose>
145 <xsl:when test="not(nodeContent and not(documentNode))">
146 <img id="ttoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">
147 <xsl:attribute name="src">
148 <xsl:choose>
149 <xsl:when test="/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or /page/pageResponse/document/@selectedNode = @nodeID">
150 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
151 </xsl:when>
152 <xsl:otherwise>
153 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/>
154 </xsl:otherwise>
155 </xsl:choose>
156 </xsl:attribute>
157 </img>
158 </xsl:when>
159 <xsl:otherwise>
160 <xsl:attribute name="class">emptyIcon</xsl:attribute>
161 </xsl:otherwise>
162 </xsl:choose>
163 </td>
164 </xsl:if>
165
166 <!-- The chapter/page icon -->
167 <td>
168 <img>
169 <xsl:if test="nodeContent and not(documentNode)">
170 <xsl:attribute name="class">leafNode</xsl:attribute>
171 </xsl:if>
172
173 <xsl:attribute name="src">
174 <xsl:choose>
175 <xsl:when test="nodeContent and not(documentNode)">
176 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_image')"/>
177 </xsl:when>
178 <xsl:otherwise>
179 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'chapter_image')"/>
180 </xsl:otherwise>
181 </xsl:choose>
182 </xsl:attribute>
183 </img>
184 </td>
185
186 <!-- The section name, links to the section in the document -->
187 <td class="tocTextCell">
188 <a id="toclink{@nodeID}" href="javascript:focusSection('{@nodeID}');">
189 <xsl:if test="util:hashToSectionId(@nodeID)">
190 <xsl:value-of select="util:hashToSectionId(@nodeID)"/>
191 <xsl:text> </xsl:text>
192 </xsl:if>
193 <xsl:call-template name="sectionHeading"/>
194 </a>
195 </td>
196 </tr></table>
197
198 <!-- display any child items -->
199 <xsl:if test="documentNode">
200 <li id="toc{@nodeID}">
201 <xsl:attribute name="style">
202 <xsl:choose>
203 <xsl:when test="/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or /page/pageResponse/document/@selectedNode = @nodeID">
204 <xsl:text>display:block;</xsl:text>
205 </xsl:when>
206 <xsl:otherwise>
207 <xsl:text>display:none;</xsl:text>
208 </xsl:otherwise>
209 </xsl:choose>
210 </xsl:attribute>
211 <xsl:for-each select="documentNode">
212 <xsl:call-template name="documentNodeTOC"/>
213 </xsl:for-each>
214 </li>
215 </xsl:if>
216
217 </ul>
218 </xsl:template>
219
220 <xsl:template name="viewOptions">
221 <div id="viewAndZoomOptions" class="ui-state-default ui-corner-all">
222 <ul id="viewOptions">
223 <!-- Paged-image options -->
224 <li id="pagedImageOptions">
225 <xsl:attribute name="style">
226 <xsl:choose>
227 <xsl:when test="count(//documentNode/metadataList/metadata[@name = 'Screen']) > 0 or /page/pageResponse/document/@docType = 'paged' or /page/pageResponse/document/@docType = 'pagedhierarchy'">
228 </xsl:when>
229 <xsl:otherwise>
230 display:none;
231 </xsl:otherwise>
232 </xsl:choose>
233 </xsl:attribute>
234 <select id="viewSelection" onchange="changeView();">
235 <xsl:choose>
236 <xsl:when test="/page/pageRequest/paramList/param[@name = 'view']/@value = 'image'">
237 <option>Default view</option>
238 <option selected="true">Image view</option>
239 <option>Text view</option>
240 </xsl:when>
241 <xsl:when test="/page/pageRequest/paramList/param[@name = 'view']/@value = 'text'">
242 <option>Default view</option>
243 <option>Image view</option>
244 <option selected="true">Text view</option>
245 </xsl:when>
246 <xsl:otherwise>
247 <option selected="true">Default view</option>
248 <option>Image view</option>
249 <option>Text view</option>
250 </xsl:otherwise>
251 </xsl:choose>
252 </select>
253 </li>
254
255 <!-- Slide-show options -->
256 <li id="slideShowOptions">
257 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.slideshowTooltip')"/></xsl:attribute>
258 <xsl:attribute name="style">
259 <xsl:choose>
260 <xsl:when test="count(//documentNode/metadataList/metadata[@name = 'Screen']) > 0 or /page/pageResponse/document/@docType = 'paged' or /page/pageResponse/document/@docType = 'pagedhierarchy'">
261 </xsl:when>
262 <xsl:otherwise>
263 display:none;
264 </xsl:otherwise>
265 </xsl:choose>
266 </xsl:attribute>
267 <img onclick="showSlideShow()">
268 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'slideshow_image')"/></xsl:attribute>
269 </img>
270 <input id="ssOption" type="checkbox" onclick="showSlideShow()" class="optionCheckBox"/>
271 <script type="text/javascript">
272 <xsl:text disable-output-escaping="yes">
273 $(window).load(function()
274 {
275 $("#ssOption").attr("checked", false);
276 });
277 </xsl:text>
278 </script>
279 </li>
280
281 <!-- Realistic books link -->
282 <xsl:if test="/page/pageResponse/collection[@name = $collName]/metadataList/metadata[@name = 'tidyoption'] = 'tidy'">
283 <li>
284 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.realisticBooksTooltip')"/></xsl:attribute>
285 <img id="rbOptionImage" onclick="bookInit();">
286 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'realistic_books_image')"/></xsl:attribute>
287 </img>
288 <input id="rbOption" type="checkbox" onclick="bookInit();" class="optionCheckBox"/>
289 </li>
290 </xsl:if>
291
292 <!-- Highlight on/off button -->
293 <xsl:if test="util:contains(/page/pageRequest/paramList/param[@name = 'p.s']/@value, 'Query')">
294 <li>
295 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.highlightTooltip')"/></xsl:attribute>
296 <img onclick="swapHighlight(true);">
297 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'highlight_image')"/></xsl:attribute>
298 </img>
299 <input id="highlightOption" type="checkbox" class="optionCheckBox" onclick="swapHighlight(false);">
300 <xsl:if test="/page/pageRequest/paramList/param[@name = 'hl']/@value = 'on'">
301 <xsl:attribute name="checked">true</xsl:attribute>
302 </xsl:if>
303 </input>
304 </li>
305 </xsl:if><xsl:text> </xsl:text>
306
307 <!-- Zoom on/off button -->
308 <li id="zoomOptions" style="display:none;">
309 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.zoomTooltip')"/></xsl:attribute>
310 <img id="zoomToggleImage">
311 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'zoom_image')"/></xsl:attribute>
312 </img>
313 <input id="zoomToggle" type="checkbox"/>
314 <script type="text/javascript">
315 <xsl:text disable-output-escaping="yes">
316 $("#zoomToggle").change(function()
317 {
318 _imageZoomEnabled = $("#zoomToggle").attr("checked");
319 });
320
321 $("#zoomToggleImage").click(function()
322 {
323 $("#zoomToggle").attr("checked", !$("#zoomToggle").attr("checked"));
324 _imageZoomEnabled = $("#zoomToggle").attr("checked");
325 });
326 </xsl:text>
327 </script>
328 </li>
329
330 <!-- Floating TOC on/off button -->
331 <xsl:if test="count(//documentNode) > 0 and (not(/page/pageResponse/format[@type='display']/gsf:option[@name='TOC']) or /page/pageResponse/format[@type='display']/gsf:option[@name='TOC']/@value='true')">
332 <li id="floatingTOCOptions">
333 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.floatingTooltip')"/></xsl:attribute>
334 <img id="floatTOCToggleImage">
335 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'float_toc_image')"/></xsl:attribute>
336 </img>
337 <input id="floatTOCToggle" type="checkbox"/>
338 <script type="text/javascript">
339 <xsl:text disable-output-escaping="yes">
340 $("#floatTOCToggle").attr("checked", false);
341 $("#floatTOCToggle").click(function()
342 {
343 floatMenu($("#floatTOCToggle").attr("checked"));
344 });
345
346 $("#floatTOCToggleImage").click(function()
347 {
348 $("#floatTOCToggle").attr("checked", !$("#floatTOCToggle").attr("checked"))
349 floatMenu($("#floatTOCToggle").attr("checked"));
350 });
351 </xsl:text>
352 </script>
353 </li>
354 </xsl:if>
355 </ul>
356 <div style="clear:both;"><xsl:text> </xsl:text></div>
357 </div>
358 </xsl:template>
359</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.