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