Commit 4a0b48ac9e1cef198fda68264a41df52e2ffffd7
1 parent
67dc08c1f9
Exists in
master
Ajout d'une fonction pour récupérer un facteur de taille de police dans
le style.
Showing 1 changed file with 10 additions and 2 deletions Inline Diff
templates/html/Wize_S5/ui/default/slides.js
| // S5 v1.1 slides.js -- released into the Public Domain | 1 | 1 | // S5 v1.1 slides.js -- released into the Public Domain | |
| // | 2 | 2 | // | |
| // Please see http://www.meyerweb.com/eric/tools/s5/credits.html for information | 3 | 3 | // Please see http://www.meyerweb.com/eric/tools/s5/credits.html for information | |
| // about all the wonderful and talented contributors to this code! | 4 | 4 | // about all the wonderful and talented contributors to this code! | |
| 5 | 5 | |||
| var undef; | 6 | 6 | var undef; | |
| var slideCSS = ''; | 7 | 7 | var slideCSS = ''; | |
| var snum = 0; | 8 | 8 | var snum = 0; | |
| var smax = 1; | 9 | 9 | var smax = 1; | |
| var incpos = 0; | 10 | 10 | var incpos = 0; | |
| var number = undef; | 11 | 11 | var number = undef; | |
| var s5mode = true; | 12 | 12 | var s5mode = true; | |
| var defaultView = 'slideshow'; | 13 | 13 | var defaultView = 'slideshow'; | |
| var controlVis = 'visible'; | 14 | 14 | var controlVis = 'visible'; | |
| 15 | 15 | |||
| var isIE = navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') < 1 ? 1 : 0; | 16 | 16 | var isIE = navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') < 1 ? 1 : 0; | |
| var isOp = navigator.userAgent.indexOf('Opera') > -1 ? 1 : 0; | 17 | 17 | var isOp = navigator.userAgent.indexOf('Opera') > -1 ? 1 : 0; | |
| var isGe = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('Safari') < 1 ? 1 : 0; | 18 | 18 | var isGe = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('Safari') < 1 ? 1 : 0; | |
| 19 | 19 | |||
| function hasClass(object, className) { | 20 | 20 | function hasClass(object, className) { | |
| if (!object.className) return false; | 21 | 21 | if (!object.className) return false; | |
| return (object.className.search('(^|\\s)' + className + '(\\s|$)') != -1); | 22 | 22 | return (object.className.search('(^|\\s)' + className + '(\\s|$)') != -1); | |
| } | 23 | 23 | } | |
| 24 | 24 | |||
| function hasValue(object, value) { | 25 | 25 | function hasValue(object, value) { | |
| if (!object) return false; | 26 | 26 | if (!object) return false; | |
| return (object.search('(^|\\s)' + value + '(\\s|$)') != -1); | 27 | 27 | return (object.search('(^|\\s)' + value + '(\\s|$)') != -1); | |
| } | 28 | 28 | } | |
| 29 | 29 | |||
| function removeClass(object,className) { | 30 | 30 | function removeClass(object,className) { | |
| if (!object) return; | 31 | 31 | if (!object) return; | |
| object.className = object.className.replace(new RegExp('(^|\\s)'+className+'(\\s|$)'), RegExp.$1+RegExp.$2); | 32 | 32 | object.className = object.className.replace(new RegExp('(^|\\s)'+className+'(\\s|$)'), RegExp.$1+RegExp.$2); | |
| } | 33 | 33 | } | |
| 34 | 34 | |||
| function addClass(object,className) { | 35 | 35 | function addClass(object,className) { | |
| if (!object || hasClass(object, className)) return; | 36 | 36 | if (!object || hasClass(object, className)) return; | |
| if (object.className) { | 37 | 37 | if (object.className) { | |
| object.className += ' '+className; | 38 | 38 | object.className += ' '+className; | |
| } else { | 39 | 39 | } else { | |
| object.className = className; | 40 | 40 | object.className = className; | |
| } | 41 | 41 | } | |
| } | 42 | 42 | } | |
| 43 | 43 | |||
| function GetElementsWithClassName(elementName,className) { | 44 | 44 | function GetElementsWithClassName(elementName,className) { | |
| var allElements = document.getElementsByTagName(elementName); | 45 | 45 | var allElements = document.getElementsByTagName(elementName); | |
| var elemColl = new Array(); | 46 | 46 | var elemColl = new Array(); | |
| for (var i = 0; i< allElements.length; i++) { | 47 | 47 | for (var i = 0; i< allElements.length; i++) { | |
| if (hasClass(allElements[i], className)) { | 48 | 48 | if (hasClass(allElements[i], className)) { | |
| elemColl[elemColl.length] = allElements[i]; | 49 | 49 | elemColl[elemColl.length] = allElements[i]; | |
| } | 50 | 50 | } | |
| } | 51 | 51 | } | |
| return elemColl; | 52 | 52 | return elemColl; | |
| } | 53 | 53 | } | |
| 54 | 54 | |||
| function isParentOrSelf(element, id) { | 55 | 55 | function isParentOrSelf(element, id) { | |
| if (element == null || element.nodeName=='BODY') return false; | 56 | 56 | if (element == null || element.nodeName=='BODY') return false; | |
| else if (element.id == id) return true; | 57 | 57 | else if (element.id == id) return true; | |
| else return isParentOrSelf(element.parentNode, id); | 58 | 58 | else return isParentOrSelf(element.parentNode, id); | |
| } | 59 | 59 | } | |
| 60 | 60 | |||
| function nodeValue(node) { | 61 | 61 | function nodeValue(node) { | |
| var result = ""; | 62 | 62 | var result = ""; | |
| if (node.nodeType == 1) { | 63 | 63 | if (node.nodeType == 1) { | |
| var children = node.childNodes; | 64 | 64 | var children = node.childNodes; | |
| for (var i = 0; i < children.length; ++i) { | 65 | 65 | for (var i = 0; i < children.length; ++i) { | |
| result += nodeValue(children[i]); | 66 | 66 | result += nodeValue(children[i]); | |
| } | 67 | 67 | } | |
| } | 68 | 68 | } | |
| else if (node.nodeType == 3) { | 69 | 69 | else if (node.nodeType == 3) { | |
| result = node.nodeValue; | 70 | 70 | result = node.nodeValue; | |
| } | 71 | 71 | } | |
| return(result); | 72 | 72 | return(result); | |
| } | 73 | 73 | } | |
| 74 | 74 | |||
| function slideLabel() { | 75 | 75 | function slideLabel() { | |
| var slideColl = GetElementsWithClassName('*','slide'); | 76 | 76 | var slideColl = GetElementsWithClassName('*','slide'); | |
| var list = document.getElementById('jumplist'); | 77 | 77 | var list = document.getElementById('jumplist'); | |
| smax = slideColl.length; | 78 | 78 | smax = slideColl.length; | |
| for (var n = 0; n < smax; n++) { | 79 | 79 | for (var n = 0; n < smax; n++) { | |
| var obj = slideColl[n]; | 80 | 80 | var obj = slideColl[n]; | |
| 81 | 81 | |||
| var did = 'slide' + n.toString(); | 82 | 82 | var did = 'slide' + n.toString(); | |
| obj.setAttribute('id',did); | 83 | 83 | obj.setAttribute('id',did); | |
| if (isOp) continue; | 84 | 84 | if (isOp) continue; | |
| 85 | 85 | |||
| var otext = ''; | 86 | 86 | var otext = ''; | |
| var menu = obj.firstChild; | 87 | 87 | var menu = obj.firstChild; | |
| if (!menu) continue; // to cope with empty slides | 88 | 88 | if (!menu) continue; // to cope with empty slides | |
| while (menu && menu.nodeType == 3) { | 89 | 89 | while (menu && menu.nodeType == 3) { | |
| menu = menu.nextSibling; | 90 | 90 | menu = menu.nextSibling; | |
| } | 91 | 91 | } | |
| if (!menu) continue; // to cope with slides with only text nodes | 92 | 92 | if (!menu) continue; // to cope with slides with only text nodes | |
| 93 | 93 | |||
| var menunodes = menu.childNodes; | 94 | 94 | var menunodes = menu.childNodes; | |
| for (var o = 0; o < menunodes.length; o++) { | 95 | 95 | for (var o = 0; o < menunodes.length; o++) { | |
| otext += nodeValue(menunodes[o]); | 96 | 96 | otext += nodeValue(menunodes[o]); | |
| } | 97 | 97 | } | |
| list.options[list.length] = new Option(n + ' : ' + otext, n); | 98 | 98 | list.options[list.length] = new Option(n + ' : ' + otext, n); | |
| } | 99 | 99 | } | |
| } | 100 | 100 | } | |
| 101 | 101 | |||
| function currentSlide() { | 102 | 102 | function currentSlide() { | |
| var cs; | 103 | 103 | var cs; | |
| if (document.getElementById) { | 104 | 104 | if (document.getElementById) { | |
| cs = document.getElementById('currentSlide'); | 105 | 105 | cs = document.getElementById('currentSlide'); | |
| } else { | 106 | 106 | } else { | |
| cs = document.currentSlide; | 107 | 107 | cs = document.currentSlide; | |
| } | 108 | 108 | } | |
| cs.innerHTML = '<span id="csHere">' + snum + '<\/span> ' + | 109 | 109 | cs.innerHTML = '<span id="csHere">' + snum + '<\/span> ' + | |
| '<span id="csSep">\/<\/span> ' + | 110 | 110 | '<span id="csSep">\/<\/span> ' + | |
| '<span id="csTotal">' + (smax-1) + '<\/span>'; | 111 | 111 | '<span id="csTotal">' + (smax-1) + '<\/span>'; | |
| if (snum == 0) { | 112 | 112 | if (snum == 0) { | |
| cs.style.visibility = 'hidden'; | 113 | 113 | cs.style.visibility = 'hidden'; | |
| } else { | 114 | 114 | } else { | |
| cs.style.visibility = 'visible'; | 115 | 115 | cs.style.visibility = 'visible'; | |
| } | 116 | 116 | } | |
| } | 117 | 117 | } | |
| 118 | 118 | |||
| function go(step) { | 119 | 119 | function go(step) { | |
| if (document.getElementById('slideProj').disabled || step == 0) return; | 120 | 120 | if (document.getElementById('slideProj').disabled || step == 0) return; | |
| var jl = document.getElementById('jumplist'); | 121 | 121 | var jl = document.getElementById('jumplist'); | |
| var cid = 'slide' + snum; | 122 | 122 | var cid = 'slide' + snum; | |
| var ce = document.getElementById(cid); | 123 | 123 | var ce = document.getElementById(cid); | |
| if (incrementals[snum].length > 0) { | 124 | 124 | if (incrementals[snum].length > 0) { | |
| for (var i = 0; i < incrementals[snum].length; i++) { | 125 | 125 | for (var i = 0; i < incrementals[snum].length; i++) { | |
| removeClass(incrementals[snum][i], 'current'); | 126 | 126 | removeClass(incrementals[snum][i], 'current'); | |
| removeClass(incrementals[snum][i], 'incremental'); | 127 | 127 | removeClass(incrementals[snum][i], 'incremental'); | |
| } | 128 | 128 | } | |
| } | 129 | 129 | } | |
| if (step != 'j') { | 130 | 130 | if (step != 'j') { | |
| snum += step; | 131 | 131 | snum += step; | |
| lmax = smax - 1; | 132 | 132 | lmax = smax - 1; | |
| if (snum > lmax) snum = lmax; | 133 | 133 | if (snum > lmax) snum = lmax; | |
| if (snum < 0) snum = 0; | 134 | 134 | if (snum < 0) snum = 0; | |
| } else | 135 | 135 | } else | |
| snum = parseInt(jl.value); | 136 | 136 | snum = parseInt(jl.value); | |
| var nid = 'slide' + snum; | 137 | 137 | var nid = 'slide' + snum; | |
| var ne = document.getElementById(nid); | 138 | 138 | var ne = document.getElementById(nid); | |
| if (!ne) { | 139 | 139 | if (!ne) { | |
| ne = document.getElementById('slide0'); | 140 | 140 | ne = document.getElementById('slide0'); | |
| snum = 0; | 141 | 141 | snum = 0; | |
| } | 142 | 142 | } | |
| if (step < 0) {incpos = incrementals[snum].length} else {incpos = 0;} | 143 | 143 | if (step < 0) {incpos = incrementals[snum].length} else {incpos = 0;} | |
| if (incrementals[snum].length > 0 && incpos == 0) { | 144 | 144 | if (incrementals[snum].length > 0 && incpos == 0) { | |
| for (var i = 0; i < incrementals[snum].length; i++) { | 145 | 145 | for (var i = 0; i < incrementals[snum].length; i++) { | |
| if (hasClass(incrementals[snum][i], 'current')) | 146 | 146 | if (hasClass(incrementals[snum][i], 'current')) | |
| incpos = i + 1; | 147 | 147 | incpos = i + 1; | |
| else | 148 | 148 | else | |
| addClass(incrementals[snum][i], 'incremental'); | 149 | 149 | addClass(incrementals[snum][i], 'incremental'); | |
| } | 150 | 150 | } | |
| } | 151 | 151 | } | |
| if (incrementals[snum].length > 0 && incpos > 0) | 152 | 152 | if (incrementals[snum].length > 0 && incpos > 0) | |
| addClass(incrementals[snum][incpos - 1], 'current'); | 153 | 153 | addClass(incrementals[snum][incpos - 1], 'current'); | |
| ce.style.visibility = 'hidden'; | 154 | 154 | ce.style.visibility = 'hidden'; | |
| ne.style.visibility = 'visible'; | 155 | 155 | ne.style.visibility = 'visible'; | |
| jl.selectedIndex = snum; | 156 | 156 | jl.selectedIndex = snum; | |
| currentSlide(); | 157 | 157 | currentSlide(); | |
| number = 0; | 158 | 158 | number = 0; | |
| } | 159 | 159 | } | |
| 160 | 160 | |||
| function goTo(target) { | 161 | 161 | function goTo(target) { | |
| if (target >= smax || target == snum) return; | 162 | 162 | if (target >= smax || target == snum) return; | |
| go(target - snum); | 163 | 163 | go(target - snum); | |
| } | 164 | 164 | } | |
| 165 | 165 | |||
| function subgo(step) { | 166 | 166 | function subgo(step) { | |
| if (step > 0) { | 167 | 167 | if (step > 0) { | |
| removeClass(incrementals[snum][incpos - 1],'current'); | 168 | 168 | removeClass(incrementals[snum][incpos - 1],'current'); | |
| removeClass(incrementals[snum][incpos], 'incremental'); | 169 | 169 | removeClass(incrementals[snum][incpos], 'incremental'); | |
| addClass(incrementals[snum][incpos],'current'); | 170 | 170 | addClass(incrementals[snum][incpos],'current'); | |
| incpos++; | 171 | 171 | incpos++; | |
| } else { | 172 | 172 | } else { | |
| incpos--; | 173 | 173 | incpos--; | |
| removeClass(incrementals[snum][incpos],'current'); | 174 | 174 | removeClass(incrementals[snum][incpos],'current'); | |
| addClass(incrementals[snum][incpos], 'incremental'); | 175 | 175 | addClass(incrementals[snum][incpos], 'incremental'); | |
| addClass(incrementals[snum][incpos - 1],'current'); | 176 | 176 | addClass(incrementals[snum][incpos - 1],'current'); | |
| } | 177 | 177 | } | |
| } | 178 | 178 | } | |
| 179 | 179 | |||
| function toggle() { | 180 | 180 | function toggle() { | |
| var slideColl = GetElementsWithClassName('*','slide'); | 181 | 181 | var slideColl = GetElementsWithClassName('*','slide'); | |
| var slides = document.getElementById('slideProj'); | 182 | 182 | var slides = document.getElementById('slideProj'); | |
| var outline = document.getElementById('outlineStyle'); | 183 | 183 | var outline = document.getElementById('outlineStyle'); | |
| if (!slides.disabled) { | 184 | 184 | if (!slides.disabled) { | |
| slides.disabled = true; | 185 | 185 | slides.disabled = true; | |
| outline.disabled = false; | 186 | 186 | outline.disabled = false; | |
| s5mode = false; | 187 | 187 | s5mode = false; | |
| fontSize('1em'); | 188 | 188 | fontSize('1em'); | |
| for (var n = 0; n < smax; n++) { | 189 | 189 | for (var n = 0; n < smax; n++) { | |
| var slide = slideColl[n]; | 190 | 190 | var slide = slideColl[n]; | |
| slide.style.visibility = 'visible'; | 191 | 191 | slide.style.visibility = 'visible'; | |
| } | 192 | 192 | } | |
| } else { | 193 | 193 | } else { | |
| slides.disabled = false; | 194 | 194 | slides.disabled = false; | |
| outline.disabled = true; | 195 | 195 | outline.disabled = true; | |
| s5mode = true; | 196 | 196 | s5mode = true; | |
| fontScale(); | 197 | 197 | fontScale(); | |
| for (var n = 0; n < smax; n++) { | 198 | 198 | for (var n = 0; n < smax; n++) { | |
| var slide = slideColl[n]; | 199 | 199 | var slide = slideColl[n]; | |
| slide.style.visibility = 'hidden'; | 200 | 200 | slide.style.visibility = 'hidden'; | |
| } | 201 | 201 | } | |
| slideColl[snum].style.visibility = 'visible'; | 202 | 202 | slideColl[snum].style.visibility = 'visible'; | |
| } | 203 | 203 | } | |
| } | 204 | 204 | } | |
| 205 | 205 | |||
| function showHide(action) { | 206 | 206 | function showHide(action) { | |
| var obj = GetElementsWithClassName('*','hideme')[0]; | 207 | 207 | var obj = GetElementsWithClassName('*','hideme')[0]; | |
| switch (action) { | 208 | 208 | switch (action) { | |
| case 's': obj.style.visibility = 'visible'; break; | 209 | 209 | case 's': obj.style.visibility = 'visible'; break; | |
| case 'h': obj.style.visibility = 'hidden'; break; | 210 | 210 | case 'h': obj.style.visibility = 'hidden'; break; | |
| case 'k': | 211 | 211 | case 'k': | |
| if (obj.style.visibility != 'visible') { | 212 | 212 | if (obj.style.visibility != 'visible') { | |
| obj.style.visibility = 'visible'; | 213 | 213 | obj.style.visibility = 'visible'; | |
| } else { | 214 | 214 | } else { | |
| obj.style.visibility = 'hidden'; | 215 | 215 | obj.style.visibility = 'hidden'; | |
| } | 216 | 216 | } | |
| break; | 217 | 217 | break; | |
| } | 218 | 218 | } | |
| } | 219 | 219 | } | |
| 220 | 220 | |||
| // 'keys' code adapted from MozPoint (http://mozpoint.mozdev.org/) | 221 | 221 | // 'keys' code adapted from MozPoint (http://mozpoint.mozdev.org/) | |
| function keys(key) { | 222 | 222 | function keys(key) { | |
| if (!key) { | 223 | 223 | if (!key) { | |
| key = event; | 224 | 224 | key = event; | |
| key.which = key.keyCode; | 225 | 225 | key.which = key.keyCode; | |
| } | 226 | 226 | } | |
| if (key.which == 84) { | 227 | 227 | if (key.which == 84) { | |
| toggle(); | 228 | 228 | toggle(); | |
| return; | 229 | 229 | return; | |
| } | 230 | 230 | } | |
| if (s5mode) { | 231 | 231 | if (s5mode) { | |
| switch (key.which) { | 232 | 232 | switch (key.which) { | |
| case 10: // return | 233 | 233 | case 10: // return | |
| case 13: // enter | 234 | 234 | case 13: // enter | |
| if (window.event && isParentOrSelf(window.event.srcElement, 'controls')) return; | 235 | 235 | if (window.event && isParentOrSelf(window.event.srcElement, 'controls')) return; | |
| if (key.target && isParentOrSelf(key.target, 'controls')) return; | 236 | 236 | if (key.target && isParentOrSelf(key.target, 'controls')) return; | |
| if(number != undef) { | 237 | 237 | if(number != undef) { | |
| goTo(number); | 238 | 238 | goTo(number); | |
| break; | 239 | 239 | break; | |
| } | 240 | 240 | } | |
| case 32: // spacebar | 241 | 241 | case 32: // spacebar | |
| case 34: // page down | 242 | 242 | case 34: // page down | |
| case 39: // rightkey | 243 | 243 | case 39: // rightkey | |
| case 40: // downkey | 244 | 244 | case 40: // downkey | |
| if(number != undef) { | 245 | 245 | if(number != undef) { | |
| go(number); | 246 | 246 | go(number); | |
| } else if (!incrementals[snum] || incpos >= incrementals[snum].length) { | 247 | 247 | } else if (!incrementals[snum] || incpos >= incrementals[snum].length) { | |
| go(1); | 248 | 248 | go(1); | |
| } else { | 249 | 249 | } else { | |
| subgo(1); | 250 | 250 | subgo(1); | |
| } | 251 | 251 | } | |
| break; | 252 | 252 | break; | |
| case 33: // page up | 253 | 253 | case 33: // page up | |
| case 37: // leftkey | 254 | 254 | case 37: // leftkey | |
| case 38: // upkey | 255 | 255 | case 38: // upkey | |
| if(number != undef) { | 256 | 256 | if(number != undef) { | |
| go(-1 * number); | 257 | 257 | go(-1 * number); | |
| } else if (!incrementals[snum] || incpos <= 0) { | 258 | 258 | } else if (!incrementals[snum] || incpos <= 0) { | |
| go(-1); | 259 | 259 | go(-1); | |
| } else { | 260 | 260 | } else { | |
| subgo(-1); | 261 | 261 | subgo(-1); | |
| } | 262 | 262 | } | |
| break; | 263 | 263 | break; | |
| case 36: // home | 264 | 264 | case 36: // home | |
| goTo(0); | 265 | 265 | goTo(0); | |
| break; | 266 | 266 | break; | |
| case 35: // end | 267 | 267 | case 35: // end | |
| goTo(smax-1); | 268 | 268 | goTo(smax-1); | |
| break; | 269 | 269 | break; | |
| case 67: // c | 270 | 270 | case 67: // c | |
| showHide('k'); | 271 | 271 | showHide('k'); | |
| break; | 272 | 272 | break; | |
| } | 273 | 273 | } | |
| if (key.which < 48 || key.which > 57) { | 274 | 274 | if (key.which < 48 || key.which > 57) { | |
| number = undef; | 275 | 275 | number = undef; | |
| } else { | 276 | 276 | } else { | |
| if (window.event && isParentOrSelf(window.event.srcElement, 'controls')) return; | 277 | 277 | if (window.event && isParentOrSelf(window.event.srcElement, 'controls')) return; | |
| if (key.target && isParentOrSelf(key.target, 'controls')) return; | 278 | 278 | if (key.target && isParentOrSelf(key.target, 'controls')) return; | |
| number = (((number != undef) ? number : 0) * 10) + (key.which - 48); | 279 | 279 | number = (((number != undef) ? number : 0) * 10) + (key.which - 48); | |
| } | 280 | 280 | } | |
| } | 281 | 281 | } | |
| return false; | 282 | 282 | return false; | |
| } | 283 | 283 | } | |
| 284 | 284 | |||
| function clicker(e) { | 285 | 285 | function clicker(e) { | |
| number = undef; | 286 | 286 | number = undef; | |
| var target; | 287 | 287 | var target; | |
| if (window.event) { | 288 | 288 | if (window.event) { | |
| target = window.event.srcElement; | 289 | 289 | target = window.event.srcElement; | |
| e = window.event; | 290 | 290 | e = window.event; | |
| } else target = e.target; | 291 | 291 | } else target = e.target; | |
| if (target.getAttribute('href') != null || hasValue(target.rel, 'external') || isParentOrSelf(target, 'controls') || isParentOrSelf(target,'embed') || isParentOrSelf(target,'object')) return true; | 292 | 292 | if (target.getAttribute('href') != null || hasValue(target.rel, 'external') || isParentOrSelf(target, 'controls') || isParentOrSelf(target,'embed') || isParentOrSelf(target,'object')) return true; | |
| if (!e.which || e.which == 1) { | 293 | 293 | if (!e.which || e.which == 1) { | |
| if (!incrementals[snum] || incpos >= incrementals[snum].length) { | 294 | 294 | if (!incrementals[snum] || incpos >= incrementals[snum].length) { | |
| go(1); | 295 | 295 | go(1); | |
| } else { | 296 | 296 | } else { | |
| subgo(1); | 297 | 297 | subgo(1); | |
| } | 298 | 298 | } | |
| } | 299 | 299 | } | |
| } | 300 | 300 | } | |
| 301 | 301 | |||
| function findSlide(hash) { | 302 | 302 | function findSlide(hash) { | |
| var target = null; | 303 | 303 | var target = null; | |
| var slides = GetElementsWithClassName('*','slide'); | 304 | 304 | var slides = GetElementsWithClassName('*','slide'); | |
| for (var i = 0; i < slides.length; i++) { | 305 | 305 | for (var i = 0; i < slides.length; i++) { | |
| var targetSlide = slides[i]; | 306 | 306 | var targetSlide = slides[i]; | |
| if ( (targetSlide.name && targetSlide.name == hash) | 307 | 307 | if ( (targetSlide.name && targetSlide.name == hash) | |
| || (targetSlide.id && targetSlide.id == hash) ) { | 308 | 308 | || (targetSlide.id && targetSlide.id == hash) ) { | |
| target = targetSlide; | 309 | 309 | target = targetSlide; | |
| break; | 310 | 310 | break; | |
| } | 311 | 311 | } | |
| } | 312 | 312 | } | |
| while(target != null && target.nodeName != 'BODY') { | 313 | 313 | while(target != null && target.nodeName != 'BODY') { | |
| if (hasClass(target, 'slide')) { | 314 | 314 | if (hasClass(target, 'slide')) { | |
| return parseInt(target.id.slice(5)); | 315 | 315 | return parseInt(target.id.slice(5)); | |
| } | 316 | 316 | } | |
| target = target.parentNode; | 317 | 317 | target = target.parentNode; | |
| } | 318 | 318 | } | |
| return null; | 319 | 319 | return null; | |
| } | 320 | 320 | } | |
| 321 | 321 | |||
| function slideJump() { | 322 | 322 | function slideJump() { | |
| if (window.location.hash == null) return; | 323 | 323 | if (window.location.hash == null) return; | |
| var sregex = /^#slide(\d+)$/; | 324 | 324 | var sregex = /^#slide(\d+)$/; | |
| var matches = sregex.exec(window.location.hash); | 325 | 325 | var matches = sregex.exec(window.location.hash); | |
| var dest = null; | 326 | 326 | var dest = null; | |
| if (matches != null) { | 327 | 327 | if (matches != null) { | |
| dest = parseInt(matches[1]); | 328 | 328 | dest = parseInt(matches[1]); | |
| } else { | 329 | 329 | } else { | |
| dest = findSlide(window.location.hash.slice(1)); | 330 | 330 | dest = findSlide(window.location.hash.slice(1)); | |
| } | 331 | 331 | } | |
| if (dest != null) | 332 | 332 | if (dest != null) | |
| go(dest - snum); | 333 | 333 | go(dest - snum); | |
| } | 334 | 334 | } | |
| 335 | 335 | |||
| function fixLinks() { | 336 | 336 | function fixLinks() { | |
| var thisUri = window.location.href; | 337 | 337 | var thisUri = window.location.href; | |
| thisUri = thisUri.slice(0, thisUri.length - window.location.hash.length); | 338 | 338 | thisUri = thisUri.slice(0, thisUri.length - window.location.hash.length); | |
| var aelements = document.getElementsByTagName('A'); | 339 | 339 | var aelements = document.getElementsByTagName('A'); | |
| for (var i = 0; i < aelements.length; i++) { | 340 | 340 | for (var i = 0; i < aelements.length; i++) { | |
| var a = aelements[i].href; | 341 | 341 | var a = aelements[i].href; | |
| var slideID = a.match('\#slide[0-9]{1,2}'); | 342 | 342 | var slideID = a.match('\#slide[0-9]{1,2}'); | |
| if ((slideID) && (slideID[0].slice(0,1) == '#')) { | 343 | 343 | if ((slideID) && (slideID[0].slice(0,1) == '#')) { | |
| var dest = findSlide(slideID[0].slice(1)); | 344 | 344 | var dest = findSlide(slideID[0].slice(1)); | |
| if (dest != null) { | 345 | 345 | if (dest != null) { | |
| if (aelements[i].addEventListener) { | 346 | 346 | if (aelements[i].addEventListener) { | |
| aelements[i].addEventListener("click", new Function("e", | 347 | 347 | aelements[i].addEventListener("click", new Function("e", | |
| "if (document.getElementById('slideProj').disabled) return;" + | 348 | 348 | "if (document.getElementById('slideProj').disabled) return;" + | |
| "go("+dest+" - snum); " + | 349 | 349 | "go("+dest+" - snum); " + | |
| "if (e.preventDefault) e.preventDefault();"), true); | 350 | 350 | "if (e.preventDefault) e.preventDefault();"), true); | |
| } else if (aelements[i].attachEvent) { | 351 | 351 | } else if (aelements[i].attachEvent) { | |
| aelements[i].attachEvent("onclick", new Function("", | 352 | 352 | aelements[i].attachEvent("onclick", new Function("", | |
| "if (document.getElementById('slideProj').disabled) return;" + | 353 | 353 | "if (document.getElementById('slideProj').disabled) return;" + | |
| "go("+dest+" - snum); " + | 354 | 354 | "go("+dest+" - snum); " + | |
| "event.returnValue = false;")); | 355 | 355 | "event.returnValue = false;")); | |
| } | 356 | 356 | } | |
| } | 357 | 357 | } | |
| } | 358 | 358 | } | |
| } | 359 | 359 | } | |
| } | 360 | 360 | } | |
| 361 | 361 | |||
| function externalLinks() { | 362 | 362 | function externalLinks() { | |
| if (!document.getElementsByTagName) return; | 363 | 363 | if (!document.getElementsByTagName) return; | |
| var anchors = document.getElementsByTagName('a'); | 364 | 364 | var anchors = document.getElementsByTagName('a'); | |
| for (var i=0; i<anchors.length; i++) { | 365 | 365 | for (var i=0; i<anchors.length; i++) { | |
| var anchor = anchors[i]; | 366 | 366 | var anchor = anchors[i]; | |
| if (anchor.getAttribute('href') && hasValue(anchor.rel, 'external')) { | 367 | 367 | if (anchor.getAttribute('href') && hasValue(anchor.rel, 'external')) { | |
| anchor.target = '_blank'; | 368 | 368 | anchor.target = '_blank'; | |
| addClass(anchor,'external'); | 369 | 369 | addClass(anchor,'external'); | |
| } | 370 | 370 | } | |
| } | 371 | 371 | } | |
| } | 372 | 372 | } | |
| 373 | 373 | |||
| function createControls() { | 374 | 374 | function createControls() { | |
| var controlsDiv = document.getElementById("controls"); | 375 | 375 | var controlsDiv = document.getElementById("controls"); | |
| if (!controlsDiv) return; | 376 | 376 | if (!controlsDiv) return; | |
| var hider = ' onmouseover="showHide(\'s\');" onmouseout="showHide(\'h\');"'; | 377 | 377 | var hider = ' onmouseover="showHide(\'s\');" onmouseout="showHide(\'h\');"'; | |
| var hideDiv, hideList = ''; | 378 | 378 | var hideDiv, hideList = ''; | |
| if (controlVis == 'hidden') { | 379 | 379 | if (controlVis == 'hidden') { | |
| hideDiv = hider; | 380 | 380 | hideDiv = hider; | |
| } else { | 381 | 381 | } else { | |
| hideList = hider; | 382 | 382 | hideList = hider; | |
| } | 383 | 383 | } | |
| controlsDiv.innerHTML = '<form action="#" id="controlForm"' + hideDiv + '>' + | 384 | 384 | controlsDiv.innerHTML = '<form action="#" id="controlForm"' + hideDiv + '>' + | |
| '<div id="navLinks">' + | 385 | 385 | '<div id="navLinks">' + | |
| '<a accesskey="t" id="toggle" href="javascript:toggle();">Ø<\/a>' + | 386 | 386 | '<a accesskey="t" id="toggle" href="javascript:toggle();">Ø<\/a>' + | |
| '<a accesskey="z" id="prev" href="javascript:go(-1);">«<\/a>' + | 387 | 387 | '<a accesskey="z" id="prev" href="javascript:go(-1);">«<\/a>' + | |
| '<a accesskey="x" id="next" href="javascript:go(1);">»<\/a>' + | 388 | 388 | '<a accesskey="x" id="next" href="javascript:go(1);">»<\/a>' + | |
| '<div id="navList"' + hideList + '><select id="jumplist" onchange="go(\'j\');"><\/select><\/div>' + | 389 | 389 | '<div id="navList"' + hideList + '><select id="jumplist" onchange="go(\'j\');"><\/select><\/div>' + | |
| '<\/div><\/form>'; | 390 | 390 | '<\/div><\/form>'; | |
| if (controlVis == 'hidden') { | 391 | 391 | if (controlVis == 'hidden') { | |
| var hidden = document.getElementById('navLinks'); | 392 | 392 | var hidden = document.getElementById('navLinks'); | |
| } else { | 393 | 393 | } else { | |
| var hidden = document.getElementById('jumplist'); | 394 | 394 | var hidden = document.getElementById('jumplist'); | |
| } | 395 | 395 | } | |
| addClass(hidden,'hideme'); | 396 | 396 | addClass(hidden,'hideme'); | |
| } | 397 | 397 | } | |
| 398 | 398 | |||
| 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 | 399 | 399 | 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 | |
| if (!s5mode) return false; | 400 | 400 | if (!s5mode) return false; | |
| var vScale = 22; // both yield 32 (after rounding) at 1024x768 | 401 | 401 | //var vScale = 22; // both yield 32 (after rounding) at 1024x768 | |
| var hScale = 32; // perhaps should auto-calculate based on theme's declared value? | 402 | 402 | //var hScale = 32; // perhaps should auto-calculate based on theme's declared value? | |
| 403 | var vScale = Math.round(22 / getScaleFromTheme()); | |||
| 404 | var hScale = Math.round(vScale * 32 / 22); | |||
| if (window.innerHeight) { | 403 | 405 | if (window.innerHeight) { | |
| var vSize = window.innerHeight; | 404 | 406 | var vSize = window.innerHeight; | |
| var hSize = window.innerWidth; | 405 | 407 | var hSize = window.innerWidth; | |
| } else if (document.documentElement.clientHeight) { | 406 | 408 | } else if (document.documentElement.clientHeight) { | |
| var vSize = document.documentElement.clientHeight; | 407 | 409 | var vSize = document.documentElement.clientHeight; | |
| var hSize = document.documentElement.clientWidth; | 408 | 410 | var hSize = document.documentElement.clientWidth; | |
| } else if (document.body.clientHeight) { | 409 | 411 | } else if (document.body.clientHeight) { | |
| var vSize = document.body.clientHeight; | 410 | 412 | var vSize = document.body.clientHeight; | |
| var hSize = document.body.clientWidth; | 411 | 413 | var hSize = document.body.clientWidth; | |
| } else { | 412 | 414 | } else { | |
| var vSize = 700; // assuming 1024x768, minus chrome and such | 413 | 415 | var vSize = 700; // assuming 1024x768, minus chrome and such | |
| var hSize = 1024; // these do not account for kiosk mode or Opera Show | 414 | 416 | var hSize = 1024; // these do not account for kiosk mode or Opera Show | |
| } | 415 | 417 | } | |
| var newSize = Math.min(Math.round(vSize/vScale),Math.round(hSize/hScale)); | 416 | 418 | var newSize = Math.min(Math.round(vSize/vScale),Math.round(hSize/hScale)); | |
| fontSize(newSize + 'px'); | 417 | 419 | fontSize(newSize + 'px'); | |
| if (isGe) { // hack to counter incremental reflow bugs | 418 | 420 | if (isGe) { // hack to counter incremental reflow bugs | |
| var obj = document.getElementsByTagName('body')[0]; | 419 | 421 | var obj = document.getElementsByTagName('body')[0]; | |
| obj.style.display = 'none'; | 420 | 422 | obj.style.display = 'none'; | |
| obj.style.display = 'block'; | 421 | 423 | obj.style.display = 'block'; | |
| } | 422 | 424 | } | |
| 425 | } | |||
| 426 | ||||
| 427 | function getScaleFromTheme() { | |||
| 428 | var sc = parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--main-pres-font-scale')); | |||
| 429 | sc = isNaN(sc) ? 1.0 : sc; | |||
| 430 | return sc; | |||
| } | 423 | 431 | } | |
| 424 | 432 | |||
| function fontSize(value) { | 425 | 433 | function fontSize(value) { | |
| if (!(s5ss = document.getElementById('s5ss'))) { | 426 | 434 | if (!(s5ss = document.getElementById('s5ss'))) { | |
| if (!isIE) { | 427 | 435 | if (!isIE) { | |
| document.getElementsByTagName('head')[0].appendChild(s5ss = document.createElement('style')); | 428 | 436 | document.getElementsByTagName('head')[0].appendChild(s5ss = document.createElement('style')); | |
| s5ss.setAttribute('media','screen, projection'); | 429 | 437 | s5ss.setAttribute('media','screen, projection'); | |
| s5ss.setAttribute('id','s5ss'); | 430 | 438 | s5ss.setAttribute('id','s5ss'); | |
| } else { | 431 | 439 | } else { | |
| document.createStyleSheet(); | 432 | 440 | document.createStyleSheet(); | |
| document.s5ss = document.styleSheets[document.styleSheets.length - 1]; | 433 | 441 | document.s5ss = document.styleSheets[document.styleSheets.length - 1]; | |
| } | 434 | 442 | } | |
| } | 435 | 443 | } | |
| if (!isIE) { | 436 | 444 | if (!isIE) { | |
| while (s5ss.lastChild) s5ss.removeChild(s5ss.lastChild); | 437 | 445 | while (s5ss.lastChild) s5ss.removeChild(s5ss.lastChild); | |
| s5ss.appendChild(document.createTextNode('body {font-size: ' + value + ' !important;}')); | 438 | 446 | s5ss.appendChild(document.createTextNode('body {font-size: ' + value + ' !important;}')); | |
| } else { | 439 | 447 | } else { | |
| document.s5ss.addRule('body','font-size: ' + value + ' !important;'); | 440 | 448 | document.s5ss.addRule('body','font-size: ' + value + ' !important;'); | |
| } | 441 | 449 | } | |
| } | 442 | 450 | } | |
| 443 | 451 | |||
| function notOperaFix() { | 444 | 452 | function notOperaFix() { | |
| slideCSS = document.getElementById('slideProj').href; | 445 | 453 | slideCSS = document.getElementById('slideProj').href; | |
| var slides = document.getElementById('slideProj'); | 446 | 454 | var slides = document.getElementById('slideProj'); | |
| var outline = document.getElementById('outlineStyle'); | 447 | 455 | var outline = document.getElementById('outlineStyle'); | |
| slides.setAttribute('media','screen'); | 448 | 456 | slides.setAttribute('media','screen'); | |
| outline.disabled = true; | 449 | 457 | outline.disabled = true; | |
| if (isGe) { | 450 | 458 | if (isGe) { | |
| slides.setAttribute('href','null'); // Gecko fix | 451 | 459 | slides.setAttribute('href','null'); // Gecko fix | |
| slides.setAttribute('href',slideCSS); // Gecko fix | 452 | 460 | slides.setAttribute('href',slideCSS); // Gecko fix | |
| } | 453 | 461 | } | |
| if (isIE && document.styleSheets && document.styleSheets[0]) { | 454 | 462 | if (isIE && document.styleSheets && document.styleSheets[0]) { | |
| document.styleSheets[0].addRule('img', 'behavior: url(ui/default/iepngfix.htc)'); | 455 | 463 | document.styleSheets[0].addRule('img', 'behavior: url(ui/default/iepngfix.htc)'); | |
| document.styleSheets[0].addRule('div', 'behavior: url(ui/default/iepngfix.htc)'); | 456 | 464 | document.styleSheets[0].addRule('div', 'behavior: url(ui/default/iepngfix.htc)'); | |
| document.styleSheets[0].addRule('.slide', 'behavior: url(ui/default/iepngfix.htc)'); | 457 | 465 | document.styleSheets[0].addRule('.slide', 'behavior: url(ui/default/iepngfix.htc)'); | |
| } | 458 | 466 | } | |
| } | 459 | 467 | } | |
| 460 | 468 | |||
| function getIncrementals(obj) { | 461 | 469 | function getIncrementals(obj) { | |
| var incrementals = new Array(); | 462 | 470 | var incrementals = new Array(); | |
| if (!obj) | 463 | 471 | if (!obj) | |
| return incrementals; | 464 | 472 | return incrementals; | |
| var children = obj.childNodes; | 465 | 473 | var children = obj.childNodes; | |
| for (var i = 0; i < children.length; i++) { | 466 | 474 | for (var i = 0; i < children.length; i++) { | |
| var child = children[i]; | 467 | 475 | var child = children[i]; | |
| if (hasClass(child, 'incremental')) { | 468 | 476 | if (hasClass(child, 'incremental')) { | |
| if (child.nodeName == 'OL' || child.nodeName == 'UL') { | 469 | 477 | if (child.nodeName == 'OL' || child.nodeName == 'UL') { | |
| removeClass(child, 'incremental'); | 470 | 478 | removeClass(child, 'incremental'); | |
| for (var j = 0; j < child.childNodes.length; j++) { | 471 | 479 | for (var j = 0; j < child.childNodes.length; j++) { | |
| if (child.childNodes[j].nodeType == 1) { | 472 | 480 | if (child.childNodes[j].nodeType == 1) { | |
| addClass(child.childNodes[j], 'incremental'); | 473 | 481 | addClass(child.childNodes[j], 'incremental'); | |
| } | 474 | 482 | } | |
| } | 475 | 483 | } | |
| } else { | 476 | 484 | } else { | |
| incrementals[incrementals.length] = child; | 477 | 485 | incrementals[incrementals.length] = child; | |
| removeClass(child,'incremental'); | 478 | 486 | removeClass(child,'incremental'); | |
| } | 479 | 487 | } | |
| } | 480 | 488 | } | |
| if (hasClass(child, 'show-first')) { | 481 | 489 | if (hasClass(child, 'show-first')) { | |
| if (child.nodeName == 'OL' || child.nodeName == 'UL') { | 482 | 490 | if (child.nodeName == 'OL' || child.nodeName == 'UL') { | |
| removeClass(child, 'show-first'); | 483 | 491 | removeClass(child, 'show-first'); | |
| if (child.childNodes[isGe].nodeType == 1) { | 484 | 492 | if (child.childNodes[isGe].nodeType == 1) { | |
| removeClass(child.childNodes[isGe], 'incremental'); | 485 | 493 | removeClass(child.childNodes[isGe], 'incremental'); | |
| } | 486 | 494 | } | |
| } else { | 487 | 495 | } else { | |
| incrementals[incrementals.length] = child; | 488 | 496 | incrementals[incrementals.length] = child; | |
| } | 489 | 497 | } | |
| } | 490 | 498 | } | |
| incrementals = incrementals.concat(getIncrementals(child)); | 491 | 499 | incrementals = incrementals.concat(getIncrementals(child)); | |
| } | 492 | 500 | } | |
| return incrementals; | 493 | 501 | return incrementals; | |
| } | 494 | 502 | } | |
| 495 | 503 | |||
| function createIncrementals() { | 496 | 504 | function createIncrementals() { | |
| var incrementals = new Array(); | 497 | 505 | var incrementals = new Array(); | |
| for (var i = 0; i < smax; i++) { | 498 | 506 | for (var i = 0; i < smax; i++) { | |
| incrementals[i] = getIncrementals(document.getElementById('slide'+i)); | 499 | 507 | incrementals[i] = getIncrementals(document.getElementById('slide'+i)); | |
| } | 500 | 508 | } | |
| return incrementals; | 501 | 509 | return incrementals; | |
| } | 502 | 510 | } | |
| 503 | 511 | |||
| function defaultCheck() { | 504 | 512 | function defaultCheck() { | |
| var allMetas = document.getElementsByTagName('meta'); | 505 | 513 | var allMetas = document.getElementsByTagName('meta'); | |
| for (var i = 0; i< allMetas.length; i++) { | 506 | 514 | for (var i = 0; i< allMetas.length; i++) { | |
| if (allMetas[i].name == 'defaultView') { | 507 | 515 | if (allMetas[i].name == 'defaultView') { | |
| defaultView = allMetas[i].content; | 508 | 516 | defaultView = allMetas[i].content; | |
| } | 509 | 517 | } | |
| if (allMetas[i].name == 'controlVis') { | 510 | 518 | if (allMetas[i].name == 'controlVis') { | |
| controlVis = allMetas[i].content; | 511 | 519 | controlVis = allMetas[i].content; | |
| } | 512 | 520 | } | |
| } | 513 | 521 | } | |
| } | 514 | 522 | } | |
| 515 | 523 | |||
| // Key trap fix, new function body for trap() | 516 | 524 | // Key trap fix, new function body for trap() | |
| function trap(e) { | 517 | 525 | function trap(e) { | |
| if (!e) { | 518 | 526 | if (!e) { | |
| e = event; | 519 | 527 | e = event; | |
| e.which = e.keyCode; | 520 | 528 | e.which = e.keyCode; | |
| } | 521 | 529 | } | |
| try { | 522 | 530 | try { |