shining 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +34 -4
- data/VERSION +1 -1
- data/css/base.css +3 -1
- data/lib/jquery.shining.js +144 -69
- data/shining.gemspec +2 -2
- data/templates/config.json +1 -1
- data/templates/index.html +4 -1
- metadata +2 -2
data/README.markdown
CHANGED
@@ -24,10 +24,23 @@ Which leads us to...
|
|
24
24
|
|
25
25
|
# Configuration
|
26
26
|
|
27
|
-
Presentation-wide configuration happens through the **config.json** file.
|
28
|
-
parameters are
|
29
|
-
|
30
|
-
|
27
|
+
Presentation-wide configuration happens through the **config.json** file. Existing
|
28
|
+
parameters are:
|
29
|
+
|
30
|
+
* slides: an array containing the name of the presentation's slides. If you're using
|
31
|
+
the generator to add slides, don't worry about editing it.
|
32
|
+
* transitions: See next section.
|
33
|
+
|
34
|
+
# Transitions
|
35
|
+
|
36
|
+
Transitions take effect when you navigate back or forward your slides. Valid options are:
|
37
|
+
|
38
|
+
* "fade": Fades slides out/in.
|
39
|
+
* "slide": Slides them horizontally.
|
40
|
+
* "slice": Cool horizontal slicing effect.
|
41
|
+
* false: Setting to false disables transitions altogether.
|
42
|
+
|
43
|
+
For anything not false, make sure you're passing a proper string.
|
31
44
|
|
32
45
|
# Slides
|
33
46
|
|
@@ -55,6 +68,23 @@ Say you have a slide template named **ROOT/slides/test.haml**. Running the afore
|
|
55
68
|
command will generate a new **test.html** from it. Note that this will _overwrite_ an
|
56
69
|
existing **test.html** slide if one exists.
|
57
70
|
|
71
|
+
# Slide scripts
|
72
|
+
|
73
|
+
Slides can have an associated script which you can use to trigger certain actions
|
74
|
+
(e.g.: effects) at a predetermined time. If you used the generator to create a slide,
|
75
|
+
you'll notice a .js file got created along with it. That's the script we're talking
|
76
|
+
about. So for instance, say you have 2 hidden paragraphs in your slide, and you intent
|
77
|
+
to show one after another. Open that .js file and do
|
78
|
+
|
79
|
+
1, $('p:first').effect('fades-in')
|
80
|
+
3, $('p:eq(1)').effect('fades-in')
|
81
|
+
|
82
|
+
The above translates to: 1 second into this slide, fade in the first
|
83
|
+
paragraph. 3 seconds in, fade in the second paragraph.
|
84
|
+
|
85
|
+
This is handy if you want to schedule things you'd like to see happening at certain
|
86
|
+
stages during a presentation.
|
87
|
+
|
58
88
|
# Steps to winning
|
59
89
|
|
60
90
|
Quickly outline of things I'm going to do with this project:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.1
|
data/css/base.css
CHANGED
@@ -39,8 +39,10 @@ ul { display: inline-block; margin-left: 2em }
|
|
39
39
|
#stage > * { text-rendering: optimizeLegibility }
|
40
40
|
a { cursor: pointer }
|
41
41
|
|
42
|
+
div.slice { position: absolute; display: block; width: 0; top: -10px; bottom: -10px }
|
43
|
+
|
42
44
|
@media all and (min-width: 480px) { #stage { font-size: 80% } }
|
43
45
|
@media all and (min-width: 640px) { #stage { font-size: 100% } }
|
44
46
|
@media all and (min-width: 800px) { #stage { font-size: 130% } }
|
45
47
|
@media all and (min-width: 1024px) { #stage { font-size: 160% } }
|
46
|
-
@media all and (min-width: 1280px) { #stage { font-size: 180% } }
|
48
|
+
@media all and (min-width: 1280px) { #stage { font-size: 180% } }
|
data/lib/jquery.shining.js
CHANGED
@@ -1,49 +1,132 @@
|
|
1
1
|
(function($) {
|
2
|
-
|
3
2
|
$.shining = function() {
|
4
3
|
$.shining.slides = {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
4
|
+
length: function() { return this._slides.length },
|
5
|
+
current: function() {
|
6
|
+
if (arguments.length) {
|
7
|
+
this._current = this._slides.indexOf(arguments[0]);
|
8
|
+
return this.current();
|
9
|
+
} else {
|
10
|
+
return (typeof this._current == 'undefined' ? this._slides[0] : this._slides[this._current]);
|
11
|
+
}
|
12
|
+
},
|
13
|
+
all: function() { return this._slides },
|
14
|
+
first: function() { return this._slides[0] },
|
15
|
+
last: function() { return this._slides[ this._slides.length - 1 ] },
|
16
|
+
next: function() { return this._slides[ this._slides.indexOf(this.current()) + 1 ] },
|
17
|
+
previous: function() { return this._slides[ this._slides.indexOf(this.current()) - 1 ] },
|
18
|
+
add: function(slides) { return Array.prototype.push.apply(this._slides, slides) },
|
14
19
|
_slides: [],
|
15
20
|
_current: 0
|
16
21
|
};
|
17
22
|
|
23
|
+
function applyTransition(enter, leave) {
|
24
|
+
switch($.shining.config.transitions) {
|
25
|
+
case 'fade':
|
26
|
+
$('#stage').fadeOut(200, function() {
|
27
|
+
enter.call();
|
28
|
+
$('#stage').fadeIn(200, function() {
|
29
|
+
leave.call();
|
30
|
+
})
|
31
|
+
})
|
32
|
+
break;
|
33
|
+
case 'slide':
|
34
|
+
$('#stage').animate(
|
35
|
+
{ opacity: 0, marginLeft: '-200' },
|
36
|
+
200,
|
37
|
+
function() {
|
38
|
+
enter.call();
|
39
|
+
$('#stage')
|
40
|
+
.css({ marginLeft: null, marginRight: '-200px' })
|
41
|
+
.animate({ opacity: 1, marginRight: '0' }, 200, function() {
|
42
|
+
leave.call();
|
43
|
+
})
|
44
|
+
}
|
45
|
+
);
|
46
|
+
break;
|
47
|
+
case 'slice':
|
48
|
+
var width = $('#stage').width() / 10;
|
49
|
+
for (var i = 0; i <= 10; i++) {
|
50
|
+
$('#stage').append(
|
51
|
+
$('<div class="slice"></div>').css({
|
52
|
+
backgroundColor: $('body').css('background-color'),
|
53
|
+
left: (i * width) - 10
|
54
|
+
}).delay(i * 50).animate({width: width + 1})
|
55
|
+
);
|
56
|
+
}
|
57
|
+
setTimeout(enter, 900);
|
58
|
+
var reversed = Array.prototype.reverse.call($('#stage .slice'));
|
59
|
+
for (var i = 0; i < reversed.length; i++) {
|
60
|
+
$(reversed[i]).delay(i * 50).animate({width: '0'})
|
61
|
+
}
|
62
|
+
setTimeout(leave, 4200);
|
63
|
+
break;
|
64
|
+
default:
|
65
|
+
enter();
|
66
|
+
setTimeout(leave, 200);
|
67
|
+
break;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
function slice() {
|
72
|
+
var width = $('#stage').width() / 10;
|
73
|
+
for (var i = 0; i <= 10; i++) {
|
74
|
+
$('#stage').append(
|
75
|
+
$('<div class="slice"></div>').css({
|
76
|
+
backgroundColor: $('body').css('background-color'),
|
77
|
+
left: (i * width) - 10
|
78
|
+
}).delay(i * 100).animate({width: width + 1})
|
79
|
+
);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
function unslice() {
|
84
|
+
var reversed = Array.prototype.reverse.call($('#stage .slice'));
|
85
|
+
for (var i = 0; i < reversed.length; i++) {
|
86
|
+
$(reversed[i]).delay(i * 100).animate({width: '0'})
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
$.shining.slice = slice;
|
91
|
+
$.shining.unslice = unslice;
|
92
|
+
|
18
93
|
String.prototype.markup = function() { return this + '.html' };
|
19
94
|
String.prototype.script = function() { return this + '.js' };
|
20
|
-
String.prototype.style
|
95
|
+
String.prototype.style = function() { return this + '.css' };
|
96
|
+
|
97
|
+
$.fn.effect = function(name) { return this.each(function() { applyEffect(this, name) }); }
|
98
|
+
$.fn.hasClasses = function(classes) {
|
99
|
+
var classes = classes.split(/\s+/), yes = true, element = this.get(0);
|
100
|
+
for (var i = 0; i < classes.length && yes; i++) { yes = $(element).hasClass(classes[i]) }
|
101
|
+
return yes;
|
102
|
+
}
|
21
103
|
|
22
104
|
$.extend($.shining, {
|
23
|
-
firstSlide: function() { getSlide($.shining.slides.first) },
|
24
|
-
lastSlide: function() { getSlide($.shining.slides.last ) },
|
25
|
-
nextSlide: function() { getSlide($.shining.slides.next) },
|
26
|
-
previousSlide: function() { getSlide($.shining.slides.previous) },
|
105
|
+
firstSlide: function() { getSlide($.shining.slides.first()) },
|
106
|
+
lastSlide: function() { getSlide($.shining.slides.last() ) },
|
107
|
+
nextSlide: function() { getSlide($.shining.slides.next()) },
|
108
|
+
previousSlide: function() { getSlide($.shining.slides.previous()) },
|
27
109
|
getSlide: function(slide) { getSlide(slide) }
|
28
110
|
});
|
29
111
|
|
30
|
-
|
112
|
+
var FILTERS = {
|
113
|
+
// reads: "fades-out" can be achieved by removing "fades-in" if the element hasClass "transparent"
|
114
|
+
'fades-out': { remove: 'fades-in', when: 'fades-in transparent' }
|
115
|
+
}
|
116
|
+
|
117
|
+
function init() {
|
31
118
|
$(document).ready(function() {
|
32
119
|
$('#controls').ondistance(
|
33
120
|
300,
|
34
|
-
function(controls) { $(controls).
|
35
|
-
function(controls) { $(controls).
|
121
|
+
function(controls) { $(controls).effect('fades-in') },
|
122
|
+
function(controls) { $(controls).effect('fades-out') }
|
36
123
|
);
|
37
124
|
$('#stage').centralize();
|
38
125
|
});
|
39
126
|
$(window).resize(function() { $('#stage').centralize() });
|
40
127
|
loadConfig(function() {
|
41
128
|
var startAt = document.location.hash.replace('#', '');
|
42
|
-
|
43
|
-
getSlide(startAt)
|
44
|
-
} else {
|
45
|
-
getSlide($.shining.slides.current);
|
46
|
-
}
|
129
|
+
loadSlide(startAt ? startAt : $.shining.slides.current());
|
47
130
|
setTitle($.shining.config.title);
|
48
131
|
setTheme($.shining.config.theme);
|
49
132
|
parseEffects();
|
@@ -51,50 +134,47 @@
|
|
51
134
|
});
|
52
135
|
}
|
53
136
|
|
54
|
-
function
|
55
|
-
if (
|
56
|
-
|
57
|
-
$('#stage').removeClass('fades-in');
|
58
|
-
setTimeout(
|
59
|
-
function() {
|
60
|
-
loadSlide(name);
|
61
|
-
setTimeout(
|
62
|
-
function() {
|
63
|
-
$('#stage').addClass('fades-in');
|
64
|
-
$.shining.scripts.run($.shining.currentScript);
|
65
|
-
},
|
66
|
-
200);
|
67
|
-
}, 200);
|
137
|
+
function applyEffect(element, name) {
|
138
|
+
if (name in FILTERS) {
|
139
|
+
if ($(element).hasClasses(FILTERS[name].when)) $(element).removeClass(FILTERS[name].remove)
|
68
140
|
} else {
|
69
|
-
|
141
|
+
$(element).addClass(name);
|
70
142
|
}
|
71
143
|
}
|
72
|
-
|
144
|
+
|
145
|
+
function getSlide(name) {
|
146
|
+
if (!name) return false;
|
147
|
+
applyTransition(
|
148
|
+
function() { loadSlide(name) },
|
149
|
+
function() { $.shining.scripts.run($.shining.currentScript) }
|
150
|
+
)
|
151
|
+
}
|
152
|
+
|
73
153
|
function setTitle(title) {
|
74
154
|
if (!title) { return false };
|
75
155
|
$('title').text(title);
|
76
156
|
}
|
77
|
-
|
157
|
+
|
78
158
|
function setTheme(name) {
|
79
159
|
if (!name || name == "default") { return false };
|
80
160
|
var path = $('link.theme').attr('href').replace('default.css', name + 'css');
|
81
161
|
return $('link.theme').attr('href', path);
|
82
162
|
}
|
83
|
-
|
163
|
+
|
84
164
|
// private
|
85
165
|
function slide(name) {
|
86
166
|
return 'slides/' + name;
|
87
167
|
}
|
88
|
-
|
168
|
+
|
89
169
|
function vendored() {
|
90
170
|
return $('script:first').attr('src').match(/^vendor/);
|
91
171
|
}
|
92
|
-
|
172
|
+
|
93
173
|
function loadSlide(name) {
|
94
|
-
$('#stage').load(
|
174
|
+
$('#stage .contents').load(
|
95
175
|
slide(name).markup(),
|
96
176
|
function(data) {
|
97
|
-
$.shining.slides.current
|
177
|
+
$.shining.slides.current(name);
|
98
178
|
$('link.slide').remove(); // remove now previous slide styles
|
99
179
|
if (SyntaxHighlighter) SyntaxHighlighter.highlight();
|
100
180
|
$('#stage').centralize();
|
@@ -107,49 +187,44 @@
|
|
107
187
|
}
|
108
188
|
);
|
109
189
|
}
|
110
|
-
|
190
|
+
|
111
191
|
function loadSlideScript(name) {
|
112
192
|
$.get(slide(name).script(), function(script) {
|
113
|
-
|
114
|
-
$.shining.currentScript = script;
|
115
|
-
} else {
|
116
|
-
$.shining.scripts.run(script)
|
117
|
-
}
|
193
|
+
$.shining.currentScript = script;
|
118
194
|
})
|
119
195
|
}
|
120
|
-
|
196
|
+
|
121
197
|
function loadSlideStyle(name) {
|
122
198
|
$('head').append('<link rel="stylesheet" type="text/css" href="' + slide(name).style() + '" media="all" class="slide"/>')
|
123
199
|
}
|
124
|
-
|
200
|
+
|
125
201
|
function loadConfig(callback) {
|
126
202
|
$.getJSON('config.json', function(config) {
|
127
203
|
$.shining.config = config;
|
128
204
|
$.shining.slides.add(config.slides);
|
129
|
-
if (config.transitions) { $('#stage').addClass('transparent fades-in'); }
|
130
205
|
callback.call();
|
131
206
|
});
|
132
207
|
}
|
133
|
-
|
208
|
+
|
134
209
|
function parseEffects() {
|
135
|
-
$.get($('link[href$=effects.css]').attr('href'),
|
210
|
+
$.get($('link[href$=effects.css]').attr('href'),
|
136
211
|
function(css) { $.shining.effects = $.parseCSS(css) }
|
137
212
|
);
|
138
213
|
}
|
139
|
-
|
214
|
+
|
140
215
|
function updateControlAnchors() {
|
141
|
-
$('#controls #first'). attr('href', '#' + $.shining.slides.first);
|
142
|
-
$('#controls #previous'). attr('href', ($.shining.slides.previous ? '#' + $.shining.slides.previous : ''));
|
143
|
-
$('#controls #next'). attr('href', ($.shining.slides.next ? '#' + $.shining.slides.next : ''));
|
144
|
-
$('#controls #last'). attr('href', '#' + $.shining.slides.first);
|
216
|
+
$('#controls #first'). attr('href', '#' + $.shining.slides.first());
|
217
|
+
$('#controls #previous'). attr('href', ($.shining.slides.previous() ? '#' + $.shining.slides.previous() : ''));
|
218
|
+
$('#controls #next'). attr('href', ($.shining.slides.next() ? '#' + $.shining.slides.next() : ''));
|
219
|
+
$('#controls #last'). attr('href', '#' + $.shining.slides.first());
|
145
220
|
}
|
146
|
-
|
221
|
+
|
147
222
|
$.shining.scripts = {
|
148
223
|
LINE: /^(\d[.\d]*),[\s]*(.*)/,
|
149
224
|
parsed: [], processes: [],
|
150
225
|
nextSlide: function() { $.shining.nextSlide() },
|
151
226
|
previousSlide: function() { $.shining.previousSlide() },
|
152
|
-
at: function(seconds, method) {
|
227
|
+
at: function(seconds, method) {
|
153
228
|
$.shining.scripts.processes.push(setTimeout(method, parseFloat(seconds) * 1000))
|
154
229
|
},
|
155
230
|
parse: function(script) {
|
@@ -167,7 +242,7 @@
|
|
167
242
|
parsed.push(lines[i]);
|
168
243
|
}
|
169
244
|
}
|
170
|
-
}
|
245
|
+
}
|
171
246
|
return parsed;
|
172
247
|
},
|
173
248
|
run: function(script) {
|
@@ -175,19 +250,19 @@
|
|
175
250
|
for (var i = 0; parsed.length > i; i += 2) {
|
176
251
|
all.push(["at(", parsed[i], ", function() { ", parsed[i+1], " })"].join(''));
|
177
252
|
}
|
178
|
-
with($.shining.scripts) { eval(all.join(';')) };
|
253
|
+
with($.shining.scripts) { eval(all.join(';')) };
|
179
254
|
},
|
180
255
|
reap: function() {
|
181
|
-
$($.shining.scripts.processes).
|
256
|
+
$($.shining.scripts.processes).each(function() { clearTimeout(this) });
|
182
257
|
return $.shining.scripts.processes = [];
|
183
258
|
}
|
184
259
|
}
|
185
|
-
|
260
|
+
|
186
261
|
init();
|
187
262
|
}
|
188
263
|
// boots!
|
189
264
|
$.shining();
|
190
|
-
|
265
|
+
|
191
266
|
})(jQuery);
|
192
267
|
|
193
268
|
// Dependencies!!
|
@@ -222,7 +297,7 @@ var RESGMLcomment=/<!--([^-]|-[^-])*-->/g;var REnotATag=/(>)[^<]*/g;var REtag=/<
|
|
222
297
|
/*
|
223
298
|
* jQuery hashchange event - v1.2 - 2/11/2010
|
224
299
|
* http://benalman.com/projects/jquery-hashchange-plugin/
|
225
|
-
*
|
300
|
+
*
|
226
301
|
* Copyright (c) 2010 "Cowboy" Ben Alman
|
227
302
|
* Dual licensed under the MIT and GPL licenses.
|
228
303
|
* http://benalman.com/about/license/
|
data/shining.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{shining}
|
8
|
-
s.version = "1.1.
|
8
|
+
s.version = "1.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Julio Cesar Ody"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-04-07}
|
13
13
|
s.description = %q{Webkit + CSS + Javascript = awesome presos}
|
14
14
|
s.email = %q{julio.ody@gmail.com}
|
15
15
|
s.executables = ["console", "shine"]
|
data/templates/config.json
CHANGED
data/templates/index.html
CHANGED
@@ -14,7 +14,10 @@
|
|
14
14
|
<script type="text/javascript" charset="utf-8" src="<%= vendorized? ? 'vendor' : Shining.root %>/lib/jquery.shining.js"></script>
|
15
15
|
</head>
|
16
16
|
<body>
|
17
|
-
<section id="stage"
|
17
|
+
<section id="stage">
|
18
|
+
<div class="contents"></div>
|
19
|
+
|
20
|
+
</section>
|
18
21
|
<nav id="controls" class="transparent">
|
19
22
|
<a id="first"><<</a>
|
20
23
|
<a id="previous"><</a>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shining
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julio Cesar Ody
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-04-07 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|