source: main/branches/64_bit_Greenstone/greenstone3/web/interfaces/oran/transform/document-scripts.xsl@ 24007

Last change on this file since 24007 was 24007, checked in by sjm84, 13 years ago

Updating this branch to match the latest Greenstone3 changes

  • Property svn:executable set to *
File size: 7.7 KB
RevLine 
[23989]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 function toggleSection(sectionID)
14 {
15 var docElem = document.getElementById("doc" + sectionID);
16 var tocElem = document.getElementById("toc" + sectionID);
17
18 var tocToggleElem = document.getElementById("ttoggle" + sectionID);
19 var docToggleElem = document.getElementById("dtoggle" + sectionID);
20
21 if(docElem.style.display == "none")
22 {
23 var imageClass = (docToggleElem.getAttribute("class").indexOf("leafNode") != -1) ? "icon toggleImageCollapse leafNode" : "icon toggleImageCollapse";
24
25 docElem.style.display = "block";
26 docToggleElem.setAttribute("class", imageClass);
27
28 if(tocToggleElem)
29 {
30 tocToggleElem.setAttribute("class", imageClass);
31 }
32
33 if(tocElem)
34 {
35 tocElem.style.display = "block";
36 }
37 }
38 else
39 {
40 docElem.style.display = "none";
41
42 //Use the page image if this is a leaf node and the chapter image if it not
43 //var imageClass = (docToggleElem.getAttribute("class").indexOf("leafNode") != -1) ? "icon toggleImagePage leafNode" : "icon toggleImageChapter";
44 var imageClass = (docToggleElem.getAttribute("class").indexOf("leafNode") != -1) ? "icon toggleImageExpand leafNode" : "icon toggleImageExpand";
45 docToggleElem.setAttribute("class", imageClass);
46
47 if(tocToggleElem)
48 {
49 tocToggleElem.setAttribute("class", imageClass);
50 }
51
52 if(tocElem)
53 {
54 tocElem.style.display = "none";
55 }
56 }
57 }
58
59 function isExpanded(sectionID)
60 {
61 var docElem = document.getElementById("doc" + sectionID);
62 if(docElem.style.display == "block")
63 {
64 return true;
65 }
66 return false;
67 }
68
69 function isParentOf(parent, child)
70 {
71 if(child.indexOf(parent) != -1 &amp;&amp; child.length > parent.length &amp;&amp; child[parent.length] == '.')
72 {
73 return true;
74 }
75 return false;
76 }
77
78 function focusSection(sectionID)
79 {
80 var tableOfContentsDiv = document.getElementById("tableOfContents");
81 var images = tableOfContentsDiv.getElementsByTagName("img");
82 var nodeArray = new Array();
83
84 for(var i = 0; i &lt; images.length; i++)
85 {
86 nodeArray[i] = images[i].getAttribute("id").substring(7);
87 }
88
89 for(var j = 0; j &lt; nodeArray.length; j++)
90 {
91 //If this is the node that was clicked and it is not expanded then expand it
92 if(nodeArray[j] == sectionID)
93 {
94 if(!isExpanded(nodeArray[j]))
95 {
96 toggleSection(nodeArray[j]);
97 }
98
99 continue;
100 }
101
102 //If the node is a parent or child of the node that is clicked and is not expanded then expand it
103 if((isParentOf(nodeArray[j], sectionID) || isParentOf(sectionID, nodeArray[j])) &amp;&amp; !isExpanded(nodeArray[j]))
104 {
105 toggleSection(nodeArray[j]);
106 }
107 //If the node is not a parent or child and is expanded then collapse it
108 else if(!(isParentOf(nodeArray[j], sectionID) || isParentOf(sectionID, nodeArray[j])) &amp;&amp; isExpanded(nodeArray[j]))
109 {
110 toggleSection(nodeArray[j]);
111 }
112 }
113 }
114 </xsl:text>
115 </script>
116 </xsl:template>
117
118 <xsl:template name="highlightingScript">
119 <script type="text/javascript">
120 <xsl:text disable-output-escaping="yes">
121 function addHighlight()
122 {
123 var spans = document.getElementsByTagName("span");
124 for(var i = 0; i &lt; spans.length; i++)
125 {
126 var currentSpan = spans[i];
127 if(currentSpan.getAttribute("class") == "noTermHighlight")
128 {
129 currentSpan.setAttribute("class", "termHighlight");
130 }
131 }
132
133 var option = document.getElementById("highlightOption");
134 option.innerHTML = "No Highlighting";
135 option.setAttribute("href", "javascript:removeHighlight();");
136 }
137
138 function removeHighlight()
139 {
140 var spans = document.getElementsByTagName("span");
141 for(var i = 0; i &lt; 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.innerHTML = "Highlighting";
152 option.setAttribute("href", "javascript:addHighlight();");
153 }
154 </xsl:text>
155 </script>
156 </xsl:template>
157
158 <xsl:template name="realisticBooksScript">
159 <div id="bookdiv"/>
160 <script type="text/javascript">
161 <xsl:text disable-output-escaping="yes">
162
163 //Helper function to create param elements
164 function createParam(name, value)
165 {
166 var param = document.createElement("PARAM");
167 param.setAttribute("name", name);
168 param.setAttribute("value", value);
169 return param;
170 }
171
172 //Work out the URL to the cover image and the document
173 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">';
174 var doc_url = document.URL;
175 doc_url = doc_url.replace(/(&amp;|\?)book=[a-z]+/gi,'');
176 doc_url += '&amp;book=flashxml';
177
178 //The outer OBJECT element
179 var objectElem = document.createElement("OBJECT");
180 objectElem.setAttribute("align", "middle");
181 objectElem.setAttribute("classid", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000");
182 objectElem.setAttribute("codebase", "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0");
183 objectElem.setAttribute("height", "600px");
184 objectElem.setAttribute("width", "100%");
185
186 //Parameter list
187 var params = new Array();
188 params[0] = createParam("allowScriptAccess", "always");
189 params[1] = createParam("movie", "Book.swf?src_image=" + escape(img_cover) + "&amp;doc_url=" + escape(doc_url));
190 params[2] = createParam("quality", "high");
191 params[3] = createParam("bgcolor", "#FFFFFF");
192
193 //The embed element that goes into the object element
194 var embedElem = document.createElement("EMBED");
195 embedElem.setAttribute("allowScriptAccess", "always");
196 embedElem.setAttribute("swLiveConnect", "true");
197 embedElem.setAttribute("bgcolor", "#FFFFFF");
198 embedElem.setAttribute("height", "600px");
199 embedElem.setAttribute("name", "Book");
200 embedElem.setAttribute("pluginspage", "http://www.macromedia.com/go/getflashplayer");
201 embedElem.setAttribute("quality", "high");
202 embedElem.setAttribute("src", "Book.swf?src_image=" + escape(img_cover) + "&amp;doc_url=" + escape(doc_url));
203 embedElem.setAttribute("type", "application/x-shockwave-flash");
204 embedElem.setAttribute("width", "100%");
205
206 //Append the param and embed elements to the object element
207 for(var i = 0; i &lt; params.length; i++)
208 {
209 objectElem.appendChild(params[i]);
210 }
211 objectElem.appendChild(embedElem);
212
213 //Append the object element to the page
214 var flashDiv = document.getElementById("bookdiv");
215 flashDiv.appendChild(objectElem);
216 </xsl:text>
217 </script>
218 </xsl:template>
219</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.