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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e325c1dbad022344147a475103c01c68b9592584
4
- data.tar.gz: 784d73087e3934e7b5310e624fd1666e4a7f6f99
3
+ metadata.gz: 4edcfe95816075e7070a7472e68f2f4f21b6c6b6
4
+ data.tar.gz: cced4bd53a7d8f3bb6cbe3908424ad0a4c23a245
5
5
  SHA512:
6
- metadata.gz: 3359570ebebc0c6904d9d1edbedd04002b32dacd03ab1fd6ffa55c03e48906d0d0b97cd99beacc624a3bdfc02d6faa0b8af7452a894678ea7c87debd2f98dcd2
7
- data.tar.gz: c5f7a441190afbfcb7c1ad1fe7cf1da6d8032f564bfc7f3e92ca7fb6e8ed3b235989182291a40fb6bf987a357da3c7458737f858a8f6fc84c63cc963c90f2256
6
+ metadata.gz: fa0623cd0f4f127362a77cbd66611146da48a7324027b1670b7310a439fa2e4dd9e4395b5fefd76f9d728a588be94377e20fdfa3ab726e942b816859b63141ac
7
+ data.tar.gz: 64243e4db2523f314378870c63d7b0d69a563e492efbf236ba0cebf22c19fadaa5a64586020e7ee48e45a167130391a7c7ec906aeddd2248e8d78d16910a5ca9
data/bin/prez CHANGED
@@ -2,7 +2,7 @@
2
2
  require "rubygems"
3
3
  gem "coffee-script", "~> 2.3"
4
4
  gem "launchy", "~> 2.4"
5
- gem "prez", "= 0.0.4"
5
+ gem "prez", "= 0.0.5"
6
6
  gem "sass", "~> 3.4"
7
7
  gem "therubyracer", "~> 0.12"
8
8
  gem "thor", "~> 0.19"
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
@@ -2,7 +2,7 @@ module Prez
2
2
  module Version
3
3
  class << self
4
4
  def to_s
5
- "0.0.4"
5
+ "0.0.5"
6
6
  end
7
7
  end
8
8
  end
@@ -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 /^\d+$/.test(hash) && $(".prez-slide[data-slide='#{hash}']", @document).length > 0
26
- @changeSlideTo hash
27
- true
28
- else
29
- false
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
- changeSlideTo: (nextValue) ->
38
- $next = $ ".prez-slide[data-slide='#{nextValue}']", @document
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 = $next.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 = $next.nextAll(".prez-slide").filter -> $(@).slideDuration() <= 0
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
- @options.slideChanged? $next, nextValue
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
- current = parseInt $(".prez-slide:visible", @document).data("slide"), 10
59
- nextValue = current + amount
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(nextValue) && @options.useHash
62
- @document.location.hash = nextValue
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()
@@ -38,6 +38,10 @@ body {
38
38
  &.right-aligned {
39
39
  text-align: right;
40
40
  }
41
+
42
+ .prez-element {
43
+ display: none;
44
+ }
41
45
  }
42
46
 
43
47
  .smaller {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prez
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Virata-Stone