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

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

Fix for why the JS-based PagedImagePlugin TOC wasn't working. Turns out to be due to a change in documentNodeTOC which changed <ul> and <li> tags to <div>. This then caused the JS to fail as it was looking for the <li> items to turn into thumbnails

  • Property svn:executable set to *
File size: 26.7 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 <ul>
178 <table>
179 <tr>
180 <!-- The expand/collapse button (not displayed for the top level node) -->
181 <xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle'">
182 <td>
183 <xsl:choose>
184 <xsl:when test="documentNode">
185 <img id="ttoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">
186 <xsl:attribute name="src">
187 <xsl:choose>
188 <xsl:when test="/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or /page/pageResponse/document/@selectedNode = @nodeID">
189 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
190 </xsl:when>
191 <xsl:otherwise>
192 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/>
193 </xsl:otherwise>
194 </xsl:choose>
195 </xsl:attribute>
196 </img>
197 </xsl:when>
198 <xsl:otherwise>
199 <xsl:attribute name="class">emptyIcon</xsl:attribute>
200
201 <!--
202 Prevent the <td> element being self-closed, which would be invalid according to the HTML spec.
203 This is also an identified issue in jQuery > 3.5.0
204 -->
205 <xsl:text> </xsl:text>
206 </xsl:otherwise>
207 </xsl:choose>
208 </td>
209 </xsl:if>
210
211 <!-- The chapter/page icon -->
212 <td>
213 <img>
214 <xsl:if test="not(documentNode)">
215 <xsl:attribute name="class">leafNode</xsl:attribute>
216 </xsl:if>
217
218 <xsl:attribute name="src">
219 <xsl:choose>
220 <xsl:when test="not(documentNode)">
221 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_image')"/>
222 </xsl:when>
223 <xsl:otherwise>
224 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'chapter_image')"/>
225 </xsl:otherwise>
226 </xsl:choose>
227 </xsl:attribute>
228 </img>
229 </td>
230
231 <!-- The section name, links to the section in the document -->
232 <td class="tocTextCell">
233 <a id="toclink{@nodeID}" href="javascript:focusSection('{@nodeID}');">
234 <xsl:if test="util:hashToSectionId(@nodeID)">
235 <span class="tocSectionNumber">
236 <xsl:value-of select="util:hashToSectionId(@nodeID)"/><!--<xsl:text> </xsl:text>-->
237 </span>
238 </xsl:if>
239 <span class="tocSectionTitle">
240 <xsl:call-template name="sectionHeading"/>
241 </span>
242 </a>
243 </td>
244 </tr>
245 </table>
246
247 <!-- display any child items -->
248 <xsl:if test="documentNode">
249 <li id="toc{@nodeID}">
250 <xsl:attribute name="style">
251 <xsl:choose>
252 <xsl:when test="/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or /page/pageResponse/document/@selectedNode = @nodeID">
253 <xsl:text>display:block;</xsl:text>
254 </xsl:when>
255 <xsl:otherwise>
256 <xsl:text>display:none;</xsl:text>
257 </xsl:otherwise>
258 </xsl:choose>
259 </xsl:attribute>
260 <xsl:for-each select="documentNode">
261 <xsl:call-template name="documentNodeTOC"/>
262 </xsl:for-each>
263 </li>
264 </xsl:if>
265 </ul>
266 </xsl:template>
267
268 <xsl:template name="viewOptions">
269 <div id="viewAndZoomOptions" class="ui-state-default ui-corner-all">
270 <ul id="viewOptions">
271 <!-- Paged-image document options -->
272 <xsl:if test="count(//documentNode/metadataList/metadata[@name = 'Screen']) > 0 or /page/pageResponse/document/@docType = 'paged' or /page/pageResponse/document/@docType = 'pagedhierarchy'">
273 <!-- view selection option -->
274 <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'">
275 <li id="pagedImageOptions">
276 <select id="viewSelection" onchange="changeView();">
277 <xsl:choose>
278 <xsl:when test="/page/pageRequest/paramList/param[@name = 'view']/@value = 'image'">
279 <option>
280 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.default_view')"/>
281 </option>
282 <option selected="true">
283 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.image_view')"/>
284 </option>
285 <option>
286 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.text_view')"/>
287 </option>
288 </xsl:when>
289 <xsl:when test="/page/pageRequest/paramList/param[@name = 'view']/@value = 'text'">
290 <option>
291 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.default_view')"/>
292 </option>
293 <option>
294 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.image_view')"/>
295 </option>
296 <option selected="true">
297 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.text_view')"/>
298 </option>
299 </xsl:when>
300 <xsl:otherwise>
301 <option selected="true">
302 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.default_view')"/>
303 </option>
304 <option>
305 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.image_view')"/>
306 </option>
307 <option>
308 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.text_view')"/>
309 </option>
310 </xsl:otherwise>
311 </xsl:choose>
312 </select>
313 </li>
314 </xsl:if>
315
316 <!-- Slide-show options -->
317 <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'">
318 <li id="slideShowOptions">
319 <xsl:attribute name="title">
320 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.slideshowTooltip')"/>
321 </xsl:attribute>
322 <img onclick="showSlideShow()">
323 <xsl:attribute name="src">
324 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'slideshow_image')"/>
325 </xsl:attribute>
326 </img>
327 </li>
328 </xsl:if>
329 </xsl:if>
330 <!-- Realistic books link -->
331 <xsl:if test="/page/pageResponse/collection[@name = $collName]/metadataList/metadata[@name = 'tidyoption'] = 'tidy'">
332 <li>
333 <xsl:attribute name="title">
334 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.realisticBooksTooltip')"/>
335 </xsl:attribute>
336 <img id="rbOptionImage" onclick="bookInit();">
337 <xsl:attribute name="src">
338 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'realistic_books_image')"/>
339 </xsl:attribute>
340 </img>
341 <input id="rbOption" type="checkbox" onclick="bookInit();" class="optionCheckBox"/>
342 </li>
343 </xsl:if>
344
345 <!-- Highlight on/off button -->
346 <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')">
347 <li>
348 <xsl:attribute name="title">
349 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.highlightTooltip')"/>
350 </xsl:attribute>
351 <img onclick="swapHighlight(true);">
352 <xsl:attribute name="src">
353 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'highlight_image')"/>
354 </xsl:attribute>
355 </img>
356 <input id="highlightOption" type="checkbox" class="optionCheckBox" onclick="swapHighlight(false);">
357 <xsl:if test="not(/page/pageRequest/paramList/param[@name = 'hl']/@value = 'off')">
358 <xsl:attribute name="checked">checked</xsl:attribute>
359 </xsl:if>
360 </input>
361 </li>
362 </xsl:if>
363 <xsl:text> </xsl:text>
364
365 <!-- Zoom on/off button -->
366 <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'">
367 <li id="zoomOptions" style="display:none;">
368 <xsl:attribute name="title">
369 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.zoomTooltip')"/>
370 </xsl:attribute>
371 <img id="zoomToggleImage">
372 <xsl:attribute name="src">
373 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'zoom_image')"/>
374 </xsl:attribute>
375 </img>
376 <input id="zoomToggle" type="checkbox"/>
377 <script type="text/javascript">
378 <xsl:text disable-output-escaping="yes">
379 $("#zoomToggle").change(function()
380 {
381 _imageZoomEnabled = $("#zoomToggle").prop("checked");
382 });
383
384 $("#zoomToggleImage").on("click", function()
385 {
386 $("#zoomToggle").prop("checked", !$("#zoomToggle").prop("checked"));
387 _imageZoomEnabled = $("#zoomToggle").prop("checked");
388 });
389 </xsl:text>
390 </script>
391 </li>
392 </xsl:if>
393
394 <!-- Floating TOC on/off button -->
395 <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')">
396 <xsl:call-template name="floatingTOCToggle" />
397 </xsl:if>
398 </ul>
399 <div style="clear:both;">
400 <xsl:text> </xsl:text>
401 </div>
402 </div>
403 </xsl:template>
404
405 <xsl:template name="floatingTOCToggle">
406 <li id="floatingTOCOptions">
407 <xsl:attribute name="title">
408 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.floatingTooltip')"/>
409 </xsl:attribute>
410 <img id="floatTOCToggleImage">
411 <xsl:attribute name="src">
412 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'float_toc_image')"/>
413 </xsl:attribute>
414 </img>
415 <input id="floatTOCToggle" type="checkbox"/>
416 <script type="text/javascript">
417 <xsl:text disable-output-escaping="yes">
418 $("#floatTOCToggle").prop("checked", false);
419 $("#floatTOCToggle").on("click", function()
420 {
421 floatMenu($("#floatTOCToggle").prop("checked"));
422 });
423
424 $("#floatTOCToggleImage").on("click", function()
425 {
426 $("#floatTOCToggle").prop("checked", !$("#floatTOCToggle").prop("checked"))
427 floatMenu($("#floatTOCToggle").prop("checked"));
428 });
429 </xsl:text>
430 </script>
431 </li>
432 <xsl:if test="/page/pageRequest/paramList/param[@name='ftoc']/@value = '1'">
433 <script type="text/javascript">
434 <xsl:text disable-output-escaping="yes">
435 $(window).on("load", function()
436 {
437 $("#floatTOCToggle").prop("checked", true);
438 floatMenu(true);
439 });
440 </xsl:text>
441 </script>
442 </xsl:if>
443 </xsl:template>
444</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.