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

Last change on this file since 26203 was 26203, checked in by sjm84, 9 years ago

Adding slideshow functionality for paged image collections

  • Property svn:executable set to *
File size: 13.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: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 style="vertical-align:top; text-align:right;">
42 <a id="sidebarMinimizeButton" href="javascript:minimizeSidebar();" style="float: right; font-size:0.6em;">
43 <img class="icon" style="padding-top:3px;">
44 <xsl:attribute name="src">
45 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
46 </xsl:attribute>
47 </img>
48 </a>
49 <a id="sidebarMaximizeButton" href="javascript:maximizeSidebar();" style="float: right; font-size:0.6em; display:none;">
50 <img class="icon" style="padding-top:3px;">
51 <xsl:attribute name="src">
52 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/>
53 </xsl:attribute>
54 </img>
55 </a>
56 </td>
57 </tr>
58 <tr><td>
59 <div id="contentsArea">
60 <!-- show the berry basket if it's turned on -->
61 <gslib:berryBasket/>
62
63 <!-- the contents (if enabled) -->
64 <xsl:choose>
65 <xsl:when test="/page/pageResponse/document/@docType = 'paged' or /page/pageResponse/document/@docType = 'pagedhierarchy'">
66 <gsf:image type="Thumb"/>
67 <!-- Table of contents will be dynamically retrieved when viewing a paged document -->
68 <script type="text/javascript">
69 <xsl:text disable-output-escaping="yes">
70 $(window).load(function()
71 {
72 retrieveTableOfContentsAndTitles();
73 });
74 </xsl:text>
75 </script>
76 <div id="tableOfContents"><xsl:text> </xsl:text></div>
77 <div id="tocLoadingImage" style="text-align:center;">
78 <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>
79 </div>
80 <table style="width:100%;"><tbody><tr>
81 <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>
82 </tr></tbody></table>
83 </xsl:when>
84 <xsl:when test="not(/page/pageRequest/paramList/param[@name = 'ed']/@value = '1')">
85 <div id="tableOfContents">
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 </div>
90 <script type="text/javascript">
91 <xsl:text disable-output-escaping="yes">
92 $(window).load(function()
93 {
94 retrieveFullTableOfContents();
95 });
96 </xsl:text>
97 </script>
98 </xsl:when>
99 <xsl:otherwise>
100 <div id="tableOfContents">
101 <xsl:attribute name="class">
102 <xsl:choose>
103 <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>
104 <xsl:otherwise>hidden</xsl:otherwise>
105 </xsl:choose>
106 </xsl:attribute>
107 <xsl:for-each select="documentNode">
108 <xsl:call-template name="documentNodeTOC"/>
109 </xsl:for-each>
110 </div>
111 </xsl:otherwise>
112 </xsl:choose>
113 </div>
114 </td></tr>
115 </table>
116 </div>
117 </xsl:template>
118
119 <!-- This template is used to display the table of contents -->
120 <xsl:template name="documentNodeTOC">
121
122 <!-- check if this is the currently selected table of contents item -->
123 <xsl:variable name="isCurrent" select="nodeContent"/>
124
125 <!-- formulate the link -->
126 <xsl:variable name="contentsLink">
127 <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
128 </xsl:variable>
129
130 <ul>
131 <table><tr>
132 <!-- The expand/collapse button (not displayed for the top level node) -->
133 <xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle'">
134 <td>
135 <xsl:choose>
136 <xsl:when test="not(nodeContent and not(documentNode))">
137 <img id="ttoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">
138 <xsl:attribute name="src">
139 <xsl:choose>
140 <xsl:when test="/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or /page/pageResponse/document/@selectedNode = @nodeID">
141 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
142 </xsl:when>
143 <xsl:otherwise>
144 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/>
145 </xsl:otherwise>
146 </xsl:choose>
147 </xsl:attribute>
148 </img>
149 </xsl:when>
150 <xsl:otherwise>
151 <xsl:attribute name="class">emptyIcon</xsl:attribute>
152 </xsl:otherwise>
153 </xsl:choose>
154 </td>
155 </xsl:if>
156
157 <!-- The chapter/page icon -->
158 <td>
159 <img>
160 <xsl:if test="nodeContent and not(documentNode)">
161 <xsl:attribute name="class">leafNode</xsl:attribute>
162 </xsl:if>
163
164 <xsl:attribute name="src">
165 <xsl:choose>
166 <xsl:when test="nodeContent and not(documentNode)">
167 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_image')"/>
168 </xsl:when>
169 <xsl:otherwise>
170 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'chapter_image')"/>
171 </xsl:otherwise>
172 </xsl:choose>
173 </xsl:attribute>
174 </img>
175 </td>
176
177 <!-- The section name, links to the section in the document -->
178 <td class="tocTextCell">
179 <a id="toclink{@nodeID}" href="javascript:focusSection('{@nodeID}');">
180 <xsl:if test="util:hashToSectionId(@nodeID)">
181 <xsl:value-of select="util:hashToSectionId(@nodeID)"/>
182 <xsl:text> </xsl:text>
183 </xsl:if>
184 <xsl:call-template name="sectionHeading"/>
185 </a>
186 </td>
187 </tr></table>
188
189 <!-- display any child items -->
190 <xsl:if test="documentNode">
191 <li id="toc{@nodeID}">
192 <xsl:attribute name="style">
193 <xsl:choose>
194 <xsl:when test="/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or /page/pageResponse/document/@selectedNode = @nodeID">
195 <xsl:text>display:block;</xsl:text>
196 </xsl:when>
197 <xsl:otherwise>
198 <xsl:text>display:none;</xsl:text>
199 </xsl:otherwise>
200 </xsl:choose>
201 </xsl:attribute>
202 <xsl:for-each select="documentNode">
203 <xsl:call-template name="documentNodeTOC"/>
204 </xsl:for-each>
205 </li>
206 </xsl:if>
207
208 </ul>
209 </xsl:template>
210
211 <xsl:template name="viewOptions">
212 <div id="viewAndZoomOptions" class="ui-state-default ui-corner-all">
213 <ul id="viewOptions">
214 <!-- Paged-image options -->
215 <li id="pagedImageOptions">
216 <xsl:attribute name="style">
217 <xsl:choose>
218 <xsl:when test="count(//documentNode/metadataList/metadata[@name = 'Screen']) > 0 or /page/pageResponse/document/@docType = 'paged' or /page/pageResponse/document/@docType = 'pagedhierarchy'">
219 </xsl:when>
220 <xsl:otherwise>
221 display:none;
222 </xsl:otherwise>
223 </xsl:choose>
224 </xsl:attribute>
225 <select id="viewSelection" onchange="changeView();">
226 <xsl:choose>
227 <xsl:when test="/page/pageRequest/paramList/param[@name = 'view']/@value = 'image'">
228 <option>Default view</option>
229 <option selected="true">Image view</option>
230 <option>Text view</option>
231 </xsl:when>
232 <xsl:when test="/page/pageRequest/paramList/param[@name = 'view']/@value = 'text'">
233 <option>Default view</option>
234 <option>Image view</option>
235 <option selected="true">Text view</option>
236 </xsl:when>
237 <xsl:otherwise>
238 <option selected="true">Default view</option>
239 <option>Image view</option>
240 <option>Text view</option>
241 </xsl:otherwise>
242 </xsl:choose>
243 </select>
244 </li>
245
246 <!-- Slide-show options -->
247 <li id="slideShowOptions">
248 <xsl:attribute name="style">
249 <xsl:choose>
250 <xsl:when test="count(//documentNode/metadataList/metadata[@name = 'Screen']) > 0 or /page/pageResponse/document/@docType = 'paged' or /page/pageResponse/document/@docType = 'pagedhierarchy'">
251 </xsl:when>
252 <xsl:otherwise>
253 display:none;
254 </xsl:otherwise>
255 </xsl:choose>
256 </xsl:attribute>
257 <img>
258 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'slideshow_image')"/></xsl:attribute>
259 </img>
260 <input id="ssOption" type="checkbox" onclick="showSlideShow()" class="optionCheckBox"/>
261 </li>
262
263 <!-- Realistic books link -->
264 <xsl:if test="/page/pageResponse/collection[@name = $collName]/metadataList/metadata[@name = 'tidyoption'] = 'tidy'">
265 <li>
266 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.realisticBooksTooltip')"/></xsl:attribute>
267 <img>
268 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'realistic_books_image')"/></xsl:attribute>
269 </img>
270 <input id="rbOption" type="checkbox" onclick="bookInit();" class="optionCheckBox"/>
271 </li>
272 </xsl:if>
273
274 <!-- Highlight on/off button -->
275 <xsl:if test="util:contains(/page/pageRequest/paramList/param[@name = 'p.s']/@value, 'Query')">
276 <li>
277 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.highlightTooltip')"/></xsl:attribute>
278 <img>
279 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'highlight_image')"/></xsl:attribute>
280 </img>
281 <input id="highlightOption" type="checkbox" class="optionCheckBox" onclick="swapHighlight();">
282 <xsl:if test="/page/pageRequest/paramList/param[@name = 'hl']/@value = 'on'">
283 <xsl:attribute name="checked">true</xsl:attribute>
284 </xsl:if>
285 </input>
286 </li>
287 </xsl:if><xsl:text> </xsl:text>
288 </ul>
289 <ul id="zoomOptions">
290 <!-- This is invisible unless it is made visible by Javascript controlling the image zooming -->
291 <xsl:attribute name="style">display: none;</xsl:attribute>
292 <li style="width:10%;">
293 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.zoom')"/>
294 </li>
295 <li style="width:5%;">
296 <input id="zoomToggle" type="checkbox"/>
297 <script type="text/javascript">
298 <xsl:text disable-output-escaping="yes">
299 $("#zoomToggle").change(function()
300 {
301 _imageZoomEnabled = $("#zoomToggle").attr("checked");
302 });
303 </xsl:text>
304 </script>
305 </li>
306 <li style="width:15%;"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.zoom_size')"/><xsl:text>:</xsl:text></li>
307 <li id="zoomSlider" style="width:50%; height:5px;"><xsl:text> </xsl:text></li>
308 <script type="text/javascript">
309 <xsl:text disable-output-escaping="yes">
310 $("#zoomSlider").slider(
311 {
312 change: function(event, ui)
313 {
314 var sliderValue = ui.value;
315 var divs = document.getElementsByTagName("DIV");
316 for(var i = 0; i &lt; divs.length; i++)
317 {
318 if(divs[i].getAttribute("id") &amp;&amp; divs[i].getAttribute("id").search(/^mover.*/) != -1)
319 {
320 divs[i].style.height = 400 + (2 * sliderValue) + "px";
321 divs[i].style.width = 400 + (2 * sliderValue) + "px";
322 }
323 }
324 }
325 });
326 </xsl:text>
327 </script>
328 <style>.ui-slider .ui-slider-handle{height:0.8em; width:1.0em;}</style>
329 </ul>
330 </div>
331 </xsl:template>
332</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.