source: main/trunk/greenstone3/web/interfaces/default/transform/javascript-global-setup.xsl@ 25936

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

Some fixes to the paged image view

  • Property svn:executable set to *
File size: 10.6 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.blank = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'blank_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
113 </script>
114 </xsl:template>
115
116 <xsl:template name="populate-request-information-values">
117 <script type="text/javascript">
118 <xsl:text disable-output-escaping="yes">
119 gs.requestInformation.fullURL = "</xsl:text><xsl:value-of select="/page/pageRequest/@fullURL"/><xsl:text disable-output-escaping="yes">";
120 </xsl:text>
121 </script>
122 </xsl:template>
123
124 <xsl:template name="include-global-javascript-functions">
125 <script type="text/javascript" src="interfaces/default/js/javascript-global-functions.js"><xsl:text> </xsl:text></script>
126 <script type="text/javascript" src="interfaces/default/js/GSMetadata.js"><xsl:text> </xsl:text></script>
127 </xsl:template>
128</xsl:stylesheet>
129
130 <!-- CAN WE FIND SOME WAY TO MAKE THIS WORK?
131 <xsl:call-template name="populate-metadata-values">
132 <xsl:with-param name="path">/page/pageResponse/metadataList/metadata</xsl:with-param>
133 <xsl:with-param name="metadataListName">siteMetadata</xsl:with-param>
134 </xsl:call-template>
135
136 <xsl:call-template name="populate-metadata-values">
137 <xsl:with-param name="path">/page/pageResponse/collection/metadataList/metadata</xsl:with-param>
138 <xsl:with-param name="metadataListName">collectionMetadata</xsl:with-param>
139 </xsl:call-template>
140
141 <xsl:call-template name="populate-metadata-values">
142 <xsl:with-param name="path">/page/pageResponse/document/metadataList/metadata</xsl:with-param>
143 <xsl:with-param name="metadataListName">documentMetadata</xsl:with-param>
144 </xsl:call-template>
145 -->
146
147 <!-- NOT WORKING BUT IT WOULD BE TIDIER IF IT DID
148 <xsl:template name="populate-metadata-values">
149 <xsl:param name="path"/>
150 <xsl:param name="metadataListName"/>
151
152 <xsl:for-each select="$path">
153 <script type="text/javascript">
154 <xsl:text disable-output-escaping="yes">var name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
155 <xsl:text disable-output-escaping="yes">var value = "</xsl:text><xsl:value-of select="."/><xsl:text disable-output-escaping="yes">";</xsl:text>
156 <xsl:text disable-output-escaping="yes">var lang = "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">";</xsl:text>
157 <xsl:text disable-output-escaping="yes">var metadataListName = "</xsl:text><xsl:value-of select="$metadataListName"/><xsl:text disable-output-escaping="yes">";</xsl:text>
158 var list = gs[metadataListName];
159 if(lang == "")
160 {
161 list[name] = value;
162 }
163 else
164 {
165 if (list[lang] == undefined)
166 {
167 list[lang] = new Array();
168 }
169 var langList = list[lang];
170 langList[name] = value;
171 }
172 </script>
173 </xsl:for-each>
174 </xsl:template>
175 -->
Note: See TracBrowser for help on using the repository browser.