| 1 | | // S5 v1.1 slides.js -- released into the Public Domain |
|---|
| 2 | | // Modified for Docutils (http://docutils.sf.net) by David Goodger |
|---|
| 3 | | // |
|---|
| 4 | | // Please see http://www.meyerweb.com/eric/tools/s5/credits.html for |
|---|
| 5 | | // information about all the wonderful and talented contributors to this code! |
|---|
| 6 | | |
|---|
| 7 | | var undef; |
|---|
| 8 | | var slideCSS = ''; |
|---|
| 9 | | var snum = 0; |
|---|
| 10 | | var smax = 1; |
|---|
| 11 | | var slideIDs = new Array(); |
|---|
| 12 | | var incpos = 0; |
|---|
| 13 | | var number = undef; |
|---|
| 14 | | var s5mode = true; |
|---|
| 15 | | var defaultView = 'slideshow'; |
|---|
| 16 | | var controlVis = 'visible'; |
|---|
| 17 | | |
|---|
| 18 | | var isIE = navigator.appName == 'Microsoft Internet Explorer' ? 1 : 0; |
|---|
| 19 | | var isOp = navigator.userAgent.indexOf('Opera') > -1 ? 1 : 0; |
|---|
| 20 | | var isGe = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('Safari') < 1 ? 1 : 0; |
|---|
| 21 | | |
|---|
| 22 | | function hasClass(object, className) { |
|---|
| 23 | | if (!object.className) return false; |
|---|
| 24 | | return (object.className.search('(^|\\s)' + className + '(\\s|$)') != -1); |
|---|
| 25 | | } |
|---|
| 26 | | |
|---|
| 27 | | function hasValue(object, value) { |
|---|
| 28 | | if (!object) return false; |
|---|
| 29 | | return (object.search('(^|\\s)' + value + '(\\s|$)') != -1); |
|---|
| 30 | | } |
|---|
| 31 | | |
|---|
| 32 | | function removeClass(object,className) { |
|---|
| 33 | | if (!object) return; |
|---|
| 34 | | object.className = object.className.replace(new RegExp('(^|\\s)'+className+'(\\s|$)'), RegExp.$1+RegExp.$2); |
|---|
| 35 | | } |
|---|
| 36 | | |
|---|
| 37 | | function addClass(object,className) { |
|---|
| 38 | | if (!object || hasClass(object, className)) return; |
|---|
| 39 | | if (object.className) { |
|---|
| 40 | | object.className += ' '+className; |
|---|
| 41 | | } else { |
|---|
| 42 | | object.className = className; |
|---|
| 43 | | } |
|---|
| 44 | | } |
|---|
| 45 | | |
|---|
| 46 | | function GetElementsWithClassName(elementName,className) { |
|---|
| 47 | | var allElements = document.getElementsByTagName(elementName); |
|---|
| 48 | | var elemColl = new Array(); |
|---|
| 49 | | for (var i = 0; i< allElements.length; i++) { |
|---|
| 50 | | if (hasClass(allElements[i], className)) { |
|---|
| 51 | | elemColl[elemColl.length] = allElements[i]; |
|---|
| 52 | | } |
|---|
| 53 | | } |
|---|
| 54 | | return elemColl; |
|---|
| 55 | | } |
|---|
| 56 | | |
|---|
| 57 | | function isParentOrSelf(element, id) { |
|---|
| 58 | | if (element == null || element.nodeName=='BODY') return false; |
|---|
| 59 | | else if (element.id == id) return true; |
|---|
| 60 | | else return isParentOrSelf(element.parentNode, id); |
|---|
| 61 | | } |
|---|
| 62 | | |
|---|
| 63 | | function nodeValue(node) { |
|---|
| 64 | | var result = ""; |
|---|
| 65 | | if (node.nodeType == 1) { |
|---|
| 66 | | var children = node.childNodes; |
|---|
| 67 | | for (var i = 0; i < children.length; ++i) { |
|---|
| 68 | | result += nodeValue(children[i]); |
|---|
| 69 | | } |
|---|
| 70 | | } |
|---|
| 71 | | else if (node.nodeType == 3) { |
|---|
| 72 | | result = node.nodeValue; |
|---|
| 73 | | } |
|---|
| 74 | | return(result); |
|---|
| 75 | | } |
|---|
| 76 | | |
|---|
| 77 | | function slideLabel() { |
|---|
| 78 | | var slideColl = GetElementsWithClassName('*','slide'); |
|---|
| 79 | | var list = document.getElementById('jumplist'); |
|---|
| 80 | | smax = slideColl.length; |
|---|
| 81 | | for (var n = 0; n < smax; n++) { |
|---|
| 82 | | var obj = slideColl[n]; |
|---|
| 83 | | |
|---|
| 84 | | var did = 'slide' + n.toString(); |
|---|
| 85 | | if (obj.getAttribute('id')) { |
|---|
| 86 | | slideIDs[n] = obj.getAttribute('id'); |
|---|
| 87 | | } |
|---|
| 88 | | else { |
|---|
| 89 | | obj.setAttribute('id',did); |
|---|
| 90 | | slideIDs[n] = did; |
|---|
| 91 | | } |
|---|
| 92 | | if (isOp) continue; |
|---|
| 93 | | |
|---|
| 94 | | var otext = ''; |
|---|
| 95 | | var menu = obj.firstChild; |
|---|
| 96 | | if (!menu) continue; // to cope with empty slides |
|---|
| 97 | | while (menu && menu.nodeType == 3) { |
|---|
| 98 | | menu = menu.nextSibling; |
|---|
| 99 | | } |
|---|
| 100 | | if (!menu) continue; // to cope with slides with only text nodes |
|---|
| 101 | | |
|---|
| 102 | | var menunodes = menu.childNodes; |
|---|
| 103 | | for (var o = 0; o < menunodes.length; o++) { |
|---|
| 104 | | otext += nodeValue(menunodes[o]); |
|---|
| 105 | | } |
|---|
| 106 | | list.options[list.length] = new Option(n + ' : ' + otext, n); |
|---|
| 107 | | } |
|---|
| 108 | | } |
|---|
| 109 | | |
|---|
| 110 | | function currentSlide() { |
|---|
| 111 | | var cs; |
|---|
| 112 | | var footer_nodes; |
|---|
| 113 | | var vis = 'visible'; |
|---|
| 114 | | if (document.getElementById) { |
|---|
| 115 | | cs = document.getElementById('currentSlide'); |
|---|
| 116 | | footer_nodes = document.getElementById('footer').childNodes; |
|---|
| 117 | | } else { |
|---|
| 118 | | cs = document.currentSlide; |
|---|
| 119 | | footer = document.footer.childNodes; |
|---|
| 120 | | } |
|---|
| 121 | | cs.innerHTML = '<span id="csHere">' + snum + '<\/span> ' + |
|---|
| 122 | | '<span id="csSep">\/<\/span> ' + |
|---|
| 123 | | '<span id="csTotal">' + (smax-1) + '<\/span>'; |
|---|
| 124 | | if (snum == 0) { |
|---|
| 125 | | vis = 'hidden'; |
|---|
| 126 | | } |
|---|
| 127 | | cs.style.visibility = vis; |
|---|
| 128 | | for (var i = 0; i < footer_nodes.length; i++) { |
|---|
| 129 | | if (footer_nodes[i].nodeType == 1) { |
|---|
| 130 | | footer_nodes[i].style.visibility = vis; |
|---|
| 131 | | } |
|---|
| 132 | | } |
|---|
| 133 | | } |
|---|
| 134 | | |
|---|
| 135 | | function go(step) { |
|---|
| 136 | | if (document.getElementById('slideProj').disabled || step == 0) return; |
|---|
| 137 | | var jl = document.getElementById('jumplist'); |
|---|
| 138 | | var cid = slideIDs[snum]; |
|---|
| 139 | | var ce = document.getElementById(cid); |
|---|
| 140 | | if (incrementals[snum].length > 0) { |
|---|
| 141 | | for (var i = 0; i < incrementals[snum].length; i++) { |
|---|
| 142 | | removeClass(incrementals[snum][i], 'current'); |
|---|
| 143 | | removeClass(incrementals[snum][i], 'incremental'); |
|---|
| 144 | | } |
|---|
| 145 | | } |
|---|
| 146 | | if (step != 'j') { |
|---|
| 147 | | snum += step; |
|---|
| 148 | | lmax = smax - 1; |
|---|
| 149 | | if (snum > lmax) snum = lmax; |
|---|
| 150 | | if (snum < 0) snum = 0; |
|---|
| 151 | | } else |
|---|
| 152 | | snum = parseInt(jl.value); |
|---|
| 153 | | var nid = slideIDs[snum]; |
|---|
| 154 | | var ne = document.getElementById(nid); |
|---|
| 155 | | if (!ne) { |
|---|
| 156 | | ne = document.getElementById(slideIDs[0]); |
|---|
| 157 | | snum = 0; |
|---|
| 158 | | } |
|---|
| 159 | | if (step < 0) {incpos = incrementals[snum].length} else {incpos = 0;} |
|---|
| 160 | | if (incrementals[snum].length > 0 && incpos == 0) { |
|---|
| 161 | | for (var i = 0; i < incrementals[snum].length; i++) { |
|---|
| 162 | | if (hasClass(incrementals[snum][i], 'current')) |
|---|
| 163 | | incpos = i + 1; |
|---|
| 164 | | else |
|---|
| 165 | | addClass(incrementals[snum][i], 'incremental'); |
|---|
| 166 | | } |
|---|
| 167 | | } |
|---|
| 168 | | if (incrementals[snum].length > 0 && incpos > 0) |
|---|
| 169 | | addClass(incrementals[snum][incpos - 1], 'current'); |
|---|
| 170 | | ce.style.visibility = 'hidden'; |
|---|
| 171 | | ne.style.visibility = 'visible'; |
|---|
| 172 | | jl.selectedIndex = snum; |
|---|
| 173 | | currentSlide(); |
|---|
| 174 | | number = 0; |
|---|
| 175 | | } |
|---|
| 176 | | |
|---|
| 177 | | function goTo(target) { |
|---|
| 178 | | if (target >= smax || target == snum) return; |
|---|
| 179 | | go(target - snum); |
|---|
| 180 | | } |
|---|
| 181 | | |
|---|
| 182 | | function subgo(step) { |
|---|
| 183 | | if (step > 0) { |
|---|
| 184 | | removeClass(incrementals[snum][incpos - 1],'current'); |
|---|
| 185 | | removeClass(incrementals[snum][incpos], 'incremental'); |
|---|
| 186 | | addClass(incrementals[snum][incpos],'current'); |
|---|
| 187 | | incpos++; |
|---|
| 188 | | } else { |
|---|
| 189 | | incpos--; |
|---|
| 190 | | removeClass(incrementals[snum][incpos],'current'); |
|---|
| 191 | | addClass(incrementals[snum][incpos], 'incremental'); |
|---|
| 192 | | addClass(incrementals[snum][incpos - 1],'current'); |
|---|
| 193 | | } |
|---|
| 194 | | } |
|---|
| 195 | | |
|---|
| 196 | | function toggle() { |
|---|
| 197 | | var slideColl = GetElementsWithClassName('*','slide'); |
|---|
| 198 | | var slides = document.getElementById('slideProj'); |
|---|
| 199 | | var outline = document.getElementById('outlineStyle'); |
|---|
| 200 | | if (!slides.disabled) { |
|---|
| 201 | | slides.disabled = true; |
|---|
| 202 | | outline.disabled = false; |
|---|
| 203 | | s5mode = false; |
|---|
| 204 | | fontSize('1em'); |
|---|
| 205 | | for (var n = 0; n < smax; n++) { |
|---|
| 206 | | var slide = slideColl[n]; |
|---|
| 207 | | slide.style.visibility = 'visible'; |
|---|
| 208 | | } |
|---|
| 209 | | } else { |
|---|
| 210 | | slides.disabled = false; |
|---|
| 211 | | outline.disabled = true; |
|---|
| 212 | | s5mode = true; |
|---|
| 213 | | fontScale(); |
|---|
| 214 | | for (var n = 0; n < smax; n++) { |
|---|
| 215 | | var slide = slideColl[n]; |
|---|
| 216 | | slide.style.visibility = 'hidden'; |
|---|
| 217 | | } |
|---|
| 218 | | slideColl[snum].style.visibility = 'visible'; |
|---|
| 219 | | } |
|---|
| 220 | | } |
|---|
| 221 | | |
|---|
| 222 | | function showHide(action) { |
|---|
| 223 | | var obj = GetElementsWithClassName('*','hideme')[0]; |
|---|
| 224 | | switch (action) { |
|---|
| 225 | | case 's': obj.style.visibility = 'visible'; break; |
|---|
| 226 | | case 'h': obj.style.visibility = 'hidden'; break; |
|---|
| 227 | | case 'k': |
|---|
| 228 | | if (obj.style.visibility != 'visible') { |
|---|
| 229 | | obj.style.visibility = 'visible'; |
|---|
| 230 | | } else { |
|---|
| 231 | | obj.style.visibility = 'hidden'; |
|---|
| 232 | | } |
|---|
| 233 | | break; |
|---|
| 234 | | } |
|---|
| 235 | | } |
|---|
| 236 | | |
|---|
| 237 | | // 'keys' code adapted from MozPoint (http://mozpoint.mozdev.org/) |
|---|
| 238 | | function keys(key) { |
|---|
| 239 | | if (!key) { |
|---|
| 240 | | key = event; |
|---|
| 241 | | key.which = key.keyCode; |
|---|
| 242 | | } |
|---|
| 243 | | if (key.which == 84) { |
|---|
| 244 | | toggle(); |
|---|
| 245 | | return; |
|---|
| 246 | | } |
|---|
| 247 | | if (s5mode) { |
|---|
| 248 | | switch (key.which) { |
|---|
| 249 | | case 10: // return |
|---|
| 250 | | case 13: // enter |
|---|
| 251 | | if (window.event && isParentOrSelf(window.event.srcElement, 'controls')) return; |
|---|
| 252 | | if (key.target && isParentOrSelf(key.target, 'controls')) return; |
|---|
| 253 | | if(number != undef) { |
|---|
| 254 | | goTo(number); |
|---|
| 255 | | break; |
|---|
| 256 | | } |
|---|
| 257 | | case 32: // spacebar |
|---|
| 258 | | case 34: // page down |
|---|
| 259 | | case 39: // rightkey |
|---|
| 260 | | case 40: // downkey |
|---|
| 261 | | if(number != undef) { |
|---|
| 262 | | go(number); |
|---|
| 263 | | } else if (!incrementals[snum] || incpos >= incrementals[snum].length) { |
|---|
| 264 | | go(1); |
|---|
| 265 | | } else { |
|---|
| 266 | | subgo(1); |
|---|
| 267 | | } |
|---|
| 268 | | break; |
|---|
| 269 | | case 33: // page up |
|---|
| 270 | | case 37: // leftkey |
|---|
| 271 | | case 38: // upkey |
|---|
| 272 | | if(number != undef) { |
|---|
| 273 | | go(-1 * number); |
|---|
| 274 | | } else if (!incrementals[snum] || incpos <= 0) { |
|---|
| 275 | | go(-1); |
|---|
| 276 | | } else { |
|---|
| 277 | | subgo(-1); |
|---|
| 278 | | } |
|---|
| 279 | | break; |
|---|
| 280 | | case 36: // home |
|---|
| 281 | | goTo(0); |
|---|
| 282 | | break; |
|---|
| 283 | | case 35: // end |
|---|
| 284 | | goTo(smax-1); |
|---|
| 285 | | break; |
|---|
| 286 | | case 67: // c |
|---|
| 287 | | showHide('k'); |
|---|
| 288 | | break; |
|---|
| 289 | | } |
|---|
| 290 | | if (key.which < 48 || key.which > 57) { |
|---|
| 291 | | number = undef; |
|---|
| 292 | | } else { |
|---|
| 293 | | if (window.event && isParentOrSelf(window.event.srcElement, 'controls')) return; |
|---|
| 294 | | if (key.target && isParentOrSelf(key.target, 'controls')) return; |
|---|
| 295 | | number = (((number != undef) ? number : 0) * 10) + (key.which - 48); |
|---|
| 296 | | } |
|---|
| 297 | | } |
|---|
| 298 | | return false; |
|---|
| 299 | | } |
|---|
| 300 | | |
|---|
| 301 | | function clicker(e) { |
|---|
| 302 | | number = undef; |
|---|
| 303 | | var target; |
|---|
| 304 | | if (window.event) { |
|---|
| 305 | | target = window.event.srcElement; |
|---|
| 306 | | e = window.event; |
|---|
| 307 | | } else target = e.target; |
|---|
| 308 | | if (target.href != null || hasValue(target.rel, 'external') || isParentOrSelf(target, 'controls') || isParentOrSelf(target,'embed') || isParentOrSelf(target, 'object')) return true; |
|---|
| 309 | | if (!e.which || e.which == 1) { |
|---|
| 310 | | if (!incrementals[snum] || incpos >= incrementals[snum].length) { |
|---|
| 311 | | go(1); |
|---|
| 312 | | } else { |
|---|
| 313 | | subgo(1); |
|---|
| 314 | | } |
|---|
| 315 | | } |
|---|
| 316 | | } |
|---|
| 317 | | |
|---|
| 318 | | function findSlide(hash) { |
|---|
| 319 | | var target = document.getElementById(hash); |
|---|
| 320 | | if (target) { |
|---|
| 321 | | for (var i = 0; i < slideIDs.length; i++) { |
|---|
| 322 | | if (target.id == slideIDs[i]) return i; |
|---|
| 323 | | } |
|---|
| 324 | | } |
|---|
| 325 | | return null; |
|---|
| 326 | | } |
|---|
| 327 | | |
|---|
| 328 | | function slideJump() { |
|---|
| 329 | | if (window.location.hash == null || window.location.hash == '') { |
|---|
| 330 | | currentSlide(); |
|---|
| 331 | | return; |
|---|
| 332 | | } |
|---|
| 333 | | if (window.location.hash == null) return; |
|---|
| 334 | | var dest = null; |
|---|
| 335 | | dest = findSlide(window.location.hash.slice(1)); |
|---|
| 336 | | if (dest == null) { |
|---|
| 337 | | dest = 0; |
|---|
| 338 | | } |
|---|
| 339 | | go(dest - snum); |
|---|
| 340 | | } |
|---|
| 341 | | |
|---|
| 342 | | function fixLinks() { |
|---|
| 343 | | var thisUri = window.location.href; |
|---|
| 344 | | thisUri = thisUri.slice(0, thisUri.length - window.location.hash.length); |
|---|
| 345 | | var aelements = document.getElementsByTagName('A'); |
|---|
| 346 | | for (var i = 0; i < aelements.length; i++) { |
|---|
| 347 | | var a = aelements[i].href; |
|---|
| 348 | | var slideID = a.match('\#.+'); |
|---|
| 349 | | if ((slideID) && (slideID[0].slice(0,1) == '#')) { |
|---|
| 350 | | var dest = findSlide(slideID[0].slice(1)); |
|---|
| 351 | | if (dest != null) { |
|---|
| 352 | | if (aelements[i].addEventListener) { |
|---|
| 353 | | aelements[i].addEventListener("click", new Function("e", |
|---|
| 354 | | "if (document.getElementById('slideProj').disabled) return;" + |
|---|
| 355 | | "go("+dest+" - snum); " + |
|---|
| 356 | | "if (e.preventDefault) e.preventDefault();"), true); |
|---|
| 357 | | } else if (aelements[i].attachEvent) { |
|---|
| 358 | | aelements[i].attachEvent("onclick", new Function("", |
|---|
| 359 | | "if (document.getElementById('slideProj').disabled) return;" + |
|---|
| 360 | | "go("+dest+" - snum); " + |
|---|
| 361 | | "event.returnValue = false;")); |
|---|
| 362 | | } |
|---|
| 363 | | } |
|---|
| 364 | | } |
|---|
| 365 | | } |
|---|
| 366 | | } |
|---|
| 367 | | |
|---|
| 368 | | function externalLinks() { |
|---|
| 369 | | if (!document.getElementsByTagName) return; |
|---|
| 370 | | var anchors = document.getElementsByTagName('a'); |
|---|
| 371 | | for (var i=0; i<anchors.length; i++) { |
|---|
| 372 | | var anchor = anchors[i]; |
|---|
| 373 | | if (anchor.getAttribute('href') && hasValue(anchor.rel, 'external')) { |
|---|
| 374 | | anchor.target = '_blank'; |
|---|
| 375 | | addClass(anchor,'external'); |
|---|
| 376 | | } |
|---|
| 377 | | } |
|---|
| 378 | | } |
|---|
| 379 | | |
|---|
| 380 | | function createControls() { |
|---|
| 381 | | var controlsDiv = document.getElementById("controls"); |
|---|
| 382 | | if (!controlsDiv) return; |
|---|
| 383 | | var hider = ' onmouseover="showHide(\'s\');" onmouseout="showHide(\'h\');"'; |
|---|
| 384 | | var hideDiv, hideList = ''; |
|---|
| 385 | | if (controlVis == 'hidden') { |
|---|
| 386 | | hideDiv = hider; |
|---|
| 387 | | } else { |
|---|
| 388 | | hideList = hider; |
|---|
| 389 | | } |
|---|
| 390 | | controlsDiv.innerHTML = '<form action="#" id="controlForm"' + hideDiv + '>' + |
|---|
| 391 | | '<div id="navLinks">' + |
|---|
| 392 | | '<a accesskey="t" id="toggle" href="javascript:toggle();">Ø<\/a>' + |
|---|
| 393 | | '<a accesskey="z" id="prev" href="javascript:go(-1);">«<\/a>' + |
|---|
| 394 | | '<a accesskey="x" id="next" href="javascript:go(1);">»<\/a>' + |
|---|
| 395 | | '<div id="navList"' + hideList + '><select id="jumplist" onchange="go(\'j\');"><\/select><\/div>' + |
|---|
| 396 | | '<\/div><\/form>'; |
|---|
| 397 | | if (controlVis == 'hidden') { |
|---|
| 398 | | var hidden = document.getElementById('navLinks'); |
|---|
| 399 | | } else { |
|---|
| 400 | | var hidden = document.getElementById('jumplist'); |
|---|
| 401 | | } |
|---|
| 402 | | addClass(hidden,'hideme'); |
|---|
| 403 | | } |
|---|
| 404 | | |
|---|
| 405 | | function fontScale() { // causes layout problems in FireFox that get fixed if browser's Reload is used; same may be true of other Gecko-based browsers |
|---|
| 406 | | if (!s5mode) return false; |
|---|
| 407 | | var vScale = 22; // both yield 32 (after rounding) at 1024x768 |
|---|
| 408 | | var hScale = 32; // perhaps should auto-calculate based on theme's declared value? |
|---|
| 409 | | if (window.innerHeight) { |
|---|
| 410 | | var vSize = window.innerHeight; |
|---|
| 411 | | var hSize = window.innerWidth; |
|---|
| 412 | | } else if (document.documentElement.clientHeight) { |
|---|
| 413 | | var vSize = document.documentElement.clientHeight; |
|---|
| 414 | | var hSize = document.documentElement.clientWidth; |
|---|
| 415 | | } else if (document.body.clientHeight) { |
|---|
| 416 | | var vSize = document.body.clientHeight; |
|---|
| 417 | | var hSize = document.body.clientWidth; |
|---|
| 418 | | } else { |
|---|
| 419 | | var vSize = 700; // assuming 1024x768, minus chrome and such |
|---|
| 420 | | var hSize = 1024; // these do not account for kiosk mode or Opera Show |
|---|
| 421 | | } |
|---|
| 422 | | var newSize = Math.min(Math.round(vSize/vScale),Math.round(hSize/hScale)); |
|---|
| 423 | | fontSize(newSize + 'px'); |
|---|
| 424 | | if (isGe) { // hack to counter incremental reflow bugs |
|---|
| 425 | | var obj = document.getElementsByTagName('body')[0]; |
|---|
| 426 | | obj.style.display = 'none'; |
|---|
| 427 | | obj.style.display = 'block'; |
|---|
| 428 | | } |
|---|
| 429 | | } |
|---|
| 430 | | |
|---|
| 431 | | function fontSize(value) { |
|---|
| 432 | | if (!(s5ss = document.getElementById('s5ss'))) { |
|---|
| 433 | | if (!isIE) { |
|---|
| 434 | | document.getElementsByTagName('head')[0].appendChild(s5ss = document.createElement('style')); |
|---|
| 435 | | s5ss.setAttribute('media','screen, projection'); |
|---|
| 436 | | s5ss.setAttribute('id','s5ss'); |
|---|
| 437 | | } else { |
|---|
| 438 | | document.createStyleSheet(); |
|---|
| 439 | | document.s5ss = document.styleSheets[document.styleSheets.length - 1]; |
|---|
| 440 | | } |
|---|
| 441 | | } |
|---|
| 442 | | if (!isIE) { |
|---|
| 443 | | while (s5ss.lastChild) s5ss.removeChild(s5ss.lastChild); |
|---|
| 444 | | s5ss.appendChild(document.createTextNode('body {font-size: ' + value + ' !important;}')); |
|---|
| 445 | | } else { |
|---|
| 446 | | document.s5ss.addRule('body','font-size: ' + value + ' !important;'); |
|---|
| 447 | | } |
|---|
| 448 | | } |
|---|
| 449 | | |
|---|
| 450 | | function notOperaFix() { |
|---|
| 451 | | slideCSS = document.getElementById('slideProj').href; |
|---|
| 452 | | var slides = document.getElementById('slideProj'); |
|---|
| 453 | | var outline = document.getElementById('outlineStyle'); |
|---|
| 454 | | slides.setAttribute('media','screen'); |
|---|
| 455 | | outline.disabled = true; |
|---|
| 456 | | if (isGe) { |
|---|
| 457 | | slides.setAttribute('href','null'); // Gecko fix |
|---|
| 458 | | slides.setAttribute('href',slideCSS); // Gecko fix |
|---|
| 459 | | } |
|---|
| 460 | | if (isIE && document.styleSheets && document.styleSheets[0]) { |
|---|
| 461 | | document.styleSheets[0].addRule('img', 'behavior: url(ui/default/iepngfix.htc)'); |
|---|
| 462 | | document.styleSheets[0].addRule('div', 'behavior: url(ui/default/iepngfix.htc)'); |
|---|
| 463 | | document.styleSheets[0].addRule('.slide', 'behavior: url(ui/default/iepngfix.htc)'); |
|---|
| 464 | | } |
|---|
| 465 | | } |
|---|
| 466 | | |
|---|
| 467 | | function getIncrementals(obj) { |
|---|
| 468 | | var incrementals = new Array(); |
|---|
| 469 | | if (!obj) |
|---|
| 470 | | return incrementals; |
|---|
| 471 | | var children = obj.childNodes; |
|---|
| 472 | | for (var i = 0; i < children.length; i++) { |
|---|
| 473 | | var child = children[i]; |
|---|
| 474 | | if (hasClass(child, 'incremental')) { |
|---|
| 475 | | if (child.nodeName == 'OL' || child.nodeName == 'UL') { |
|---|
| 476 | | removeClass(child, 'incremental'); |
|---|
| 477 | | for (var j = 0; j < child.childNodes.length; j++) { |
|---|
| 478 | | if (child.childNodes[j].nodeType == 1) { |
|---|
| 479 | | addClass(child.childNodes[j], 'incremental'); |
|---|
| 480 | | } |
|---|
| 481 | | } |
|---|
| 482 | | } else { |
|---|
| 483 | | incrementals[incrementals.length] = child; |
|---|
| 484 | | removeClass(child,'incremental'); |
|---|
| 485 | | } |
|---|
| 486 | | } |
|---|
| 487 | | if (hasClass(child, 'show-first')) { |
|---|
| 488 | | if (child.nodeName == 'OL' || child.nodeName == 'UL') { |
|---|
| 489 | | removeClass(child, 'show-first'); |
|---|
| 490 | | if (child.childNodes[isGe].nodeType == 1) { |
|---|
| 491 | | removeClass(child.childNodes[isGe], 'incremental'); |
|---|
| 492 | | } |
|---|
| 493 | | } else { |
|---|
| 494 | | incrementals[incrementals.length] = child; |
|---|
| 495 | | } |
|---|
| 496 | | } |
|---|
| 497 | | incrementals = incrementals.concat(getIncrementals(child)); |
|---|
| 498 | | } |
|---|
| 499 | | return incrementals; |
|---|
| 500 | | } |
|---|
| 501 | | |
|---|
| 502 | | function createIncrementals() { |
|---|
| 503 | | var incrementals = new Array(); |
|---|
| 504 | | for (var i = 0; i < smax; i++) { |
|---|
| 505 | | incrementals[i] = getIncrementals(document.getElementById(slideIDs[i])); |
|---|
| 506 | | } |
|---|
| 507 | | return incrementals; |
|---|
| 508 | | } |
|---|
| 509 | | |
|---|
| 510 | | function defaultCheck() { |
|---|
| 511 | | var allMetas = document.getElementsByTagName('meta'); |
|---|
| 512 | | for (var i = 0; i< allMetas.length; i++) { |
|---|
| 513 | | if (allMetas[i].name == 'defaultView') { |
|---|
| 514 | | defaultView = allMetas[i].content; |
|---|
| 515 | | } |
|---|
| 516 | | if (allMetas[i].name == 'controlVis') { |
|---|
| 517 | | controlVis = allMetas[i].content; |
|---|
| 518 | | } |
|---|
| 519 | | } |
|---|
| 520 | | } |
|---|
| 521 | | |
|---|
| 522 | | // Key trap fix, new function body for trap() |
|---|
| 523 | | function trap(e) { |
|---|
| 524 | | if (!e) { |
|---|
| 525 | | e = event; |
|---|
| 526 | | e.which = e.keyCode; |
|---|
| 527 | | } |
|---|
| 528 | | try { |
|---|
| 529 | | modifierKey = e.ctrlKey || e.altKey || e.metaKey; |
|---|
| 530 | | } |
|---|
| 531 | | catch(e) { |
|---|
| 532 | | modifierKey = false; |
|---|
| 533 | | } |
|---|
| 534 | | return modifierKey || e.which == 0; |
|---|
| 535 | | } |
|---|
| 536 | | |
|---|
| 537 | | function startup() { |
|---|
| 538 | | defaultCheck(); |
|---|
| 539 | | if (!isOp) createControls(); |
|---|
| 540 | | slideLabel(); |
|---|
| 541 | | fixLinks(); |
|---|
| 542 | | externalLinks(); |
|---|
| 543 | | fontScale(); |
|---|
| 544 | | if (!isOp) { |
|---|
| 545 | | notOperaFix(); |
|---|
| 546 | | incrementals = createIncrementals(); |
|---|
| 547 | | slideJump(); |
|---|
| 548 | | if (defaultView == 'outline') { |
|---|
| 549 | | toggle(); |
|---|
| 550 | | } |
|---|
| 551 | | document.onkeyup = keys; |
|---|
| 552 | | document.onkeypress = trap; |
|---|
| 553 | | document.onclick = clicker; |
|---|
| 554 | | } |
|---|
| 555 | | } |
|---|
| 556 | | |
|---|
| 557 | | window.onload = startup; |
|---|
| 558 | | window.onresize = function(){setTimeout('fontScale()', 50);} |
|---|
| 559 | | |
|---|
| | 4780 | // S5 v1.1 slides.js -- released into the Public Domain |
|---|
| | 4781 | // Modified for Docutils (http://docutils.sf.net) by David Goodger |
|---|
| | 4782 | // |
|---|
| | 4783 | // Please see http://www.meyerweb.com/eric/tools/s5/credits.html for |
|---|
| | 4784 | // information about all the wonderful and talented contributors to this code! |
|---|
| | 4785 | |
|---|
| | 4786 | var undef; |
|---|
| | 4787 | var slideCSS = ''; |
|---|
| | 4788 | var snum = 0; |
|---|
| | 4789 | var smax = 1; |
|---|
| | 4790 | var slideIDs = new Array(); |
|---|
| | 4791 | var incpos = 0; |
|---|
| | 4792 | var number = undef; |
|---|
| | 4793 | var s5mode = true; |
|---|
| | 4794 | var defaultView = 'slideshow'; |
|---|
| | 4795 | var controlVis = 'visible'; |
|---|
| | 4796 | |
|---|
| | 4797 | var isIE = navigator.appName == 'Microsoft Internet Explorer' ? 1 : 0; |
|---|
| | 4798 | var isOp = navigator.userAgent.indexOf('Opera') > -1 ? 1 : 0; |
|---|
| | 4799 | var isGe = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('Safari') < 1 ? 1 : 0; |
|---|
| | 4800 | |
|---|
| | 4801 | function hasClass(object, className) { |
|---|
| | 4802 | if (!object.className) return false; |
|---|
| | 4803 | return (object.className.search('(^|\\s)' + className + '(\\s|$)') != -1); |
|---|
| | 4804 | } |
|---|
| | 4805 | |
|---|
| | 4806 | function hasValue(object, value) { |
|---|
| | 4807 | if (!object) return false; |
|---|
| | 4808 | return (object.search('(^|\\s)' + value + '(\\s|$)') != -1); |
|---|
| | 4809 | } |
|---|
| | 4810 | |
|---|
| | 4811 | function removeClass(object,className) { |
|---|
| | 4812 | if (!object) return; |
|---|
| | 4813 | object.className = object.className.replace(new RegExp('(^|\\s)'+className+'(\\s|$)'), RegExp.$1+RegExp.$2); |
|---|
| | 4814 | } |
|---|
| | 4815 | |
|---|
| | 4816 | function addClass(object,className) { |
|---|
| | 4817 | if (!object || hasClass(object, className)) return; |
|---|
| | 4818 | if (object.className) { |
|---|
| | 4819 | object.className += ' '+className; |
|---|
| | 4820 | } else { |
|---|
| | 4821 | object.className = className; |
|---|
| | 4822 | } |
|---|
| | 4823 | } |
|---|
| | 4824 | |
|---|
| | 4825 | function GetElementsWithClassName(elementName,className) { |
|---|
| | 4826 | var allElements = document.getElementsByTagName(elementName); |
|---|
| | 4827 | var elemColl = new Array(); |
|---|
| | 4828 | for (var i = 0; i< allElements.length; i++) { |
|---|
| | 4829 | if (hasClass(allElements[i], className)) { |
|---|
| | 4830 | elemColl[elemColl.length] = allElements[i]; |
|---|
| | 4831 | } |
|---|
| | 4832 | } |
|---|
| | 4833 | return elemColl; |
|---|
| | 4834 | } |
|---|
| | 4835 | |
|---|
| | 4836 | function isParentOrSelf(element, id) { |
|---|
| | 4837 | if (element == null || element.nodeName=='BODY') return false; |
|---|
| | 4838 | else if (element.id == id) return true; |
|---|
| | 4839 | else return isParentOrSelf(element.parentNode, id); |
|---|
| | 4840 | } |
|---|
| | 4841 | |
|---|
| | 4842 | function nodeValue(node) { |
|---|
| | 4843 | var result = ""; |
|---|
| | 4844 | if (node.nodeType == 1) { |
|---|
| | 4845 | var children = node.childNodes; |
|---|
| | 4846 | for (var i = 0; i < children.length; ++i) { |
|---|
| | 4847 | result += nodeValue(children[i]); |
|---|
| | 4848 | } |
|---|
| | 4849 | } |
|---|
| | 4850 | else if (node.nodeType == 3) { |
|---|
| | 4851 | result = node.nodeValue; |
|---|
| | 4852 | } |
|---|
| | 4853 | return(result); |
|---|
| | 4854 | } |
|---|
| | 4855 | |
|---|
| | 4856 | function slideLabel() { |
|---|
| | 4857 | var slideColl = GetElementsWithClassName('*','slide'); |
|---|
| | 4858 | var list = document.getElementById('jumplist'); |
|---|
| | 4859 | smax = slideColl.length; |
|---|
| | 4860 | for (var n = 0; n < smax; n++) { |
|---|
| | 4861 | var obj = slideColl[n]; |
|---|
| | 4862 | |
|---|
| | 4863 | var did = 'slide' + n.toString(); |
|---|
| | 4864 | if (obj.getAttribute('id')) { |
|---|
| | 4865 | slideIDs[n] = obj.getAttribute('id'); |
|---|
| | 4866 | } |
|---|
| | 4867 | else { |
|---|
| | 4868 | obj.setAttribute('id',did); |
|---|
| | 4869 | slideIDs[n] = did; |
|---|
| | 4870 | } |
|---|
| | 4871 | if (isOp) continue; |
|---|
| | 4872 | |
|---|
| | 4873 | var otext = ''; |
|---|
| | 4874 | var menu = obj.firstChild; |
|---|
| | 4875 | if (!menu) continue; // to cope with empty slides |
|---|
| | 4876 | while (menu && menu.nodeType == 3) { |
|---|
| | 4877 | menu = menu.nextSibling; |
|---|
| | 4878 | } |
|---|
| | 4879 | if (!menu) continue; // to cope with slides with only text nodes |
|---|
| | 4880 | |
|---|
| | 4881 | var menunodes = menu.childNodes; |
|---|
| | 4882 | for (var o = 0; o < menunodes.length; o++) { |
|---|
| | 4883 | otext += nodeValue(menunodes[o]); |
|---|
| | 4884 | } |
|---|
| | 4885 | list.options[list.length] = new Option(n + ' : ' + otext, n); |
|---|
| | 4886 | } |
|---|
| | 4887 | } |
|---|
| | 4888 | |
|---|
| | 4889 | function currentSlide() { |
|---|
| | 4890 | var cs; |
|---|
| | 4891 | var footer_nodes; |
|---|
| | 4892 | var vis = 'visible'; |
|---|
| | 4893 | if (document.getElementById) { |
|---|
| | 4894 | cs = document.getElementById('currentSlide'); |
|---|
| | 4895 | footer_nodes = document.getElementById('footer').childNodes; |
|---|
| | 4896 | } else { |
|---|
| | 4897 | cs = document.currentSlide; |
|---|
| | 4898 | footer = document.footer.childNodes; |
|---|
| | 4899 | } |
|---|
| | 4900 | cs.innerHTML = '<span id="csHere">' + snum + '<\/span> ' + |
|---|
| | 4901 | '<span id="csSep">\/<\/span> ' + |
|---|
| | 4902 | '<span id="csTotal">' + (smax-1) + '<\/span>'; |
|---|
| | 4903 | if (snum == 0) { |
|---|
| | 4904 | vis = 'hidden'; |
|---|
| | 4905 | } |
|---|
| | 4906 | cs.style.visibility = vis; |
|---|
| | 4907 | for (var i = 0; i < footer_nodes.length; i++) { |
|---|
| | 4908 | if (footer_nodes[i].nodeType == 1) { |
|---|
| | 4909 | footer_nodes[i].style.visibility = vis; |
|---|
| | 4910 | } |
|---|
| | 4911 | } |
|---|
| | 4912 | } |
|---|
| | 4913 | |
|---|
| | 4914 | function go(step) { |
|---|
| | 4915 | if (document.getElementById('slideProj').disabled || step == 0) return; |
|---|
| | 4916 | var jl = document.getElementById('jumplist'); |
|---|
| | 4917 | var cid = slideIDs[snum]; |
|---|
| | 4918 | var ce = document.getElementById(cid); |
|---|
| | 4919 | |
|---|