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

Last change on this file since 37002 was 37002, checked in by davidb, 18 months ago

Adding comment about the need for documentNodeTOC to be wrapped up in a root element (<ul> in this case)

  • Property svn:executable set to *
File size: 27.0 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
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:include href="../pages/document-shared.xsl" />
12
13 <xsl:template name="rightSidebarTOC">
14 <div id="rightSidebar">
15 <xsl:choose>
16 <xsl:when test="@docType = 'simple'">
17 <xsl:for-each select=".">
18 <xsl:call-template name="displayCoverImage"/>
19 </xsl:for-each>
20 <xsl:call-template name="viewOptions"/>
21 <!--<xsl:text> </xsl:text>-->
22 </xsl:when>
23 <xsl:otherwise>
24 <xsl:for-each select="documentNode[1]">
25 <xsl:call-template name="displayCoverImage"/>
26 </xsl:for-each>
27 <xsl:call-template name="viewOptions"/>
28 <xsl:call-template name="displayTOC"/>
29 </xsl:otherwise>
30 </xsl:choose>
31 </div>
32 </xsl:template>
33
34 <!-- this is called in the context of the top level node with the metadataList. For a simple doc, this is the document node. For a comples document, this is the first documentNode hcild of the document node. -->
35 <xsl:template name="displayCoverImage">
36 <xsl:variable name="hasCover">
37 <gsf:metadata name="hascover"/>
38 </xsl:variable>
39 <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')">
40 <!-- the book's cover image -->
41 <div id="coverImage">
42 <img>
43 <xsl:attribute name="src">
44 <xsl:value-of select="$httpPath"/>/index/assoc/<gsf:metadata name="assocfilepath" pos="1"/>/cover.jpg
45 </xsl:attribute>
46 </img>
47 <xsl:text> </xsl:text>
48 </div>
49 </xsl:if>
50 </xsl:template>
51
52 <xsl:template name="displayTOC">
53 <xsl:if test="not(/page/pageResponse/format[@type='display']/gsf:option[@name='TOC']) or /page/pageResponse/format[@type='display']/gsf:option[@name='TOC']/@value='true'">
54 <div class="tableOfContentsContainer ui-state-default">
55 <table class="tocTable ui-widget-content">
56 <tr>
57 <td id="unfloatTOCButton" style="display:none;">
58 <a href="javascript:floatMenu(false);">
59 <img class="icon" style="padding-top:3px;">
60 <xsl:attribute name="src">
61 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'left_arrow_image')"/>
62 </xsl:attribute>
63 </img>
64 </a>
65 </td>
66 <td style="vertical-align:top; text-align:right;">
67 <a id="sidebarMinimizeButton" href="javascript:minimizeSidebar();" style="float: right; font-size:0.6em;">
68 <img class="icon" style="padding-top:3px;">
69 <xsl:attribute name="src">
70 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
71 </xsl:attribute>
72 </img>
73 </a>
74 <a id="sidebarMaximizeButton" href="javascript:maximizeSidebar();" style="float: right; font-size:0.6em; display:none;">
75 <img class="icon" style="padding-top:3px;">
76 <xsl:attribute name="src">
77 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/>
78 </xsl:attribute>
79 </img>
80 </a>
81 </td>
82 </tr>
83 <tr>
84 <td id="tdContentsArea">
85 <div id="contentsArea">
86
87 <!-- this won't display anything if favourites are not on -->
88 <xsl:call-template name="gotoFavourites"/>
89
90 <!-- add in expand and contract document links -->
91 <xsl:call-template name="expandContractDocumentLinks"/>
92 <!-- dynamically get the contents (if enabled) -->
93 <xsl:choose>
94 <xsl:when test="/page/pageResponse/document/@docType = 'paged' or /page/pageResponse/document/@docType = 'pagedhierarchy'">
95 <gsf:image type="Thumb"/>
96 <!-- Table of contents will be dynamically retrieved when viewing a paged document -->
97 <script type="text/javascript">
98 <xsl:text disable-output-escaping="yes">
99 $(window).on("load", function()
100 {
101 retrieveTableOfContentsAndTitles();
102 <!--setUpFilterButtons();-->
103 });
104 </xsl:text>
105 </script>
106
107 <div id="tableOfContents">
108 <xsl:text> </xsl:text>
109 </div>
110
111 <div id="tocLoadingImage" style="text-align:center;">
112 <img src="{util:getInterfaceText($interface_name, /page/@lang, 'loading_image')}"/>
113 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.loading')"/>
114 <xsl:text>...</xsl:text>
115 </div>
116
117 <label for="filterText">
118 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.filter_pages')"/>
119 <xsl:text>: </xsl:text>
120 </label>
121 <span id="filterOnButtons" style="float: right;">...</span>
122 <input id="filterText" type="text" style="width: 100%;" />
123
124 <!-- <xsl:if test="/page/pageRequest/userInformation and /page/pageRequest/userInformation/@editEnabled = 'true'"> -->
125 <xsl:if test="/page/pageRequest/userInformation and /page/pageRequest/userInformation/@editEnabled = 'true' and /page/pageRequest/paramList/param[@name='docEdit']/@value = '1' and (util:contains(/page/pageRequest/userInformation/@groups, 'administrator') or util:contains(/page/pageRequest/userInformation/@groups, 'all-collections-editor') or util:contains(/page/pageRequest/userInformation/@groups, $thisCollectionEditor))">
126 <a href="javascript:extractFilteredPagesToOwnDocument();">
127 <button id="extractDocButton">
128 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'de.extract_pages')"/>
129 </button>
130 </a>
131 </xsl:if>
132 </xsl:when>
133 <xsl:when test="not(/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or /page/pageRequest/paramList/param[@name = 'ec']/@value = '1')">
134 <div id="tableOfContents">
135 <div id="tocLoadingImage" style="text-align:center;">
136 <img src="{util:getInterfaceText($interface_name, /page/@lang, 'loading_image')}"/>
137 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.loading')"/>
138 <xsl:text>...</xsl:text>
139 </div>
140 </div>
141 <script type="text/javascript">
142 <xsl:text disable-output-escaping="yes">
143 $(window).on("load", function()
144 {
145 retrieveFullTableOfContents();
146 });
147 </xsl:text>
148 </script>
149 </xsl:when>
150 <xsl:otherwise>
151
152 <div id="tableOfContents">
153 <!-- if ed=1 or ec=1 then we have the complete section hierarchy in the page xml source, so we don't need an ajax call to get the table of contents, we just generate it from the list of nodes -->
154 <xsl:attribute name="class"> <!-- do we ever need this ?? -->
155 <xsl:choose>
156 <xsl:when test="count(//documentNode) > 1">visible</xsl:when>
157 <xsl:otherwise>hidden</xsl:otherwise>
158 </xsl:choose>
159 </xsl:attribute>
160
161 <xsl:for-each select="documentNode">
162 <xsl:call-template name="documentNodeTOC"/>
163 </xsl:for-each>
164 </div>
165 </xsl:otherwise>
166 </xsl:choose>
167 </div>
168 </td>
169 </tr>
170 </table>
171 </div>
172 </xsl:if>
173 </xsl:template>
174
175 <!-- This template is used to display the table of contents -->
176 <xsl:template name="documentNodeTOC">
177 <!--
178 Important that the following is all wrapped up in a root tag (<ul>) in this case.
179 This is because the rule is called using an ajax-based 'ilt' (inline template) call, and if
180 there isn't a root tag, it causes the XSLT to blowup
181 -->
182 <ul>
183 <table>
184 <tr>
185 <!-- The expand/collapse button (not displayed for the top level node) -->
186 <xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle'">
187 <td>
188 <xsl:choose>
189 <xsl:when test="documentNode">
190 <img id="ttoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">
191 <xsl:attribute name="src">
192 <xsl:choose>
193 <xsl:when test="/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or /page/pageResponse/document/@selectedNode = @nodeID">
194 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
195 </xsl:when>
196 <xsl:otherwise>
197 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/>
198 </xsl:otherwise>
199 </xsl:choose>
200 </xsl:attribute>
201 </img>
202 </xsl:when>
203 <xsl:otherwise>
204 <xsl:attribute name="class">emptyIcon</xsl:attribute>
205
206 <!--
207 Prevent the <td> element being self-closed, which would be invalid according to the HTML spec.
208 This is also an identified issue in jQuery > 3.5.0
209 -->
210 <xsl:text> </xsl:text>
211 </xsl:otherwise>
212 </xsl:choose>
213 </td>
214 </xsl:if>
215
216 <!-- The chapter/page icon -->
217 <td>
218 <img>
219 <xsl:if test="not(documentNode)">
220 <xsl:attribute name="class">leafNode</xsl:attribute>
221 </xsl:if>
222
223 <xsl:attribute name="src">
224 <xsl:choose>
225 <xsl:when test="not(documentNode)">
226 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_image')"/>
227 </xsl:when>
228 <xsl:otherwise>
229 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'chapter_image')"/>
230 </xsl:otherwise>
231 </xsl:choose>
232 </xsl:attribute>
233 </img>
234 </td>
235
236 <!-- The section name, links to the section in the document -->
237 <td class="tocTextCell">
238 <a id="toclink{@nodeID}" href="javascript:focusSection('{@nodeID}');">
239 <xsl:if test="util:hashToSectionId(@nodeID)">
240 <span class="tocSectionNumber">
241 <xsl:value-of select="util:hashToSectionId(@nodeID)"/><!--<xsl:text> </xsl:text>-->
242 </span>
243 </xsl:if>
244 <span class="tocSectionTitle">
245 <xsl:call-template name="sectionHeading"/>
246 </span>
247 </a>
248 </td>
249 </tr>
250 </table>
251
252 <!-- display any child items -->
253 <xsl:if test="documentNode">
254 <li id="toc{@nodeID}">
255 <xsl:attribute name="style">
256 <xsl:choose>
257 <xsl:when test="/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or /page/pageResponse/document/@selectedNode = @nodeID">
258 <xsl:text>display:block;</xsl:text>
259 </xsl:when>
260 <xsl:otherwise>
261 <xsl:text>display:none;</xsl:text>
262 </xsl:otherwise>
263 </xsl:choose>
264 </xsl:attribute>
265 <xsl:for-each select="documentNode">
266 <xsl:call-template name="documentNodeTOC"/>
267 </xsl:for-each>
268 </li>
269 </xsl:if>
270 </ul>
271 </xsl:template>
272
273 <xsl:template name="viewOptions">
274 <div id="viewAndZoomOptions" class="ui-state-default ui-corner-all">
275 <ul id="viewOptions">
276 <!-- Paged-image document options -->
277 <xsl:if test="count(//documentNode/metadataList/metadata[@name = 'Screen']) > 0 or /page/pageResponse/document/@docType = 'paged' or /page/pageResponse/document/@docType = 'pagedhierarchy'">
278 <!-- view selection option -->
279 <xsl:if test="not(/page/pageResponse/format[@type='display']/gsf:option[@name='viewSelection']) or /page/pageResponse/format[@type='display']/gsf:option[@name='viewSelection']/@value='true'">
280 <li id="pagedImageOptions">
281 <select id="viewSelection" onchange="changeView();">
282 <xsl:choose>
283 <xsl:when test="/page/pageRequest/paramList/param[@name = 'view']/@value = 'image'">
284 <option>
285 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.default_view')"/>
286 </option>
287 <option selected="true">
288 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.image_view')"/>
289 </option>
290 <option>
291 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.text_view')"/>
292 </option>
293 </xsl:when>
294 <xsl:when test="/page/pageRequest/paramList/param[@name = 'view']/@value = 'text'">
295 <option>
296 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.default_view')"/>
297 </option>
298 <option>
299 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.image_view')"/>
300 </option>
301 <option selected="true">
302 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.text_view')"/>
303 </option>
304 </xsl:when>
305 <xsl:otherwise>
306 <option selected="true">
307 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.default_view')"/>
308 </option>
309 <option>
310 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.image_view')"/>
311 </option>
312 <option>
313 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.text_view')"/>
314 </option>
315 </xsl:otherwise>
316 </xsl:choose>
317 </select>
318 </li>
319 </xsl:if>
320
321 <!-- Slide-show options -->
322 <xsl:if test="not(/page/pageResponse/format[@type='display']/gsf:option[@name='slideShow']) or /page/pageResponse/format[@type='display']/gsf:option[@name='slideShow']/@value='true'">
323 <li id="slideShowOptions">
324 <xsl:attribute name="title">
325 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.slideshowTooltip')"/>
326 </xsl:attribute>
327 <img onclick="showSlideShow()">
328 <xsl:attribute name="src">
329 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'slideshow_image')"/>
330 </xsl:attribute>
331 </img>
332 </li>
333 </xsl:if>
334 </xsl:if>
335 <!-- Realistic books link -->
336 <xsl:if test="/page/pageResponse/collection[@name = $collName]/metadataList/metadata[@name = 'tidyoption'] = 'tidy'">
337 <li>
338 <xsl:attribute name="title">
339 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.realisticBooksTooltip')"/>
340 </xsl:attribute>
341 <img id="rbOptionImage" onclick="bookInit();">
342 <xsl:attribute name="src">
343 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'realistic_books_image')"/>
344 </xsl:attribute>
345 </img>
346 <input id="rbOption" type="checkbox" onclick="bookInit();" class="optionCheckBox"/>
347 </li>
348 </xsl:if>
349
350 <!-- Highlight on/off button -->
351 <xsl:if test="util:contains(/page/pageRequest/paramList/param[@name = 'p.s']/@value, 'Query') and not(metadataList/metadata[@name='NoText']) and not(/page/pageResponse/format[@type='display']/gsf:option[@name='disableSearchTermHighlighting']/@value='true')">
352 <li>
353 <xsl:attribute name="title">
354 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.highlightTooltip')"/>
355 </xsl:attribute>
356 <img onclick="swapHighlight(true);">
357 <xsl:attribute name="src">
358 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'highlight_image')"/>
359 </xsl:attribute>
360 </img>
361 <input id="highlightOption" type="checkbox" class="optionCheckBox" onclick="swapHighlight(false);">
362 <xsl:if test="not(/page/pageRequest/paramList/param[@name = 'hl']/@value = 'off')">
363 <xsl:attribute name="checked">checked</xsl:attribute>
364 </xsl:if>
365 </input>
366 </li>
367 </xsl:if>
368 <xsl:text> </xsl:text>
369
370 <!-- Zoom on/off button -->
371 <xsl:if test="not(/page/pageResponse/format[@type='display']/gsf:option[@name='disableZoom']) or /page/pageResponse/format[@type='display']/gsf:option[@name='disableZoom']/@value='false'">
372 <li id="zoomOptions" style="display:none;">
373 <xsl:attribute name="title">
374 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.zoomTooltip')"/>
375 </xsl:attribute>
376 <img id="zoomToggleImage">
377 <xsl:attribute name="src">
378 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'zoom_image')"/>
379 </xsl:attribute>
380 </img>
381 <input id="zoomToggle" type="checkbox"/>
382 <script type="text/javascript">
383 <xsl:text disable-output-escaping="yes">
384 $("#zoomToggle").change(function()
385 {
386 _imageZoomEnabled = $("#zoomToggle").prop("checked");
387 });
388
389 $("#zoomToggleImage").on("click", function()
390 {
391 $("#zoomToggle").prop("checked", !$("#zoomToggle").prop("checked"));
392 _imageZoomEnabled = $("#zoomToggle").prop("checked");
393 });
394 </xsl:text>
395 </script>
396 </li>
397 </xsl:if>
398
399 <!-- Floating TOC on/off button -->
400 <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')">
401 <xsl:call-template name="floatingTOCToggle" />
402 </xsl:if>
403 </ul>
404 <div style="clear:both;">
405 <xsl:text> </xsl:text>
406 </div>
407 </div>
408 </xsl:template>
409
410 <xsl:template name="floatingTOCToggle">
411 <li id="floatingTOCOptions">
412 <xsl:attribute name="title">
413 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.floatingTooltip')"/>
414 </xsl:attribute>
415 <img id="floatTOCToggleImage">
416 <xsl:attribute name="src">
417 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'float_toc_image')"/>
418 </xsl:attribute>
419 </img>
420 <input id="floatTOCToggle" type="checkbox"/>
421 <script type="text/javascript">
422 <xsl:text disable-output-escaping="yes">
423 $("#floatTOCToggle").prop("checked", false);
424 $("#floatTOCToggle").on("click", function()
425 {
426 floatMenu($("#floatTOCToggle").prop("checked"));
427 });
428
429 $("#floatTOCToggleImage").on("click", function()
430 {
431 $("#floatTOCToggle").prop("checked", !$("#floatTOCToggle").prop("checked"))
432 floatMenu($("#floatTOCToggle").prop("checked"));
433 });
434 </xsl:text>
435 </script>
436 </li>
437 <xsl:if test="/page/pageRequest/paramList/param[@name='ftoc']/@value = '1'">
438 <script type="text/javascript">
439 <xsl:text disable-output-escaping="yes">
440 $(window).on("load", function()
441 {
442 $("#floatTOCToggle").prop("checked", true);
443 floatMenu(true);
444 });
445 </xsl:text>
446 </script>
447 </xsl:if>
448 </xsl:template>
449</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.