slidy.js 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974
  1. /* slidy.js
  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 gap1 = document.createTextNode(" ");
  700. left.appendChild(gap1);
  701. var contents = this.create_element("a");
  702. contents.setAttribute("href", "javascript:w3c_slidy.toggle_table_of_contents()");
  703. contents.setAttribute("title", this.localize("table of contents"));
  704. contents.innerHTML = this.localize("contents?");
  705. left.appendChild(contents);
  706. var gap2 = document.createTextNode(" ");
  707. left.appendChild(gap2);
  708. var copyright = this.find_copyright();
  709. if (copyright)
  710. {
  711. var span = this.create_element("span");
  712. span.className = "copyright";
  713. span.innerHTML = copyright;
  714. left.appendChild(span);
  715. }
  716. this.toolbar.setAttribute("tabindex", "0");
  717. this.toolbar.appendChild(left);
  718. }
  719. else // IE6 so need to work around its poor CSS support
  720. {
  721. this.toolbar.style.position = (this.ie7 ? "fixed" : "absolute");
  722. this.toolbar.style.zIndex = "200";
  723. this.toolbar.style.width = "99.9%";
  724. this.toolbar.style.height = "1.2em";
  725. this.toolbar.style.top = "auto";
  726. this.toolbar.style.bottom = "0";
  727. this.toolbar.style.left = "0";
  728. this.toolbar.style.right = "0";
  729. this.toolbar.style.textAlign = "left";
  730. this.toolbar.style.fontSize = "60%";
  731. this.toolbar.style.color = "red";
  732. this.toolbar.borderWidth = 0;
  733. this.toolbar.className = "toolbar";
  734. this.toolbar.style.background = "rgb(240,240,240)";
  735. // would like to have help text left aligned
  736. // and page counter right aligned, floating
  737. // div's don't work, so instead use nested
  738. // absolutely positioned div's.
  739. var sp = this.create_element("span");
  740. sp.innerHTML = "&nbsp;&nbsp;*&nbsp;";
  741. this.toolbar.appendChild(sp);
  742. this.eos = sp; // end of slide indicator
  743. var help = this.create_element("a");
  744. help.setAttribute("href", this.help_page);
  745. help.setAttribute("title", this.localize(this.help_text));
  746. help.innerHTML = this.localize("help?");
  747. this.toolbar.appendChild(help);
  748. this.help_anchor = help; // save for focus hack
  749. var gap1 = document.createTextNode(" ");
  750. this.toolbar.appendChild(gap1);
  751. var contents = this.create_element("a");
  752. contents.setAttribute("href", "javascript:toggleTableOfContents()");
  753. contents.setAttribute("title", this.localize("table of contents".localize));
  754. contents.innerHTML = this.localize("contents?");
  755. this.toolbar.appendChild(contents);
  756. var gap2 = document.createTextNode(" ");
  757. this.toolbar.appendChild(gap2);
  758. var copyright = this.find_copyright();
  759. if (copyright)
  760. {
  761. var span = this.create_element("span");
  762. span.innerHTML = copyright;
  763. span.style.color = "black";
  764. span.style.marginLeft = "0.5em";
  765. this.toolbar.appendChild(span);
  766. }
  767. counter = this.create_element("div")
  768. counter.style.position = "absolute";
  769. counter.style.width = "auto"; //"20%";
  770. counter.style.height = "1.2em";
  771. counter.style.top = "auto";
  772. counter.style.bottom = 0;
  773. counter.style.right = "0";
  774. counter.style.textAlign = "right";
  775. counter.style.color = "red";
  776. counter.style.background = "rgb(240,240,240)";
  777. counter.innerHTML = this.localize("slide") + " n/m";
  778. this.toolbar.appendChild(counter);
  779. }
  780. // ensure that click isn't passed through to the page
  781. this.toolbar.onclick =
  782. function (e) {
  783. if (!e)
  784. e = window.event;
  785. var target = e.target;
  786. if (!target && e.srcElement)
  787. target = e.srcElement;
  788. // work around Safari bug
  789. if (target && target.nodeType == 3)
  790. target = target.parentNode;
  791. w3c_slidy.stop_propagation(e);
  792. if (target && target.nodeName.toLowerCase() != "a")
  793. w3c_slidy.mouse_button_click(e);
  794. };
  795. this.slide_number_element = counter;
  796. this.set_eos_status(false);
  797. document.body.appendChild(this.toolbar);
  798. },
  799. // wysiwyg editors make it hard to use div elements
  800. // e.g. amaya loses the div when you copy and paste
  801. // this function wraps div elements around implicit
  802. // slides which start with an h1 element and continue
  803. // up to the next heading or div element
  804. wrap_implicit_slides: function () {
  805. var i, heading, node, next, div;
  806. var headings = document.getElementsByTagName("h1");
  807. if (!headings)
  808. return;
  809. for (i = 0; i < headings.length; ++i)
  810. {
  811. heading = headings[i];
  812. if (heading.parentNode != document.body)
  813. continue;
  814. node = heading.nextSibling;
  815. div = document.createElement("div");
  816. this.add_class(div, "slide");
  817. document.body.replaceChild(div, heading);
  818. div.appendChild(heading);
  819. while (node)
  820. {
  821. if (node.nodeType == 1) // an element
  822. {
  823. if (node.nodeName == "H1" || node.nodeName == "h1")
  824. break;
  825. if (node.nodeName == "DIV" || node.nodeName == "div")
  826. {
  827. if (this.has_class(node, "slide"))
  828. break;
  829. if (this.has_class(node, "handout"))
  830. break;
  831. }
  832. }
  833. next = node.nextSibling;
  834. node = document.body.removeChild(node);
  835. div.appendChild(node);
  836. node = next;
  837. }
  838. }
  839. },
  840. // return new array of all slides
  841. collect_slides: function () {
  842. var slides = new Array();
  843. var divs = document.body.getElementsByTagName("div");
  844. for (var i = 0; i < divs.length; ++i)
  845. {
  846. div = divs.item(i);
  847. if (this.has_class(div, "slide"))
  848. {
  849. // add slide to collection
  850. slides[slides.length] = div;
  851. // hide each slide as it is found
  852. this.add_class(div, "hidden");
  853. // add dummy <br/> at end for scrolling hack
  854. var node1 = document.createElement("br");
  855. div.appendChild(node1);
  856. var node2 = document.createElement("br");
  857. div.appendChild(node2);
  858. }
  859. else if (this.has_class(div, "background"))
  860. { // work around for Firefox SVG reload bug
  861. // which otherwise replaces 1st SVG graphic with 2nd
  862. div.style.display = "block";
  863. }
  864. }
  865. this.slides = slides;
  866. },
  867. // return new array of all <div class="handout">
  868. collect_notes: function () {
  869. var notes = new Array();
  870. var divs = document.body.getElementsByTagName("div");
  871. for (var i = 0; i < divs.length; ++i)
  872. {
  873. div = divs.item(i);
  874. if (this.has_class(div, "handout"))
  875. {
  876. // add note to collection
  877. notes[notes.length] = div;
  878. // and hide it
  879. this.add_class(div, "hidden");
  880. }
  881. }
  882. this.notes = notes;
  883. },
  884. // return new array of all <div class="background">
  885. // including named backgrounds e.g. class="background titlepage"
  886. collect_backgrounds: function () {
  887. var backgrounds = new Array();
  888. var divs = document.body.getElementsByTagName("div");
  889. for (var i = 0; i < divs.length; ++i)
  890. {
  891. div = divs.item(i);
  892. if (this.has_class(div, "background"))
  893. {
  894. // add background to collection
  895. backgrounds[backgrounds.length] = div;
  896. // and hide it
  897. this.add_class(div, "hidden");
  898. }
  899. }
  900. this.backgrounds = backgrounds;
  901. },
  902. // set click handlers on all anchors
  903. patch_anchors: function () {
  904. var self = w3c_slidy;
  905. var handler = function (event) {
  906. // compare this.href with location.href
  907. // for link to another slide in this doc
  908. if (self.page_address(this.href) == self.page_address(location.href))
  909. {
  910. // yes, so find new slide number
  911. var newslidenum = self.find_slide_number(this.href);
  912. if (newslidenum != self.slide_number)
  913. {
  914. var slide = self.slides[self.slide_number];
  915. self.hide_slide(slide);
  916. self.slide_number = newslidenum;
  917. slide = self.slides[self.slide_number];
  918. self.show_slide(slide);
  919. self.set_location();
  920. }
  921. }
  922. else
  923. w3c_slidy.stop_propagation(event);
  924. // else if (this.target == null)
  925. // location.href = this.href;
  926. this.blur();
  927. self.disable_slide_click = true;
  928. };
  929. var anchors = document.body.getElementsByTagName("a");
  930. for (var i = 0; i < anchors.length; ++i)
  931. {
  932. if (window.addEventListener)
  933. anchors[i].addEventListener("click", handler, false);
  934. else
  935. anchors[i].attachEvent("onclick", handler);
  936. }
  937. },
  938. // ### CHECK ME ### see which functions are invoked via setTimeout
  939. // either directly or indirectly for use of w3c_slidy vs this
  940. show_slide_number: function () {
  941. var timer = w3c_slidy.get_timer();
  942. w3c_slidy.slide_number_element.innerHTML = timer + w3c_slidy.localize("slide") + " " +
  943. (w3c_slidy.slide_number + 1) + "/" + w3c_slidy.slides.length;
  944. },
  945. // every 200mS check if the location has been changed as a
  946. // result of the user activating the Back button/menu item
  947. // doesn't work for Opera < 9.5
  948. check_location: function () {
  949. var hash = location.hash;
  950. if (w3c_slidy.slide_number > 0 && (hash == "" || hash == "#"))
  951. w3c_slidy.goto_slide(0);
  952. else if (hash.length > 2 && hash != "#("+(w3c_slidy.slide_number+1)+")")
  953. {
  954. var num = parseInt(location.hash.substr(2));
  955. if (!isNaN(num))
  956. w3c_slidy.goto_slide(num-1);
  957. }
  958. if (w3c_slidy.time_left && w3c_slidy.slide_number > 0)
  959. {
  960. w3c_slidy.show_slide_number();
  961. if (w3c_slidy.time_left > 0)
  962. w3c_slidy.time_left -= 200;
  963. }
  964. },
  965. get_timer: function () {
  966. var timer = "";
  967. if (w3c_slidy.time_left)
  968. {
  969. var mins, secs;
  970. secs = Math.floor(w3c_slidy.time_left/1000);
  971. mins = Math.floor(secs / 60);
  972. secs = secs % 60;
  973. timer = (mins ? mins+"m" : "") + secs + "s ";
  974. }
  975. return timer;
  976. },
  977. // this doesn't push location onto history stack for IE
  978. // for which a hidden iframe hack is needed: load page into
  979. // the iframe with script that set's parent's location.hash
  980. // but that won't work for standalone use unless we can
  981. // create the page dynamically via a javascript: URL
  982. // ### use history.pushState if available
  983. set_location: function () {
  984. var uri = w3c_slidy.page_address(location.href);
  985. var hash = "#(" + (w3c_slidy.slide_number+1) + ")";
  986. if (w3c_slidy.slide_number >= 0)
  987. uri = uri + hash;
  988. if (typeof(history.pushState) != "undefined")
  989. {
  990. document.title = w3c_slidy.title + " (" + (w3c_slidy.slide_number+1) + ")";
  991. history.pushState(0, document.title, hash);
  992. w3c_slidy.show_slide_number();
  993. return;
  994. }
  995. if (w3c_slidy.ie && (w3c_slidy.ie6 || w3c_slidy.ie7))
  996. w3c_slidy.push_hash(hash);
  997. if (uri != location.href) // && !khtml
  998. location.href = uri;
  999. if (this.khtml)
  1000. hash = "(" + (w3c_slidy.slide_number+1) + ")";
  1001. if (!this.ie && location.hash != hash && location.hash != "")
  1002. location.hash = hash;
  1003. document.title = w3c_slidy.title + " (" + (w3c_slidy.slide_number+1) + ")";
  1004. w3c_slidy.show_slide_number();
  1005. },
  1006. page_address: function (uri) {
  1007. var i = uri.indexOf("#");
  1008. if (i < 0)
  1009. i = uri.indexOf("%23");
  1010. // check if anchor is entire page
  1011. if (i < 0)
  1012. return uri; // yes
  1013. return uri.substr(0, i);
  1014. },
  1015. // only used for IE6 and IE7
  1016. on_frame_loaded: function (hash) {
  1017. location.hash = hash;
  1018. var uri = w3c_slidy.page_address(location.href);
  1019. location.href = uri + hash;
  1020. },
  1021. // history hack with thanks to Bertrand Le Roy
  1022. push_hash: function (hash) {
  1023. if (hash == "") hash = "#(1)";
  1024. window.location.hash = hash;
  1025. var doc = document.getElementById("historyFrame").contentWindow.document;
  1026. doc.open("javascript:'<html></html>'");
  1027. doc.write("<html><head><script type=\"text/javascript\">window.parent.w3c_slidy.on_frame_loaded('"+
  1028. (hash) + "');</script></head><body>hello mum</body></html>");
  1029. doc.close();
  1030. },
  1031. // find current slide based upon location
  1032. // first find target anchor and then look
  1033. // for associated div element enclosing it
  1034. // finally map that to slide number
  1035. find_slide_number: function (uri) {
  1036. // first get anchor from page location
  1037. var i = uri.indexOf("#");
  1038. // check if anchor is entire page
  1039. if (i < 0)
  1040. return 0; // yes
  1041. var anchor = unescape(uri.substr(i+1));
  1042. // now use anchor as XML ID to find target
  1043. var target = document.getElementById(anchor);
  1044. if (!target)
  1045. {
  1046. // does anchor look like "(2)" for slide 2 ??
  1047. // where first slide is (1)
  1048. var re = /\((\d)+\)/;
  1049. if (anchor.match(re))
  1050. {
  1051. var num = parseInt(anchor.substring(1, anchor.length-1));
  1052. if (num > this.slides.length)
  1053. num = 1;
  1054. if (--num < 0)
  1055. num = 0;
  1056. return num;
  1057. }
  1058. // accept [2] for backwards compatibility
  1059. re = /\[(\d)+\]/;
  1060. if (anchor.match(re))
  1061. {
  1062. var num = parseInt(anchor.substring(1, anchor.length-1));
  1063. if (num > this.slides.length)
  1064. num = 1;
  1065. if (--num < 0)
  1066. num = 0;
  1067. return num;
  1068. }
  1069. // oh dear unknown anchor
  1070. return 0;
  1071. }
  1072. // search for enclosing slide
  1073. while (true)
  1074. {
  1075. // browser coerces html elements to uppercase!
  1076. if (target.nodeName.toLowerCase() == "div" &&
  1077. this.has_class(target, "slide"))
  1078. {
  1079. // found the slide element
  1080. break;
  1081. }
  1082. // otherwise try parent element if any
  1083. target = target.parentNode;
  1084. if (!target)
  1085. {
  1086. return 0; // no luck!
  1087. }
  1088. };
  1089. for (i = 0; i < slides.length; ++i)
  1090. {
  1091. if (slides[i] == target)
  1092. return i; // success
  1093. }
  1094. // oh dear still no luck
  1095. return 0;
  1096. },
  1097. previous_slide: function (incremental) {
  1098. if (!w3c_slidy.view_all)
  1099. {
  1100. var slide;
  1101. if ((incremental || w3c_slidy.slide_number == 0) && w3c_slidy.last_shown != null)
  1102. {
  1103. w3c_slidy.last_shown = w3c_slidy.hide_previous_item(w3c_slidy.last_shown);
  1104. w3c_slidy.set_eos_status(false);
  1105. }
  1106. else if (w3c_slidy.slide_number > 0)
  1107. {
  1108. slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1109. w3c_slidy.hide_slide(slide);
  1110. w3c_slidy.slide_number = w3c_slidy.slide_number - 1;
  1111. slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1112. w3c_slidy.set_visibility_all_incremental("visible");
  1113. w3c_slidy.last_shown = w3c_slidy.previous_incremental_item(null);
  1114. w3c_slidy.set_eos_status(true);
  1115. w3c_slidy.show_slide(slide);
  1116. }
  1117. w3c_slidy.set_location();
  1118. if (!w3c_slidy.ns_pos)
  1119. w3c_slidy.refresh_toolbar(200);
  1120. }
  1121. },
  1122. next_slide: function (incremental) {
  1123. if (!w3c_slidy.view_all)
  1124. {
  1125. var slide, last = w3c_slidy.last_shown;
  1126. if (incremental || w3c_slidy.slide_number == w3c_slidy.slides.length - 1)
  1127. w3c_slidy.last_shown = w3c_slidy.reveal_next_item(w3c_slidy.last_shown);
  1128. if ((!incremental || w3c_slidy.last_shown == null) &&
  1129. w3c_slidy.slide_number < w3c_slidy.slides.length - 1)
  1130. {
  1131. slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1132. w3c_slidy.hide_slide(slide);
  1133. w3c_slidy.slide_number = w3c_slidy.slide_number + 1;
  1134. slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1135. w3c_slidy.last_shown = null;
  1136. w3c_slidy.set_visibility_all_incremental("hidden");
  1137. w3c_slidy.show_slide(slide);
  1138. }
  1139. else if (!w3c_slidy.last_shown)
  1140. {
  1141. if (last && incremental)
  1142. w3c_slidy.last_shown = last;
  1143. }
  1144. w3c_slidy.set_location();
  1145. w3c_slidy.set_eos_status(!w3c_slidy.next_incremental_item(w3c_slidy.last_shown));
  1146. if (!w3c_slidy.ns_pos)
  1147. w3c_slidy.refresh_toolbar(200);
  1148. }
  1149. },
  1150. // to first slide with nothing revealed
  1151. // i.e. state at start of presentation
  1152. first_slide: function () {
  1153. if (!w3c_slidy.view_all)
  1154. {
  1155. var slide;
  1156. if (w3c_slidy.slide_number != 0)
  1157. {
  1158. slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1159. w3c_slidy.hide_slide(slide);
  1160. w3c_slidy.slide_number = 0;
  1161. slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1162. w3c_slidy.last_shown = null;
  1163. w3c_slidy.set_visibility_all_incremental("hidden");
  1164. w3c_slidy.show_slide(slide);
  1165. }
  1166. w3c_slidy.set_eos_status(
  1167. !w3c_slidy.next_incremental_item(w3c_slidy.last_shown));
  1168. w3c_slidy.set_location();
  1169. }
  1170. },
  1171. // goto last slide with everything revealed
  1172. // i.e. state at end of presentation
  1173. last_slide: function () {
  1174. if (!w3c_slidy.view_all)
  1175. {
  1176. var slide;
  1177. w3c_slidy.last_shown = null; //revealNextItem(lastShown);
  1178. if (w3c_slidy.last_shown == null &&
  1179. w3c_slidy.slide_number < w3c_slidy.slides.length - 1)
  1180. {
  1181. slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1182. w3c_slidy.hide_slide(slide);
  1183. w3c_slidy.slide_number = w3c_slidy.slides.length - 1;
  1184. slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1185. w3c_slidy.set_visibility_all_incremental("visible");
  1186. w3c_slidy.last_shown = w3c_slidy.previous_incremental_item(null);
  1187. w3c_slidy.show_slide(slide);
  1188. }
  1189. else
  1190. {
  1191. w3c_slidy.set_visibility_all_incremental("visible");
  1192. w3c_slidy.last_shown = w3c_slidy.previous_incremental_item(null);
  1193. }
  1194. w3c_slidy.set_eos_status(true);
  1195. w3c_slidy.set_location();
  1196. }
  1197. },
  1198. // ### check this and consider add/remove class
  1199. set_eos_status: function (state) {
  1200. if (this.eos)
  1201. this.eos.style.color = (state ? "rgb(240,240,240)" : "red");
  1202. },
  1203. // first slide is 0
  1204. goto_slide: function (num) {
  1205. //alert("going to slide " + (num+1));
  1206. var slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1207. w3c_slidy.hide_slide(slide);
  1208. w3c_slidy.slide_number = num;
  1209. slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1210. w3c_slidy.last_shown = null;
  1211. w3c_slidy.set_visibility_all_incremental("hidden");
  1212. w3c_slidy.set_eos_status(!w3c_slidy.next_incremental_item(w3c_slidy.last_shown));
  1213. document.title = w3c_slidy.title + " (" + (w3c_slidy.slide_number+1) + ")";
  1214. w3c_slidy.show_slide(slide);
  1215. w3c_slidy.show_slide_number();
  1216. },
  1217. show_slide: function (slide) {
  1218. this.sync_background(slide);
  1219. window.scrollTo(0,0);
  1220. this.remove_class(slide, "hidden");
  1221. },
  1222. hide_slide: function (slide) {
  1223. this.add_class(slide, "hidden");
  1224. },
  1225. // show just the backgrounds pertinent to this slide
  1226. // when slide background-color is transparent
  1227. // this should now work with rgba color values
  1228. sync_background: function (slide) {
  1229. var background;
  1230. var bgColor;
  1231. if (slide.currentStyle)
  1232. bgColor = slide.currentStyle["backgroundColor"];
  1233. else if (document.defaultView)
  1234. {
  1235. var styles = document.defaultView.getComputedStyle(slide,null);
  1236. if (styles)
  1237. bgColor = styles.getPropertyValue("background-color");
  1238. else // broken implementation probably due Safari or Konqueror
  1239. {
  1240. //alert("defective implementation of getComputedStyle()");
  1241. bgColor = "transparent";
  1242. }
  1243. }
  1244. else
  1245. bgColor == "transparent";
  1246. if (bgColor == "transparent" ||
  1247. bgColor.indexOf("rgba") >= 0 ||
  1248. bgColor.indexOf("opacity") >= 0)
  1249. {
  1250. var slideClass = this.get_class_list(slide);
  1251. for (var i = 0; i < this.backgrounds.length; i++)
  1252. {
  1253. background = this.backgrounds[i];
  1254. var bgClass = this.get_class_list(background);
  1255. if (this.matching_background(slideClass, bgClass))
  1256. this.remove_class(background, "hidden");
  1257. else
  1258. this.add_class(background, "hidden");
  1259. }
  1260. }
  1261. else // forcibly hide all backgrounds
  1262. this.hide_backgrounds();
  1263. },
  1264. hide_backgrounds: function () {
  1265. for (var i = 0; i < this.backgrounds.length; i++)
  1266. {
  1267. background = this.backgrounds[i];
  1268. this.add_class(background, "hidden");
  1269. }
  1270. },
  1271. // compare classes for slide and background
  1272. matching_background: function (slideClass, bgClass) {
  1273. var i, count, pattern, result;
  1274. // define pattern as regular expression
  1275. pattern = /\w+/g;
  1276. // check background class names
  1277. result = bgClass.match(pattern);
  1278. for (i = count = 0; i < result.length; i++)
  1279. {
  1280. if (result[i] == "hidden")
  1281. continue;
  1282. if (result[i] == "background")
  1283. continue;
  1284. ++count;
  1285. }
  1286. if (count == 0) // default match
  1287. return true;
  1288. // check for matches and place result in array
  1289. result = slideClass.match(pattern);
  1290. // now check if desired name is present for background
  1291. for (i = count = 0; i < result.length; i++)
  1292. {
  1293. if (result[i] == "hidden")
  1294. continue;
  1295. if (this.has_token(bgClass, result[i]))
  1296. return true;
  1297. }
  1298. return false;
  1299. },
  1300. resized: function () {
  1301. var width = 0;
  1302. if ( typeof( window.innerWidth ) == 'number' )
  1303. width = window.innerWidth; // Non IE browser
  1304. else if (document.documentElement && document.documentElement.clientWidth)
  1305. width = document.documentElement.clientWidth; // IE6
  1306. else if (document.body && document.body.clientWidth)
  1307. width = document.body.clientWidth; // IE4
  1308. var height = 0;
  1309. if ( typeof( window.innerHeight ) == 'number' )
  1310. height = window.innerHeight; // Non IE browser
  1311. else if (document.documentElement && document.documentElement.clientHeight)
  1312. height = document.documentElement.clientHeight; // IE6
  1313. else if (document.body && document.body.clientHeight)
  1314. height = document.body.clientHeight; // IE4
  1315. if (height && (width/height > 1.05*1024/768))
  1316. {
  1317. width = height * 1024.0/768;
  1318. }
  1319. // IE fires onresize even when only font size is changed!
  1320. // so we do a check to avoid blocking < and > actions
  1321. if (width != w3c_slidy.last_width || height != w3c_slidy.last_height)
  1322. {
  1323. if (width >= 1100)
  1324. w3c_slidy.size_index = 5; // 4
  1325. else if (width >= 1000)
  1326. w3c_slidy.size_index = 4; // 3
  1327. else if (width >= 800)
  1328. w3c_slidy.size_index = 3; // 2
  1329. else if (width >= 600)
  1330. w3c_slidy.size_index = 2; // 1
  1331. else if (width)
  1332. w3c_slidy.size_index = 0;
  1333. // add in font size adjustment from meta element e.g.
  1334. // <meta name="font-size-adjustment" content="-2" />
  1335. // useful when slides have too much content ;-)
  1336. if (0 <= w3c_slidy.size_index + w3c_slidy.size_adjustment &&
  1337. w3c_slidy.size_index + w3c_slidy.size_adjustment < w3c_slidy.sizes.length)
  1338. w3c_slidy.size_index = w3c_slidy.size_index + w3c_slidy.size_adjustment;
  1339. // enables cross browser use of relative width/height
  1340. // on object elements for use with SVG and Flash media
  1341. w3c_slidy.adjust_object_dimensions(width, height);
  1342. if (document.body.style.fontSize != w3c_slidy.sizes[w3c_slidy.size_index])
  1343. {
  1344. document.body.style.fontSize = w3c_slidy.sizes[w3c_slidy.size_index];
  1345. }
  1346. w3c_slidy.last_width = width;
  1347. w3c_slidy.last_height = height;
  1348. // force reflow to work around Mozilla bug
  1349. if (w3c_slidy.ns_pos)
  1350. {
  1351. var slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1352. w3c_slidy.hide_slide(slide);
  1353. w3c_slidy.show_slide(slide);
  1354. }
  1355. // force correct positioning of toolbar
  1356. w3c_slidy.refresh_toolbar(200);
  1357. }
  1358. },
  1359. scrolled: function () {
  1360. if (w3c_slidy.toolbar && !w3c_slidy.ns_pos && !w3c_slidy.ie7)
  1361. {
  1362. w3c_slidy.hack_offset = w3c_slidy.scroll_x_offset();
  1363. // hide toolbar
  1364. w3c_slidy.toolbar.style.display = "none";
  1365. // make it reappear later
  1366. if (w3c_slidy.scrollhack == 0 && !w3c_slidy.view_all)
  1367. {
  1368. setTimeout(function () {w3c_slidy.show_toolbar(); }, 1000);
  1369. w3c_slidy.scrollhack = 1;
  1370. }
  1371. }
  1372. },
  1373. hide_toolbar: function () {
  1374. w3c_slidy.add_class(w3c_slidy.toolbar, "hidden");
  1375. window.focus();
  1376. },
  1377. // used to ensure IE refreshes toolbar in correct position
  1378. refresh_toolbar: function (interval) {
  1379. if (!w3c_slidy.ns_pos && !w3c_slidy.ie7)
  1380. {
  1381. w3c_slidy.hide_toolbar();
  1382. setTimeout(function () {w3c_slidy.show_toolbar(); }, interval);
  1383. }
  1384. },
  1385. // restores toolbar after short delay
  1386. show_toolbar: function () {
  1387. if (w3c_slidy.want_toolbar)
  1388. {
  1389. w3c_slidy.toolbar.style.display = "block";
  1390. if (!w3c_slidy.ns_pos)
  1391. {
  1392. // adjust position to allow for scrolling
  1393. var xoffset = w3c_slidy.scroll_x_offset();
  1394. w3c_slidy.toolbar.style.left = xoffset;
  1395. w3c_slidy.toolbar.style.right = xoffset;
  1396. // determine vertical scroll offset
  1397. //var yoffset = scrollYOffset();
  1398. // bottom is doc height - window height - scroll offset
  1399. //var bottom = documentHeight() - lastHeight - yoffset
  1400. //if (yoffset > 0 || documentHeight() > lastHeight)
  1401. // bottom += 16; // allow for height of scrollbar
  1402. w3c_slidy.toolbar.style.bottom = 0; //bottom;
  1403. }
  1404. w3c_slidy.remove_class(w3c_slidy.toolbar, "hidden");
  1405. }
  1406. w3c_slidy.scrollhack = 0;
  1407. // set the keyboard focus to the help link on the
  1408. // toolbar to ensure that document has the focus
  1409. // IE doesn't always work with window.focus()
  1410. // and this hack has benefit of Enter for help
  1411. try
  1412. {
  1413. if (!w3c_slidy.opera)
  1414. w3c_slidy.help_anchor.focus();
  1415. }
  1416. catch (e)
  1417. {
  1418. }
  1419. },
  1420. // invoked via F key
  1421. toggle_toolbar: function () {
  1422. if (!w3c_slidy.view_all)
  1423. {
  1424. if (w3c_slidy.has_class(w3c_slidy.toolbar, "hidden"))
  1425. {
  1426. w3c_slidy.remove_class(w3c_slidy.toolbar, "hidden")
  1427. w3c_slidy.want_toolbar = 1;
  1428. }
  1429. else
  1430. {
  1431. w3c_slidy.add_class(w3c_slidy.toolbar, "hidden")
  1432. w3c_slidy.want_toolbar = 0;
  1433. }
  1434. }
  1435. },
  1436. scroll_x_offset: function () {
  1437. if (window.pageXOffset)
  1438. return self.pageXOffset;
  1439. if (document.documentElement &&
  1440. document.documentElement.scrollLeft)
  1441. return document.documentElement.scrollLeft;
  1442. if (document.body)
  1443. return document.body.scrollLeft;
  1444. return 0;
  1445. },
  1446. scroll_y_offset: function () {
  1447. if (window.pageYOffset)
  1448. return self.pageYOffset;
  1449. if (document.documentElement &&
  1450. document.documentElement.scrollTop)
  1451. return document.documentElement.scrollTop;
  1452. if (document.body)
  1453. return document.body.scrollTop;
  1454. return 0;
  1455. },
  1456. // looking for a way to determine height of slide content
  1457. // the slide itself is set to the height of the window
  1458. optimize_font_size: function () {
  1459. var slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1460. //var dh = documentHeight(); //getDocHeight(document);
  1461. var dh = slide.scrollHeight;
  1462. var wh = getWindowHeight();
  1463. var u = 100 * dh / wh;
  1464. alert("window utilization = " + u + "% (doc "
  1465. + dh + " win " + wh + ")");
  1466. },
  1467. // from document object
  1468. get_doc_height: function (doc) {
  1469. if (!doc)
  1470. doc = document;
  1471. if (doc && doc.body && doc.body.offsetHeight)
  1472. return doc.body.offsetHeight; // ns/gecko syntax
  1473. if (doc && doc.body && doc.body.scrollHeight)
  1474. return doc.body.scrollHeight;
  1475. alert("couldn't determine document height");
  1476. },
  1477. get_window_height: function () {
  1478. if ( typeof( window.innerHeight ) == 'number' )
  1479. return window.innerHeight; // Non IE browser
  1480. if (document.documentElement && document.documentElement.clientHeight)
  1481. return document.documentElement.clientHeight; // IE6
  1482. if (document.body && document.body.clientHeight)
  1483. return document.body.clientHeight; // IE4
  1484. },
  1485. document_height: function () {
  1486. var sh, oh;
  1487. sh = document.body.scrollHeight;
  1488. oh = document.body.offsetHeight;
  1489. if (sh && oh)
  1490. {
  1491. return (sh > oh ? sh : oh);
  1492. }
  1493. // no idea!
  1494. return 0;
  1495. },
  1496. smaller: function () {
  1497. if (w3c_slidy.size_index > 0)
  1498. {
  1499. --w3c_slidy.size_index;
  1500. }
  1501. w3c_slidy.toolbar.style.display = "none";
  1502. document.body.style.fontSize = w3c_slidy.sizes[w3c_slidy.size_index];
  1503. var slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1504. w3c_slidy.hide_slide(slide);
  1505. w3c_slidy.show_slide(slide);
  1506. setTimeout(function () {w3c_slidy.show_toolbar(); }, 50);
  1507. },
  1508. bigger: function () {
  1509. if (w3c_slidy.size_index < w3c_slidy.sizes.length - 1)
  1510. {
  1511. ++w3c_slidy.size_index;
  1512. }
  1513. w3c_slidy.toolbar.style.display = "none";
  1514. document.body.style.fontSize = w3c_slidy.sizes[w3c_slidy.size_index];
  1515. var slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1516. w3c_slidy.hide_slide(slide);
  1517. w3c_slidy.show_slide(slide);
  1518. setTimeout(function () {w3c_slidy.show_toolbar(); }, 50);
  1519. },
  1520. // enables cross browser use of relative width/height
  1521. // on object elements for use with SVG and Flash media
  1522. // with thanks to Ivan Herman for the suggestion
  1523. adjust_object_dimensions: function (width, height) {
  1524. for( var i = 0; i < w3c_slidy.objects.length; i++ )
  1525. {
  1526. var obj = this.objects[i];
  1527. var mimeType = obj.getAttribute("type");
  1528. if (mimeType == "image/svg+xml" || mimeType == "application/x-shockwave-flash")
  1529. {
  1530. if ( !obj.initialWidth )
  1531. obj.initialWidth = obj.getAttribute("width");
  1532. if ( !obj.initialHeight )
  1533. obj.initialHeight = obj.getAttribute("height");
  1534. if ( obj.initialWidth && obj.initialWidth.charAt(obj.initialWidth.length-1) == "%" )
  1535. {
  1536. var w = parseInt(obj.initialWidth.slice(0, obj.initialWidth.length-1));
  1537. var newW = width * (w/100.0);
  1538. obj.setAttribute("width",newW);
  1539. }
  1540. if ( obj.initialHeight &&
  1541. obj.initialHeight.charAt(obj.initialHeight.length-1) == "%" )
  1542. {
  1543. var h = parseInt(obj.initialHeight.slice(0, obj.initialHeight.length-1));
  1544. var newH = height * (h/100.0);
  1545. obj.setAttribute("height", newH);
  1546. }
  1547. }
  1548. }
  1549. },
  1550. // needed for Opera to inhibit default behavior
  1551. // since Opera delivers keyPress even if keyDown
  1552. // was cancelled
  1553. key_press: function (event) {
  1554. if (!event)
  1555. event = window.event;
  1556. if (!w3c_slidy.key_wanted)
  1557. return w3c_slidy.cancel(event);
  1558. return true;
  1559. },
  1560. // See e.g. http://www.quirksmode.org/js/events/keys.html for keycodes
  1561. key_down: function (event) {
  1562. var key, target, tag;
  1563. w3c_slidy.key_wanted = true;
  1564. if (!event)
  1565. event = window.event;
  1566. // kludge around NS/IE differences
  1567. if (window.event)
  1568. {
  1569. key = window.event.keyCode;
  1570. target = window.event.srcElement;
  1571. }
  1572. else if (event.which)
  1573. {
  1574. key = event.which;
  1575. target = event.target;
  1576. }
  1577. else
  1578. return true; // Yikes! unknown browser
  1579. // ignore event if key value is zero
  1580. // as for alt on Opera and Konqueror
  1581. if (!key)
  1582. return true;
  1583. // avoid interfering with keystroke
  1584. // behavior for non-slidy chrome elements
  1585. if (!w3c_slidy.slidy_chrome(target) &&
  1586. w3c_slidy.special_element(target))
  1587. return true;
  1588. // check for concurrent control/command/alt key
  1589. // but are these only present on mouse events?
  1590. if (event.ctrlKey || event.altKey || event.metaKey)
  1591. return true;
  1592. // dismiss table of contents if visible
  1593. if (w3c_slidy.is_shown_toc() && key != 9 && key != 16 && key != 38 && key != 40)
  1594. {
  1595. w3c_slidy.hide_table_of_contents(true);
  1596. if (key == 27 || key == 84 || key == 67)
  1597. return w3c_slidy.cancel(event);
  1598. }
  1599. if (key == 34) // Page Down
  1600. {
  1601. if (w3c_slidy.view_all)
  1602. return true;
  1603. w3c_slidy.next_slide(false);
  1604. return w3c_slidy.cancel(event);
  1605. }
  1606. else if (key == 33) // Page Up
  1607. {
  1608. if (w3c_slidy.view_all)
  1609. return true;
  1610. w3c_slidy.previous_slide(false);
  1611. return w3c_slidy.cancel(event);
  1612. }
  1613. else if (key == 32) // space bar
  1614. {
  1615. w3c_slidy.next_slide(true);
  1616. return w3c_slidy.cancel(event);
  1617. }
  1618. else if (key == 37) // Left arrow
  1619. {
  1620. w3c_slidy.previous_slide(!event.shiftKey);
  1621. return w3c_slidy.cancel(event);
  1622. }
  1623. else if (key == 36) // Home
  1624. {
  1625. w3c_slidy.first_slide();
  1626. return w3c_slidy.cancel(event);
  1627. }
  1628. else if (key == 35) // End
  1629. {
  1630. w3c_slidy.last_slide();
  1631. return w3c_slidy.cancel(event);
  1632. }
  1633. else if (key == 39) // Right arrow
  1634. {
  1635. w3c_slidy.next_slide(!event.shiftKey);
  1636. return w3c_slidy.cancel(event);
  1637. }
  1638. else if (key == 13) // Enter
  1639. {
  1640. if (w3c_slidy.outline)
  1641. {
  1642. if (w3c_slidy.outline.visible)
  1643. w3c_slidy.fold(w3c_slidy.outline);
  1644. else
  1645. w3c_slidy.unfold(w3c_slidy.outline);
  1646. return w3c_slidy.cancel(event);
  1647. }
  1648. }
  1649. else if (key == 188) // < for smaller fonts
  1650. {
  1651. w3c_slidy.smaller();
  1652. return w3c_slidy.cancel(event);
  1653. }
  1654. else if (key == 190) // > for larger fonts
  1655. {
  1656. w3c_slidy.bigger();
  1657. return w3c_slidy.cancel(event);
  1658. }
  1659. else if (key == 189 || key == 109) // - for smaller fonts
  1660. {
  1661. w3c_slidy.smaller();
  1662. return w3c_slidy.cancel(event);
  1663. }
  1664. else if (key == 187 || key == 191 || key == 107) // = + for larger fonts
  1665. {
  1666. w3c_slidy.bigger();
  1667. return w3c_slidy.cancel(event);
  1668. }
  1669. else if (key == 83) // S for smaller fonts
  1670. {
  1671. w3c_slidy.smaller();
  1672. return w3c_slidy.cancel(event);
  1673. }
  1674. else if (key == 66) // B for larger fonts
  1675. {
  1676. w3c_slidy.bigger();
  1677. return w3c_slidy.cancel(event);
  1678. }
  1679. else if (key == 90) // Z for last slide
  1680. {
  1681. w3c_slidy.last_slide();
  1682. return w3c_slidy.cancel(event);
  1683. }
  1684. else if (key == 70) // F for toggle toolbar
  1685. {
  1686. w3c_slidy.toggle_toolbar();
  1687. return w3c_slidy.cancel(event);
  1688. }
  1689. else if (key == 65) // A for toggle view single/all slides
  1690. {
  1691. w3c_slidy.toggle_view();
  1692. return w3c_slidy.cancel(event);
  1693. }
  1694. else if (key == 75) // toggle action of left click for next page
  1695. {
  1696. w3c_slidy.mouse_click_enabled = !w3c_slidy.mouse_click_enabled;
  1697. var alert_msg = (w3c_slidy.mouse_click_enabled ?
  1698. "enabled" : "disabled") + " mouse click advance";
  1699. alert(w3c_slidy.localize(alert_msg));
  1700. return w3c_slidy.cancel(event);
  1701. }
  1702. else if (key == 84 || key == 67) // T or C for table of contents
  1703. {
  1704. if (w3c_slidy.toc)
  1705. w3c_slidy.toggle_table_of_contents();
  1706. return w3c_slidy.cancel(event);
  1707. }
  1708. else if (key == 72) // H for help
  1709. {
  1710. window.location = w3c_slidy.help_page;
  1711. return w3c_slidy.cancel(event);
  1712. }
  1713. //else alert("key code is "+ key);
  1714. return true;
  1715. },
  1716. // safe for both text/html and application/xhtml+xml
  1717. create_element: function (name) {
  1718. if (this.xhtml && (typeof document.createElementNS != 'undefined'))
  1719. return document.createElementNS("http://www.w3.org/1999/xhtml", name)
  1720. return document.createElement(name);
  1721. },
  1722. get_element_style: function (elem, IEStyleProp, CSSStyleProp) {
  1723. if (elem.currentStyle)
  1724. {
  1725. return elem.currentStyle[IEStyleProp];
  1726. }
  1727. else if (window.getComputedStyle)
  1728. {
  1729. var compStyle = window.getComputedStyle(elem, "");
  1730. return compStyle.getPropertyValue(CSSStyleProp);
  1731. }
  1732. return "";
  1733. },
  1734. // the string str is a whitespace separated list of tokens
  1735. // test if str contains a particular token, e.g. "slide"
  1736. has_token: function (str, token) {
  1737. if (str)
  1738. {
  1739. // define pattern as regular expression
  1740. var pattern = /\w+/g;
  1741. // check for matches
  1742. // place result in array
  1743. var result = str.match(pattern);
  1744. // now check if desired token is present
  1745. for (var i = 0; i < result.length; i++)
  1746. {
  1747. if (result[i] == token)
  1748. return true;
  1749. }
  1750. }
  1751. return false;
  1752. },
  1753. get_class_list: function (element) {
  1754. if (typeof element.className != 'undefined')
  1755. return element.className;
  1756. return element.getAttribute("class");
  1757. },
  1758. has_class: function (element, name) {
  1759. if (element.nodeType != 1)
  1760. return false;
  1761. var regexp = new RegExp("(^| )" + name + "\W*");
  1762. if (typeof element.className != 'undefined')
  1763. return regexp.test(element.className);
  1764. return regexp.test(element.getAttribute("class"));
  1765. },
  1766. remove_class: function (element, name) {
  1767. var regexp = new RegExp("(^| )" + name + "\W*");
  1768. var clsval = "";
  1769. if (typeof element.className != 'undefined')
  1770. {
  1771. clsval = element.className;
  1772. if (clsval)
  1773. {
  1774. clsval = clsval.replace(regexp, "");
  1775. element.className = clsval;
  1776. }
  1777. }
  1778. else
  1779. {
  1780. clsval = element.getAttribute("class");
  1781. if (clsval)
  1782. {
  1783. clsval = clsval.replace(regexp, "");
  1784. element.setAttribute("class", clsval);
  1785. }
  1786. }
  1787. },
  1788. add_class: function (element, name) {
  1789. if (!this.has_class(element, name))
  1790. {
  1791. if (typeof element.className != 'undefined')
  1792. element.className += " " + name;
  1793. else
  1794. {
  1795. var clsval = element.getAttribute("class");
  1796. clsval = clsval ? clsval + " " + name : name;
  1797. element.setAttribute("class", clsval);
  1798. }
  1799. }
  1800. },
  1801. // HTML elements that can be used with class="incremental"
  1802. // note that you can also put the class on containers like
  1803. // up, ol, dl, and div to make their contents appear
  1804. // incrementally. Upper case is used since this is what
  1805. // browsers report for HTML node names (text/html).
  1806. incremental_elements: null,
  1807. okay_for_incremental: function (name) {
  1808. if (!this.incremental_elements)
  1809. {
  1810. var inclist = new Array();
  1811. inclist["p"] = true;
  1812. inclist["pre"] = true;
  1813. inclist["li"] = true;
  1814. inclist["blockquote"] = true;
  1815. inclist["dt"] = true;
  1816. inclist["dd"] = true;
  1817. inclist["h2"] = true;
  1818. inclist["h3"] = true;
  1819. inclist["h4"] = true;
  1820. inclist["h5"] = true;
  1821. inclist["h6"] = true;
  1822. inclist["span"] = true;
  1823. inclist["address"] = true;
  1824. inclist["table"] = true;
  1825. inclist["tr"] = true;
  1826. inclist["th"] = true;
  1827. inclist["td"] = true;
  1828. inclist["img"] = true;
  1829. inclist["object"] = true;
  1830. this.incremental_elements = inclist;
  1831. }
  1832. return this.incremental_elements[name.toLowerCase()];
  1833. },
  1834. next_incremental_item: function (node) {
  1835. var br = this.is_xhtml ? "br" : "BR";
  1836. var slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1837. for (;;)
  1838. {
  1839. node = w3c_slidy.next_node(slide, node);
  1840. if (node == null || node.parentNode == null)
  1841. break;
  1842. if (node.nodeType == 1) // ELEMENT
  1843. {
  1844. if (node.nodeName == br)
  1845. continue;
  1846. if (w3c_slidy.has_class(node, "incremental")
  1847. && w3c_slidy.okay_for_incremental(node.nodeName))
  1848. return node;
  1849. if (w3c_slidy.has_class(node.parentNode, "incremental")
  1850. && !w3c_slidy.has_class(node, "non-incremental"))
  1851. return node;
  1852. }
  1853. }
  1854. return node;
  1855. },
  1856. previous_incremental_item: function (node) {
  1857. var br = this.is_xhtml ? "br" : "BR";
  1858. var slide = w3c_slidy.slides[w3c_slidy.slide_number];
  1859. for (;;)
  1860. {
  1861. node = w3c_slidy.previous_node(slide, node);
  1862. if (node == null || node.parentNode == null)
  1863. break;
  1864. if (node.nodeType == 1)
  1865. {
  1866. if (node.nodeName == br)
  1867. continue;
  1868. if (w3c_slidy.has_class(node, "incremental")
  1869. && w3c_slidy.okay_for_incremental(node.nodeName))
  1870. return node;
  1871. if (w3c_slidy.has_class(node.parentNode, "incremental")
  1872. && !w3c_slidy.has_class(node, "non-incremental"))
  1873. return node;
  1874. }
  1875. }
  1876. return node;
  1877. },
  1878. // set visibility for all elements on current slide with
  1879. // a parent element with attribute class="incremental"
  1880. set_visibility_all_incremental: function (value) {
  1881. var node = this.next_incremental_item(null);
  1882. if (value == "hidden")
  1883. {
  1884. while (node)
  1885. {
  1886. w3c_slidy.add_class(node, "invisible");
  1887. node = w3c_slidy.next_incremental_item(node);
  1888. }
  1889. }
  1890. else // value == "visible"
  1891. {
  1892. while (node)
  1893. {
  1894. w3c_slidy.remove_class(node, "invisible");
  1895. node = w3c_slidy.next_incremental_item(node);
  1896. }
  1897. }
  1898. },
  1899. // reveal the next hidden item on the slide
  1900. // node is null or the node that was last revealed
  1901. reveal_next_item: function (node) {
  1902. node = w3c_slidy.next_incremental_item(node);
  1903. if (node && node.nodeType == 1) // an element
  1904. w3c_slidy.remove_class(node, "invisible");
  1905. return node;
  1906. },
  1907. // exact inverse of revealNextItem(node)
  1908. hide_previous_item: function (node) {
  1909. if (node && node.nodeType == 1) // an element
  1910. w3c_slidy.add_class(node, "invisible");
  1911. return this.previous_incremental_item(node);
  1912. },
  1913. // left to right traversal of root's content
  1914. next_node: function (root, node) {
  1915. if (node == null)
  1916. return root.firstChild;
  1917. if (node.firstChild)
  1918. return node.firstChild;
  1919. if (node.nextSibling)
  1920. return node.nextSibling;
  1921. for (;;)
  1922. {
  1923. node = node.parentNode;
  1924. if (!node || node == root)
  1925. break;
  1926. if (node && node.nextSibling)
  1927. return node.nextSibling;
  1928. }
  1929. return null;
  1930. },
  1931. // right to left traversal of root's content
  1932. previous_node: function (root, node) {
  1933. if (node == null)
  1934. {
  1935. node = root.lastChild;
  1936. if (node)
  1937. {
  1938. while (node.lastChild)
  1939. node = node.lastChild;
  1940. }
  1941. return node;
  1942. }
  1943. if (node.previousSibling)
  1944. {
  1945. node = node.previousSibling;
  1946. while (node.lastChild)
  1947. node = node.lastChild;
  1948. return node;
  1949. }
  1950. if (node.parentNode != root)
  1951. return node.parentNode;
  1952. return null;
  1953. },
  1954. previous_sibling_element: function (el) {
  1955. el = el.previousSibling;
  1956. while (el && el.nodeType != 1)
  1957. el = el.previousSibling;
  1958. return el;
  1959. },
  1960. next_sibling_element: function (el) {
  1961. el = el.nextSibling;
  1962. while (el && el.nodeType != 1)
  1963. el = el.nextSibling;
  1964. return el;
  1965. },
  1966. first_child_element: function (el) {
  1967. var node;
  1968. for (node = el.firstChild; node; node = node.nextSibling)
  1969. {
  1970. if (node.nodeType == 1)
  1971. break;
  1972. }
  1973. return node;
  1974. },
  1975. first_tag: function (element, tag) {
  1976. var node;
  1977. if (!this.is_xhtml)
  1978. tag = tag.toUpperCase();
  1979. for (node = element.firstChild; node; node = node.nextSibling)
  1980. {
  1981. if (node.nodeType == 1 && node.nodeName == tag)
  1982. break;
  1983. }
  1984. return node;
  1985. },
  1986. hide_selection: function () {
  1987. if (window.getSelection) // Firefox, Chromium, Safari, Opera
  1988. {
  1989. var selection = window.getSelection();
  1990. if (selection.rangeCount > 0)
  1991. {
  1992. var range = selection.getRangeAt(0);
  1993. range.collapse (false);
  1994. }
  1995. }
  1996. else // Internet Explorer
  1997. {
  1998. var textRange = document.selection.createRange ();
  1999. textRange.collapse (false);
  2000. }
  2001. },
  2002. get_selected_text: function () {
  2003. try
  2004. {
  2005. if (window.getSelection)
  2006. return window.getSelection().toString();
  2007. if (document.getSelection)
  2008. return document.getSelection().toString();
  2009. if (document.selection)
  2010. return document.selection.createRange().text;
  2011. }
  2012. catch (e)
  2013. {
  2014. }
  2015. return "";
  2016. },
  2017. // make note of length of selected text
  2018. // as this evaluates to zero in click event
  2019. mouse_button_up: function (e) {
  2020. w3c_slidy.selected_text_len = w3c_slidy.get_selected_text().length;
  2021. },
  2022. // right mouse button click is reserved for context menus
  2023. // it is more reliable to detect rightclick than leftclick
  2024. mouse_button_click: function (e) {
  2025. var rightclick = false;
  2026. var leftclick = false;
  2027. var middleclick = false;
  2028. var target;
  2029. if (!e)
  2030. var e = window.event;
  2031. if (e.target)
  2032. target = e.target;
  2033. else if (e.srcElement)
  2034. target = e.srcElement;
  2035. // work around Safari bug
  2036. if (target.nodeType == 3)
  2037. target = target.parentNode;
  2038. if (e.which) // all browsers except IE
  2039. {
  2040. leftclick = (e.which == 1);
  2041. middleclick = (e.which == 2);
  2042. rightclick = (e.which == 3);
  2043. }
  2044. else if (e.button)
  2045. {
  2046. // Konqueror gives 1 for left, 4 for middle
  2047. // IE6 gives 0 for left and not 1 as I expected
  2048. if (e.button == 4)
  2049. middleclick = true;
  2050. // all browsers agree on 2 for right button
  2051. rightclick = (e.button == 2);
  2052. }
  2053. else
  2054. leftclick = true;
  2055. if (w3c_slidy.selected_text_len > 0)
  2056. {
  2057. w3c_slidy.stop_propagation(e);
  2058. e.cancel = true;
  2059. e.returnValue = false;
  2060. return false;
  2061. }
  2062. // dismiss table of contents
  2063. w3c_slidy.hide_table_of_contents(false);
  2064. // check if target is something that probably want's clicks
  2065. // e.g. a, embed, object, input, textarea, select, option
  2066. var tag = target.nodeName.toLowerCase();
  2067. if (w3c_slidy.mouse_click_enabled && leftclick &&
  2068. !w3c_slidy.special_element(target) &&
  2069. !target.onclick)
  2070. {
  2071. w3c_slidy.next_slide(true);
  2072. w3c_slidy.stop_propagation(e);
  2073. e.cancel = true;
  2074. e.returnValue = false;
  2075. return false;
  2076. }
  2077. return true;
  2078. },
  2079. special_element: function (element) {
  2080. if (this.has_class(element, "non-interactive"))
  2081. return false;
  2082. var tag = element.nodeName.toLowerCase();
  2083. return element.onkeydown ||
  2084. element.onclick ||
  2085. tag == "a" ||
  2086. tag == "embed" ||
  2087. tag == "object" ||
  2088. tag == "video" ||
  2089. tag == "audio" ||
  2090. tag == "svg" ||
  2091. tag == "canvas" ||
  2092. tag == "input" ||
  2093. tag == "textarea" ||
  2094. tag == "select" ||
  2095. tag == "option";
  2096. },
  2097. slidy_chrome: function (el) {
  2098. while (el)
  2099. {
  2100. if (el == w3c_slidy.toc ||
  2101. el == w3c_slidy.toolbar ||
  2102. w3c_slidy.has_class(el, "outline"))
  2103. return true;
  2104. el = el.parentNode;
  2105. }
  2106. return false;
  2107. },
  2108. get_key: function (e)
  2109. {
  2110. var key;
  2111. // kludge around NS/IE differences
  2112. if (typeof window.event != "undefined")
  2113. key = window.event.keyCode;
  2114. else if (e.which)
  2115. key = e.which;
  2116. return key;
  2117. },
  2118. get_target: function (e) {
  2119. var target;
  2120. if (!e)
  2121. e = window.event;
  2122. if (e.target)
  2123. target = e.target;
  2124. else if (e.srcElement)
  2125. target = e.srcElement;
  2126. if (target.nodeType != 1)
  2127. target = target.parentNode;
  2128. return target;
  2129. },
  2130. // does display property provide correct defaults?
  2131. is_block: function (elem) {
  2132. var tag = elem.nodeName.toLowerCase();
  2133. return tag == "ol" || tag == "ul" || tag == "p" ||
  2134. tag == "li" || tag == "table" || tag == "pre" ||
  2135. tag == "h1" || tag == "h2" || tag == "h3" ||
  2136. tag == "h4" || tag == "h5" || tag == "h6" ||
  2137. tag == "blockquote" || tag == "address";
  2138. },
  2139. add_listener: function (element, event, handler) {
  2140. if (window.addEventListener)
  2141. element.addEventListener(event, handler, false);
  2142. else
  2143. element.attachEvent("on"+event, handler);
  2144. },
  2145. // used to prevent event propagation from field controls
  2146. stop_propagation: function (event) {
  2147. event = event ? event : window.event;
  2148. event.cancelBubble = true; // for IE
  2149. if (event.stopPropagation)
  2150. event.stopPropagation();
  2151. return true;
  2152. },
  2153. cancel: function (event) {
  2154. if (event)
  2155. {
  2156. event.cancel = true;
  2157. event.returnValue = false;
  2158. if (event.preventDefault)
  2159. event.preventDefault();
  2160. }
  2161. w3c_slidy.key_wanted = false;
  2162. return false;
  2163. },
  2164. // for each language define an associative array
  2165. // and also the help text which is longer
  2166. strings_es: {
  2167. "slide":"pág.",
  2168. "help?":"Ayuda",
  2169. "contents?":"Índice",
  2170. "table of contents":"tabla de contenidos",
  2171. "Table of Contents":"Tabla de Contenidos",
  2172. "restart presentation":"Reiniciar presentación",
  2173. "restart?":"Inicio"
  2174. },
  2175. help_es:
  2176. "Utilice el ratón, barra espaciadora, teclas Izda/Dcha, " +
  2177. "o Re pág y Av pág. Use S y B para cambiar el tamaño de fuente.",
  2178. strings_ca: {
  2179. "slide":"pàg..",
  2180. "help?":"Ajuda",
  2181. "contents?":"Índex",
  2182. "table of contents":"taula de continguts",
  2183. "Table of Contents":"Taula de Continguts",
  2184. "restart presentation":"Reiniciar presentació",
  2185. "restart?":"Inici"
  2186. },
  2187. help_ca:
  2188. "Utilitzi el ratolí, barra espaiadora, tecles Esq./Dta. " +
  2189. "o Re pàg y Av pàg. Usi S i B per canviar grandària de font.",
  2190. strings_cs: {
  2191. "slide":"snímek",
  2192. "help?":"nápověda",
  2193. "contents?":"obsah",
  2194. "table of contents":"obsah prezentace",
  2195. "Table of Contents":"Obsah prezentace",
  2196. "restart presentation":"znovu spustit prezentaci",
  2197. "restart?":"restart"
  2198. },
  2199. help_cs:
  2200. "Prezentaci můžete procházet pomocí kliknutí myši, mezerníku, " +
  2201. "šipek vlevo a vpravo nebo kláves PageUp a PageDown. Písmo se " +
  2202. "dá zvětšit a zmenšit pomocí kláves B a S.",
  2203. strings_nl: {
  2204. "slide":"pagina",
  2205. "help?":"Help?",
  2206. "contents?":"Inhoud?",
  2207. "table of contents":"inhoudsopgave",
  2208. "Table of Contents":"Inhoudsopgave",
  2209. "restart presentation":"herstart presentatie",
  2210. "restart?":"Herstart?"
  2211. },
  2212. help_nl:
  2213. "Navigeer d.m.v. het muis, spatiebar, Links/Rechts toetsen, " +
  2214. "of PgUp en PgDn. Gebruik S en B om de karaktergrootte te veranderen.",
  2215. strings_de: {
  2216. "slide":"Seite",
  2217. "help?":"Hilfe",
  2218. "contents?":"Übersicht",
  2219. "table of contents":"Inhaltsverzeichnis",
  2220. "Table of Contents":"Inhaltsverzeichnis",
  2221. "restart presentation":"Präsentation neu starten",
  2222. "restart?":"Neustart"
  2223. },
  2224. help_de:
  2225. "Benutzen Sie die Maus, Leerschlag, die Cursortasten links/rechts oder " +
  2226. "Page up/Page Down zum Wechseln der Seiten und S und B für die Schriftgrösse.",
  2227. strings_pl: {
  2228. "slide":"slajd",
  2229. "help?":"pomoc?",
  2230. "contents?":"spis treści?",
  2231. "table of contents":"spis treści",
  2232. "Table of Contents":"Spis Treści",
  2233. "restart presentation":"Restartuj prezentację",
  2234. "restart?":"restart?"
  2235. },
  2236. help_pl:
  2237. "Zmieniaj slajdy klikając myszą, naciskając spację, strzałki lewo/prawo" +
  2238. "lub PgUp / PgDn. Użyj klawiszy S i B, aby zmienić rozmiar czczionki.",
  2239. strings_fr: {
  2240. "slide":"page",
  2241. "help?":"Aide",
  2242. "contents?":"Index",
  2243. "table of contents":"table des matières",
  2244. "Table of Contents":"Table des matières",
  2245. "restart presentation":"Recommencer l'exposé",
  2246. "restart?":"Début"
  2247. },
  2248. help_fr:
  2249. "Naviguez avec la souris, la barre d'espace, les flèches " +
  2250. "gauche/droite ou les touches Pg Up, Pg Dn. Utilisez " +
  2251. "les touches S et B pour modifier la taille de la police.",
  2252. strings_hu: {
  2253. "slide":"oldal",
  2254. "help?":"segítség",
  2255. "contents?":"tartalom",
  2256. "table of contents":"tartalomjegyzék",
  2257. "Table of Contents":"Tartalomjegyzék",
  2258. "restart presentation":"bemutató újraindítása",
  2259. "restart?":"újraindítás"
  2260. },
  2261. help_hu:
  2262. "Az oldalak közti lépkedéshez kattintson az egérrel, vagy " +
  2263. "használja a szóköz, a bal, vagy a jobb nyíl, illetve a Page Down, " +
  2264. "Page Up billentyűket. Az S és a B billentyűkkel változtathatja " +
  2265. "a szöveg méretét.",
  2266. strings_it: {
  2267. "slide":"pag.",
  2268. "help?":"Aiuto",
  2269. "contents?":"Indice",
  2270. "table of contents":"indice",
  2271. "Table of Contents":"Indice",
  2272. "restart presentation":"Ricominciare la presentazione",
  2273. "restart?":"Inizio"
  2274. },
  2275. help_it:
  2276. "Navigare con mouse, barra spazio, frecce sinistra/destra o " +
  2277. "PgUp e PgDn. Usare S e B per cambiare la dimensione dei caratteri.",
  2278. strings_el: {
  2279. "slide":"σελίδα",
  2280. "help?":"βοήθεια;",
  2281. "contents?":"περιεχόμενα;",
  2282. "table of contents":"πίνακας περιεχομένων",
  2283. "Table of Contents":"Πίνακας Περιεχομένων",
  2284. "restart presentation":"επανεκκίνηση παρουσίασης",
  2285. "restart?":"επανεκκίνηση;"
  2286. },
  2287. help_el:
  2288. "Πλοηγηθείτε με το κλίκ του ποντικιού, το space, τα βέλη αριστερά/δεξιά, " +
  2289. "ή Page Up και Page Down. Χρησιμοποιήστε τα πλήκτρα S και B για να αλλάξετε " +
  2290. "το μέγεθος της γραμματοσειράς.",
  2291. strings_ja: {
  2292. "slide":"スライド",
  2293. "help?":"ヘルプ",
  2294. "contents?":"目次",
  2295. "table of contents":"目次を表示",
  2296. "Table of Contents":"目次",
  2297. "restart presentation":"最初から再生",
  2298. "restart?":"最初から"
  2299. },
  2300. help_ja:
  2301. "マウス左クリック ・ スペース ・ 左右キー " +
  2302. "または Page Up ・ Page Downで操作, S ・ Bでフォントサイズ変更",
  2303. strings_zh: {
  2304. "slide":"幻灯片",
  2305. "help?":"帮助?",
  2306. "contents?":"内容?",
  2307. "table of contents":"目录",
  2308. "Table of Contents":"目录",
  2309. "restart presentation":"重新启动展示",
  2310. "restart?":"重新启动?"
  2311. },
  2312. help_zh:
  2313. "用鼠标点击, 空格条, 左右箭头, Pg Up 和 Pg Dn 导航. " +
  2314. "用 S, B 改变字体大小.",
  2315. strings_ru: {
  2316. "slide":"слайд",
  2317. "help?":"помощь?",
  2318. "contents?":"содержание?",
  2319. "table of contents":"оглавление",
  2320. "Table of Contents":"Оглавление",
  2321. "restart presentation":"перезапустить презентацию",
  2322. "restart?":"перезапуск?"
  2323. },
  2324. help_ru:
  2325. "Перемещайтесь кликая мышкой, используя клавишу пробел, стрелки" +
  2326. "влево/вправо или Pg Up и Pg Dn. Клавиши S и B меняют размер шрифта.",
  2327. strings_sv: {
  2328. "slide":"sida",
  2329. "help?":"hjälp",
  2330. "contents?":"innehåll",
  2331. "table of contents":"innehållsförteckning",
  2332. "Table of Contents":"Innehållsförteckning",
  2333. "restart presentation":"visa presentationen från början",
  2334. "restart?":"börja om"
  2335. },
  2336. help_sv:
  2337. "Bläddra med ett klick med vänstra musknappen, mellanslagstangenten, " +
  2338. "vänster- och högerpiltangenterna eller tangenterna Pg Up, Pg Dn. " +
  2339. "Använd tangenterna S och B för att ändra textens storlek.",
  2340. strings: { },
  2341. localize: function (src) {
  2342. if (src == "")
  2343. return src;
  2344. // try full language code, e.g. en-US
  2345. var s, lookup = w3c_slidy.strings[w3c_slidy.lang];
  2346. if (lookup)
  2347. {
  2348. s = lookup[src];
  2349. if (s)
  2350. return s;
  2351. }
  2352. // strip country code suffix, e.g.
  2353. // try en if undefined for en-US
  2354. var lg = w3c_slidy.lang.split("-");
  2355. if (lg.length > 1)
  2356. {
  2357. lookup = w3c_slidy.strings[lg[0]];
  2358. if (lookup)
  2359. {
  2360. s = lookup[src];
  2361. if (s)
  2362. return s;
  2363. }
  2364. }
  2365. // otherwise string as is
  2366. return src;
  2367. },
  2368. init_localization: function () {
  2369. var i18n = w3c_slidy;
  2370. var help_text = w3c_slidy.help_text;
  2371. // each such language array is declared in the localize array
  2372. // this is used as in w3c_slidy.localize("foo");
  2373. this.strings = {
  2374. "es":this.strings_es,
  2375. "ca":this.strings_ca,
  2376. "cs":this.strings_cs,
  2377. "nl":this.strings_nl,
  2378. "de":this.strings_de,
  2379. "pl":this.strings_pl,
  2380. "fr":this.strings_fr,
  2381. "hu":this.strings_hu,
  2382. "it":this.strings_it,
  2383. "el":this.strings_el,
  2384. "jp":this.strings_ja,
  2385. "zh":this.strings_zh,
  2386. "ru":this.strings_ru,
  2387. "sv":this.strings_sv
  2388. },
  2389. i18n.strings_es[help_text] = i18n.help_es;
  2390. i18n.strings_ca[help_text] = i18n.help_ca;
  2391. i18n.strings_cs[help_text] = i18n.help_cs;
  2392. i18n.strings_nl[help_text] = i18n.help_nl;
  2393. i18n.strings_de[help_text] = i18n.help_de;
  2394. i18n.strings_pl[help_text] = i18n.help_pl;
  2395. i18n.strings_fr[help_text] = i18n.help_fr;
  2396. i18n.strings_hu[help_text] = i18n.help_hu;
  2397. i18n.strings_it[help_text] = i18n.help_it;
  2398. i18n.strings_el[help_text] = i18n.help_el;
  2399. i18n.strings_ja[help_text] = i18n.help_ja;
  2400. i18n.strings_zh[help_text] = i18n.help_zh;
  2401. i18n.strings_ru[help_text] = i18n.help_ru;
  2402. i18n.strings_sv[help_text] = i18n.help_sv;
  2403. w3c_slidy.lang = document.body.parentNode.getAttribute("lang");
  2404. if (!w3c_slidy.lang)
  2405. w3c_slidy.lang = document.body.parentNode.getAttribute("xml:lang");
  2406. if (!w3c_slidy.lang)
  2407. w3c_slidy.lang = "en";
  2408. }
  2409. };
  2410. // hack for back button behavior
  2411. if (w3c_slidy.ie6 || w3c_slidy.ie7)
  2412. {
  2413. document.write("<iframe id='historyFrame' " +
  2414. "src='javascript:\"<html"+"></"+"html>\"' " +
  2415. "height='1' width='1' " +
  2416. "style='position:absolute;left:-800px'></iframe>");
  2417. }
  2418. // attach event listeners for initialization
  2419. w3c_slidy.set_up();
  2420. // hide the slides as soon as body element is available
  2421. // to reduce annoying screen mess before the onload event
  2422. setTimeout(w3c_slidy.hide_slides, 50);