source: main/trunk/greenstone3/web/interfaces/default/transform/javascript-global-setup.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: 10.8 KB
Line 
1<xsl:stylesheet version="1.0"
2 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:java="http://xml.apache.org/xslt/java"
4 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
5 xmlns:gslib="http://www.greenstone.org/skinning"
6 extension-element-prefixes="java util"
7 exclude-result-prefixes="java util">
8
9 <xsl:template name="setup-gs-variable">
10 <script type="text/javascript">
11 gs = new Array();
12 gs.cgiParams = new Array();
13 gs.xsltParams = new Array();
14 gs.siteMetadata = new Array();
15 gs.collectionMetadata = new Array();
16 gs.documentMetadata = new Array();
17 gs.imageURLs = new Array();
18 gs.variables = new Array();
19 gs.requestInformation = new Array();
20 </script>
21 <xsl:call-template name="populate-cgi-param-values"/>
22 <xsl:call-template name="populate-xslt-param-values"/>
23 <xsl:call-template name="populate-image-url-values"/>
24 <xsl:call-template name="populate-metadata-values"/>
25 <xsl:call-template name="populate-request-information-values"/>
26 <xsl:call-template name="include-global-javascript-functions"/>
27 </xsl:template>
28
29 <xsl:template name="populate-cgi-param-values">
30 <script type="text/javascript">
31 var name;
32 var value;
33 <xsl:for-each select="/page/pageRequest/paramList/param">
34 <xsl:text disable-output-escaping="yes">name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
35 <xsl:text disable-output-escaping="yes">value = "</xsl:text><xsl:value-of select="util:escapeNewLinesAndQuotes(@value)"/><xsl:text disable-output-escaping="yes">";</xsl:text>
36 <xsl:text disable-output-escaping="yes">name = name.replace(".", "_");</xsl:text>
37 gs.cgiParams[name] = value;
38 </xsl:for-each>
39 </script>
40 </xsl:template>
41
42 <xsl:template name="populate-xslt-param-values">
43 <script type="text/javascript">
44 <xsl:text disable-output-escaping="yes">gs.xsltParams.library_name = "</xsl:text><xsl:value-of select="$library_name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
45 <xsl:text disable-output-escaping="yes">gs.xsltParams.interface_name = "</xsl:text><xsl:value-of select="$interface_name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
46 <xsl:text disable-output-escaping="yes">gs.xsltParams.site_name = "</xsl:text><xsl:value-of select="$site_name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
47 </script>
48 </xsl:template>
49
50 <xsl:template name="populate-metadata-values">
51 <script type="text/javascript">
52 <xsl:text disable-output-escaping="yes">
53 function addMetadataToList(name, value, list, lang)
54 {
55 name = name.replace(".", "_");
56 if(lang == "" || lang == "en")
57 {
58 list[name] = value;
59 }
60 else
61 {
62 if (list[lang] == undefined)
63 {
64 list[lang] = new Array();
65 }
66 var langList = list[lang];
67 langList[name] = value;
68 }
69 }
70 var name;
71 var value;
72 var lang;
73 </xsl:text>
74 <xsl:for-each select="/page/pageResponse/metadataList/metadata">
75 <xsl:text disable-output-escaping="yes">name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
76 <xsl:text disable-output-escaping="yes">value = "</xsl:text><xsl:value-of disable-output-escaping="yes" select="util:escapeNewLinesAndQuotes(.)"/><xsl:text disable-output-escaping="yes">";</xsl:text>
77 <xsl:text disable-output-escaping="yes">lang = "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">";</xsl:text>
78 addMetadataToList(name, value, gs.siteMetadata, lang);
79 </xsl:for-each>
80
81 <xsl:for-each select="/page/pageResponse/collection/metadataList/metadata">
82 <xsl:text disable-output-escaping="yes">name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
83 <xsl:text disable-output-escaping="yes">value = "</xsl:text><xsl:value-of disable-output-escaping="yes" select="util:escapeNewLinesAndQuotes(.)"/><xsl:text disable-output-escaping="yes">";</xsl:text>
84 <xsl:text disable-output-escaping="yes">lang = "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">";</xsl:text>
85 addMetadataToList(name, value, gs.collectionMetadata, lang);
86 </xsl:for-each>
87
88 <xsl:for-each select="/page/pageResponse/document/metadataList/metadata">
89 <xsl:text disable-output-escaping="yes">name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
90 <xsl:text disable-output-escaping="yes">value = "</xsl:text><xsl:value-of disable-output-escaping="yes" select="util:escapeNewLinesAndQuotes(.)"/><xsl:text disable-output-escaping="yes">";</xsl:text>
91 <xsl:text disable-output-escaping="yes">lang = "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">";</xsl:text>
92 addMetadataToList(name, value, gs.documentMetadata, lang);
93 </xsl:for-each>
94
95 <xsl:text disable-output-escaping="yes">addMetadataToList("docType", "</xsl:text><xsl:value-of select="/page/pageResponse/document/@docType"/><xsl:text disable-output-escaping="yes">", gs.documentMetadata, "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">");</xsl:text>
96 </script>
97 </xsl:template>
98
99 <xsl:template name="populate-image-url-values">
100 <script type="text/javascript">
101 <xsl:text disable-output-escaping="yes">gs.imageURLs.expand = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
102 <xsl:text disable-output-escaping="yes">gs.imageURLs.collapse = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
103 <xsl:text disable-output-escaping="yes">gs.imageURLs.page = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
104 <xsl:text disable-output-escaping="yes">gs.imageURLs.chapter = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'chapter_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
105 <xsl:text disable-output-escaping="yes">gs.imageURLs.realisticBook = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'realistic_books_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
106 <xsl:text disable-output-escaping="yes">gs.imageURLs.highlight = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'highlight_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
107 <xsl:text disable-output-escaping="yes">gs.imageURLs.bookshelf = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'bookshelf_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
108 <xsl:text disable-output-escaping="yes">gs.imageURLs.book = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'book_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
109 <xsl:text disable-output-escaping="yes">gs.imageURLs.loading = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'loading_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
110 <xsl:text disable-output-escaping="yes">gs.imageURLs.pageIcon = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_icon_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
111 <xsl:text disable-output-escaping="yes">gs.imageURLs.trashFull = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'trash_full_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
112 <xsl:text disable-output-escaping="yes">gs.imageURLs.next = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'next_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
113 <xsl:text disable-output-escaping="yes">gs.imageURLs.prev = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'prev_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
114 </script>
115 </xsl:template>
116
117 <xsl:template name="populate-request-information-values">
118 <script type="text/javascript">
119 <xsl:text disable-output-escaping="yes">
120 gs.requestInformation.fullURL = "</xsl:text><xsl:value-of select="/page/pageRequest/@fullURL"/><xsl:text disable-output-escaping="yes">";
121 </xsl:text>
122 </script>
123 </xsl:template>
124
125 <xsl:template name="include-global-javascript-functions">
126 <script type="text/javascript" src="interfaces/default/js/javascript-global-functions.js"><xsl:text> </xsl:text></script>
127 <script type="text/javascript" src="interfaces/default/js/GSMetadata.js"><xsl:text> </xsl:text></script>
128 </xsl:template>
129</xsl:stylesheet>
130
131 <!-- CAN WE FIND SOME WAY TO MAKE THIS WORK?
132 <xsl:call-template name="populate-metadata-values">
133 <xsl:with-param name="path">/page/pageResponse/metadataList/metadata</xsl:with-param>
134 <xsl:with-param name="metadataListName">siteMetadata</xsl:with-param>
135 </xsl:call-template>
136
137 <xsl:call-template name="populate-metadata-values">
138 <xsl:with-param name="path">/page/pageResponse/collection/metadataList/metadata</xsl:with-param>
139 <xsl:with-param name="metadataListName">collectionMetadata</xsl:with-param>
140 </xsl:call-template>
141
142 <xsl:call-template name="populate-metadata-values">
143 <xsl:with-param name="path">/page/pageResponse/document/metadataList/metadata</xsl:with-param>
144 <xsl:with-param name="metadataListName">documentMetadata</xsl:with-param>
145 </xsl:call-template>
146 -->
147
148 <!-- NOT WORKING BUT IT WOULD BE TIDIER IF IT DID
149 <xsl:template name="populate-metadata-values">
150 <xsl:param name="path"/>
151 <xsl:param name="metadataListName"/>
152
153 <xsl:for-each select="$path">
154 <script type="text/javascript">
155 <xsl:text disable-output-escaping="yes">var name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
156 <xsl:text disable-output-escaping="yes">var value = "</xsl:text><xsl:value-of select="."/><xsl:text disable-output-escaping="yes">";</xsl:text>
157 <xsl:text disable-output-escaping="yes">var lang = "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">";</xsl:text>
158 <xsl:text disable-output-escaping="yes">var metadataListName = "</xsl:text><xsl:value-of select="$metadataListName"/><xsl:text disable-output-escaping="yes">";</xsl:text>
159 var list = gs[metadataListName];
160 if(lang == "")
161 {
162 list[name] = value;
163 }
164 else
165 {
166 if (list[lang] == undefined)
167 {
168 list[lang] = new Array();
169 }
170 var langList = list[lang];
171 langList[name] = value;
172 }
173 </script>
174 </xsl:for-each>
175 </xsl:template>
176 -->
Note: See TracBrowser for help on using the repository browser.