-
Notifications
You must be signed in to change notification settings - Fork 1
/
slidy.js
2930 lines (2398 loc) · 66.4 KB
/
slidy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* slidy.js
Copyright (c) 2005-2009 W3C (MIT, ERCIM, Keio), All Rights Reserved.
W3C liability, trademark, document use and software licensing
rules apply, see:
http://www.w3.org/Consortium/Legal/copyright-documents
http://www.w3.org/Consortium/Legal/copyright-software
*/
var ns_pos = (typeof window.pageYOffset!='undefined');
var khtml = ((navigator.userAgent).indexOf("KHTML") >= 0 ? true : false);
var opera = ((navigator.userAgent).indexOf("Opera") >= 0 ? true : false);
var ie = (typeof document.all != "undefined" && !opera);
var ie7 = (!ns_pos && navigator.userAgent.indexOf("MSIE 7") != -1);
var ie8 = (!ns_pos && navigator.userAgent.indexOf("MSIE 8") != -1);
var slidy_started = false;
if (ie && !ie8)
document.write("<iframe id='historyFrame' src='javascript:\"<html"+"></"+"html>\"' height='1' width='1' style='position:absolute;left:-800px'></iframe>");
// IE only event handlers to ensure all slides are printed
// I don't yet know how to emulate these for other browsers
if (typeof beforePrint != 'undefined')
{
window.onbeforeprint = beforePrint;
window.onafterprint = afterPrint;
}
// to avoid a clash with other scripts or onload attribute on <body>
// we use something smarter than window.onload
//window.onload = startup;
if (ie)
setTimeout(ieSlidyInit, 100);
else if (document.addEventListener)
document.addEventListener("DOMContentLoaded", startup, false);
function ieSlidyInit()
{
if (//document.readyState == "interactive" ||
document.readyState == "complete" ||
document.readyState == "loaded")
{
startup();
}
else
{
setTimeout(ieSlidyInit, 100);
}
}
setTimeout(hideSlides, 50);
function hideSlides()
{
if (document.body)
document.body.style.visibility = "hidden";
else
setTimeout(hideSlides, 50);
}
var slidenum = 0; // integer slide count: 0, 1, 2, ...
var slides; // set to array of slide div's
var slideNumElement; // element containing slide number
var notes; // set to array of handout div's
var backgrounds; // set to array of background div's
var toolbar; // element containing toolbar
var title; // document title
var lastShown = null; // last incrementally shown item
var eos = null; // span element for end of slide indicator
var toc = null; // table of contents
var outline = null; // outline element with the focus
var selectedTextLen; // length of drag selection on document
var viewAll = 0; // 1 to view all slides + handouts
var wantToolbar = 1; // 0 if toolbar isn't wanted
var mouseClickEnabled = true; // enables left click for next slide
var scrollhack = 0; // IE work around for position: fixed
var helpAnchor; // used for keyboard focus hack in showToolbar()
var helpPage = "http://www.w3.org/Talks/Tools/Slidy/help.html";
var helpText = "Navigate with mouse click, space bar, Cursor Left/Right, " +
"or Pg Up and Pg Dn. Use S and B to change font size.";
var sizeIndex = 0;
var sizeAdjustment = 0;
var sizes = new Array("10pt", "12pt", "14pt", "16pt", "18pt", "20pt",
"22pt", "24pt", "26pt", "28pt", "30pt", "32pt");
var okayForIncremental = incrementalElementList();
// needed for efficient resizing
var lastWidth = 0;
var lastHeight = 0;
// Needed for cross browser support for relative width/height on
// object elements. The work around is to save width/height attributes
// and then to recompute absolute width/height dimensions on resizing
var objects;
// updated to language specified by html file
var lang = "en";
//var localize = {};
// for each language there is an associative array
var strings_es = {
"slide":"pág.",
"help?":"Ayuda",
"contents?":"Índice",
"table of contents":"tabla de contenidos",
"Table of Contents":"Tabla de Contenidos",
"restart presentation":"Reiniciar presentación",
"restart?":"Inicio"
};
strings_es[helpText] =
"Utilice el ratón, barra espaciadora, teclas Izda/Dcha, " +
"o Re pág y Av pág. Use S y B para cambiar el tamaño de fuente.";
var strings_ca = {
"slide":"pàg..",
"help?":"Ajuda",
"contents?":"Índex",
"table of contents":"taula de continguts",
"Table of Contents":"Taula de Continguts",
"restart presentation":"Reiniciar presentació",
"restart?":"Inici"
};
strings_ca[helpText] =
"Utilitzi el ratolí, barra espaiadora, tecles Esq./Dta. " +
"o Re pàg y Av pàg. Usi S i B per canviar grandària de font.";
var strings_nl = {
"slide":"pagina",
"help?":"Help?",
"contents?":"Inhoud?",
"table of contents":"inhoudsopgave",
"Table of Contents":"Inhoudsopgave",
"restart presentation":"herstart presentatie",
"restart?":"Herstart?"
};
strings_nl[helpText] =
"Navigeer d.m.v. het muis, spatiebar, Links/Rechts toetsen, " +
"of PgUp en PgDn. Gebruik S en B om de karaktergrootte te veranderen.";
var strings_de = {
"slide":"Seite",
"help?":"Hilfe",
"contents?":"Übersicht",
"table of contents":"Inhaltsverzeichnis",
"Table of Contents":"Inhaltsverzeichnis",
"restart presentation":"Präsentation neu starten",
"restart?":"Neustart"
};
strings_de[helpText] =
"Benutzen Sie die Maus, Leerschlag, die Cursortasten links/rechts oder " +
"Page up/Page Down zum Wechseln der Seiten und S und B für die Schriftgrösse.";
var strings_pl = {
"slide":"slajd",
"help?":"pomoc?",
"contents?":"spis treści?",
"table of contents":"spis treści",
"Table of Contents":"Spis Treści",
"restart presentation":"Restartuj prezentację",
"restart?":"restart?"
};
strings_pl[helpText] =
"Zmieniaj slajdy klikając myszą, naciskając spację, strzałki lewo/prawo" +
"lub PgUp / PgDn. Użyj klawiszy S i B, aby zmienić rozmiar czczionki.";
var strings_fr = {
"slide":"page",
"help?":"Aide",
"contents?":"Index",
"table of contents":"table des matières",
"Table of Contents":"Table des matières",
"restart presentation":"Recommencer l'exposé",
"restart?":"Début"
};
strings_fr[helpText] =
"Naviguez avec la souris, la barre d'espace, les flèches " +
"gauche/droite ou les touches Pg Up, Pg Dn. Utilisez " +
"les touches S et B pour modifier la taille de la police.";
var strings_hu = {
"slide":"oldal",
"help?":"segítség",
"contents?":"tartalom",
"table of contents":"tartalomjegyzék",
"Table of Contents":"Tartalomjegyzék",
"restart presentation":"bemutató újraindítása",
"restart?":"újraindítás"
};
strings_hu[helpText] =
"Az oldalak közti lépkedéshez kattintson az egérrel, vagy " +
"használja a szóköz, a bal, vagy a jobb nyíl, illetve a Page Down, " +
"Page Up billentyűket. Az S és a B billentyűkkel változtathatja " +
"a szöveg méretét.";
var strings_it = {
"slide":"pag.",
"help?":"Aiuto",
"contents?":"Indice",
"table of contents":"indice",
"Table of Contents":"Indice",
"restart presentation":"Ricominciare la presentazione",
"restart?":"Inizio"
};
strings_it[helpText] =
"Navigare con mouse, barra spazio, frecce sinistra/destra o " +
"PgUp e PgDn. Usare S e B per cambiare la dimensione dei caratteri.";
var strings_el = {
"slide":"σελίδα",
"help?":"βοήθεια;",
"contents?":"περιεχόμενα;",
"table of contents":"πίνακας περιεχομένων",
"Table of Contents":"Πίνακας Περιεχομένων",
"restart presentation":"επανεκκίνηση παρουσίασης",
"restart?":"επανεκκίνηση;"
};
strings_el[helpText] =
"Πλοηγηθείτε με το κλίκ του ποντικιού, το space, τα βέλη αριστερά/δεξιά, " +
"ή Page Up και Page Down. Χρησιμοποιήστε τα πλήκτρα S και B για να αλλάξετε " +
"το μέγεθος της γραμματοσειράς.";
var strings_ja = {
"slide":"スライド",
"help?":"ヘルプ",
"contents?":"目次",
"table of contents":"目次を表示",
"Table of Contents":"目次",
"restart presentation":"最初から再生",
"restart?":"最初から"
};
strings_ja[helpText] =
"マウス左クリック ・ スペース ・ 左右キー " +
"または Page Up ・ Page Downで操作, S ・ Bでフォントサイズ変更";
var strings_zh = {
"slide":"幻灯片",
"help?":"帮助?",
"contents?":"内容?",
"table of contents":"目录",
"Table of Contents":"目录",
"restart presentation":"重新启动展示",
"restart?":"重新启动?"
};
strings_zh[helpText] =
"用鼠标点击, 空格条, 左右箭头, Pg Up 和 Pg Dn 导航. " +
"用 S, B 改变字体大小.";
var strings_ru = {
"slide":"слайд",
"help?":"помощь?",
"contents?":"содержание?",
"table of contents":"оглавление",
"Table of Contents":"Оглавление",
"restart presentation":"перезапустить презентацию",
"restart?":"перезапуск?"
};
strings_ru[helpText] =
"Перемещайтесь кликая мышкой, используя клавишу пробел, стрелки" +
"влево/вправо или Pg Up и Pg Dn. Клавиши S и B меняют размер шрифта.";
// each such language array is declared in the localize array
// used indirectly as in help.innerHTML = "help".localize();
var localize = {
"es":strings_es,
"ca":strings_ca,
"nl":strings_nl,
"de":strings_de,
"pl":strings_pl,
"fr":strings_fr,
"hu":strings_hu,
"it":strings_it,
"el":strings_el,
"jp":strings_ja,
"zh":strings_zh,
"ru":strings_ru
};
/* general initialization */
function startup()
{
if (slidy_started)
{
alert("already started");
return;
}
slidy_started = true;
// find human language from html element
// for use in localizing strings
lang = document.body.parentNode.getAttribute("lang");
if (!lang)
lang = document.body.parentNode.getAttribute("xml:lang");
if (!lang)
lang = "en";
document.body.style.visibility = "visible";
title = document.title;
toolbar = addToolbar();
wrapImplicitSlides();
slides = collectSlides();
notes = collectNotes();
objects = document.body.getElementsByTagName("object");
backgrounds = collectBackgrounds();
patchAnchors();
slidenum = findSlideNumber(location.href);
window.offscreenbuffering = true;
sizeAdjustment = findSizeAdjust();
hideImageToolbar(); // suppress IE image toolbar popup
initOutliner(); // activate fold/unfold support
if (slides.length > 0)
{
var slide = slides[slidenum];
slide.style.position = "absolute";
if (slidenum > 0)
{
setVisibilityAllIncremental("visible");
lastShown = previousIncrementalItem(null);
setEosStatus(true);
}
else
{
lastShown = null;
setVisibilityAllIncremental("hidden");
setEosStatus(!nextIncrementalItem(lastShown));
}
setLocation();
}
toc = tableOfContents();
hideTableOfContents();
// bind event handlers
document.onclick = mouseButtonClick;
document.onmouseup = mouseButtonUp;
document.onkeydown = keyDown;
window.onresize = resized;
window.onscroll = scrolled;
window.onunload = unloaded;
singleSlideView();
setLocation();
resized();
if (ie7)
setTimeout("ieHack()", 100);
showToolbar();
setInterval("checkLocation()", 200); // for back button detection
}
// add localize method to all strings for use
// as in help.innerHTML = "help".localize();
String.prototype.localize = function()
{
if (this == "")
return this;
// try full language code, e.g. en-US
var s, lookup = localize[lang];
if (lookup)
{
s = lookup[this];
if (s)
return s;
}
// try en if undefined for en-US
var lg = lang.split("-");
if (lg.length > 1)
{
lookup = localize[lg[0]];
if (lookup)
{
s = lookup[this];
if (s)
return s;
}
}
// otherwise string as is
return this;
}
// suppress IE's image toolbar pop up
function hideImageToolbar()
{
if (!ns_pos)
{
var images = document.getElementsByTagName("IMG");
for (var i = 0; i < images.length; ++i)
images[i].setAttribute("galleryimg", "no");
}
}
// hack to persuade IE to compute correct document height
// as needed for simulating fixed positioning of toolbar
function ieHack()
{
window.resizeBy(0,-1);
window.resizeBy(0, 1);
}
function unloaded(e)
{
//alert("unloaded");
}
// Firefox reload SVG bug work around
function reload(e)
{
if (!e)
var e = window.event;
hideBackgrounds();
setTimeout("document.reload();", 100);
stopPropagation(e);
e.cancel = true;
e.returnValue = false;
return false;
}
// Safari and Konqueror don't yet support getComputedStyle()
// and they always reload page when location.href is updated
function isKHTML()
{
var agent = navigator.userAgent;
return (agent.indexOf("KHTML") >= 0 ? true : false);
}
function resized()
{
var width = 0;
if ( typeof( window.innerWidth ) == 'number' )
width = window.innerWidth; // Non IE browser
else if (document.documentElement && document.documentElement.clientWidth)
width = document.documentElement.clientWidth; // IE6
else if (document.body && document.body.clientWidth)
width = document.body.clientWidth; // IE4
var height = 0;
if ( typeof( window.innerHeight ) == 'number' )
height = window.innerHeight; // Non IE browser
else if (document.documentElement && document.documentElement.clientHeight)
height = document.documentElement.clientHeight; // IE6
else if (document.body && document.body.clientHeight)
height = document.body.clientHeight; // IE4
if (height && (width/height > 1.05*1024/768))
{
width = height * 1024.0/768;
}
// IE fires onresize even when only font size is changed!
// so we do a check to avoid blocking < and > actions
if (width != lastWidth || height != lastHeight)
{
if (width >= 1100)
sizeIndex = 5; // 4
else if (width >= 1000)
sizeIndex = 4; // 3
else if (width >= 800)
sizeIndex = 3; // 2
else if (width >= 600)
sizeIndex = 2; // 1
else if (width)
sizeIndex = 0;
// add in font size adjustment from meta element e.g.
// <meta name="font-size-adjustment" content="-2" />
// useful when slides have too much content ;-)
if (0 <= sizeIndex + sizeAdjustment &&
sizeIndex + sizeAdjustment < sizes.length)
sizeIndex = sizeIndex + sizeAdjustment;
// enables cross browser use of relative width/height
// on object elements for use with SVG and Flash media
adjustObjectDimensions(width, height);
document.body.style.fontSize = sizes[sizeIndex];
lastWidth = width;
lastHeight = height;
// force reflow to work around Mozilla bug
//if (ns_pos)
{
var slide = slides[slidenum];
hideSlide(slide);
showSlide(slide);
}
// force correct positioning of toolbar
refreshToolbar(200);
}
}
function scrolled()
{
if (toolbar && !ns_pos && !ie7)
{
hackoffset = scrollXOffset();
// hide toolbar
toolbar.style.display = "none";
// make it reappear later
if (scrollhack == 0 && !viewAll)
{
setTimeout(showToolbar, 1000);
scrollhack = 1;
}
}
}
// used to ensure IE refreshes toolbar in correct position
function refreshToolbar(interval)
{
if (!ns_pos && !ie7)
{
hideToolbar();
setTimeout(showToolbar, interval);
}
}
// restores toolbar after short delay
function showToolbar()
{
if (wantToolbar)
{
if (!ns_pos)
{
// adjust position to allow for scrolling
var xoffset = scrollXOffset();
toolbar.style.left = xoffset;
toolbar.style.right = xoffset;
// determine vertical scroll offset
//var yoffset = scrollYOffset();
// bottom is doc height - window height - scroll offset
//var bottom = documentHeight() - lastHeight - yoffset
//if (yoffset > 0 || documentHeight() > lastHeight)
// bottom += 16; // allow for height of scrollbar
toolbar.style.bottom = 0; //bottom;
}
toolbar.style.display = "block";
toolbar.style.visibility = "visible";
}
scrollhack = 0;
// set the keyboard focus to the help link on the
// toolbar to ensure that document has the focus
// IE doesn't always work with window.focus()
// and this hack has benefit of Enter for help
try
{
if (!opera)
helpAnchor.focus();
}
catch (e)
{
}
}
function hideToolbar()
{
toolbar.style.display = "none";
toolbar.style.visibility = "hidden";
window.focus();
}
// invoked via F key
function toggleToolbar()
{
if (!viewAll)
{
if (toolbar.style.display == "none")
{
toolbar.style.display = "block";
toolbar.style.visibility = "visible";
wantToolbar = 1;
}
else
{
toolbar.style.display = "none";
toolbar.style.visibility = "hidden";
wantToolbar = 0;
}
}
}
function scrollXOffset()
{
if (window.pageXOffset)
return self.pageXOffset;
if (document.documentElement &&
document.documentElement.scrollLeft)
return document.documentElement.scrollLeft;
if (document.body)
return document.body.scrollLeft;
return 0;
}
function scrollYOffset()
{
if (window.pageYOffset)
return self.pageYOffset;
if (document.documentElement &&
document.documentElement.scrollTop)
return document.documentElement.scrollTop;
if (document.body)
return document.body.scrollTop;
return 0;
}
// looking for a way to determine height of slide content
// the slide itself is set to the height of the window
function optimizeFontSize()
{
var slide = slides[slidenum];
//var dh = documentHeight(); //getDocHeight(document);
var dh = slide.scrollHeight;
var wh = getWindowHeight();
var u = 100 * dh / wh;
alert("window utilization = " + u + "% (doc "
+ dh + " win " + wh + ")");
}
function getDocHeight(doc) // from document object
{
if (!doc)
doc = document;
if (doc && doc.body && doc.body.offsetHeight)
return doc.body.offsetHeight; // ns/gecko syntax
if (doc && doc.body && doc.body.scrollHeight)
return doc.body.scrollHeight;
alert("couldn't determine document height");
}
function getWindowHeight()
{
if ( typeof( window.innerHeight ) == 'number' )
return window.innerHeight; // Non IE browser
if (document.documentElement && document.documentElement.clientHeight)
return document.documentElement.clientHeight; // IE6
if (document.body && document.body.clientHeight)
return document.body.clientHeight; // IE4
}
function documentHeight()
{
var sh, oh;
sh = document.body.scrollHeight;
oh = document.body.offsetHeight;
if (sh && oh)
{
return (sh > oh ? sh : oh);
}
// no idea!
return 0;
}
function smaller()
{
if (sizeIndex > 0)
{
--sizeIndex;
}
toolbar.style.display = "none";
document.body.style.fontSize = sizes[sizeIndex];
var slide = slides[slidenum];
hideSlide(slide);
showSlide(slide);
setTimeout(showToolbar, 300);
}
function bigger()
{
if (sizeIndex < sizes.length - 1)
{
++sizeIndex;
}
toolbar.style.display = "none";
document.body.style.fontSize = sizes[sizeIndex];
var slide = slides[slidenum];
hideSlide(slide);
showSlide(slide);
setTimeout(showToolbar, 300);
}
// enables cross browser use of relative width/height
// on object elements for use with SVG and Flash media
// with thanks to Ivan Herman for the suggestion
function adjustObjectDimensions(width, height)
{
for( var i = 0; i < objects.length; i++ )
{
var obj = objects[i];
var mimeType = obj.getAttribute("type");
if (mimeType == "image/svg+xml" || mimeType == "application/x-shockwave-flash")
{
if ( !obj.initialWidth )
obj.initialWidth = obj.getAttribute("width");
if ( !obj.initialHeight )
obj.initialHeight = obj.getAttribute("height");
if ( obj.initialWidth && obj.initialWidth.charAt(obj.initialWidth.length-1) == "%" )
{
var w = parseInt(obj.initialWidth.slice(0, obj.initialWidth.length-1));
var newW = width * (w/100.0);
obj.setAttribute("width",newW);
}
if ( obj.initialHeight && obj.initialHeight.charAt(obj.initialHeight.length-1) == "%" )
{
var h = parseInt(obj.initialHeight.slice(0, obj.initialHeight.length-1));
var newH = height * (h/100.0);
obj.setAttribute("height", newH);
}
}
}
}
function cancel(event)
{
if (event)
{
event.cancel = true;
event.returnValue = false;
if (event.preventDefault)
event.preventDefault();
}
return false;
}
// See e.g. http://www.quirksmode.org/js/events/keys.html for keycodes
function keyDown(event)
{
var key;
if (!event)
var event = window.event;
// kludge around NS/IE differences
if (window.event)
key = window.event.keyCode;
else if (event.which)
key = event.which;
else
return true; // Yikes! unknown browser
// ignore event if key value is zero
// as for alt on Opera and Konqueror
if (!key)
return true;
// check for concurrent control/command/alt key
// but are these only present on mouse events?
if (event.ctrlKey || event.altKey || event.metaKey)
return true;
// dismiss table of contents if visible
if (isShownToc() && key != 9 && key != 16 && key != 38 && key != 40)
{
hideTableOfContents();
if (key == 27 || key == 84 || key == 67)
return cancel(event);
}
if (key == 34) // Page Down
{
if (viewAll)
return true;
nextSlide(false);
return cancel(event);
}
else if (key == 33) // Page Up
{
if (viewAll)
return true;
previousSlide(false);
return cancel(event);
}
else if (key == 32) // space bar
{
nextSlide(true);
return cancel(event);
}
else if (key == 37) // Left arrow
{
previousSlide(!event.shiftKey);
return cancel(event);
}
else if (key == 36) // Home
{
firstSlide();
return cancel(event);
}
else if (key == 35) // End
{
lastSlide();
return cancel(event);
}
else if (key == 39) // Right arrow
{
nextSlide(!event.shiftKey);
return cancel(event);
}
else if (key == 13) // Enter
{
if (outline)
{
if (outline.visible)
fold(outline);
else
unfold(outline);
return cancel(event);
}
}
else if (key == 188) // < for smaller fonts
{
smaller();
return cancel(event);
}
else if (key == 190) // > for larger fonts
{
bigger();
return cancel(event);
}
else if (key == 189 || key == 109) // - for smaller fonts
{
smaller();
return cancel(event);
}
else if (key == 187 || key == 191 || key == 107) // = + for larger fonts
{
bigger();
return cancel(event);
}
else if (key == 83) // S for smaller fonts
{
smaller();
return cancel(event);
}
else if (key == 66) // B for larger fonts
{
bigger();
return cancel(event);
}
else if (key == 90) // Z for last slide
{
lastSlide();
return cancel(event);
}
else if (key == 70) // F for toggle toolbar
{
toggleToolbar();
return cancel(event);
}
else if (key == 65) // A for toggle view single/all slides
{
toggleView();
return cancel(event);
}
else if (key == 75) // toggle action of left click for next page
{
mouseClickEnabled = !mouseClickEnabled;
alert((mouseClickEnabled ? "enabled" : "disabled") + " mouse click advance");
return cancel(event);
}
else if (key == 84 || key == 67) // T or C for table of contents
{
if (toc)
showTableOfContents();
return cancel(event);
}
else if (key == 72) // H for help
{
window.location = helpPage;
return cancel(event);
}
//else if (key == 93) // Windows menu key
//alert("lastShown is " + lastShown);
//else alert("key code is "+ key);
return true;
}
// make note of length of selected text
// as this evaluates to zero in click event
function mouseButtonUp(e)
{
selectedTextLen = getSelectedText().length;
}
// right mouse button click is reserved for context menus
// it is more reliable to detect rightclick than leftclick
function mouseButtonClick(e)
{
var rightclick = false;
var leftclick = false;
var middleclick = false;
var target;
if (!e)
var e = window.event;
if (e.target)
target = e.target;
else if (e.srcElement)
target = e.srcElement;
// work around Safari bug
if (target.nodeType == 3)
target = target.parentNode;
if (e.which) // all browsers except IE
{
leftclick = (e.which == 1);
middleclick = (e.which == 2);
rightclick = (e.which == 3);
}
else if (e.button)
{