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

Last change on this file since 30169 was 30169, checked in by kjdon, 6 years ago

changing the filtering algorithm. Can choose between pagenum and title. pagenum is numeric by default, title is string matching.

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