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.visibility = "hidden";
|
---|
172 | }
|
---|
173 |
|
---|
174 | function showText()
|
---|
175 | {
|
---|
176 | var textDiv = document.getElementById("gs-document-text");
|
---|
177 | textDiv.style.visibility = "visible";
|
---|
178 | }
|
---|
179 |
|
---|
180 | function hideBook()
|
---|
181 | {
|
---|
182 | var bookDiv = document.getElementById("bookdiv");
|
---|
183 | bookDiv.style.visibility = "hidden";
|
---|
184 | bookDiv.style.height = "0px";
|
---|
185 |
|
---|
186 | var bookObject = document.getElementById("bookObject");
|
---|
187 | bookObject.style.visibility = "hidden";
|
---|
188 | bookObject.style.height = "0px";
|
---|
189 |
|
---|
190 | var bookEmbed = document.getElementById("bookEmbed");
|
---|
191 | bookEmbed.style.visibility = "hidden";
|
---|
192 | bookEmbed.style.height = "0px";
|
---|
193 | }
|
---|
194 |
|
---|
195 | function showBook()
|
---|
196 | {
|
---|
197 | var bookDiv = document.getElementById("bookdiv");
|
---|
198 | bookDiv.style.visibility = "visible";
|
---|
199 | bookDiv.style.height = "600px";
|
---|
200 |
|
---|
201 | var bookObject = document.getElementById("bookObject");
|
---|
202 | bookObject.style.visibility = "visible";
|
---|
203 | bookObject.style.height = "600px";
|
---|
204 |
|
---|
205 | var bookEmbed = document.getElementById("bookEmbed");
|
---|
206 | bookEmbed.style.visibility = "visible";
|
---|
207 | bookEmbed.style.height = "600px";
|
---|
208 | }
|
---|
209 |
|
---|
210 | function swapLinkJavascript(rbOn)
|
---|
211 | {
|
---|
212 | var option = document.getElementById("rbOption");
|
---|
213 | if(rbOn)
|
---|
214 | {
|
---|
215 | option.setAttribute("onclick", "hideText(); showBook(); swapLinkJavascript(false);");
|
---|
216 | }
|
---|
217 | else
|
---|
218 | {
|
---|
219 | option.setAttribute("onclick", "hideBook(); showText(); swapLinkJavascript(true);");
|
---|
220 | }
|
---|
221 | }
|
---|
222 |
|
---|
223 | //Helper function to create param elements
|
---|
224 | function createParam(name, value)
|
---|
225 | {
|
---|
226 | var param = document.createElement("PARAM");
|
---|
227 | param.setAttribute("name", name);
|
---|
228 | param.setAttribute("value", value);
|
---|
229 | return param;
|
---|
230 | }
|
---|
231 |
|
---|
232 | function loadBook()
|
---|
233 | {
|
---|
234 | var doc_url = document.URL;
|
---|
235 | doc_url = doc_url.replace(/(&|\?)book=[a-z]+/gi,'');
|
---|
236 | doc_url += '&book=flashxml';
|
---|
237 |
|
---|
238 | 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">';
|
---|
239 |
|
---|
240 | var flash_plug_html = ""
|
---|
241 | flash_plug_html += '<OBJECT align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" \n';
|
---|
242 | flash_plug_html += ' height="600px" id="bookObject" swLiveConnect="true" \n';
|
---|
243 | flash_plug_html += ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" \n';
|
---|
244 | flash_plug_html += ' width="70%">\n';
|
---|
245 | flash_plug_html += ' <PARAM name="allowScriptAccess" value="always" />\n';
|
---|
246 | flash_plug_html += ' <PARAM name="movie" value="Book.swf';
|
---|
247 | flash_plug_html += '?src_image=' + escape(img_cover);
|
---|
248 | flash_plug_html += '&doc_url=' + escape(doc_url)
|
---|
249 | flash_plug_html += '" />\n';
|
---|
250 | flash_plug_html += ' <PARAM name="quality" value="high" />\n';
|
---|
251 | flash_plug_html += ' <PARAM name="bgcolor" value="#FFFFFF" />\n';
|
---|
252 | flash_plug_html += ' <EMBED align="middle" \n';
|
---|
253 | flash_plug_html += ' allowScriptAccess="always" swLiveConnect="true" \n';
|
---|
254 | flash_plug_html += ' bgcolor="#FFFFFF" height="600px" name="Book" \n';
|
---|
255 | flash_plug_html += ' pluginspage="http://www.macromedia.com/go/getflashplayer" \n';
|
---|
256 | flash_plug_html += ' quality="high" id="bookEmbed"\n';
|
---|
257 | flash_plug_html += ' src="Book.swf';
|
---|
258 | flash_plug_html += '?src_image=' + escape(img_cover);
|
---|
259 | flash_plug_html += '&doc_url=' + escape(doc_url);
|
---|
260 | flash_plug_html += '"\n';
|
---|
261 | flash_plug_html += ' type="application/x-shockwave-flash" width="70%" />\n';
|
---|
262 | flash_plug_html += '</OBJECT>\n';
|
---|
263 | var flash_div = document.getElementById("bookdiv");
|
---|
264 | flash_div.innerHTML = flash_plug_html;
|
---|
265 | }
|
---|
266 |
|
---|
267 | if(document.URL.indexOf("book=on") != -1)
|
---|
268 | {
|
---|
269 | loadBook();
|
---|
270 | }
|
---|
271 | </xsl:text>
|
---|
272 | </script>
|
---|
273 | </xsl:template>
|
---|
274 | </xsl:stylesheet> |
---|