prez 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/prez.rb +13 -12
- data/lib/prez/assets.rb +4 -0
- data/lib/prez/helpers.rb +44 -4
- data/lib/prez/javascript_element.rb +31 -0
- data/lib/prez/version.rb +1 -1
- data/templates/build.html.tt +24 -1
- data/vendor/javascripts/prez-controller.js.coffee +38 -4
- data/vendor/stylesheets/prez.scss +40 -16
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61bd46e9dbbcaa94c63e40f43c90798044fe6b9f
|
4
|
+
data.tar.gz: e9864049a4427603b161277065a74c28ab2e43f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bfb70b26ef52434c4f070fe251ef92fd8ba3504826bb88193b042cc9494a54137933f7872ad9486b157930ddf9ef356c9fb5133a2cd35733e0795a8a281393f
|
7
|
+
data.tar.gz: 3752d8e50eba7f00b3bc78778a04b2f664a780883bb2c256e4434e60d1c4df631847c6dd3826f66e8184c1a7324133b0e9eb57f4c755404777c0cbbb58f46655
|
data/lib/prez.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
module Prez
|
2
|
-
autoload :Assets,
|
3
|
-
autoload :Build,
|
4
|
-
autoload :Builder,
|
5
|
-
autoload :Cache,
|
6
|
-
autoload :CLI,
|
7
|
-
autoload :DataUri,
|
8
|
-
autoload :Error,
|
9
|
-
autoload :Files,
|
10
|
-
autoload :Helpers,
|
11
|
-
autoload :
|
12
|
-
autoload :
|
13
|
-
autoload :
|
2
|
+
autoload :Assets, "prez/assets"
|
3
|
+
autoload :Build, "prez/build"
|
4
|
+
autoload :Builder, "prez/builder"
|
5
|
+
autoload :Cache, "prez/cache"
|
6
|
+
autoload :CLI, "prez/cli"
|
7
|
+
autoload :DataUri, "prez/data_uri"
|
8
|
+
autoload :Error, "prez/error"
|
9
|
+
autoload :Files, "prez/files"
|
10
|
+
autoload :Helpers, "prez/helpers"
|
11
|
+
autoload :JavascriptElement, "prez/javascript_element"
|
12
|
+
autoload :New, "prez/new"
|
13
|
+
autoload :Start, "prez/start"
|
14
|
+
autoload :Version, "prez/version"
|
14
15
|
end
|
data/lib/prez/assets.rb
CHANGED
data/lib/prez/helpers.rb
CHANGED
@@ -5,6 +5,7 @@ module Prez
|
|
5
5
|
protected
|
6
6
|
|
7
7
|
def reset_helpers!
|
8
|
+
@launch = :choose
|
8
9
|
@duration = nil
|
9
10
|
end
|
10
11
|
|
@@ -50,6 +51,18 @@ module Prez
|
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
54
|
+
def launch(new_window: true)
|
55
|
+
if new_window
|
56
|
+
@launch = :new_window
|
57
|
+
else
|
58
|
+
@launch = :current_window
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def launch_type
|
63
|
+
@launch
|
64
|
+
end
|
65
|
+
|
53
66
|
def html_escape(value = nil, &block)
|
54
67
|
if block
|
55
68
|
value = capture &block
|
@@ -76,6 +89,7 @@ module Prez
|
|
76
89
|
|
77
90
|
def slide(options = {})
|
78
91
|
classes = ["prez-slide"]
|
92
|
+
classes << options[:class] if options[:class]
|
79
93
|
align = options.fetch :align, :center
|
80
94
|
|
81
95
|
case align
|
@@ -84,27 +98,53 @@ module Prez
|
|
84
98
|
when :right
|
85
99
|
classes << "right-aligned"
|
86
100
|
when :center
|
87
|
-
|
101
|
+
classes << "center-aligned"
|
88
102
|
else
|
89
103
|
raise Prez::Error.new("Invalid slide align: #{align.inspect}")
|
90
104
|
end
|
91
105
|
|
106
|
+
attributes = [%{class="#{classes.join " "}"}]
|
107
|
+
|
108
|
+
if options[:id]
|
109
|
+
attributes << %{id="#{options[:id]}"}
|
110
|
+
end
|
111
|
+
|
112
|
+
if options[:style]
|
113
|
+
attributes << %{style="#{options[:style]}"}
|
114
|
+
end
|
115
|
+
|
92
116
|
if options[:duration]
|
93
|
-
|
117
|
+
attributes << %{data-duration="#{options[:duration]}"}
|
94
118
|
end
|
95
119
|
|
96
|
-
concat %{<div
|
120
|
+
concat %{<div #{attributes.join " "}>}
|
97
121
|
yield
|
98
122
|
concat %{</div>}
|
99
123
|
end
|
100
124
|
|
101
125
|
def element(options = {})
|
102
126
|
tag = options.fetch :tag, :div
|
103
|
-
|
127
|
+
classes = ["prez-element"]
|
128
|
+
classes << options[:class] if options[:class]
|
129
|
+
attributes = [%{class="#{classes.join " "}"}]
|
130
|
+
|
131
|
+
if options[:id]
|
132
|
+
attributes << %{id="#{options[:id]}"}
|
133
|
+
end
|
134
|
+
|
135
|
+
if options[:style]
|
136
|
+
attributes << %{style="#{options[:style]}"}
|
137
|
+
end
|
138
|
+
|
139
|
+
concat %{<#{tag} #{attributes.join " "}>}
|
104
140
|
yield
|
105
141
|
concat %{</#{tag}>}
|
106
142
|
end
|
107
143
|
|
144
|
+
def element_js(up:, down:)
|
145
|
+
concat Prez::JavascriptElement.new(capture(&up), capture(&down)).to_s
|
146
|
+
end
|
147
|
+
|
108
148
|
def notes
|
109
149
|
concat %{<div class="prez-notes">}
|
110
150
|
yield
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Prez
|
2
|
+
class JavascriptElement
|
3
|
+
def self.next_id
|
4
|
+
@next_id ||= 0
|
5
|
+
@next_id += 1
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(up, down)
|
9
|
+
@id = Prez::JavascriptElement.next_id
|
10
|
+
@up_js = up
|
11
|
+
@down_js = down
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
<<-EOF
|
16
|
+
<script>
|
17
|
+
window.elementJs = window.elementJs || {};
|
18
|
+
|
19
|
+
window.elementJs.up#{@id} = function($) {
|
20
|
+
#{@up_js}
|
21
|
+
};
|
22
|
+
|
23
|
+
window.elementJs.down#{@id} = function($) {
|
24
|
+
#{@down_js}
|
25
|
+
};
|
26
|
+
</script>
|
27
|
+
<span class="prez-element" data-element-js data-element-js-up="up#{@id}" data-element-js-down="down#{@id}"></span>
|
28
|
+
EOF
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/prez/version.rb
CHANGED
data/templates/build.html.tt
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
|
-
<html lang="en">
|
2
|
+
<html lang="en" data-launch-type="<%= launch_type %>">
|
3
3
|
<head>
|
4
4
|
<meta charset="utf-8">
|
5
5
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
@@ -85,6 +85,29 @@
|
|
85
85
|
</div>
|
86
86
|
</div>
|
87
87
|
</div>
|
88
|
+
|
89
|
+
<div id="new-window-popup-blocked-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="popup-blocked" aria-hidden="true">
|
90
|
+
<div class="modal-dialog">
|
91
|
+
<div class="modal-content">
|
92
|
+
<div class="modal-header">
|
93
|
+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
94
|
+
<h4 class="modal-title" id="popup-blocked">Popup Blocked</h4>
|
95
|
+
</div>
|
96
|
+
|
97
|
+
<div class="modal-body">
|
98
|
+
<p>
|
99
|
+
Sorry, but your new presentation was blocked! Please click
|
100
|
+
'Launch' to try again, or just dismiss this modal.
|
101
|
+
</p>
|
102
|
+
</div>
|
103
|
+
|
104
|
+
<div class="modal-footer">
|
105
|
+
<button type="button" class="btn btn-primary" id="launch-after-blocked">Launch</button>
|
106
|
+
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
107
|
+
</div>
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
</div>
|
88
111
|
</div>
|
89
112
|
</body>
|
90
113
|
</html>
|
@@ -87,13 +87,14 @@ class Prez
|
|
87
87
|
@slideStarted $next
|
88
88
|
|
89
89
|
if nextElement == 0
|
90
|
-
$next.find(".prez-element").
|
90
|
+
$next.find(".prez-element").each (i, e) =>
|
91
|
+
@hideElement $(e)
|
91
92
|
else if @currentElement() > nextElement
|
92
93
|
for i in [@currentElement()..(nextElement + 1)]
|
93
|
-
$next.find(".prez-element[data-slide-element='#{i}']")
|
94
|
+
@hideElement $next.find(".prez-element[data-slide-element='#{i}']")
|
94
95
|
else if @currentElement() < nextElement
|
95
96
|
for i in [(@currentElement() + 1)..nextElement]
|
96
|
-
$next.find(".prez-element[data-slide-element='#{i}']")
|
97
|
+
@showElement $next.find(".prez-element[data-slide-element='#{i}']")
|
97
98
|
|
98
99
|
# Hack to fix Chrome sometimes not rendering opacity changes,
|
99
100
|
# thanks to http://stackoverflow.com/a/8840703/122
|
@@ -103,6 +104,18 @@ class Prez
|
|
103
104
|
@options.slideChanged? $next, nextValue, nextElement
|
104
105
|
true
|
105
106
|
|
107
|
+
hideElement: ($element) ->
|
108
|
+
if $element.is(".visible[data-element-js]")
|
109
|
+
@window.elementJs[$element.data("element-js-down")]($)
|
110
|
+
|
111
|
+
$element.addClass("hidden").removeClass("visible")
|
112
|
+
|
113
|
+
showElement: ($element) ->
|
114
|
+
if $element.is(".hidden[data-element-js]")
|
115
|
+
@window.elementJs[$element.data("element-js-up")]($)
|
116
|
+
|
117
|
+
$element.removeClass("hidden").addClass("visible")
|
118
|
+
|
106
119
|
currentSlide: ->
|
107
120
|
return null if $(".prez-slide:visible", @document).size() == 0
|
108
121
|
parseInt $(".prez-slide:visible", @document).data("slide"), 10
|
@@ -245,6 +258,11 @@ $(document).on "click", "#new-window", (e) ->
|
|
245
258
|
$("#new-window #launch-message").text "Launch in this window"
|
246
259
|
$("#new-window .glyphicon").removeClass("glyphicon-new-window").addClass("glyphicon-unchecked")
|
247
260
|
|
261
|
+
$(document).on "click", "#launch-after-blocked", (e) ->
|
262
|
+
e.preventDefault()
|
263
|
+
$("#new-window-popup-blocked-modal").modal "hide"
|
264
|
+
$("#launch").click()
|
265
|
+
|
248
266
|
$(document).on "click", "#launch", (e) ->
|
249
267
|
e.preventDefault()
|
250
268
|
return if Prez.current
|
@@ -261,6 +279,12 @@ $(document).on "click", "#launch", (e) ->
|
|
261
279
|
|
262
280
|
|
263
281
|
if useNewWindow
|
282
|
+
newWindow = window.open("", "prez", "width=640,height=480")
|
283
|
+
|
284
|
+
unless newWindow
|
285
|
+
$("#new-window-popup-blocked-modal").modal "show"
|
286
|
+
return
|
287
|
+
|
264
288
|
iframePrez = new Prez
|
265
289
|
window: iframe.getFrameWindow()
|
266
290
|
useHash: false
|
@@ -268,7 +292,7 @@ $(document).on "click", "#launch", (e) ->
|
|
268
292
|
|
269
293
|
Prez.current = new Prez
|
270
294
|
duration: Prez.timeToSeconds($("#prez-duration").val())
|
271
|
-
window:
|
295
|
+
window: newWindow
|
272
296
|
slideChanged: ($slide, slideNumber, elementNumber) ->
|
273
297
|
notes = $slide.find(".prez-notes").html() || ""
|
274
298
|
$("#slide-notes").html notes
|
@@ -329,3 +353,13 @@ $(window).bind "beforeunload", ->
|
|
329
353
|
|
330
354
|
$(document).on "keydown", Prez.handlers.keyDown
|
331
355
|
$.setInterval 50, Prez.handlers.timeChange
|
356
|
+
|
357
|
+
$ ->
|
358
|
+
launchType = $("html").data("launch-type")
|
359
|
+
|
360
|
+
if launchType == "new_window"
|
361
|
+
$("#new-window").addClass("active");
|
362
|
+
$("#launch").click()
|
363
|
+
else if launchType == "current_window"
|
364
|
+
$("#new-window").removeClass("active");
|
365
|
+
$("#launch").click()
|
@@ -23,29 +23,17 @@ body {
|
|
23
23
|
}
|
24
24
|
|
25
25
|
.prez-slide {
|
26
|
-
&,
|
26
|
+
&, input, table {
|
27
27
|
font-size: 50;
|
28
28
|
}
|
29
29
|
|
30
30
|
display: none;
|
31
31
|
min-height: $prez-slide-min-height;
|
32
32
|
padding: $prez-padding;
|
33
|
-
text-align: center;
|
34
|
-
|
35
|
-
.center-aligned {
|
36
|
-
text-align: center;
|
37
|
-
}
|
38
|
-
|
39
|
-
&.left-aligned, .left-aligned {
|
40
|
-
text-align: left;
|
41
|
-
}
|
42
|
-
|
43
|
-
.left-aligned {
|
44
|
-
padding-left: 5%;
|
45
|
-
}
|
46
33
|
|
47
|
-
|
48
|
-
|
34
|
+
table td {
|
35
|
+
padding-left: 3%;
|
36
|
+
padding-right: 3%;
|
49
37
|
}
|
50
38
|
|
51
39
|
.prez-element.hide-style.hidden {
|
@@ -57,6 +45,38 @@ body {
|
|
57
45
|
}
|
58
46
|
}
|
59
47
|
|
48
|
+
.center-aligned, .prez-slide .center-aligned {
|
49
|
+
text-align: center;
|
50
|
+
}
|
51
|
+
|
52
|
+
.center-aligned table, .prez-slide table.center-aligned {
|
53
|
+
margin: 0 auto;
|
54
|
+
}
|
55
|
+
|
56
|
+
.left-aligned, .prez-slide .left-aligned {
|
57
|
+
text-align: left;
|
58
|
+
}
|
59
|
+
|
60
|
+
.left-aligned table, .prez-slide table.left-aligned {
|
61
|
+
margin: 0;
|
62
|
+
}
|
63
|
+
|
64
|
+
.left-aligned {
|
65
|
+
padding-left: 5%;
|
66
|
+
}
|
67
|
+
|
68
|
+
.right-aligned, .prez-slide .right-aligned {
|
69
|
+
text-align: right;
|
70
|
+
}
|
71
|
+
|
72
|
+
.right-aligned table, .prez-slide table.right-aligned {
|
73
|
+
margin: 0 0 0 auto;
|
74
|
+
}
|
75
|
+
|
76
|
+
.right-aligned {
|
77
|
+
padding-right: 5%;
|
78
|
+
}
|
79
|
+
|
60
80
|
.pre {
|
61
81
|
font-family: monospace;
|
62
82
|
font-size: 0.9em;
|
@@ -88,6 +108,10 @@ body {
|
|
88
108
|
font-weight: bold;
|
89
109
|
}
|
90
110
|
|
111
|
+
.strikeout {
|
112
|
+
text-decoration: line-through;
|
113
|
+
}
|
114
|
+
|
91
115
|
dt {
|
92
116
|
font-weight: bold;
|
93
117
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prez
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Virata-Stone
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coffee-script
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- lib/prez/error.rb
|
142
142
|
- lib/prez/files.rb
|
143
143
|
- lib/prez/helpers.rb
|
144
|
+
- lib/prez/javascript_element.rb
|
144
145
|
- lib/prez/new.rb
|
145
146
|
- lib/prez/sass_extensions.rb
|
146
147
|
- lib/prez/start.rb
|