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:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
|
---|
7 | extension-element-prefixes="java util"
|
---|
8 | exclude-result-prefixes="java util gsf">
|
---|
9 |
|
---|
10 | <xsl:template name="expansionScript">
|
---|
11 | <script type="text/javascript">
|
---|
12 | <xsl:text disable-output-escaping="yes">
|
---|
13 | var collapseImageURL = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/><xsl:text disable-output-escaping="yes">";
|
---|
14 | var expandImageURL = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/><xsl:text disable-output-escaping="yes">";
|
---|
15 | var chapterImageURL = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'chapter_image')"/><xsl:text disable-output-escaping="yes">";
|
---|
16 | var pageImageURL = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_image')"/><xsl:text disable-output-escaping="yes">";
|
---|
17 |
|
---|
18 | function toggleSection(sectionID)
|
---|
19 | {
|
---|
20 | var docElem = document.getElementById("doc" + sectionID);
|
---|
21 | var tocElem = document.getElementById("toc" + sectionID);
|
---|
22 |
|
---|
23 | var tocToggleElem = document.getElementById("ttoggle" + sectionID);
|
---|
24 | var docToggleElem = document.getElementById("dtoggle" + sectionID);
|
---|
25 |
|
---|
26 | if(docElem.style.display == "none")
|
---|
27 | {
|
---|
28 | docElem.style.display = "block";
|
---|
29 | docToggleElem.setAttribute("src", collapseImageURL);
|
---|
30 |
|
---|
31 | if(tocToggleElem)
|
---|
32 | {
|
---|
33 | tocToggleElem.setAttribute("src", collapseImageURL);
|
---|
34 | }
|
---|
35 |
|
---|
36 | if(tocElem)
|
---|
37 | {
|
---|
38 | tocElem.style.display = "block";
|
---|
39 | }
|
---|
40 | }
|
---|
41 | else
|
---|
42 | {
|
---|
43 | docElem.style.display = "none";
|
---|
44 |
|
---|
45 | //Use the page image if this is a leaf node and the chapter image if it not
|
---|
46 | docToggleElem.setAttribute("src", expandImageURL);
|
---|
47 |
|
---|
48 | if(tocToggleElem)
|
---|
49 | {
|
---|
50 | tocToggleElem.setAttribute("src", expandImageURL);
|
---|
51 | }
|
---|
52 |
|
---|
53 | if(tocElem)
|
---|
54 | {
|
---|
55 | tocElem.style.display = "none";
|
---|
56 | }
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|
60 | function isExpanded(sectionID)
|
---|
61 | {
|
---|
62 | var docElem = document.getElementById("doc" + sectionID);
|
---|
63 | if(docElem.style.display == "block")
|
---|
64 | {
|
---|
65 | return true;
|
---|
66 | }
|
---|
67 | return false;
|
---|
68 | }
|
---|
69 |
|
---|
70 | function isParentOf(parent, child)
|
---|
71 | {
|
---|
72 | if(child.indexOf(parent) != -1 && child.length > parent.length && child[parent.length] == '.')
|
---|
73 | {
|
---|
74 | return true;
|
---|
75 | }
|
---|
76 | return false;
|
---|
77 | }
|
---|
78 |
|
---|
79 | function focusSection(sectionID)
|
---|
80 | {
|
---|
81 | var tableOfContentsDiv = document.getElementById("tableOfContents");
|
---|
82 | var images = tableOfContentsDiv.getElementsByTagName("img");
|
---|
83 | var nodeArray = new Array();
|
---|
84 |
|
---|
85 | for(var i = 0; i < images.length; i++)
|
---|
86 | {
|
---|
87 | nodeArray[i] = images[i].getAttribute("id").substring(7);
|
---|
88 | }
|
---|
89 |
|
---|
90 | for(var j = 0; j < nodeArray.length; j++)
|
---|
91 | {
|
---|
92 | //If this is the node that was clicked and it is not expanded then expand it
|
---|
93 | if(nodeArray[j] == sectionID)
|
---|
94 | {
|
---|
95 | if(!isExpanded(nodeArray[j]))
|
---|
96 | {
|
---|
97 | toggleSection(nodeArray[j]);
|
---|
98 | }
|
---|
99 |
|
---|
100 | continue;
|
---|
101 | }
|
---|
102 |
|
---|
103 | //If the node is a parent or child of the node that is clicked and is not expanded then expand it
|
---|
104 | if((isParentOf(nodeArray[j], sectionID) || isParentOf(sectionID, nodeArray[j])) && !isExpanded(nodeArray[j]))
|
---|
105 | {
|
---|
106 | toggleSection(nodeArray[j]);
|
---|
107 | }
|
---|
108 | //If the node is not a parent or child and is expanded then collapse it
|
---|
109 | else if(!(isParentOf(nodeArray[j], sectionID) || isParentOf(sectionID, nodeArray[j])) && isExpanded(nodeArray[j]))
|
---|
110 | {
|
---|
111 | toggleSection(nodeArray[j]);
|
---|
112 | }
|
---|
113 | }
|
---|
114 | }
|
---|
115 | </xsl:text>
|
---|
116 | </script>
|
---|
117 | </xsl:template>
|
---|
118 |
|
---|
119 | <xsl:template name="highlightingScript">
|
---|
120 | <script type="text/javascript">
|
---|
121 | <xsl:text disable-output-escaping="yes">
|
---|
122 | function addHighlight()
|
---|
123 | {
|
---|
124 | var spans = document.getElementsByTagName("span");
|
---|
125 | for(var i = 0; i < spans.length; i++)
|
---|
126 | {
|
---|
127 | var currentSpan = spans[i];
|
---|
128 | if(currentSpan.getAttribute("class") == "noTermHighlight")
|
---|
129 | {
|
---|
130 | currentSpan.setAttribute("class", "termHighlight");
|
---|
131 | }
|
---|
132 | }
|
---|
133 |
|
---|
134 | var option = document.getElementById("highlightOption");
|
---|
135 | option.setAttribute("onclick", "removeHighlight();");
|
---|
136 | }
|
---|
137 |
|
---|
138 | function removeHighlight()
|
---|
139 | {
|
---|
140 | var spans = document.getElementsByTagName("span");
|
---|
141 | for(var i = 0; i < spans.length; i++)
|
---|
142 | {
|
---|
143 | var currentSpan = spans[i];
|
---|
144 | if(currentSpan.getAttribute("class") == "termHighlight")
|
---|
145 | {
|
---|
146 | currentSpan.setAttribute("class", "noTermHighlight");
|
---|
147 | }
|
---|
148 | }
|
---|
149 |
|
---|
150 | var option = document.getElementById("highlightOption");
|
---|
151 | option.setAttribute("onclick", "addHighlight();");
|
---|
152 | }
|
---|
153 | </xsl:text>
|
---|
154 | </script>
|
---|
155 | </xsl:template>
|
---|
156 |
|
---|
157 | <xsl:template name="realisticBooksScript">
|
---|
158 | <script type="text/javascript">
|
---|
159 | <xsl:text disable-output-escaping="yes">
|
---|
160 | function bookInit()
|
---|
161 | {
|
---|
162 | loadBook();
|
---|
163 | hideText();
|
---|
164 | showBook();
|
---|
165 | swapLinkJavascript(false);
|
---|
166 | }
|
---|
167 |
|
---|
168 | function hideText()
|
---|
169 | {
|
---|
170 | var textDiv = document.getElementById("gs-document-text");
|
---|
171 | textDiv.style.display = "none";
|
---|
172 | }
|
---|
173 |
|
---|
174 | function showText()
|
---|
175 | {
|
---|
176 | var textDiv = document.getElementById("gs-document-text");
|
---|
177 | textDiv.style.display = "block";
|
---|
178 | }
|
---|
179 |
|
---|
180 | function hideBook()
|
---|
181 | {
|
---|
182 | var bookDiv = document.getElementById("bookdiv");
|
---|
183 | bookDiv.style.visibility = "hidden";
|
---|
184 | bookDiv.style.height = "0px";
|
---|
185 | }
|
---|
186 |
|
---|
187 | function showBook()
|
---|
188 | {
|
---|
189 | var bookDiv = document.getElementById("bookdiv");
|
---|
190 | bookDiv.style.visibility = "visible";
|
---|
191 | bookDiv.style.height = "600px";
|
---|
192 | }
|
---|
193 |
|
---|
194 | //Helper function to create param elements
|
---|
195 | function createParam(name, value)
|
---|
196 | {
|
---|
197 | var param = document.createElement("PARAM");
|
---|
198 | param.setAttribute("name", name);
|
---|
199 | param.setAttribute("value", value);
|
---|
200 | return param;
|
---|
201 | }
|
---|
202 |
|
---|
203 | function swapLinkJavascript(rbOn)
|
---|
204 | {
|
---|
205 | var option = document.getElementById("rbOption");
|
---|
206 | if(rbOn)
|
---|
207 | {
|
---|
208 | option.setAttribute("onclick", "hideText(); showBook(); swapLinkJavascript(false);");
|
---|
209 | }
|
---|
210 | else
|
---|
211 | {
|
---|
212 | option.setAttribute("onclick", "hideBook(); showText(); swapLinkJavascript(true);");
|
---|
213 | }
|
---|
214 | }
|
---|
215 |
|
---|
216 | function loadBook()
|
---|
217 | {
|
---|
218 | //Work out the URL to the cover image and the document
|
---|
219 | var img_cover = '</xsl:text><xsl:value-of select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']"/>/index/assoc/<xsl:value-of select="metadataList/metadata[@name='assocfilepath']"/>/cover.jpg<xsl:text disable-output-escaping="yes">';
|
---|
220 | var doc_url = document.URL;
|
---|
221 | doc_url = doc_url.replace(/(&|\?)book=[a-z]+/gi,'');
|
---|
222 | doc_url += '&book=flashxml';
|
---|
223 |
|
---|
224 | //The outer OBJECT element
|
---|
225 | var objectElem = document.createElement("OBJECT");
|
---|
226 | objectElem.setAttribute("align", "middle");
|
---|
227 | objectElem.setAttribute("classid", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000");
|
---|
228 | objectElem.setAttribute("codebase", "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0");
|
---|
229 | objectElem.setAttribute("height", "600px");
|
---|
230 | objectElem.setAttribute("width", "70%");
|
---|
231 | objectElem.setAttribute("id", "bookObject");
|
---|
232 |
|
---|
233 | //Parameter list
|
---|
234 | var params = new Array();
|
---|
235 | params[0] = createParam("allowScriptAccess", "always");
|
---|
236 | params[1] = createParam("movie", "RealisticBook.swf?src_image=" + escape(img_cover) + "&doc_url=" + escape(doc_url));
|
---|
237 | params[2] = createParam("quality", "high");
|
---|
238 | params[3] = createParam("bgcolor", "#FFFFFF");
|
---|
239 |
|
---|
240 | //The embed element that goes into the object element
|
---|
241 | var embedElem = document.createElement("EMBED");
|
---|
242 | embedElem.setAttribute("allowScriptAccess", "always");
|
---|
243 | embedElem.setAttribute("swLiveConnect", "true");
|
---|
244 | embedElem.setAttribute("bgcolor", "#FFFFFF");
|
---|
245 | embedElem.setAttribute("height", "600px");
|
---|
246 | embedElem.setAttribute("name", "Book");
|
---|
247 | embedElem.setAttribute("pluginspage", "http://www.macromedia.com/go/getflashplayer");
|
---|
248 | embedElem.setAttribute("quality", "high");
|
---|
249 | embedElem.setAttribute("src", "RealisticBook.swf?src_image=" + escape(img_cover) + "&doc_url=" + escape(doc_url));
|
---|
250 | embedElem.setAttribute("type", "application/x-shockwave-flash");
|
---|
251 | embedElem.setAttribute("width", "70%");
|
---|
252 |
|
---|
253 | //Append the param and embed elements to the object element
|
---|
254 | for(var i = 0; i < params.length; i++)
|
---|
255 | {
|
---|
256 | objectElem.appendChild(params[i]);
|
---|
257 | }
|
---|
258 | objectElem.appendChild(embedElem);
|
---|
259 |
|
---|
260 | //Append the object element to the page
|
---|
261 | var flashDiv = document.getElementById("bookdiv");
|
---|
262 | flashDiv.appendChild(objectElem);
|
---|
263 | }
|
---|
264 | </xsl:text>
|
---|
265 | </script>
|
---|
266 | </xsl:template>
|
---|
267 | </xsl:stylesheet> |
---|