slidy.js 80 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014
  1. /* slidy.js (modified by Dehos)
  2. Copyright (c) 2005-2011 W3C (MIT, ERCIM, Keio), All Rights Reserved.
  3. W3C liability, trademark, document use and software licensing
  4. rules apply, see:
  5. http://www.w3.org/Consortium/Legal/copyright-documents
  6. http://www.w3.org/Consortium/Legal/copyright-software
  7. Defines single name "w3c_slidy" in global namespace
  8. Adds event handlers without trampling on any others
  9. */
  10. // the slidy object implementation
  11. var w3c_slidy = {
  12. // classify which kind of browser we're running under
  13. ns_pos: (typeof window.pageYOffset!='undefined'),
  14. khtml: ((navigator.userAgent).indexOf("KHTML") >= 0 ? true : false),
  15. opera: ((navigator.userAgent).indexOf("Opera") >= 0 ? true : false),
  16. ipad: ((navigator.userAgent).indexOf("iPad") >= 0 ? true : false),
  17. iphone: ((navigator.userAgent).indexOf("iPhone") >= 0 ? true : false),
  18. android: ((navigator.userAgent).indexOf("Android") >= 0 ? true : false),
  19. ie: (typeof document.all != "undefined" && !this.opera),
  20. ie6: (!this.ns_pos && navigator.userAgent.indexOf("MSIE 6") != -1),
  21. ie7: (!this.ns_pos && navigator.userAgent.indexOf("MSIE 7") != -1),
  22. ie8: (!this.ns_pos && navigator.userAgent.indexOf("MSIE 8") != -1),
  23. ie9: (!this.ns_pos && navigator.userAgent.indexOf("MSIE 9") != -1),
  24. // data for swipe and double tap detection on touch screens
  25. last_tap: 0,
  26. prev_tap: 0,
  27. start_x: 0,
  28. start_y: 0,
  29. delta_x: 0,
  30. delta_y: 0,
  31. // are we running as XHTML? (doesn't work on Opera)
  32. is_xhtml: /xml/.test(document.contentType),
  33. slide_number: 0, // integer slide count: 0, 1, 2, ...
  34. slide_number_element: null, // element containing slide number
  35. slides: [], // set to array of slide div's
  36. notes: [], // set to array of handout div's
  37. backgrounds: [], // set to array of background div's
  38. toolbar: null, // element containing toolbar
  39. title: null, // document title
  40. last_shown: null, // last incrementally shown item
  41. eos: null, // span element for end of slide indicator
  42. toc: null, // table of contents
  43. outline: null, // outline element with the focus
  44. selected_text_len: 0, // length of drag selection on document
  45. view_all: 0, // 1 to view all slides + handouts
  46. want_toolbar: true, // user preference to show/hide toolbar
  47. mouse_click_enabled: true, // enables left click for next slide
  48. scroll_hack: 0, // IE work around for position: fixed
  49. disable_slide_click: false, // used by clicked anchors
  50. lang: "en", // updated to language specified by html file
  51. help_anchor: null, // used for keyboard focus hack in showToolbar()
  52. help_page: "http://www.w3.org/Talks/Tools/Slidy2/help/help.html",
  53. help_text: "Navigate with mouse click, space bar, Cursor Left/Right, " +
  54. "or Pg Up and Pg Dn. Use S and B to change font size.",
  55. size_index: 0,
  56. size_adjustment: 0,
  57. sizes: new Array("10pt", "12pt", "14pt", "16pt", "18pt", "20pt",
  58. "22pt", "24pt", "26pt", "28pt", "30pt", "32pt"),
  59. // needed for efficient resizing
  60. last_width: 0,
  61. last_height: 0,
  62. // Needed for cross browser support for relative width/height on
  63. // object elements. The work around is to save width/height attributes
  64. // and then to recompute absolute width/height dimensions on resizing
  65. objects: [],
  66. // attach initialiation event handlers
  67. set_up: function () {
  68. var init = function() { w3c_slidy.init(); };
  69. if (typeof window.addEventListener != "undefined")
  70. window.addEventListener("load", init, false);
  71. else
  72. window.attachEvent("onload", init);
  73. },
  74. hide_slides: function () {
  75. if (document.body && !w3c_slidy.initialized)
  76. document.body.style.visibility = "hidden";
  77. else
  78. setTimeout(w3c_slidy.hide_slides, 50);
  79. },
  80. // hack to persuade IE to compute correct document height
  81. // as needed for simulating fixed positioning of toolbar
  82. ie_hack: function () {
  83. window.resizeBy(0,-1);
  84. window.resizeBy(0, 1);
  85. },
  86. init: function () {
  87. //alert("slidy starting test 10");
  88. document.body.style.visibility = "visible";
  89. this.init_localization();
  90. this.add_toolbar();
  91. this.wrap_implicit_slides();
  92. this.collect_slides();
  93. this.collect_notes();
  94. this.collect_backgrounds();
  95. this.objects = document.body.getElementsByTagName("object");
  96. this.patch_anchors();
  97. this.slide_number = this.find_slide_number(location.href);
  98. window.offscreenbuffering = true;
  99. this.size_adjustment = this.find_size_adjust();
  100. this.time_left = this.find_duration();
  101. this.hide_image_toolbar(); // suppress IE image toolbar popup
  102. this.init_outliner(); // activate fold/unfold support
  103. this.title = document.title;
  104. this.keyboardless = (this.ipad||this.iphone||this.android);
  105. if (this.keyboardless)
  106. {
  107. w3c_slidy.remove_class(w3c_slidy.toolbar, "hidden")
  108. this.want_toolbar = 0;
  109. }
  110. // work around for opera bug
  111. this.is_xhtml = (document.body.tagName == "BODY" ? false : true);
  112. if (this.slides.length > 0)
  113. {
  114. var slide = this.slides[this.slide_number];
  115. if (this.slide_number > 0)
  116. {
  117. this.set_visibility_all_incremental("visible");
  118. this.last_shown = this.previous_incremental_item(null);
  119. this.set_eos_status(true);
  120. }
  121. else
  122. {
  123. this.last_shown = null;
  124. this.set_visibility_all_incremental("hidden");
  125. this.set_eos_status(!this.next_incremental_item(this.last_shown));
  126. }
  127. this.set_location();
  128. this.add_class(this.slides[0], "first-slide");
  129. w3c_slidy.show_slide(slide);
  130. }
  131. this.toc = this.table_of_contents();
  132. this.add_initial_prompt();
  133. // bind event handlers without interfering with custom page scripts
  134. // Tap events behave too weirdly to support clicks reliably on
  135. // iPhone and iPad, so exclude these from click handler
  136. if (!this.keyboardless)
  137. this.add_listener(document.body, "click", this.mouse_button_click);
  138. this.add_listener(document, "keydown", this.key_down);
  139. this.add_listener(document, "keypress", this.key_press);
  140. this.add_listener(window, "resize", this.resized);
  141. this.add_listener(window, "scroll", this.scrolled);
  142. this.add_listener(window, "unload", this.unloaded);
  143. this.add_listener(document, "touchstart", this.touchstart);
  144. this.add_listener(document, "touchmove", this.touchmove);
  145. this.add_listener(document, "touchend", this.touchend);
  146. // this seems to be a debugging hack
  147. //if (!document.body.onclick)
  148. // document.body.onclick = function () { };
  149. this.single_slide_view();
  150. //this.set_location();
  151. this.resized();
  152. if (this.ie7)
  153. setTimeout(w3c_slidy.ie_hack, 100);
  154. this.show_toolbar();
  155. // for back button detection
  156. setInterval(function () { w3c_slidy.check_location(); }, 200);
  157. w3c_slidy.initialized = true;
  158. },
  159. // create div element with links to each slide
  160. table_of_contents: function () {
  161. var toc = this.create_element("div");
  162. this.add_class(toc, "slidy_toc hidden");
  163. //toc.setAttribute("tabindex", "0");
  164. var heading = this.create_element("div");
  165. this.add_class(heading, "toc-heading");
  166. heading.innerHTML = this.localize("Table of Contents");
  167. toc.appendChild(heading);
  168. var previous = null;
  169. for (var i = 0; i < this.slides.length; ++i)
  170. {
  171. var title = this.has_class(this.slides[i], "title");
  172. var num = document.createTextNode((i + 1) + ". ");
  173. toc.appendChild(num);
  174. var a = this.create_element("a");
  175. a.setAttribute("href", "#(" + (i+1) + ")");
  176. if (title)
  177. this.add_class(a, "titleslide");
  178. var name = document.createTextNode(this.slide_name(i));
  179. a.appendChild(name);
  180. a.onclick = w3c_slidy.toc_click;
  181. a.onkeydown = w3c_slidy.toc_key_down;
  182. a.previous = previous;
  183. if (previous)
  184. previous.next = a;
  185. toc.appendChild(a);
  186. if (i == 0)
  187. toc.first = a;
  188. if (i < this.slides.length - 1)
  189. {
  190. var br = this.create_element("br");
  191. toc.appendChild(br);
  192. }
  193. previous = a;
  194. }
  195. toc.focus = function () {
  196. if (this.first)
  197. this.first.focus();
  198. }
  199. toc.onmouseup = w3c_slidy.mouse_button_up;
  200. toc.onclick = function (e) {
  201. e||(e=window.event);
  202. if (w3c_slidy.selected_text_len <= 0)
  203. w3c_slidy.hide_table_of_contents(true);
  204. w3c_slidy.stop_propagation(e);
  205. if (e.cancel != undefined)
  206. e.cancel = true;
  207. if (e.returnValue != undefined)
  208. e.returnValue = false;
  209. return false;
  210. };
  211. document.body.insertBefore(toc, document.body.firstChild);
  212. return toc;
  213. },
  214. is_shown_toc: function () {
  215. return !w3c_slidy.has_class(w3c_slidy.toc, "hidden");
  216. },
  217. show_table_of_contents: function () {
  218. w3c_slidy.remove_class(w3c_slidy.toc, "hidden");
  219. var toc = w3c_slidy.toc;
  220. toc.focus();
  221. if (w3c_slidy.ie7 && w3c_slidy.slide_number == 0)
  222. setTimeout(w3c_slidy.ie_hack, 100);
  223. },
  224. hide_table_of_contents: function (focus) {
  225. w3c_slidy.add_class(w3c_slidy.toc, "hidden");
  226. if (focus && !w3c_slidy.opera)
  227. w3c_slidy.help_anchor.focus();
  228. },
  229. toggle_table_of_contents: function () {
  230. if (w3c_slidy.is_shown_toc())
  231. w3c_slidy.hide_table_of_contents(true);
  232. else
  233. w3c_slidy.show_table_of_contents();
  234. },
  235. // called on clicking toc entry
  236. toc_click: function (e) {
  237. if (!e)
  238. e = window.event;
  239. var target = w3c_slidy.get_target(e);
  240. if (target && target.nodeType == 1)
  241. {
  242. var uri = target.getAttribute("href");
  243. if (uri)
  244. {
  245. //alert("going to " + uri);
  246. var slide = w3c_slidy.slides[w3c_slidy.slide_number];
  247. w3c_slidy.hide_slide(slide);
  248. w3c_slidy.slide_number = w3c_slidy.find_slide_number(uri);
  249. slide = w3c_slidy.slides[w3c_slidy.slide_number];
  250. w3c_slidy.last_shown = null;
  251. w3c_slidy.set_location();
  252. w3c_slidy.set_visibility_all_incremental("hidden");
  253. w3c_slidy.set_eos_status(!w3c_slidy.next_incremental_item(w3c_slidy.last_shown));
  254. w3c_slidy.show_slide(slide);
  255. //target.focus();
  256. try
  257. {
  258. if (!w3c_slidy.opera)
  259. w3c_slidy.help_anchor.focus();
  260. }
  261. catch (e)
  262. {
  263. }
  264. }
  265. }
  266. w3c_slidy.hide_table_of_contents(true);
  267. if (w3c_slidy.ie7) w3c_slidy.ie_hack();
  268. w3c_slidy.stop_propagation(e);
  269. return w3c_slidy.cancel(e);
  270. },
  271. // called onkeydown for toc entry
  272. toc_key_down: function (event) {
  273. var key;
  274. if (!event)
  275. var event = window.event;
  276. // kludge around NS/IE differences
  277. if (window.event)
  278. key = window.event.keyCode;
  279. else if (event.which)
  280. key = event.which;
  281. else
  282. return true; // Yikes! unknown browser
  283. // ignore event if key value is zero
  284. // as for alt on Opera and Konqueror
  285. if (!key)
  286. return true;
  287. // check for concurrent control/command/alt key
  288. // but are these only present on mouse events?
  289. if (event.ctrlKey || event.altKey)
  290. return true;
  291. if (key == 13)
  292. {
  293. var uri = this.getAttribute("href");
  294. if (uri)
  295. {
  296. //alert("going to " + uri);
  297. var slide = w3c_slidy.slides[w3c_slidy.slide_number];
  298. w3c_slidy.hide_slide(slide);
  299. w3c_slidy.slide_number = w3c_slidy.find_slide_number(uri);
  300. slide = w3c_slidy.slides[w3c_slidy.slide_number];
  301. w3c_slidy.last_shown = null;
  302. w3c_slidy.set_location();
  303. w3c_slidy.set_visibility_all_incremental("hidden");
  304. w3c_slidy.set_eos_status(!w3c_slidy.next_incremental_item(w3c_slidy.last_shown));
  305. w3c_slidy.show_slide(slide);
  306. //target.focus();
  307. try
  308. {
  309. if (!w3c_slidy.opera)
  310. w3c_slidy.help_anchor.focus();
  311. }
  312. catch (e)
  313. {
  314. }
  315. }
  316. w3c_slidy.hide_table_of_contents(true);
  317. if (self.ie7)
  318. w3c_slidy.ie_hack();
  319. return w3c_slidy.cancel(event);
  320. }
  321. if (key == 40 && this.next)
  322. {
  323. this.next.focus();
  324. return w3c_slidy.cancel(event);
  325. }
  326. if (key == 38 && this.previous)
  327. {
  328. this.previous.focus();
  329. return w3c_slidy.cancel(event);
  330. }
  331. return true;
  332. },
  333. touchstart: function (e)
  334. {
  335. //e.preventDefault();
  336. this.prev_tap = this.last_tap;
  337. this.last_tap = (new Date).getTime();
  338. var tap_delay = this.last_tap - this.prev_tap;
  339. if (tap_delay <= 200)
  340. {
  341. // double tap
  342. }
  343. var touch = e.touches[0];
  344. this.start_x = touch.pageX;
  345. this.start_y = touch.pageY;
  346. this.delta_x = this.delta_y = 0;
  347. },
  348. touchmove: function (e)
  349. {
  350. //e.preventDefault();
  351. var touch = e.touches[0];
  352. this.delta_x = touch.pageX - this.start_x;
  353. this.delta_y = touch.pageY - this.start_y;
  354. },
  355. touchend: function (e)
  356. {
  357. //e.preventDefault();
  358. var delay = (new Date).getTime() - this.last_tap;
  359. var dx = this.delta_x;
  360. var dy = this.delta_y;
  361. var abs_dx = Math.abs(dx);
  362. var abs_dy = Math.abs(dy);
  363. if (delay < 500 && (abs_dx > 100 || abs_dy > 100))
  364. {
  365. if (abs_dx > 0.5 * abs_dy)
  366. {
  367. if (dx < 0)
  368. w3c_slidy.next_slide(true);
  369. else
  370. w3c_slidy.previous_slide(true);
  371. }
  372. else if (abs_dy > 2 * abs_dx)
  373. {
  374. w3c_slidy.toggle_table_of_contents();
  375. }
  376. }
  377. },
  378. // ### OBSOLETE ###
  379. before_print: function () {
  380. this.show_all_slides();
  381. this.hide_toolbar();
  382. alert("before print");
  383. },
  384. // ### OBSOLETE ###
  385. after_print: function () {
  386. if (!this.view_all)
  387. {
  388. this.single_slide_view();
  389. this.show_toolbar();
  390. }
  391. alert("after print");
  392. },
  393. // ### OBSOLETE ###
  394. print_slides: function () {
  395. this.before_print();
  396. window.print();
  397. this.after_print();
  398. },
  399. // ### OBSOLETE ?? ###
  400. toggle_view: function () {
  401. if (this.view_all)
  402. {
  403. this.single_slide_view();
  404. this.show_toolbar();
  405. this.view_all = 0;
  406. }
  407. else
  408. {
  409. this.show_all_slides();
  410. this.hide_toolbar();
  411. this.view_all = 1;
  412. }
  413. },
  414. // prepare for printing ### OBSOLETE ###
  415. show_all_slides: function () {
  416. this.remove_class(document.body, "single_slide");
  417. this.set_visibility_all_incremental("visible");
  418. },
  419. // restore after printing ### OBSOLETE ###
  420. single_slide_view: function () {
  421. this.add_class(document.body, "single_slide");
  422. this.set_visibility_all_incremental("visible");
  423. this.last_shown = this.previous_incremental_item(null);
  424. },
  425. // suppress IE's image toolbar pop up
  426. hide_image_toolbar: function () {
  427. if (!this.ns_pos)
  428. {
  429. var images = document.getElementsByTagName("IMG");
  430. for (var i = 0; i < images.length; ++i)
  431. images[i].setAttribute("galleryimg", "no");
  432. }
  433. },
  434. unloaded: function (e) {
  435. //alert("unloaded");
  436. },
  437. // Safari and Konqueror don't yet support getComputedStyle()
  438. // and they always reload page when location.href is updated
  439. is_KHTML: function () {
  440. var agent = navigator.userAgent;
  441. return (agent.indexOf("KHTML") >= 0 ? true : false);
  442. },
  443. // find slide name from first h1 element
  444. // default to document title + slide number
  445. slide_name: function (index) {
  446. var name = null;
  447. var slide = this.slides[index];
  448. var heading = this.find_heading(slide);
  449. if (heading)
  450. name = this.extract_text(heading);
  451. if (!name)
  452. name = this.title + "(" + (index + 1) + ")";
  453. name.replace(/\&/g, "&amp;");
  454. name.replace(/\</g, "&lt;");
  455. name.replace(/\>/g, "&gt;");
  456. return name;
  457. },
  458. // find first h1 element in DOM tree
  459. find_heading: function (node) {
  460. if (!node || node.nodeType != 1)
  461. return null;
  462. if (node.nodeName == "H1" || node.nodeName == "h1")
  463. return node;
  464. var child = node.firstChild;
  465. while (child)
  466. {
  467. node = this.find_heading(child);
  468. if (node)
  469. return node;
  470. child = child.nextSibling;
  471. }
  472. return null;
  473. },
  474. // recursively extract text from DOM tree
  475. extract_text: function (node) {
  476. if (!node)
  477. return "";
  478. // text nodes
  479. if (node.nodeType == 3)
  480. return node.nodeValue;
  481. // elements
  482. if (node.nodeType == 1)
  483. {
  484. node = node.firstChild;
  485. var text = "";
  486. while (node)
  487. {
  488. text = text + this.extract_text(node);
  489. node = node.nextSibling;
  490. }
  491. return text;
  492. }
  493. return "";
  494. },
  495. // find copyright text from meta element
  496. find_copyright: function () {
  497. var name, content;
  498. var meta = document.getElementsByTagName("meta");
  499. for (var i = 0; i < meta.length; ++i)
  500. {
  501. name = meta[i].getAttribute("name");
  502. content = meta[i].getAttribute("content");
  503. if (name == "copyright")
  504. return content;
  505. }
  506. return null;
  507. },
  508. find_size_adjust: function () {
  509. var name, content, offset;
  510. var meta = document.getElementsByTagName("meta");
  511. for (var i = 0; i < meta.length; ++i)
  512. {
  513. name = meta[i].getAttribute("name");
  514. content = meta[i].getAttribute("content");
  515. if (name == "font-size-adjustment")
  516. return 1 * content;
  517. }
  518. return 1;
  519. },
  520. // <meta name="duration" content="20" /> for 20 minutes
  521. find_duration: function () {
  522. var name, content, offset;
  523. var meta = document.getElementsByTagName("meta");
  524. for (var i = 0; i < meta.length; ++i)
  525. {
  526. name = meta[i].getAttribute("name");
  527. content = meta[i].getAttribute("content");
  528. if (name == "duration")
  529. return 60000 * content;
  530. }
  531. return null;
  532. },
  533. replace_by_non_breaking_space: function (str) {
  534. for (var i = 0; i < str.length; ++i)
  535. str[i] = 160;
  536. },
  537. // ### CHECK ME ### is use of "li" okay for text/html?
  538. // for XHTML do we also need to specify namespace?
  539. init_outliner: function () {
  540. var items = document.getElementsByTagName("li");
  541. for (var i = 0; i < items.length; ++i)
  542. {
  543. var target = items[i];
  544. if (!this.has_class(target.parentNode, "outline"))
  545. continue;
  546. target.onclick = this.outline_click;
  547. /* ### more work needed for IE6
  548. if (!this.ns_pos)
  549. {
  550. target.onmouseover = this.hover_outline;
  551. target.onmouseout = this.unhover_outline;
  552. }
  553. */
  554. if (this.foldable(target))
  555. {
  556. target.foldable = true;
  557. target.onfocus = function () {w3c_slidy.outline = this;};
  558. target.onblur = function () {w3c_slidy.outline = null;};
  559. if (!target.getAttribute("tabindex"))
  560. target.setAttribute("tabindex", "0");
  561. if (this.has_class(target, "expand"))
  562. this.unfold(target);
  563. else
  564. this.fold(target);
  565. }
  566. else
  567. {
  568. this.add_class(target, "nofold");
  569. target.visible = true;
  570. target.foldable = false;
  571. }
  572. }
  573. },
  574. foldable: function (item) {
  575. if (!item || item.nodeType != 1)
  576. return false;
  577. var node = item.firstChild;
  578. while (node)
  579. {
  580. if (node.nodeType == 1 && this.is_block(node))
  581. return true;
  582. node = node.nextSibling;
  583. }
  584. return false;
  585. },
  586. // ### CHECK ME ### switch to add/remove "hidden" class
  587. fold: function (item) {
  588. if (item)
  589. {
  590. this.remove_class(item, "unfolded");
  591. this.add_class(item, "folded");
  592. }
  593. var node = item ? item.firstChild : null;
  594. while (node)
  595. {
  596. if (node.nodeType == 1 && this.is_block(node)) // element
  597. {
  598. w3c_slidy.add_class(node, "hidden");
  599. }
  600. node = node.nextSibling;
  601. }
  602. item.visible = false;
  603. },
  604. // ### CHECK ME ### switch to add/remove "hidden" class
  605. unfold: function (item) {
  606. if (item)
  607. {
  608. this.add_class(item, "unfolded");
  609. this.remove_class(item, "folded");
  610. }
  611. var node = item ? item.firstChild : null;
  612. while (node)
  613. {
  614. if (node.nodeType == 1 && this.is_block(node)) // element
  615. {
  616. w3c_slidy.remove_class(node, "hidden");
  617. }
  618. node = node.nextSibling;
  619. }
  620. item.visible = true;
  621. },
  622. outline_click: function (e) {
  623. if (!e)
  624. e = window.event;
  625. var rightclick = false;
  626. var target = w3c_slidy.get_target(e);
  627. while (target && target.visible == undefined)
  628. target = target.parentNode;
  629. if (!target)
  630. return true;
  631. if (e.which)
  632. rightclick = (e.which == 3);
  633. else if (e.button)
  634. rightclick = (e.button == 2);
  635. if (!rightclick && target.visible != undefined)
  636. {
  637. if (target.foldable)
  638. {
  639. if (target.visible)
  640. w3c_slidy.fold(target);
  641. else
  642. w3c_slidy.unfold(target);
  643. }
  644. w3c_slidy.stop_propagation(e);
  645. e.cancel = true;
  646. e.returnValue = false;
  647. }
  648. return false;
  649. },
  650. add_initial_prompt: function () {
  651. var prompt = this.create_element("div");
  652. prompt.setAttribute("class", "initial_prompt");
  653. var p1 = this.create_element("p");
  654. prompt.appendChild(p1);
  655. p1.setAttribute("class", "help");
  656. if (this.keyboardless)
  657. p1.innerHTML = "swipe left to move to next slide";
  658. else
  659. p1.innerHTML = "Space, Right Arrow or swipe left to move to " +
  660. "next slide, click help below for more details";
  661. this.add_listener(prompt, "click", function (e) {
  662. document.body.removeChild(prompt);
  663. w3c_slidy.stop_propagation(e);
  664. if (e.cancel != undefined)
  665. e.cancel = true;
  666. if (e.returnValue != undefined)
  667. e.returnValue = false;
  668. return false;
  669. });
  670. document.body.appendChild(prompt);
  671. this.initial_prompt = prompt;
  672. setTimeout(function() {document.body.removeChild(prompt);}, 5000);
  673. },
  674. add_toolbar: function () {
  675. var counter, page;
  676. this.toolbar = this.create_element("div");
  677. this.toolbar.setAttribute("class", "toolbar");
  678. // a reasonably behaved browser
  679. if (this.ns_pos || !this.ie6)
  680. {
  681. var right = this.create_element("div");
  682. right.setAttribute("style", "float: right; text-align: right");
  683. counter = this.create_element("span")
  684. counter.innerHTML = this.localize("slide") + " n/m";
  685. right.appendChild(counter);
  686. this.toolbar.appendChild(right);
  687. var left = this.create_element("div");
  688. left.setAttribute("style", "text-align: left");
  689. // global end of slide indicator
  690. this.eos = this.create_element("span");
  691. this.eos.innerHTML = "* ";
  692. left.appendChild(this.eos);
  693. var help = this.create_element("a");
  694. help.setAttribute("href", this.help_page);
  695. help.setAttribute("title", this.localize(this.help_text));
  696. help.innerHTML = " [" + this.localize("help?") + "] ";
  697. left.appendChild(help);
  698. this.help_anchor = help; // save for focus hack
  699. var contents = this.create_element("a");
  700. contents.setAttribute("href", "javascript:w3c_slidy.toggle_table_of_contents()");
  701. contents.setAttribute("title", this.localize("table of contents"));
  702. contents.innerHTML = " [" + this.localize("contents?") + "] ";
  703. left.appendChild(contents);
  704. // modif Dehos
  705. var toc = this.create_element("a");
  706. toc.setAttribute("href", "#(2)");
  707. toc.innerHTML = " [" + "Table des matières" + "] "; //this.localize("help?");
  708. left.appendChild(toc);
  709. var previous_page = this.create_element("a");
  710. previous_page.setAttribute("href", "index.html");
  711. previous_page.innerHTML = " [" + "Page du module" + "] "; //this.localize("help?");
  712. left.appendChild(previous_page);
  713. var homepage = this.create_element("a");
  714. homepage.setAttribute("href", "https://www-lisic.univ-littoral.fr/~dehos/");
  715. homepage.innerHTML = " [" + "Page d'accueil" + "] "; //this.localize("help?");
  716. left.appendChild(homepage);
  717. var copyright = this.find_copyright();
  718. if (copyright)
  719. {
  720. var span = this.create_element("span");
  721. span.className = "copyright";
  722. span.innerHTML = copyright;
  723. left.appendChild(span);
  724. }
  725. this.toolbar.setAttribute("tabindex", "0");
  726. this.toolbar.appendChild(left);
  727. }
  728. else // IE6 so need to work around its poor CSS support
  729. {
  730. this.toolbar.style.position = (this.ie7 ? "fixed" : "absolute");
  731. this.toolbar.style.zIndex = "200";
  732. this.toolbar.style.width = "99.9%";
  733. this.toolbar.style.height = "1.2em";
  734. this.toolbar.style.top = "auto";
  735. this.toolbar.style.bottom = "0";
  736. this.toolbar.style.left = "0";
  737. this.toolbar.style.right = "0";
  738. this.toolbar.style.textAlign = "left";
  739. this.toolbar.style.fontSize = "60%";
  740. this.toolbar.style.color = "red";
  741. this.toolbar.borderWidth = 0;
  742. this.toolbar.className = "toolbar";
  743. this.toolbar.style.background = "rgb(240,240,240)";
  744. // would like to have help text left aligned
  745. // and page counter right aligned, floating
  746. // div's don't work, so instead use nested
  747. // absolutely positioned div's.
  748. var sp = this.create_element("span");
  749. sp.innerHTML = "&nbsp;&nbsp;*&nbsp;";
  750. this.toolbar.appendChild(sp);
  751. this.eos = sp; // end of slide indicator
  752. var help = this.create_element("a");
  753. help.setAttribute("href", this.help_page);
  754. help.setAttribute("title", this.localize(this.help_text));
  755. help.innerHTML = this.localize("help?");
  756. this.toolbar.appendChild(help);
  757. this.help_anchor = help; // save for focus hack
  758. var gap1 = document.createTextNode(" ");
  759. this.toolbar.appendChild(gap1);
  760. var contents = this.create_element("a");
  761. contents.setAttribute("href", "javascript:toggleTableOfContents()");
  762. contents.setAttribute("title", this.localize("table of contents".localize));
  763. contents.innerHTML = this.localize("contents?");
  764. this.toolbar.appendChild(contents);
  765. var gap2 = document.createTextNode(" ");
  766. this.toolbar.appendChild(gap2);
  767. // modif Dehos
  768. var toc = this.create_element("a");
  769. toc.setAttribute("href", "#(2)");
  770. toc.innerHTML = " [" + "Table des matières" + "] "; //this.localize("help?");
  771. left.appendChild(toc);
  772. var previous_page = this.create_element("a");
  773. previous_page.setAttribute("href", "index.html");
  774. previous_page.innerHTML = " [" + "Page du module" + "] "; //this.localize("help?");
  775. left.appendChild(previous_page);
  776. var homepage = this.create_element("a");
  777. homepage.setAttribute("href", "https://www-lisic.univ-littoral.fr/~dehos/");
  778. homepage.innerHTML = " [" + "Page d'accueil" + "] "; //this.localize("help?");
  779. left.appendChild(homepage);
  780. var copyright = this.find_copyright();
  781. if (copyright)
  782. {
  783. var span = this.create_element("span");
  784. span.innerHTML = copyright;
  785. span.style.color = "black";
  786. span.style.marginLeft = "0.5em";
  787. this.toolbar.appendChild(span);
  788. }
  789. counter = this.create_element("div")
  790. counter.style.position = "absolute";
  791. counter.style.width = "auto"; //"20%";
  792. counter.style.height = "1.2em";
  793. counter.style.top = "auto";
  794. counter.style.bottom = 0;
  795. counter.style.right = "0";
  796. counter.style.textAlign = "right";
  797. counter.style.color = "red";
  798. counter.style.background = "rgb(240,240,240)";
  799. counter.innerHTML = this.localize("slide") + " n/m";
  800. this.toolbar.appendChild(counter);
  801. }
  802. // ensure that click isn't passed through to the page
  803. this.toolbar.onclick =
  804. function (e) {
  805. if (!e)
  806. e = window.event;
  807. var target = e.target;
  808. if (!target && e.srcElement)
  809. target = e.srcElement;
  810. // work around Safari bug
  811. if (target && target.nodeType == 3)
  812. target = target.parentNode;
  813. w3c_slidy.stop_propagation(e);
  814. if (target && target.nodeName.toLowerCase() != "a")
  815. w3c_slidy.mouse_button_click(e);
  816. };
  817. this.slide_number_element = counter;
  818. this.set_eos_status(false);
  819. document.body.appendChild(this.toolbar);
  820. },
  821. // wysiwyg editors make it hard to use div elements
  822. // e.g. amaya loses the div when you copy and paste
  823. // this function wraps div elements around implicit
  824. // slides which start with an h1 element and continue
  825. // up to the next heading or div element
  826. wrap_implicit_slides: function () {
  827. var i, heading, node, next, div;
  828. var headings = document.getElementsByTagName("h1");
  829. if (!headings)
  830. return;
  831. for (i = 0; i < headings.length; ++i)
  832. {
  833. heading = headings[i];
  834. if (heading.parentNode != document.body)
  835. continue;
  836. node = heading.nextSibling;
  837. div = document.createElement("div");
  838. this.add_class(div, "slide");
  839. document.body.replaceChild(div, heading);
  840. div.appendChild(heading);
  841. while (node)
  842. {
  843. if (node.nodeType == 1) // an element
  844. {
  845. if (node.nodeName == "H1" || node.nodeName == "h1")
  846. break;
  847. if (node.nodeName == "DIV" || node.nodeName == "div")
  848. {
  849. if (this.has_class(node, "slide"))
  850. break;
  851. if (this.has_class(node, "handout"))
  852. break;
  853. }
  854. }
  855. next = node.nextSibling;
  856. node = document.body.removeChild(node);
  857. div.appendChild(node);
  858. node = next;
  859. }
  860. }
  861. },
  862. // return new array of all slides
  863. collect_slides: function () {
  864. var slides = new Array();
  865. var divs = document.body.getElementsByTagName("div");
  866. // modif Dehos
  867. var toctoc = document.getElementById("toctoc");
  868. var k=0;
  869. for (var i = 0; i < divs.length; ++i)
  870. {
  871. div = divs.item(i);
  872. if (this.has_class(div, "slide"))
  873. {
  874. // modif Dehos
  875. k++;
  876. if (this.has_class(div, "level1")) {
  877. var h1_nodes = div.getElementsByTagName("h1");
  878. if (h1_nodes.length > 0) {
  879. var h1_text = h1_nodes[0].innerHTML;
  880. var new_li = document.createElement("li");
  881. var a_id = "#(" + k + ")";
  882. new_li.innerHTML = "<a href='" + a_id + "'>" + h1_text + "</a>";
  883. toctoc.appendChild(new_li);
  884. }
  885. }
  886. // add slide to collection
  887. slides[slides.length] = div;
  888. // hide each slide as it is found
  889. this.add_class(div, "hidden");
  890. // add dummy <br/> at end for scrolling hack
  891. var node1 = document.createElement("br");
  892. div.appendChild(node1);
  893. var node2 = document.createElement("br");
  894. div.appendChild(node2);
  895. }
  896. else if (this.has_class(div, "background"))
  897. { // work around for Firefox SVG reload bug
  898. // which otherwise replaces 1st SVG graphic with 2nd
  899. div.style.display = "block";
  900. }
  901. }
  902. this.slides = slides;
  903. },
  904. // return new array of all <div class="handout">
  905. collect_notes: function () {
  906. var notes = new Array();
  907. var divs = document.body.getElementsByTagName("div");
  908. for (var i = 0; i < divs.length; ++i)
  909. {
  910. div = divs.item(i);
  911. if (this.has_class(div, "handout"))
  912. {
  913. // add note to collection
  914. notes[notes.length] = div;
  915. // and hide it
  916. this.add_class(div, "hidden");
  917. }
  918. }
  919. this.notes = notes;
  920. },
  921. // return new array of all <div class="background">
  922. // including named backgrounds e.g. class="background titlepage"
  923. collect_backgrounds: function () {
  924. var backgrounds = new Array();
  925. var divs = document.body.getElementsByTagName("div");
  926. for (var i = 0; i < divs.length; ++i)
  927. {
  928. div = divs.item(i);
  929. if (this.has_class(div, "background"))
  930. {
  931. // add background to collection
  932. backgrounds[backgrounds.length] = div;
  933. // and hide it
  934. this.add_class(div, "hidden");
  935. }
  936. }
  937. this.backgrounds = backgrounds;
  938. },
  939. // set click handlers on all anchors
  940. patch_anchors: function () {
  941. var self = w3c_slidy;
  942. var handler = function (event) {
  943. // compare this.href with location.href
  944. // for link to another slide in this doc
  945. if (self.page_address(this.href) == self.page_address(location.href))
  946. {
  947. // yes, so find new slide number
  948. var newslidenum = self.find_slide_number(this.href);
  949. if (newslidenum != self.slide_number)
  950. {
  951. var slide = self.slides[self.slide_number];
  952. self.hide_slide(slide);
  953. self.slide_number = newslidenum;
  954. slide = self.slides[self.slide_number];
  955. self.show_slide(slide);
  956. self.set_location();
  957. }
  958. }
  959. else
  960. w3c_slidy.stop_propagation(event);
  961. // else if (this.target == null)
  962. // location.href = this.href;
  963. this.blur();
  964. self.disable_slide_click = true;
  965. };
  966. var anchors = document.body.getElementsByTagName("a");
  967. for (var i = 0; i < anchors.length; ++i)
  968. {
  969. if (window.addEventListener)
  970. anchors[i].addEventListener("click", handler, false);
  971. else
  972. anchors[i].attachEvent("onclick", handler);
  973. }
  974. },
  975. // ### CHECK ME ### see which functions are invoked via setTimeout
  976. // either directly or indirectly for use of w3c_slidy vs this
  977. show_slide_number: function () {
  978. var timer = w3c_slidy.get_timer();
  979. w3c_slidy.slide_number_element.innerHTML = timer + w3c_slidy.localize("slide") + " " +
  980. (w3c_slidy.slide_number + 1) + "/" + w3c_slidy.slides.length;
  981. },
  982. // every 200mS check if the location has been changed as a
  983. // result of the user activating the Back button/menu item
  984. // doesn't work for Opera < 9.5
  985. check_location: function () {
  986. var hash = location.hash;
  987. if (w3c_slidy.slide_number > 0 && (hash == "" || hash == "#"))
  988. w3c_slidy.goto_slide(0);
  989. else if (hash.length > 2 && hash != "#("+(w3c_slidy.slide_number+1)+")")
  990. {
  991. var num = parseInt(location.hash.substr(2));
  992. if (!isNaN(num))
  993. w3c_slidy.goto_slide(num-1);
  994. }
  995. if (w3c_slidy.time_left && w3c_slidy.slide_number > 0)
  996. {
  997. w3c_slidy.show_slide_number();
  998. if (w3c_slidy.time_left > 0)
  999. w3c_slidy.time_left -= 200;
  1000. }
  1001. },
  1002. get_timer: function () {
  1003. var timer = "";
  1004. if (w3c_slidy.time_left)
  1005. {
  1006. var mins, secs;
  1007. secs = Math.floor(w3c_slidy.time_left/1000);
  1008. mins = Math.floor(secs / 60);
  1009. secs = secs % 60;
  1010. timer = (mins ? mins+"m" : "") + secs + "s ";
  1011. }
  1012. return timer;
  1013. },
  1014. // this doesn't push location onto history stack for IE
  1015. // for which a hidden iframe hack is needed: load page into
  1016. // the iframe with script that set's parent's location.hash
  1017. // but that won't work for standalone use unless we can
  1018. // create the page dynamically via a javascript: URL
  1019. // ### use history.pushState if available
  1020. set_location: function () {
  1021. var uri = w3c_slidy.page_address(location.href);
  1022. var hash = "#(" + (w3c_slidy.slide_number+1) + ")";
  1023. if (w3c_slidy.slide_number >= 0)
  1024. uri = uri + hash;
  1025. if (typeof(history.pushState) != "undefined")
  1026. {
  1027. document.title = w3c_slidy.title + " (" + (w3c_slidy.slide_number+1) + ")";
  1028. history.pushState(0, document.title, hash);
  1029. w3c_slidy.show_slide_number();
  1030. return;
  1031. }
  1032. if (w3c_slidy.ie && (w3c_slidy.ie6 || w3c_slidy.ie7))
  1033. w3c_slidy.push_hash(hash);
  1034. if (uri != location.href) // && !khtml
  1035. location.href = uri;
  1036. if (this.khtml)
  1037. hash = "(" + (w3c_slidy.slide_number+1) + ")";
  1038. if (!this.ie && location.hash != hash && location.hash != "")
  1039. location.hash = hash;
  1040. document.title = w3c_slidy.title + " (" + (w3c_slidy.slide_number+1) + ")";
  1041. w3c_slidy.show_slide_number();
  1042. },
  1043. page_address: function (uri) {
  1044. var i = uri.indexOf("#");
  1045. if (i < 0)
  1046. i = uri.indexOf("%23");
  1047. // check if anchor is entire page
  1048. if (i < 0)
  1049. return uri; // yes
  1050. return uri.substr(0, i);
  1051. },
  1052. // only used for IE6 and IE7
  1053. on_frame_loaded: function (hash) {
  1054. location.hash = hash;
  1055. var uri = w3c_slidy.page_address(location.href);
  1056. location.href = uri + hash;
  1057. },
  1058. // history hack with thanks to Bertrand Le Roy
  1059. push_hash: function (hash) {
  1060. if (hash == "") hash = "#(1)";
  1061. window.location.hash = hash;
  1062. var doc = document.getElementById("historyFrame").contentWindow.document;
  1063. doc.open("javascript:'<html></html>'");
  1064. doc.write("<html><head><script type=\"text/javascript\">window.parent.w3c_slidy.on_frame_loaded('"+
  1065. (hash) + "');</script></head><body>hello mum</body></html>");
  1066. doc.close();
  1067. },
  1068. // find current slide based upon location
  1069. // first find target anchor and then look
  1070. // for associated div element enclosing it
  1071. // finally map that to slide number
  1072. find_slide_number: function (uri) {
  1073. // first get anchor from page location
  1074. var i = uri.indexOf("#");
  1075. // check if anchor is entire page
  1076. if (i < 0)
  1077. return 0; // yes
  1078. var anchor = unescape(uri.substr(i+1));
  1079. // now use anchor as XML ID to find target
  1080. var target = document.getElementById(anchor);
  1081. if (!target)
  1082. {
  1083. // does anchor look like "(2)" for slide 2 ??
  1084. // where first slide is (1)
  1085. var re = /\((\d)+\)/;
  1086. if (anchor.match(re))
  1087. {
  1088. var num = parseInt(anchor.substring(1, anchor.length-1));
  1089. if (num > this.slides.length)
  1090. num = 1;
  1091. if (--num < 0)
  1092. num = 0;
  1093. return num;
  1094. }
  1095. // accept [2] for backwards compatibility
  1096. re = /\[(\d)+\]/;
  1097. if (anchor.match(re))
  1098. {
  1099. var num = parseInt(anchor.substring(1, anchor.length-1));
  1100. if (num > this.slides.length)
  1101. num = 1;
  1102. if (--num < 0)
  1103. num = 0;
  1104. return num;
  1105. }
  1106. // oh dear unknown anchor
  1107. return 0;
  1108. }
  1109. // search for enclosing slide
  1110. while (true)
  1111. {
  1112. // browser coerces html elements to uppercase!
  1113. if (target.nodeName.toLowerCase() == "div" &&
  1114. this.has_class(target, "slide"))
  1115. {
  1116. // found the slide element
  1117. break;
  1118. }
  1119. // otherwise try parent element if any
  1120. target = target.parentNode;
  1121. if (!target)
  1122. {
  1123. return 0; // no luck!
  1124. }
  1125. };
  1126. for (i = 0; i < slides.length; ++i)
  1127. {
  1128. if (slides[i] == target)
  1129. return i; // success
  1130. }
  1131. // oh dear still no luck
  1132. return 0;
  1133. },
  1134. previous_slide: function (incremental) {
  1135. if (!w3c_slidy.view_all)
  1136. {
  1137. var slide;
  1138. if ((incremental || w3c_slidy.slide_number == 0) && w3c_slidy.last_shown != null)
  1139. {
  1140. w3c_slidy.last_shown = w3c_slidy.hide_previous_item(w3c_slidy.last_shown);
  1141. w3c_slidy.set_eos_status(false);
  1142. }
  1143. else if (w3c_slidy.slide_number > 0)
  1144. {
  1145. slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1146. w3c_slidy.hide_slide(slide);
  1147. w3c_slidy.slide_number = w3c_slidy.slide_number - 1;
  1148. slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1149. w3c_slidy.set_visibility_all_incremental("visible");
  1150. w3c_slidy.last_shown = w3c_slidy.previous_incremental_item(null);
  1151. w3c_slidy.set_eos_status(true);
  1152. w3c_slidy.show_slide(slide);
  1153. }
  1154. w3c_slidy.set_location();
  1155. if (!w3c_slidy.ns_pos)
  1156. w3c_slidy.refresh_toolbar(200);
  1157. }
  1158. },
  1159. next_slide: function (incremental) {
  1160. if (!w3c_slidy.view_all)
  1161. {
  1162. var slide, last = w3c_slidy.last_shown;
  1163. if (incremental || w3c_slidy.slide_number == w3c_slidy.slides.length - 1)
  1164. w3c_slidy.last_shown = w3c_slidy.reveal_next_item(w3c_slidy.last_shown);
  1165. if ((!incremental || w3c_slidy.last_shown == null) &&
  1166. w3c_slidy.slide_number < w3c_slidy.slides.length - 1)
  1167. {
  1168. slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1169. w3c_slidy.hide_slide(slide);
  1170. w3c_slidy.slide_number = w3c_slidy.slide_number + 1;
  1171. slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1172. w3c_slidy.last_shown = null;
  1173. w3c_slidy.set_visibility_all_incremental("hidden");
  1174. w3c_slidy.show_slide(slide);
  1175. }
  1176. else if (!w3c_slidy.last_shown)
  1177. {
  1178. if (last && incremental)
  1179. w3c_slidy.last_shown = last;
  1180. }
  1181. w3c_slidy.set_location();
  1182. w3c_slidy.set_eos_status(!w3c_slidy.next_incremental_item(w3c_slidy.last_shown));
  1183. if (!w3c_slidy.ns_pos)
  1184. w3c_slidy.refresh_toolbar(200);
  1185. }
  1186. },
  1187. // to first slide with nothing revealed
  1188. // i.e. state at start of presentation
  1189. first_slide: function () {
  1190. if (!w3c_slidy.view_all)
  1191. {
  1192. var slide;
  1193. if (w3c_slidy.slide_number != 0)
  1194. {
  1195. slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1196. w3c_slidy.hide_slide(slide);
  1197. w3c_slidy.slide_number = 0;
  1198. slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1199. w3c_slidy.last_shown = null;
  1200. w3c_slidy.set_visibility_all_incremental("hidden");
  1201. w3c_slidy.show_slide(slide);
  1202. }
  1203. w3c_slidy.set_eos_status(
  1204. !w3c_slidy.next_incremental_item(w3c_slidy.last_shown));
  1205. w3c_slidy.set_location();
  1206. }
  1207. },
  1208. // goto last slide with everything revealed
  1209. // i.e. state at end of presentation
  1210. last_slide: function () {
  1211. if (!w3c_slidy.view_all)
  1212. {
  1213. var slide;
  1214. w3c_slidy.last_shown = null; //revealNextItem(lastShown);
  1215. if (w3c_slidy.last_shown == null &&
  1216. w3c_slidy.slide_number < w3c_slidy.slides.length - 1)
  1217. {
  1218. slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1219. w3c_slidy.hide_slide(slide);
  1220. w3c_slidy.slide_number = w3c_slidy.slides.length - 1;
  1221. slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1222. w3c_slidy.set_visibility_all_incremental("visible");
  1223. w3c_slidy.last_shown = w3c_slidy.previous_incremental_item(null);
  1224. w3c_slidy.show_slide(slide);
  1225. }
  1226. else
  1227. {
  1228. w3c_slidy.set_visibility_all_incremental("visible");
  1229. w3c_slidy.last_shown = w3c_slidy.previous_incremental_item(null);
  1230. }
  1231. w3c_slidy.set_eos_status(true);
  1232. w3c_slidy.set_location();
  1233. }
  1234. },
  1235. // ### check this and consider add/remove class
  1236. set_eos_status: function (state) {
  1237. if (this.eos)
  1238. this.eos.style.color = (state ? "rgb(240,240,240)" : "red");
  1239. },
  1240. // first slide is 0
  1241. goto_slide: function (num) {
  1242. //alert("going to slide " + (num+1));
  1243. var slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1244. w3c_slidy.hide_slide(slide);
  1245. w3c_slidy.slide_number = num;
  1246. slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1247. w3c_slidy.last_shown = null;
  1248. w3c_slidy.set_visibility_all_incremental("hidden");
  1249. w3c_slidy.set_eos_status(!w3c_slidy.next_incremental_item(w3c_slidy.last_shown));
  1250. document.title = w3c_slidy.title + " (" + (w3c_slidy.slide_number+1) + ")";
  1251. w3c_slidy.show_slide(slide);
  1252. w3c_slidy.show_slide_number();
  1253. },
  1254. show_slide: function (slide) {
  1255. this.sync_background(slide);
  1256. window.scrollTo(0,0);
  1257. this.remove_class(slide, "hidden");
  1258. },
  1259. hide_slide: function (slide) {
  1260. this.add_class(slide, "hidden");
  1261. },
  1262. // show just the backgrounds pertinent to this slide
  1263. // when slide background-color is transparent
  1264. // this should now work with rgba color values
  1265. sync_background: function (slide) {
  1266. var background;
  1267. var bgColor;
  1268. if (slide.currentStyle)
  1269. bgColor = slide.currentStyle["backgroundColor"];
  1270. else if (document.defaultView)
  1271. {
  1272. var styles = document.defaultView.getComputedStyle(slide,null);
  1273. if (styles)
  1274. bgColor = styles.getPropertyValue("background-color");
  1275. else // broken implementation probably due Safari or Konqueror
  1276. {
  1277. //alert("defective implementation of getComputedStyle()");
  1278. bgColor = "transparent";
  1279. }
  1280. }
  1281. else
  1282. bgColor == "transparent";
  1283. if (bgColor == "transparent" ||
  1284. bgColor.indexOf("rgba") >= 0 ||
  1285. bgColor.indexOf("opacity") >= 0)
  1286. {
  1287. var slideClass = this.get_class_list(slide);
  1288. for (var i = 0; i < this.backgrounds.length; i++)
  1289. {
  1290. background = this.backgrounds[i];
  1291. var bgClass = this.get_class_list(background);
  1292. if (this.matching_background(slideClass, bgClass))
  1293. this.remove_class(background, "hidden");
  1294. else
  1295. this.add_class(background, "hidden");
  1296. }
  1297. }
  1298. else // forcibly hide all backgrounds
  1299. this.hide_backgrounds();
  1300. },
  1301. hide_backgrounds: function () {
  1302. for (var i = 0; i < this.backgrounds.length; i++)
  1303. {
  1304. background = this.backgrounds[i];
  1305. this.add_class(background, "hidden");
  1306. }
  1307. },
  1308. // compare classes for slide and background
  1309. matching_background: function (slideClass, bgClass) {
  1310. var i, count, pattern, result;
  1311. // define pattern as regular expression
  1312. pattern = /\w+/g;
  1313. // check background class names
  1314. result = bgClass.match(pattern);
  1315. for (i = count = 0; i < result.length; i++)
  1316. {
  1317. if (result[i] == "hidden")
  1318. continue;
  1319. if (result[i] == "background")
  1320. continue;
  1321. ++count;
  1322. }
  1323. if (count == 0) // default match
  1324. return true;
  1325. // check for matches and place result in array
  1326. result = slideClass.match(pattern);
  1327. // now check if desired name is present for background
  1328. for (i = count = 0; i < result.length; i++)
  1329. {
  1330. if (result[i] == "hidden")
  1331. continue;
  1332. if (this.has_token(bgClass, result[i]))
  1333. return true;
  1334. }
  1335. return false;
  1336. },
  1337. resized: function () {
  1338. var width = 0;
  1339. if ( typeof( window.innerWidth ) == 'number' )
  1340. width = window.innerWidth; // Non IE browser
  1341. else if (document.documentElement && document.documentElement.clientWidth)
  1342. width = document.documentElement.clientWidth; // IE6
  1343. else if (document.body && document.body.clientWidth)
  1344. width = document.body.clientWidth; // IE4
  1345. var height = 0;
  1346. if ( typeof( window.innerHeight ) == 'number' )
  1347. height = window.innerHeight; // Non IE browser
  1348. else if (document.documentElement && document.documentElement.clientHeight)
  1349. height = document.documentElement.clientHeight; // IE6
  1350. else if (document.body && document.body.clientHeight)
  1351. height = document.body.clientHeight; // IE4
  1352. if (height && (width/height > 1.05*1024/768))
  1353. {
  1354. width = height * 1024.0/768;
  1355. }
  1356. // IE fires onresize even when only font size is changed!
  1357. // so we do a check to avoid blocking < and > actions
  1358. if (width != w3c_slidy.last_width || height != w3c_slidy.last_height)
  1359. {
  1360. if (width >= 1100)
  1361. w3c_slidy.size_index = 5; // 4
  1362. else if (width >= 1000)
  1363. w3c_slidy.size_index = 4; // 3
  1364. else if (width >= 800)
  1365. w3c_slidy.size_index = 3; // 2
  1366. else if (width >= 600)
  1367. w3c_slidy.size_index = 2; // 1
  1368. else if (width)
  1369. w3c_slidy.size_index = 0;
  1370. // add in font size adjustment from meta element e.g.
  1371. // <meta name="font-size-adjustment" content="-2" />
  1372. // useful when slides have too much content ;-)
  1373. if (0 <= w3c_slidy.size_index + w3c_slidy.size_adjustment &&
  1374. w3c_slidy.size_index + w3c_slidy.size_adjustment < w3c_slidy.sizes.length)
  1375. w3c_slidy.size_index = w3c_slidy.size_index + w3c_slidy.size_adjustment;
  1376. // enables cross browser use of relative width/height
  1377. // on object elements for use with SVG and Flash media
  1378. w3c_slidy.adjust_object_dimensions(width, height);
  1379. if (document.body.style.fontSize != w3c_slidy.sizes[w3c_slidy.size_index])
  1380. {
  1381. document.body.style.fontSize = w3c_slidy.sizes[w3c_slidy.size_index];
  1382. }
  1383. w3c_slidy.last_width = width;
  1384. w3c_slidy.last_height = height;
  1385. // force reflow to work around Mozilla bug
  1386. if (w3c_slidy.ns_pos)
  1387. {
  1388. var slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1389. w3c_slidy.hide_slide(slide);
  1390. w3c_slidy.show_slide(slide);
  1391. }
  1392. // force correct positioning of toolbar
  1393. w3c_slidy.refresh_toolbar(200);
  1394. }
  1395. },
  1396. scrolled: function () {
  1397. if (w3c_slidy.toolbar && !w3c_slidy.ns_pos && !w3c_slidy.ie7)
  1398. {
  1399. w3c_slidy.hack_offset = w3c_slidy.scroll_x_offset();
  1400. // hide toolbar
  1401. w3c_slidy.toolbar.style.display = "none";
  1402. // make it reappear later
  1403. if (w3c_slidy.scrollhack == 0 && !w3c_slidy.view_all)
  1404. {
  1405. setTimeout(function () {w3c_slidy.show_toolbar(); }, 1000);
  1406. w3c_slidy.scrollhack = 1;
  1407. }
  1408. }
  1409. },
  1410. hide_toolbar: function () {
  1411. w3c_slidy.add_class(w3c_slidy.toolbar, "hidden");
  1412. window.focus();
  1413. },
  1414. // used to ensure IE refreshes toolbar in correct position
  1415. refresh_toolbar: function (interval) {
  1416. if (!w3c_slidy.ns_pos && !w3c_slidy.ie7)
  1417. {
  1418. w3c_slidy.hide_toolbar();
  1419. setTimeout(function () {w3c_slidy.show_toolbar(); }, interval);
  1420. }
  1421. },
  1422. // restores toolbar after short delay
  1423. show_toolbar: function () {
  1424. if (w3c_slidy.want_toolbar)
  1425. {
  1426. w3c_slidy.toolbar.style.display = "block";
  1427. if (!w3c_slidy.ns_pos)
  1428. {
  1429. // adjust position to allow for scrolling
  1430. var xoffset = w3c_slidy.scroll_x_offset();
  1431. w3c_slidy.toolbar.style.left = xoffset;
  1432. w3c_slidy.toolbar.style.right = xoffset;
  1433. // determine vertical scroll offset
  1434. //var yoffset = scrollYOffset();
  1435. // bottom is doc height - window height - scroll offset
  1436. //var bottom = documentHeight() - lastHeight - yoffset
  1437. //if (yoffset > 0 || documentHeight() > lastHeight)
  1438. // bottom += 16; // allow for height of scrollbar
  1439. w3c_slidy.toolbar.style.bottom = 0; //bottom;
  1440. }
  1441. w3c_slidy.remove_class(w3c_slidy.toolbar, "hidden");
  1442. }
  1443. w3c_slidy.scrollhack = 0;
  1444. // set the keyboard focus to the help link on the
  1445. // toolbar to ensure that document has the focus
  1446. // IE doesn't always work with window.focus()
  1447. // and this hack has benefit of Enter for help
  1448. try
  1449. {
  1450. if (!w3c_slidy.opera)
  1451. w3c_slidy.help_anchor.focus();
  1452. }
  1453. catch (e)
  1454. {
  1455. }
  1456. },
  1457. // invoked via F key
  1458. toggle_toolbar: function () {
  1459. if (!w3c_slidy.view_all)
  1460. {
  1461. if (w3c_slidy.has_class(w3c_slidy.toolbar, "hidden"))
  1462. {
  1463. w3c_slidy.remove_class(w3c_slidy.toolbar, "hidden")
  1464. w3c_slidy.want_toolbar = 1;
  1465. }
  1466. else
  1467. {
  1468. w3c_slidy.add_class(w3c_slidy.toolbar, "hidden")
  1469. w3c_slidy.want_toolbar = 0;
  1470. }
  1471. }
  1472. },
  1473. scroll_x_offset: function () {
  1474. if (window.pageXOffset)
  1475. return self.pageXOffset;
  1476. if (document.documentElement &&
  1477. document.documentElement.scrollLeft)
  1478. return document.documentElement.scrollLeft;
  1479. if (document.body)
  1480. return document.body.scrollLeft;
  1481. return 0;
  1482. },
  1483. scroll_y_offset: function () {
  1484. if (window.pageYOffset)
  1485. return self.pageYOffset;
  1486. if (document.documentElement &&
  1487. document.documentElement.scrollTop)
  1488. return document.documentElement.scrollTop;
  1489. if (document.body)
  1490. return document.body.scrollTop;
  1491. return 0;
  1492. },
  1493. // looking for a way to determine height of slide content
  1494. // the slide itself is set to the height of the window
  1495. optimize_font_size: function () {
  1496. var slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1497. //var dh = documentHeight(); //getDocHeight(document);
  1498. var dh = slide.scrollHeight;
  1499. var wh = getWindowHeight();
  1500. var u = 100 * dh / wh;
  1501. alert("window utilization = " + u + "% (doc "
  1502. + dh + " win " + wh + ")");
  1503. },
  1504. // from document object
  1505. get_doc_height: function (doc) {
  1506. if (!doc)
  1507. doc = document;
  1508. if (doc && doc.body && doc.body.offsetHeight)
  1509. return doc.body.offsetHeight; // ns/gecko syntax
  1510. if (doc && doc.body && doc.body.scrollHeight)
  1511. return doc.body.scrollHeight;
  1512. alert("couldn't determine document height");
  1513. },
  1514. get_window_height: function () {
  1515. if ( typeof( window.innerHeight ) == 'number' )
  1516. return window.innerHeight; // Non IE browser
  1517. if (document.documentElement && document.documentElement.clientHeight)
  1518. return document.documentElement.clientHeight; // IE6
  1519. if (document.body && document.body.clientHeight)
  1520. return document.body.clientHeight; // IE4
  1521. },
  1522. document_height: function () {
  1523. var sh, oh;
  1524. sh = document.body.scrollHeight;
  1525. oh = document.body.offsetHeight;
  1526. if (sh && oh)
  1527. {
  1528. return (sh > oh ? sh : oh);
  1529. }
  1530. // no idea!
  1531. return 0;
  1532. },
  1533. smaller: function () {
  1534. if (w3c_slidy.size_index > 0)
  1535. {
  1536. --w3c_slidy.size_index;
  1537. }
  1538. w3c_slidy.toolbar.style.display = "none";
  1539. document.body.style.fontSize = w3c_slidy.sizes[w3c_slidy.size_index];
  1540. var slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1541. w3c_slidy.hide_slide(slide);
  1542. w3c_slidy.show_slide(slide);
  1543. setTimeout(function () {w3c_slidy.show_toolbar(); }, 50);
  1544. },
  1545. bigger: function () {
  1546. if (w3c_slidy.size_index < w3c_slidy.sizes.length - 1)
  1547. {
  1548. ++w3c_slidy.size_index;
  1549. }
  1550. w3c_slidy.toolbar.style.display = "none";
  1551. document.body.style.fontSize = w3c_slidy.sizes[w3c_slidy.size_index];
  1552. var slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1553. w3c_slidy.hide_slide(slide);
  1554. w3c_slidy.show_slide(slide);
  1555. setTimeout(function () {w3c_slidy.show_toolbar(); }, 50);
  1556. },
  1557. // enables cross browser use of relative width/height
  1558. // on object elements for use with SVG and Flash media
  1559. // with thanks to Ivan Herman for the suggestion
  1560. adjust_object_dimensions: function (width, height) {
  1561. for( var i = 0; i < w3c_slidy.objects.length; i++ )
  1562. {
  1563. var obj = this.objects[i];
  1564. var mimeType = obj.getAttribute("type");
  1565. if (mimeType == "image/svg+xml" || mimeType == "application/x-shockwave-flash")
  1566. {
  1567. if ( !obj.initialWidth )
  1568. obj.initialWidth = obj.getAttribute("width");
  1569. if ( !obj.initialHeight )
  1570. obj.initialHeight = obj.getAttribute("height");
  1571. if ( obj.initialWidth && obj.initialWidth.charAt(obj.initialWidth.length-1) == "%" )
  1572. {
  1573. var w = parseInt(obj.initialWidth.slice(0, obj.initialWidth.length-1));
  1574. var newW = width * (w/100.0);
  1575. obj.setAttribute("width",newW);
  1576. }
  1577. if ( obj.initialHeight &&
  1578. obj.initialHeight.charAt(obj.initialHeight.length-1) == "%" )
  1579. {
  1580. var h = parseInt(obj.initialHeight.slice(0, obj.initialHeight.length-1));
  1581. var newH = height * (h/100.0);
  1582. obj.setAttribute("height", newH);
  1583. }
  1584. }
  1585. }
  1586. },
  1587. // needed for Opera to inhibit default behavior
  1588. // since Opera delivers keyPress even if keyDown
  1589. // was cancelled
  1590. key_press: function (event) {
  1591. if (!event)
  1592. event = window.event;
  1593. if (!w3c_slidy.key_wanted)
  1594. return w3c_slidy.cancel(event);
  1595. return true;
  1596. },
  1597. // See e.g. http://www.quirksmode.org/js/events/keys.html for keycodes
  1598. key_down: function (event) {
  1599. var key, target, tag;
  1600. w3c_slidy.key_wanted = true;
  1601. if (!event)
  1602. event = window.event;
  1603. // kludge around NS/IE differences
  1604. if (window.event)
  1605. {
  1606. key = window.event.keyCode;
  1607. target = window.event.srcElement;
  1608. }
  1609. else if (event.which)
  1610. {
  1611. key = event.which;
  1612. target = event.target;
  1613. }
  1614. else
  1615. return true; // Yikes! unknown browser
  1616. // ignore event if key value is zero
  1617. // as for alt on Opera and Konqueror
  1618. if (!key)
  1619. return true;
  1620. // avoid interfering with keystroke
  1621. // behavior for non-slidy chrome elements
  1622. if (!w3c_slidy.slidy_chrome(target) &&
  1623. w3c_slidy.special_element(target))
  1624. return true;
  1625. // check for concurrent control/command/alt key
  1626. // but are these only present on mouse events?
  1627. if (event.ctrlKey || event.altKey || event.metaKey)
  1628. return true;
  1629. // dismiss table of contents if visible
  1630. if (w3c_slidy.is_shown_toc() && key != 9 && key != 16 && key != 38 && key != 40)
  1631. {
  1632. w3c_slidy.hide_table_of_contents(true);
  1633. if (key == 27 || key == 84 || key == 67)
  1634. return w3c_slidy.cancel(event);
  1635. }
  1636. if (key == 34) // Page Down
  1637. {
  1638. if (w3c_slidy.view_all)
  1639. return true;
  1640. w3c_slidy.next_slide(false);
  1641. return w3c_slidy.cancel(event);
  1642. }
  1643. else if (key == 33) // Page Up
  1644. {
  1645. if (w3c_slidy.view_all)
  1646. return true;
  1647. w3c_slidy.previous_slide(false);
  1648. return w3c_slidy.cancel(event);
  1649. }
  1650. else if (key == 32) // space bar
  1651. {
  1652. w3c_slidy.next_slide(true);
  1653. return w3c_slidy.cancel(event);
  1654. }
  1655. else if (key == 37) // Left arrow
  1656. {
  1657. w3c_slidy.previous_slide(!event.shiftKey);
  1658. return w3c_slidy.cancel(event);
  1659. }
  1660. else if (key == 36) // Home
  1661. {
  1662. w3c_slidy.first_slide();
  1663. return w3c_slidy.cancel(event);
  1664. }
  1665. else if (key == 35) // End
  1666. {
  1667. w3c_slidy.last_slide();
  1668. return w3c_slidy.cancel(event);
  1669. }
  1670. else if (key == 39) // Right arrow
  1671. {
  1672. w3c_slidy.next_slide(!event.shiftKey);
  1673. return w3c_slidy.cancel(event);
  1674. }
  1675. else if (key == 13) // Enter
  1676. {
  1677. if (w3c_slidy.outline)
  1678. {
  1679. if (w3c_slidy.outline.visible)
  1680. w3c_slidy.fold(w3c_slidy.outline);
  1681. else
  1682. w3c_slidy.unfold(w3c_slidy.outline);
  1683. return w3c_slidy.cancel(event);
  1684. }
  1685. }
  1686. else if (key == 188) // < for smaller fonts
  1687. {
  1688. w3c_slidy.smaller();
  1689. return w3c_slidy.cancel(event);
  1690. }
  1691. else if (key == 190) // > for larger fonts
  1692. {
  1693. w3c_slidy.bigger();
  1694. return w3c_slidy.cancel(event);
  1695. }
  1696. else if (key == 189 || key == 109) // - for smaller fonts
  1697. {
  1698. w3c_slidy.smaller();
  1699. return w3c_slidy.cancel(event);
  1700. }
  1701. else if (key == 187 || key == 191 || key == 107) // = + for larger fonts
  1702. {
  1703. w3c_slidy.bigger();
  1704. return w3c_slidy.cancel(event);
  1705. }
  1706. else if (key == 83) // S for smaller fonts
  1707. {
  1708. w3c_slidy.smaller();
  1709. return w3c_slidy.cancel(event);
  1710. }
  1711. else if (key == 66) // B for larger fonts
  1712. {
  1713. w3c_slidy.bigger();
  1714. return w3c_slidy.cancel(event);
  1715. }
  1716. else if (key == 90) // Z for last slide
  1717. {
  1718. w3c_slidy.last_slide();
  1719. return w3c_slidy.cancel(event);
  1720. }
  1721. else if (key == 70) // F for toggle toolbar
  1722. {
  1723. w3c_slidy.toggle_toolbar();
  1724. return w3c_slidy.cancel(event);
  1725. }
  1726. else if (key == 65) // A for toggle view single/all slides
  1727. {
  1728. w3c_slidy.toggle_view();
  1729. return w3c_slidy.cancel(event);
  1730. }
  1731. else if (key == 75) // toggle action of left click for next page
  1732. {
  1733. w3c_slidy.mouse_click_enabled = !w3c_slidy.mouse_click_enabled;
  1734. var alert_msg = (w3c_slidy.mouse_click_enabled ?
  1735. "enabled" : "disabled") + " mouse click advance";
  1736. alert(w3c_slidy.localize(alert_msg));
  1737. return w3c_slidy.cancel(event);
  1738. }
  1739. else if (key == 84 || key == 67) // T or C for table of contents
  1740. {
  1741. if (w3c_slidy.toc)
  1742. w3c_slidy.toggle_table_of_contents();
  1743. return w3c_slidy.cancel(event);
  1744. }
  1745. else if (key == 72) // H for help
  1746. {
  1747. window.location = w3c_slidy.help_page;
  1748. return w3c_slidy.cancel(event);
  1749. }
  1750. //else alert("key code is "+ key);
  1751. return true;
  1752. },
  1753. // safe for both text/html and application/xhtml+xml
  1754. create_element: function (name) {
  1755. if (this.xhtml && (typeof document.createElementNS != 'undefined'))
  1756. return document.createElementNS("http://www.w3.org/1999/xhtml", name)
  1757. return document.createElement(name);
  1758. },
  1759. get_element_style: function (elem, IEStyleProp, CSSStyleProp) {
  1760. if (elem.currentStyle)
  1761. {
  1762. return elem.currentStyle[IEStyleProp];
  1763. }
  1764. else if (window.getComputedStyle)
  1765. {
  1766. var compStyle = window.getComputedStyle(elem, "");
  1767. return compStyle.getPropertyValue(CSSStyleProp);
  1768. }
  1769. return "";
  1770. },
  1771. // the string str is a whitespace separated list of tokens
  1772. // test if str contains a particular token, e.g. "slide"
  1773. has_token: function (str, token) {
  1774. if (str)
  1775. {
  1776. // define pattern as regular expression
  1777. var pattern = /\w+/g;
  1778. // check for matches
  1779. // place result in array
  1780. var result = str.match(pattern);
  1781. // now check if desired token is present
  1782. for (var i = 0; i < result.length; i++)
  1783. {
  1784. if (result[i] == token)
  1785. return true;
  1786. }
  1787. }
  1788. return false;
  1789. },
  1790. get_class_list: function (element) {
  1791. if (typeof element.className != 'undefined')
  1792. return element.className;
  1793. return element.getAttribute("class");
  1794. },
  1795. has_class: function (element, name) {
  1796. if (element.nodeType != 1)
  1797. return false;
  1798. var regexp = new RegExp("(^| )" + name + "\W*");
  1799. if (typeof element.className != 'undefined')
  1800. return regexp.test(element.className);
  1801. return regexp.test(element.getAttribute("class"));
  1802. },
  1803. remove_class: function (element, name) {
  1804. var regexp = new RegExp("(^| )" + name + "\W*");
  1805. var clsval = "";
  1806. if (typeof element.className != 'undefined')
  1807. {
  1808. clsval = element.className;
  1809. if (clsval)
  1810. {
  1811. clsval = clsval.replace(regexp, "");
  1812. element.className = clsval;
  1813. }
  1814. }
  1815. else
  1816. {
  1817. clsval = element.getAttribute("class");
  1818. if (clsval)
  1819. {
  1820. clsval = clsval.replace(regexp, "");
  1821. element.setAttribute("class", clsval);
  1822. }
  1823. }
  1824. },
  1825. add_class: function (element, name) {
  1826. if (!this.has_class(element, name))
  1827. {
  1828. if (typeof element.className != 'undefined')
  1829. element.className += " " + name;
  1830. else
  1831. {
  1832. var clsval = element.getAttribute("class");
  1833. clsval = clsval ? clsval + " " + name : name;
  1834. element.setAttribute("class", clsval);
  1835. }
  1836. }
  1837. },
  1838. // HTML elements that can be used with class="incremental"
  1839. // note that you can also put the class on containers like
  1840. // up, ol, dl, and div to make their contents appear
  1841. // incrementally. Upper case is used since this is what
  1842. // browsers report for HTML node names (text/html).
  1843. incremental_elements: null,
  1844. okay_for_incremental: function (name) {
  1845. if (!this.incremental_elements)
  1846. {
  1847. var inclist = new Array();
  1848. inclist["p"] = true;
  1849. inclist["pre"] = true;
  1850. inclist["li"] = true;
  1851. inclist["blockquote"] = true;
  1852. inclist["dt"] = true;
  1853. inclist["dd"] = true;
  1854. inclist["h2"] = true;
  1855. inclist["h3"] = true;
  1856. inclist["h4"] = true;
  1857. inclist["h5"] = true;
  1858. inclist["h6"] = true;
  1859. inclist["span"] = true;
  1860. inclist["address"] = true;
  1861. inclist["table"] = true;
  1862. inclist["tr"] = true;
  1863. inclist["th"] = true;
  1864. inclist["td"] = true;
  1865. inclist["img"] = true;
  1866. inclist["object"] = true;
  1867. this.incremental_elements = inclist;
  1868. }
  1869. return this.incremental_elements[name.toLowerCase()];
  1870. },
  1871. next_incremental_item: function (node) {
  1872. var br = this.is_xhtml ? "br" : "BR";
  1873. var slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1874. for (;;)
  1875. {
  1876. node = w3c_slidy.next_node(slide, node);
  1877. if (node == null || node.parentNode == null)
  1878. break;
  1879. if (node.nodeType == 1) // ELEMENT
  1880. {
  1881. if (node.nodeName == br)
  1882. continue;
  1883. if (w3c_slidy.has_class(node, "incremental")
  1884. && w3c_slidy.okay_for_incremental(node.nodeName))
  1885. return node;
  1886. if (w3c_slidy.has_class(node.parentNode, "incremental")
  1887. && !w3c_slidy.has_class(node, "non-incremental"))
  1888. return node;
  1889. }
  1890. }
  1891. return node;
  1892. },
  1893. previous_incremental_item: function (node) {
  1894. var br = this.is_xhtml ? "br" : "BR";
  1895. var slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1896. for (;;)
  1897. {
  1898. node = w3c_slidy.previous_node(slide, node);
  1899. if (node == null || node.parentNode == null)
  1900. break;
  1901. if (node.nodeType == 1)
  1902. {
  1903. if (node.nodeName == br)
  1904. continue;
  1905. if (w3c_slidy.has_class(node, "incremental")
  1906. && w3c_slidy.okay_for_incremental(node.nodeName))
  1907. return node;
  1908. if (w3c_slidy.has_class(node.parentNode, "incremental")
  1909. && !w3c_slidy.has_class(node, "non-incremental"))
  1910. return node;
  1911. }
  1912. }
  1913. return node;
  1914. },
  1915. // set visibility for all elements on current slide with
  1916. // a parent element with attribute class="incremental"
  1917. set_visibility_all_incremental: function (value) {
  1918. var node = this.next_incremental_item(null);
  1919. if (value == "hidden")
  1920. {
  1921. while (node)
  1922. {
  1923. w3c_slidy.add_class(node, "invisible");
  1924. node = w3c_slidy.next_incremental_item(node);
  1925. }
  1926. }
  1927. else // value == "visible"
  1928. {
  1929. while (node)
  1930. {
  1931. w3c_slidy.remove_class(node, "invisible");
  1932. node = w3c_slidy.next_incremental_item(node);
  1933. }
  1934. }
  1935. },
  1936. // reveal the next hidden item on the slide
  1937. // node is null or the node that was last revealed
  1938. reveal_next_item: function (node) {
  1939. node = w3c_slidy.next_incremental_item(node);
  1940. if (node && node.nodeType == 1) // an element
  1941. w3c_slidy.remove_class(node, "invisible");
  1942. return node;
  1943. },
  1944. // exact inverse of revealNextItem(node)
  1945. hide_previous_item: function (node) {
  1946. if (node && node.nodeType == 1) // an element
  1947. w3c_slidy.add_class(node, "invisible");
  1948. return this.previous_incremental_item(node);
  1949. },
  1950. // left to right traversal of root's content
  1951. next_node: function (root, node) {
  1952. if (node == null)
  1953. return root.firstChild;
  1954. if (node.firstChild)
  1955. return node.firstChild;
  1956. if (node.nextSibling)
  1957. return node.nextSibling;
  1958. for (;;)
  1959. {
  1960. node = node.parentNode;
  1961. if (!node || node == root)
  1962. break;
  1963. if (node && node.nextSibling)
  1964. return node.nextSibling;
  1965. }
  1966. return null;
  1967. },
  1968. // right to left traversal of root's content
  1969. previous_node: function (root, node) {
  1970. if (node == null)
  1971. {
  1972. node = root.lastChild;
  1973. if (node)
  1974. {
  1975. while (node.lastChild)
  1976. node = node.lastChild;
  1977. }
  1978. return node;
  1979. }
  1980. if (node.previousSibling)
  1981. {
  1982. node = node.previousSibling;
  1983. while (node.lastChild)
  1984. node = node.lastChild;
  1985. return node;
  1986. }
  1987. if (node.parentNode != root)
  1988. return node.parentNode;
  1989. return null;
  1990. },
  1991. previous_sibling_element: function (el) {
  1992. el = el.previousSibling;
  1993. while (el && el.nodeType != 1)
  1994. el = el.previousSibling;
  1995. return el;
  1996. },
  1997. next_sibling_element: function (el) {
  1998. el = el.nextSibling;
  1999. while (el && el.nodeType != 1)
  2000. el = el.nextSibling;
  2001. return el;
  2002. },
  2003. first_child_element: function (el) {
  2004. var node;
  2005. for (node = el.firstChild; node; node = node.nextSibling)
  2006. {
  2007. if (node.nodeType == 1)
  2008. break;
  2009. }
  2010. return node;
  2011. },
  2012. first_tag: function (element, tag) {
  2013. var node;
  2014. if (!this.is_xhtml)
  2015. tag = tag.toUpperCase();
  2016. for (node = element.firstChild; node; node = node.nextSibling)
  2017. {
  2018. if (node.nodeType == 1 && node.nodeName == tag)
  2019. break;
  2020. }
  2021. return node;
  2022. },
  2023. hide_selection: function () {
  2024. if (window.getSelection) // Firefox, Chromium, Safari, Opera
  2025. {
  2026. var selection = window.getSelection();
  2027. if (selection.rangeCount > 0)
  2028. {
  2029. var range = selection.getRangeAt(0);
  2030. range.collapse (false);
  2031. }
  2032. }
  2033. else // Internet Explorer
  2034. {
  2035. var textRange = document.selection.createRange ();
  2036. textRange.collapse (false);
  2037. }
  2038. },
  2039. get_selected_text: function () {
  2040. try
  2041. {
  2042. if (window.getSelection)
  2043. return window.getSelection().toString();
  2044. if (document.getSelection)
  2045. return document.getSelection().toString();
  2046. if (document.selection)
  2047. return document.selection.createRange().text;
  2048. }
  2049. catch (e)
  2050. {
  2051. }
  2052. return "";
  2053. },
  2054. // make note of length of selected text
  2055. // as this evaluates to zero in click event
  2056. mouse_button_up: function (e) {
  2057. w3c_slidy.selected_text_len = w3c_slidy.get_selected_text().length;
  2058. },
  2059. // right mouse button click is reserved for context menus
  2060. // it is more reliable to detect rightclick than leftclick
  2061. mouse_button_click: function (e) {
  2062. var rightclick = false;
  2063. var leftclick = false;
  2064. var middleclick = false;
  2065. var target;
  2066. if (!e)
  2067. var e = window.event;
  2068. if (e.target)
  2069. target = e.target;
  2070. else if (e.srcElement)
  2071. target = e.srcElement;
  2072. // work around Safari bug
  2073. if (target.nodeType == 3)
  2074. target = target.parentNode;
  2075. if (e.which) // all browsers except IE
  2076. {
  2077. leftclick = (e.which == 1);
  2078. middleclick = (e.which == 2);
  2079. rightclick = (e.which == 3);
  2080. }
  2081. else if (e.button)
  2082. {
  2083. // Konqueror gives 1 for left, 4 for middle
  2084. // IE6 gives 0 for left and not 1 as I expected
  2085. if (e.button == 4)
  2086. middleclick = true;
  2087. // all browsers agree on 2 for right button
  2088. rightclick = (e.button == 2);
  2089. }
  2090. else
  2091. leftclick = true;
  2092. if (w3c_slidy.selected_text_len > 0)
  2093. {
  2094. w3c_slidy.stop_propagation(e);
  2095. e.cancel = true;
  2096. e.returnValue = false;
  2097. return false;
  2098. }
  2099. // dismiss table of contents
  2100. w3c_slidy.hide_table_of_contents(false);
  2101. // check if target is something that probably want's clicks
  2102. // e.g. a, embed, object, input, textarea, select, option
  2103. var tag = target.nodeName.toLowerCase();
  2104. if (w3c_slidy.mouse_click_enabled && leftclick &&
  2105. !w3c_slidy.special_element(target) &&
  2106. !target.onclick)
  2107. {
  2108. w3c_slidy.next_slide(true);
  2109. w3c_slidy.stop_propagation(e);
  2110. e.cancel = true;
  2111. e.returnValue = false;
  2112. return false;
  2113. }
  2114. return true;
  2115. },
  2116. special_element: function (element) {
  2117. if (this.has_class(element, "non-interactive"))
  2118. return false;
  2119. var tag = element.nodeName.toLowerCase();
  2120. return element.onkeydown ||
  2121. element.onclick ||
  2122. tag == "a" ||
  2123. tag == "embed" ||
  2124. tag == "object" ||
  2125. tag == "video" ||
  2126. tag == "audio" ||
  2127. tag == "svg" ||
  2128. tag == "canvas" ||
  2129. tag == "input" ||
  2130. tag == "textarea" ||
  2131. tag == "select" ||
  2132. tag == "option";
  2133. },
  2134. slidy_chrome: function (el) {
  2135. while (el)
  2136. {
  2137. if (el == w3c_slidy.toc ||
  2138. el == w3c_slidy.toolbar ||
  2139. w3c_slidy.has_class(el, "outline"))
  2140. return true;
  2141. el = el.parentNode;
  2142. }
  2143. return false;
  2144. },
  2145. get_key: function (e)
  2146. {
  2147. var key;
  2148. // kludge around NS/IE differences
  2149. if (typeof window.event != "undefined")
  2150. key = window.event.keyCode;
  2151. else if (e.which)
  2152. key = e.which;
  2153. return key;
  2154. },
  2155. get_target: function (e) {
  2156. var target;
  2157. if (!e)
  2158. e = window.event;
  2159. if (e.target)
  2160. target = e.target;
  2161. else if (e.srcElement)
  2162. target = e.srcElement;
  2163. if (target.nodeType != 1)
  2164. target = target.parentNode;
  2165. return target;
  2166. },
  2167. // does display property provide correct defaults?
  2168. is_block: function (elem) {
  2169. var tag = elem.nodeName.toLowerCase();
  2170. return tag == "ol" || tag == "ul" || tag == "p" ||
  2171. tag == "li" || tag == "table" || tag == "pre" ||
  2172. tag == "h1" || tag == "h2" || tag == "h3" ||
  2173. tag == "h4" || tag == "h5" || tag == "h6" ||
  2174. tag == "blockquote" || tag == "address";
  2175. },
  2176. add_listener: function (element, event, handler) {
  2177. if (window.addEventListener)
  2178. element.addEventListener(event, handler, false);
  2179. else
  2180. element.attachEvent("on"+event, handler);
  2181. },
  2182. // used to prevent event propagation from field controls
  2183. stop_propagation: function (event) {
  2184. event = event ? event : window.event;
  2185. event.cancelBubble = true; // for IE
  2186. if (event.stopPropagation)
  2187. event.stopPropagation();
  2188. return true;
  2189. },
  2190. cancel: function (event) {
  2191. if (event)
  2192. {
  2193. event.cancel = true;
  2194. event.returnValue = false;
  2195. if (event.preventDefault)
  2196. event.preventDefault();
  2197. }
  2198. w3c_slidy.key_wanted = false;
  2199. return false;
  2200. },
  2201. // for each language define an associative array
  2202. // and also the help text which is longer
  2203. strings_es: {
  2204. "slide":"pág.",
  2205. "help?":"Ayuda",
  2206. "contents?":"Índice",
  2207. "table of contents":"tabla de contenidos",
  2208. "Table of Contents":"Tabla de Contenidos",
  2209. "restart presentation":"Reiniciar presentación",
  2210. "restart?":"Inicio"
  2211. },
  2212. help_es:
  2213. "Utilice el ratón, barra espaciadora, teclas Izda/Dcha, " +
  2214. "o Re pág y Av pág. Use S y B para cambiar el tamaño de fuente.",
  2215. strings_ca: {
  2216. "slide":"pàg..",
  2217. "help?":"Ajuda",
  2218. "contents?":"Índex",
  2219. "table of contents":"taula de continguts",
  2220. "Table of Contents":"Taula de Continguts",
  2221. "restart presentation":"Reiniciar presentació",
  2222. "restart?":"Inici"
  2223. },
  2224. help_ca:
  2225. "Utilitzi el ratolí, barra espaiadora, tecles Esq./Dta. " +
  2226. "o Re pàg y Av pàg. Usi S i B per canviar grandària de font.",
  2227. strings_cs: {
  2228. "slide":"snímek",
  2229. "help?":"nápověda",
  2230. "contents?":"obsah",
  2231. "table of contents":"obsah prezentace",
  2232. "Table of Contents":"Obsah prezentace",
  2233. "restart presentation":"znovu spustit prezentaci",
  2234. "restart?":"restart"
  2235. },
  2236. help_cs:
  2237. "Prezentaci můžete procházet pomocí kliknutí myši, mezerníku, " +
  2238. "šipek vlevo a vpravo nebo kláves PageUp a PageDown. Písmo se " +
  2239. "dá zvětšit a zmenšit pomocí kláves B a S.",
  2240. strings_nl: {
  2241. "slide":"pagina",
  2242. "help?":"Help?",
  2243. "contents?":"Inhoud?",
  2244. "table of contents":"inhoudsopgave",
  2245. "Table of Contents":"Inhoudsopgave",
  2246. "restart presentation":"herstart presentatie",
  2247. "restart?":"Herstart?"
  2248. },
  2249. help_nl:
  2250. "Navigeer d.m.v. het muis, spatiebar, Links/Rechts toetsen, " +
  2251. "of PgUp en PgDn. Gebruik S en B om de karaktergrootte te veranderen.",
  2252. strings_de: {
  2253. "slide":"Seite",
  2254. "help?":"Hilfe",
  2255. "contents?":"Übersicht",
  2256. "table of contents":"Inhaltsverzeichnis",
  2257. "Table of Contents":"Inhaltsverzeichnis",
  2258. "restart presentation":"Präsentation neu starten",
  2259. "restart?":"Neustart"
  2260. },
  2261. help_de:
  2262. "Benutzen Sie die Maus, Leerschlag, die Cursortasten links/rechts oder " +
  2263. "Page up/Page Down zum Wechseln der Seiten und S und B für die Schriftgrösse.",
  2264. strings_pl: {
  2265. "slide":"slajd",
  2266. "help?":"pomoc?",
  2267. "contents?":"spis treści?",
  2268. "table of contents":"spis treści",
  2269. "Table of Contents":"Spis Treści",
  2270. "restart presentation":"Restartuj prezentację",
  2271. "restart?":"restart?"
  2272. },
  2273. help_pl:
  2274. "Zmieniaj slajdy klikając myszą, naciskając spację, strzałki lewo/prawo" +
  2275. "lub PgUp / PgDn. Użyj klawiszy S i B, aby zmienić rozmiar czczionki.",
  2276. strings_fr: {
  2277. "slide":"page",
  2278. "help?":"Aide",
  2279. "contents?":"Index",
  2280. "table of contents":"table des matières",
  2281. "Table of Contents":"Table des matières",
  2282. "restart presentation":"Recommencer l'exposé",
  2283. "restart?":"Début"
  2284. },
  2285. help_fr:
  2286. "Naviguez avec la souris, la barre d'espace, les flèches " +
  2287. "gauche/droite ou les touches Pg Up, Pg Dn. Utilisez " +
  2288. "les touches S et B pour modifier la taille de la police.",
  2289. strings_hu: {
  2290. "slide":"oldal",
  2291. "help?":"segítség",
  2292. "contents?":"tartalom",
  2293. "table of contents":"tartalomjegyzék",
  2294. "Table of Contents":"Tartalomjegyzék",
  2295. "restart presentation":"bemutató újraindítása",
  2296. "restart?":"újraindítás"
  2297. },
  2298. help_hu:
  2299. "Az oldalak közti lépkedéshez kattintson az egérrel, vagy " +
  2300. "használja a szóköz, a bal, vagy a jobb nyíl, illetve a Page Down, " +
  2301. "Page Up billentyűket. Az S és a B billentyűkkel változtathatja " +
  2302. "a szöveg méretét.",
  2303. strings_it: {
  2304. "slide":"pag.",
  2305. "help?":"Aiuto",
  2306. "contents?":"Indice",
  2307. "table of contents":"indice",
  2308. "Table of Contents":"Indice",
  2309. "restart presentation":"Ricominciare la presentazione",
  2310. "restart?":"Inizio"
  2311. },
  2312. help_it:
  2313. "Navigare con mouse, barra spazio, frecce sinistra/destra o " +
  2314. "PgUp e PgDn. Usare S e B per cambiare la dimensione dei caratteri.",
  2315. strings_el: {
  2316. "slide":"σελίδα",
  2317. "help?":"βοήθεια;",
  2318. "contents?":"περιεχόμενα;",
  2319. "table of contents":"πίνακας περιεχομένων",
  2320. "Table of Contents":"Πίνακας Περιεχομένων",
  2321. "restart presentation":"επανεκκίνηση παρουσίασης",
  2322. "restart?":"επανεκκίνηση;"
  2323. },
  2324. help_el:
  2325. "Πλοηγηθείτε με το κλίκ του ποντικιού, το space, τα βέλη αριστερά/δεξιά, " +
  2326. "ή Page Up και Page Down. Χρησιμοποιήστε τα πλήκτρα S και B για να αλλάξετε " +
  2327. "το μέγεθος της γραμματοσειράς.",
  2328. strings_ja: {
  2329. "slide":"スライド",
  2330. "help?":"ヘルプ",
  2331. "contents?":"目次",
  2332. "table of contents":"目次を表示",
  2333. "Table of Contents":"目次",
  2334. "restart presentation":"最初から再生",
  2335. "restart?":"最初から"
  2336. },
  2337. help_ja:
  2338. "マウス左クリック ・ スペース ・ 左右キー " +
  2339. "または Page Up ・ Page Downで操作, S ・ Bでフォントサイズ変更",
  2340. strings_zh: {
  2341. "slide":"幻灯片",
  2342. "help?":"帮助?",
  2343. "contents?":"内容?",
  2344. "table of contents":"目录",
  2345. "Table of Contents":"目录",
  2346. "restart presentation":"重新启动展示",
  2347. "restart?":"重新启动?"
  2348. },
  2349. help_zh:
  2350. "用鼠标点击, 空格条, 左右箭头, Pg Up 和 Pg Dn 导航. " +
  2351. "用 S, B 改变字体大小.",
  2352. strings_ru: {
  2353. "slide":"слайд",
  2354. "help?":"помощь?",
  2355. "contents?":"содержание?",
  2356. "table of contents":"оглавление",
  2357. "Table of Contents":"Оглавление",
  2358. "restart presentation":"перезапустить презентацию",
  2359. "restart?":"перезапуск?"
  2360. },
  2361. help_ru:
  2362. "Перемещайтесь кликая мышкой, используя клавишу пробел, стрелки" +
  2363. "влево/вправо или Pg Up и Pg Dn. Клавиши S и B меняют размер шрифта.",
  2364. strings_sv: {
  2365. "slide":"sida",
  2366. "help?":"hjälp",
  2367. "contents?":"innehåll",
  2368. "table of contents":"innehållsförteckning",
  2369. "Table of Contents":"Innehållsförteckning",
  2370. "restart presentation":"visa presentationen från början",
  2371. "restart?":"börja om"
  2372. },
  2373. help_sv:
  2374. "Bläddra med ett klick med vänstra musknappen, mellanslagstangenten, " +
  2375. "vänster- och högerpiltangenterna eller tangenterna Pg Up, Pg Dn. " +
  2376. "Använd tangenterna S och B för att ändra textens storlek.",
  2377. strings: { },
  2378. localize: function (src) {
  2379. if (src == "")
  2380. return src;
  2381. // try full language code, e.g. en-US
  2382. var s, lookup = w3c_slidy.strings[w3c_slidy.lang];
  2383. if (lookup)
  2384. {
  2385. s = lookup[src];
  2386. if (s)
  2387. return s;
  2388. }
  2389. // strip country code suffix, e.g.
  2390. // try en if undefined for en-US
  2391. var lg = w3c_slidy.lang.split("-");
  2392. if (lg.length > 1)
  2393. {
  2394. lookup = w3c_slidy.strings[lg[0]];
  2395. if (lookup)
  2396. {
  2397. s = lookup[src];
  2398. if (s)
  2399. return s;
  2400. }
  2401. }
  2402. // otherwise string as is
  2403. return src;
  2404. },
  2405. init_localization: function () {
  2406. var i18n = w3c_slidy;
  2407. var help_text = w3c_slidy.help_text;
  2408. // each such language array is declared in the localize array
  2409. // this is used as in w3c_slidy.localize("foo");
  2410. this.strings = {
  2411. "es":this.strings_es,
  2412. "ca":this.strings_ca,
  2413. "cs":this.strings_cs,
  2414. "nl":this.strings_nl,
  2415. "de":this.strings_de,
  2416. "pl":this.strings_pl,
  2417. "fr":this.strings_fr,
  2418. "hu":this.strings_hu,
  2419. "it":this.strings_it,
  2420. "el":this.strings_el,
  2421. "jp":this.strings_ja,
  2422. "zh":this.strings_zh,
  2423. "ru":this.strings_ru,
  2424. "sv":this.strings_sv
  2425. },
  2426. i18n.strings_es[help_text] = i18n.help_es;
  2427. i18n.strings_ca[help_text] = i18n.help_ca;
  2428. i18n.strings_cs[help_text] = i18n.help_cs;
  2429. i18n.strings_nl[help_text] = i18n.help_nl;
  2430. i18n.strings_de[help_text] = i18n.help_de;
  2431. i18n.strings_pl[help_text] = i18n.help_pl;
  2432. i18n.strings_fr[help_text] = i18n.help_fr;
  2433. i18n.strings_hu[help_text] = i18n.help_hu;
  2434. i18n.strings_it[help_text] = i18n.help_it;
  2435. i18n.strings_el[help_text] = i18n.help_el;
  2436. i18n.strings_ja[help_text] = i18n.help_ja;
  2437. i18n.strings_zh[help_text] = i18n.help_zh;
  2438. i18n.strings_ru[help_text] = i18n.help_ru;
  2439. i18n.strings_sv[help_text] = i18n.help_sv;
  2440. w3c_slidy.lang = document.body.parentNode.getAttribute("lang");
  2441. if (!w3c_slidy.lang)
  2442. w3c_slidy.lang = document.body.parentNode.getAttribute("xml:lang");
  2443. if (!w3c_slidy.lang)
  2444. w3c_slidy.lang = "en";
  2445. }
  2446. };
  2447. // hack for back button behavior
  2448. if (w3c_slidy.ie6 || w3c_slidy.ie7)
  2449. {
  2450. document.write("<iframe id='historyFrame' " +
  2451. "src='javascript:\"<html"+"></"+"html>\"' " +
  2452. "height='1' width='1' " +
  2453. "style='position:absolute;left:-800px'></iframe>");
  2454. }
  2455. // attach event listeners for initialization
  2456. w3c_slidy.set_up();
  2457. // hide the slides as soon as body element is available
  2458. // to reduce annoying screen mess before the onload event
  2459. setTimeout(w3c_slidy.hide_slides, 50);