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