prez 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/prez +1 -1
- data/lib/prez/helpers.rb +7 -0
- data/lib/prez/version.rb +1 -1
- data/vendor/javascripts/prez-controller.js.coffee +79 -20
- data/vendor/stylesheets/prez.scss +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4edcfe95816075e7070a7472e68f2f4f21b6c6b6
|
4
|
+
data.tar.gz: cced4bd53a7d8f3bb6cbe3908424ad0a4c23a245
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa0623cd0f4f127362a77cbd66611146da48a7324027b1670b7310a439fa2e4dd9e4395b5fefd76f9d728a588be94377e20fdfa3ab726e942b816859b63141ac
|
7
|
+
data.tar.gz: 64243e4db2523f314378870c63d7b0d69a563e492efbf236ba0cebf22c19fadaa5a64586020e7ee48e45a167130391a7c7ec906aeddd2248e8d78d16910a5ca9
|
data/bin/prez
CHANGED
data/lib/prez/helpers.rb
CHANGED
@@ -76,6 +76,13 @@ module Prez
|
|
76
76
|
concat %{</div>}
|
77
77
|
end
|
78
78
|
|
79
|
+
def element(options = {})
|
80
|
+
tag = options.fetch :tag, :div
|
81
|
+
concat %{<#{tag} class="prez-element">}
|
82
|
+
yield
|
83
|
+
concat %{</#{tag}>}
|
84
|
+
end
|
85
|
+
|
79
86
|
def notes
|
80
87
|
concat %{<div class="prez-notes">}
|
81
88
|
yield
|
data/lib/prez/version.rb
CHANGED
@@ -21,45 +21,104 @@ class Prez
|
|
21
21
|
changeToHashSlide = =>
|
22
22
|
return false unless @options.useHash
|
23
23
|
hash = @document.location.hash.replace /^#/, ""
|
24
|
+
match = /^(\d+)-(\d+)$/.exec hash
|
24
25
|
|
25
|
-
if
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
if match
|
27
|
+
slide = parseInt match[1], 10
|
28
|
+
element = parseInt match[2], 10
|
29
|
+
selector = ".prez-slide[data-slide='#{slide}']"
|
30
|
+
|
31
|
+
if element > 0
|
32
|
+
selector = "#{selector} .prez-element[data-slide-element='#{element}']"
|
33
|
+
|
34
|
+
if $(selector, @document).length > 0
|
35
|
+
@changeSlideTo slide, element
|
36
|
+
return true
|
37
|
+
|
38
|
+
false
|
39
|
+
|
40
|
+
$(".prez-slide", @document).each (i) ->
|
41
|
+
$(@).attr "data-slide", "#{i + 1}"
|
42
|
+
|
43
|
+
$(@).find(".prez-element").each (j) ->
|
44
|
+
$(@).attr "data-slide-element", "#{j + 1}"
|
30
45
|
|
31
|
-
$(".prez-slide", @document).each (i) -> $(@).attr "data-slide", "#{i + 1}"
|
32
46
|
@startTime = Date.now()
|
33
47
|
@changeSlideTo 1 unless changeToHashSlide()
|
34
48
|
$(@window).on "hashchange", changeToHashSlide
|
35
49
|
$(@document).on "keydown", Prez.handlers.keyDown
|
36
50
|
|
37
|
-
|
38
|
-
|
39
|
-
return false if $next.size() == 0
|
40
|
-
$(".prez-slide", @document).hide()
|
41
|
-
$next.show()
|
51
|
+
|
52
|
+
slideStarted: ($slide) ->
|
42
53
|
@slideStartTime = Date.now()
|
43
|
-
@slideDuration = $
|
54
|
+
@slideDuration = $slide.slideDuration()
|
44
55
|
|
45
56
|
# When unspecified, the slide duration is an even amount based
|
46
57
|
# on the remaining slides that don't have a specific duration
|
47
58
|
if @slideDuration <= 0
|
48
|
-
$remainingUntimed = $
|
59
|
+
$remainingUntimed = $slide.nextAll(".prez-slide").filter -> $(@).slideDuration() <= 0
|
49
60
|
@slideDuration = @remainingPresentationSeconds() / ($remainingUntimed.size() + 1)
|
50
61
|
|
51
62
|
if @slideDuration < 0
|
52
63
|
@slideDuration = 0
|
53
64
|
|
54
|
-
|
65
|
+
changeSlideTo: (nextValue, nextElement = 0) ->
|
66
|
+
$next = $ ".prez-slide[data-slide='#{nextValue}']", @document
|
67
|
+
return false if $next.size() == 0
|
68
|
+
|
69
|
+
if nextValue != @currentSlide()
|
70
|
+
$(".prez-slide", @document).hide()
|
71
|
+
$next.show()
|
72
|
+
@slideStarted $next
|
73
|
+
|
74
|
+
if nextElement == 0
|
75
|
+
$next.find(".prez-element").hide()
|
76
|
+
else if @currentElement() > nextElement
|
77
|
+
for i in [@currentElement()..(nextElement + 1)]
|
78
|
+
$next.find(".prez-element[data-slide-element='#{i}']").hide()
|
79
|
+
else if @currentElement() < nextElement
|
80
|
+
for i in [(@currentElement() + 1)..nextElement]
|
81
|
+
$next.find(".prez-element[data-slide-element='#{i}']").show()
|
82
|
+
|
83
|
+
@options.slideChanged? $next, nextValue, nextElement
|
55
84
|
true
|
56
85
|
|
86
|
+
currentSlide: ->
|
87
|
+
return null if $(".prez-slide:visible", @document).size() == 0
|
88
|
+
parseInt $(".prez-slide:visible", @document).data("slide"), 10
|
89
|
+
|
90
|
+
currentElement: ->
|
91
|
+
return null if @currentSlide() == null
|
92
|
+
return 0 if $(".prez-element:visible", @document).size() == 0
|
93
|
+
parseInt $(".prez-element:visible:last", @document).data("slide-element"), 10
|
94
|
+
|
95
|
+
countSlideElements: (slide) ->
|
96
|
+
$slide = $(".prez-slide[data-slide='#{slide}']", @document)
|
97
|
+
return 0 if $slide.size() == 0
|
98
|
+
$slide.find(".prez-element").size()
|
99
|
+
|
57
100
|
changeSlideBy: (amount) ->
|
58
|
-
|
59
|
-
|
101
|
+
slide = @currentSlide()
|
102
|
+
element = @currentElement()
|
103
|
+
nextSlide = slide
|
104
|
+
nextElement = element
|
105
|
+
|
106
|
+
for _ in [1..Math.abs(amount)]
|
107
|
+
if amount > 0
|
108
|
+
if nextElement >= @countSlideElements(nextSlide)
|
109
|
+
nextSlide++
|
110
|
+
nextElement = 0
|
111
|
+
else
|
112
|
+
nextElement++
|
113
|
+
else
|
114
|
+
if nextElement <= 0
|
115
|
+
nextSlide--
|
116
|
+
nextElement = @countSlideElements nextSlide
|
117
|
+
else
|
118
|
+
nextElement--
|
60
119
|
|
61
|
-
if @changeSlideTo(
|
62
|
-
@document.location.hash =
|
120
|
+
if @changeSlideTo(nextSlide, nextElement) && @options.useHash
|
121
|
+
@document.location.hash = "#{nextSlide}-#{nextElement}"
|
63
122
|
|
64
123
|
nextSlide: -> @changeSlideBy 1
|
65
124
|
prevSlide: -> @changeSlideBy -1
|
@@ -186,12 +245,12 @@ $(document).on "click", "#launch", (e) ->
|
|
186
245
|
Prez.current = new Prez
|
187
246
|
duration: Prez.timeToSeconds($("#prez-duration").val())
|
188
247
|
window: window.open("", "prez", "width=640,height=480")
|
189
|
-
slideChanged: ($slide, slideNumber) ->
|
248
|
+
slideChanged: ($slide, slideNumber, elementNumber) ->
|
190
249
|
notes = $slide.find(".prez-notes").html() || ""
|
191
250
|
$("#slide-notes").html notes
|
192
251
|
$(".current-slide-number").text $slide.data("slide")
|
193
252
|
Prez.handlers.timeChange()
|
194
|
-
iframePrez.changeSlideTo slideNumber
|
253
|
+
iframePrez.changeSlideTo slideNumber, elementNumber
|
195
254
|
|
196
255
|
$(".total-slides").text $(".prez-slide", Prez.current.document).size()
|
197
256
|
$("#pre-launch").hide()
|