-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslideshow.coffee~
80 lines (69 loc) · 2.6 KB
/
slideshow.coffee~
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
slideCount = 0 # index of array for <section class="slide">
speakerNotesShown = helpMenuShown = controlsShown = false
slides = document.getElementsByClassName('slide')
notes = document.getElementsByClassName('note')
help = document.getElementsByClassName('help')
controls = document.getElementsByClassName('controls')
load = ->
unless window.location.hash.slice(1).length < 1 # for some reason using unless window.location.hash.slice(1)? ... didn't work
for slide in slides # go through and see if the hash tag in the URL matches any of the ID's for the slides. if not, keep the slideCount at 0
if slide.id == window.location.hash.slice(1)
slideCount = _i
for slide in slides
slide.style.display = 'none'
slides[slideCount].style.display = 'inline'
slideControl = (event) ->
switch event.which
when 110, 78
speakerNotes()
when 37
previousSlide()
when 39
nextSlide()
when 72
helpMenu()
when 67
controlsMenu()
else
nextSlide = ->
slides[slideCount].style.display = "none"
slideCount++ if slideCount < (slides.length - 1)
window.location = "#" + slides[slideCount].id
slides[slideCount].style.display = "inline"
previousSlide = ->
console.log "entering previousSlide()"
slides[slideCount].style.display = "none"
console.log "slide count: #{slideCount}"
slideCount-- if slideCount > 0
console.log "slide count: #{slideCount}"
console.log "slides[slideCount].id: #{slides[slideCount].id}"
window.location = "#" + slides[slideCount].id
console.log "set window.location"
slides[slideCount].style.display = "inline"
changeSlide = (direction) ->
if direction?
if direction is 'next'
nextSlide()
if direction is 'prev'
previousSlide()
# i would like to eventually incorporate a "jump to slide" feature that puts up a little box letting you go back to where you originally came from in the presentation
# that same (above) idea could also be use to create a table of contents
speakerNotes = ->
if speakerNotesShown then hide(notes) else display(notes, 'inline')
speakerNotesShown = !speakerNotesShown
helpMenu = ->
hide(help) if helpMenuShown
display(help) unless helpMenuShown
helpMenuShown = !helpMenuShown
controlsMenu = ->
hide(controls) if controlsShown
display(controls) unless controlsShown
controlsShown = !controlsShown
hide = (group) ->
for thing in group
thing.style.display = 'none'
display = (group, displayType) -> # sets default display type to block, include 'inline' to override
unless displayType?
displayType = 'block'
for thing in group
thing.style.display = displayType