shining 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/shine +0 -7
- data/css/base.css +3 -20
- data/lib/config.ru +9 -3
- data/lib/ext/filemethods.rb +15 -9
- data/lib/plugins/resize.js +23 -0
- data/lib/plugins/syntaxhighlighter.js +3 -0
- data/lib/shining.js +358 -0
- data/lib/shining.rb +2 -3
- data/lib/shining/preso.rb +6 -20
- data/shining.gemspec +7 -4
- data/spec/cli_spec.rb +1 -8
- data/spec/filemethods_spec.rb +57 -0
- data/spec/javascripts/dom.html +1 -1
- data/spec/javascripts/unit/spec.js +10 -10
- data/spec/preso_spec.rb +7 -32
- data/templates/config.json +1 -0
- data/templates/index.html +11 -11
- data/themes/default.css +5 -12
- metadata +8 -5
- data/lib/jquery.shining.js +0 -361
- data/lib/plugins/jquery.shining-audio-0.0.1.js +0 -0
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
data/bin/shine
CHANGED
@@ -8,7 +8,6 @@ ACTIONS = {
|
|
8
8
|
:new_on! => ['build'],
|
9
9
|
:new_slide! => ['slide'],
|
10
10
|
:compile_templates! => ['compile'],
|
11
|
-
:vendorize => ['vendor', 'vendorize'],
|
12
11
|
:play => ['play', 'go'],
|
13
12
|
:deploy => ['deploy']
|
14
13
|
}
|
@@ -48,12 +47,6 @@ def new_slide! name, format = 'html'
|
|
48
47
|
preso.new_slide "#{name}.#{format}", :with => ['styles', 'script']
|
49
48
|
end
|
50
49
|
|
51
|
-
def vendorize
|
52
|
-
preso = Shining::Preso.open Dir.pwd
|
53
|
-
bail! 'This preso seems vendorized already.' if preso.vendorized?
|
54
|
-
preso.vendorize!
|
55
|
-
end
|
56
|
-
|
57
50
|
def compile_templates!
|
58
51
|
preso = Shining::Preso.open Dir.pwd
|
59
52
|
preso.compile_templates!
|
data/css/base.css
CHANGED
@@ -8,19 +8,8 @@ ol, ul { list-style-type : none; }
|
|
8
8
|
ins { text-decoration : none; }
|
9
9
|
del { text-decoration : line-through }
|
10
10
|
|
11
|
-
body
|
12
|
-
|
13
|
-
overflow: hidden;
|
14
|
-
text-align: center;
|
15
|
-
}
|
16
|
-
|
17
|
-
#stage {
|
18
|
-
position: relative;
|
19
|
-
display: inline-block;
|
20
|
-
padding: 40px 20px;
|
21
|
-
max-width: 90%;
|
22
|
-
text-align: left;
|
23
|
-
}
|
11
|
+
body { font: 12px/1.5 "Lucida Grande", Tahoma, serif; overflow: hidden; text-align: center }
|
12
|
+
#stage { position: absolute; display: inline-block; padding: 40px 20px; max-width: 90%; text-align: left }
|
24
13
|
|
25
14
|
.no-text-shadow { text-shadow: none }
|
26
15
|
.no-drop-shadow {}
|
@@ -52,10 +41,4 @@ div.slice { position: absolute; display: block; width: 0; top: -10px; bottom: -1
|
|
52
41
|
background-color: rgba(0, 0, 0, 0.2);
|
53
42
|
color: #fff;
|
54
43
|
padding: 10px;
|
55
|
-
}
|
56
|
-
|
57
|
-
@media all and (min-width: 480px) { #stage { font-size: 80% } }
|
58
|
-
@media all and (min-width: 640px) { #stage { font-size: 100% } }
|
59
|
-
@media all and (min-width: 800px) { #stage { font-size: 130% } }
|
60
|
-
@media all and (min-width: 1024px) { #stage { font-size: 160% } }
|
61
|
-
@media all and (min-width: 1280px) { #stage { font-size: 180% } }
|
44
|
+
}
|
data/lib/config.ru
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
use Rack::Static,
|
2
|
-
|
3
|
-
|
1
|
+
use Rack::Static,
|
2
|
+
:root => File.dirname(__FILE__),
|
3
|
+
:urls => %w(/vendor/css /vendor/lib /slides /config.json /vendor/themes)
|
4
|
+
run lambda { |env|
|
5
|
+
[
|
6
|
+
200,
|
7
|
+
{ 'Content-Type' => 'text/html', 'Cache-Control' => 'public, max-age=86400' },
|
8
|
+
[File.read('index.html')]
|
9
|
+
]
|
4
10
|
}
|
data/lib/ext/filemethods.rb
CHANGED
@@ -11,22 +11,28 @@ module FileMethods
|
|
11
11
|
def dir? dir
|
12
12
|
File.directory? dir
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def change_dir to
|
16
16
|
Dir.chdir to
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def move from, to
|
20
|
-
Shining.say("Moving
|
20
|
+
Shining.say(" Moving\t#{from} to #{to}") {
|
21
|
+
Dir[from].each do |something| FileUtils.mv something, to end
|
22
|
+
}
|
21
23
|
end
|
22
24
|
|
23
25
|
def copy from, to
|
24
|
-
Shining.say("Copying
|
26
|
+
Shining.say(" Copying\t#{from} to #{to}") {
|
27
|
+
Dir[from].each do |something|
|
28
|
+
File.directory?(something) ? FileUtils.cp_r(something, to) : FileUtils.cp(something, to)
|
29
|
+
end
|
30
|
+
}
|
25
31
|
end
|
26
32
|
|
27
33
|
def new_dir dir, careful = true
|
28
34
|
confirm "#{dir} already exists. Proceed?" if careful and dir?(dir)
|
29
|
-
Shining.say("Creating
|
35
|
+
Shining.say(" Creating\t#{dir}") { FileUtils.mkdir_p dir }
|
30
36
|
end
|
31
37
|
|
32
38
|
def read_file file
|
@@ -36,7 +42,7 @@ module FileMethods
|
|
36
42
|
def erb file
|
37
43
|
ERB.new(read_file(file)).result(binding)
|
38
44
|
end
|
39
|
-
|
45
|
+
|
40
46
|
def json file
|
41
47
|
JSON.parse read_file(file)
|
42
48
|
end
|
@@ -48,15 +54,15 @@ module FileMethods
|
|
48
54
|
def dirname file
|
49
55
|
File.dirname file
|
50
56
|
end
|
51
|
-
|
57
|
+
|
52
58
|
def extname file
|
53
59
|
File.extname file
|
54
60
|
end
|
55
|
-
|
61
|
+
|
56
62
|
def basename file, take = ''
|
57
63
|
File.basename file, take
|
58
64
|
end
|
59
|
-
|
65
|
+
|
60
66
|
def delete! file
|
61
67
|
dir?(file) ? FileUtils.rm_rf(file) : FileUtils.rm(file)
|
62
68
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
// resize.js: Shining plugin for resizing the font sizes depending
|
2
|
+
// on the available screen dimensions
|
3
|
+
|
4
|
+
$(window).resize(function() {
|
5
|
+
$.throttle(function() {
|
6
|
+
var width = $(window).width();
|
7
|
+
if (width < 480) {
|
8
|
+
$('#stage').css({fontSize: '80%'});
|
9
|
+
} else if (width >= 480 && width < 640) {
|
10
|
+
$('#stage').css({fontSize: '80%'});
|
11
|
+
} else if (width >= 640 && width < 800) {
|
12
|
+
$('#stage').css({fontSize: '100%'});
|
13
|
+
} else if (width >= 800 && width < 640) {
|
14
|
+
$('#stage').css({fontSize: '130%'});
|
15
|
+
} else if (width >= 1024 && width < 800) {
|
16
|
+
$('#stage').css({fontSize: '160%'});
|
17
|
+
} else if (width >= 1280 & width < 1024) {
|
18
|
+
$('#stage').css({fontSize: '180%'});
|
19
|
+
} else if (width > 1280) {
|
20
|
+
$('#stage').css({fontSize: '180%'});
|
21
|
+
}
|
22
|
+
}, 500);
|
23
|
+
})
|
data/lib/shining.js
ADDED
@@ -0,0 +1,358 @@
|
|
1
|
+
(function($) {
|
2
|
+
String.prototype.markup = function() { return this + '.html' };
|
3
|
+
String.prototype.script = function() { return this + '.js' };
|
4
|
+
String.prototype.style = function() { return this + '.css' };
|
5
|
+
var KEY = { SPACE: 32, RIGHT: 39, LEFT: 37 };
|
6
|
+
|
7
|
+
// jQuery extensions
|
8
|
+
$.fn.effect = function(name) { return this.each(function() { applyEffect(this, name) }); };
|
9
|
+
$.fn.hasClasses = function(classes) {
|
10
|
+
var classes = classes.split(/\s+/), yes = true, element = this.get(0);
|
11
|
+
for (var i = 0; i < classes.length && yes; i++) { yes = $(element).hasClass(classes[i]) }
|
12
|
+
return yes;
|
13
|
+
};
|
14
|
+
$.throttle = function(method, interval) {
|
15
|
+
if (!$.throttle.throttling) $.throttle.throttling = {};
|
16
|
+
var now = new Date().getTime();
|
17
|
+
if (!(method.toString() in $.throttle.throttling)) {
|
18
|
+
$.throttle.throttling[method.toString()] = { interval: interval, last: now };
|
19
|
+
return method();
|
20
|
+
} else {
|
21
|
+
var throttled = $.throttle.throttling[method.toString()];
|
22
|
+
if (now - throttled.last < throttled.interval) {
|
23
|
+
return false;
|
24
|
+
} else {
|
25
|
+
$.throttle.throttling[method.toString()].last = now;
|
26
|
+
return method();
|
27
|
+
}
|
28
|
+
}
|
29
|
+
};
|
30
|
+
|
31
|
+
Shining = {
|
32
|
+
// slides
|
33
|
+
slides: {
|
34
|
+
length: function() { return this._slides.length },
|
35
|
+
current: function() {
|
36
|
+
if (arguments.length) {
|
37
|
+
this._current = this._slides.indexOf(arguments[0]);
|
38
|
+
return this.current();
|
39
|
+
} else {
|
40
|
+
return (typeof this._current == 'undefined' ? this._slides[0] : this._slides[this._current]);
|
41
|
+
}
|
42
|
+
},
|
43
|
+
all: function() { return this._slides },
|
44
|
+
first: function() { return this._slides[0] },
|
45
|
+
last: function() { return this._slides[ this._slides.length - 1 ] },
|
46
|
+
next: function() { return this._slides[ this._slides.indexOf(this.current()) + 1 ] },
|
47
|
+
previous: function() {
|
48
|
+
var previous = this._slides[ this._slides.indexOf(this.current()) - 1 ];
|
49
|
+
return previous ? previous : this.first();
|
50
|
+
},
|
51
|
+
add: function(slides) { return Array.prototype.push.apply(this._slides, slides) },
|
52
|
+
loaded: function(name) { return !!Shining.slides._loaded[name] },
|
53
|
+
_slides: [],
|
54
|
+
_loaded: {},
|
55
|
+
_current: 0
|
56
|
+
},
|
57
|
+
|
58
|
+
// public methods
|
59
|
+
firstSlide: function() { getSlide(Shining.slides.first()) },
|
60
|
+
lastSlide: function() { getSlide(Shining.slides.last() ) },
|
61
|
+
nextSlide: function() {
|
62
|
+
if (Shining.slides.next()) {
|
63
|
+
document.location.hash = Shining.slides.next();
|
64
|
+
trigger('next');
|
65
|
+
}
|
66
|
+
},
|
67
|
+
previousSlide: function() {
|
68
|
+
if (Shining.slides.previous()) {
|
69
|
+
document.location.hash = Shining.slides.previous();
|
70
|
+
trigger('previous');
|
71
|
+
}
|
72
|
+
},
|
73
|
+
getSlide: function(slide) { getSlide(slide) },
|
74
|
+
help: help,
|
75
|
+
init: init,
|
76
|
+
when: when,
|
77
|
+
trigger: trigger,
|
78
|
+
// slide scripts
|
79
|
+
scripts: {
|
80
|
+
LINE: /^(\d[.\d]*),[\s]*(.*)/,
|
81
|
+
parsed: [], processes: [],
|
82
|
+
nextSlide: function() { Shining.nextSlide() },
|
83
|
+
previousSlide: function() { Shining.previousSlide() },
|
84
|
+
at: function(seconds, method) {
|
85
|
+
Shining.scripts.processes.push(setTimeout(method, parseFloat(seconds) * 1000))
|
86
|
+
},
|
87
|
+
parse: function(script) {
|
88
|
+
var lines = script.split("\n"), tokens, parsed = [];
|
89
|
+
for (var i = 0; lines.length > i; i++) {
|
90
|
+
if (Shining.scripts.LINE.test(lines[i])) {
|
91
|
+
var tokens = lines[i].match(Shining.scripts.LINE);
|
92
|
+
var time = tokens[1], code = tokens[2];
|
93
|
+
parsed.push(time);
|
94
|
+
if (code.length) parsed.push(code);
|
95
|
+
} else {
|
96
|
+
if (isNaN(parsed[parsed.length - 1])) {
|
97
|
+
parsed[parsed.length - 1] += ("; " + lines[i]);
|
98
|
+
} else {
|
99
|
+
parsed.push(lines[i]);
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
return parsed;
|
104
|
+
},
|
105
|
+
run: function(script) {
|
106
|
+
if (typeof script == 'undefined' || script == '') return false;
|
107
|
+
var parsed = Shining.scripts.parse(script), all = [];
|
108
|
+
for (var i = 0; parsed.length > i; i += 2) {
|
109
|
+
all.push(["at(", parsed[i], ", function() { ", parsed[i+1], " })"].join(''));
|
110
|
+
}
|
111
|
+
with(Shining.scripts) { eval(all.join(';')) };
|
112
|
+
},
|
113
|
+
reap: function() {
|
114
|
+
$(Shining.scripts.processes).each(function() { clearTimeout(this) });
|
115
|
+
return Shining.scripts.processes = [];
|
116
|
+
}
|
117
|
+
}
|
118
|
+
};
|
119
|
+
|
120
|
+
function applyTransition(enter, leave) {
|
121
|
+
switch(Shining.config.transitions) {
|
122
|
+
case 'fade':
|
123
|
+
$('#stage').fadeOut(200, function() {
|
124
|
+
enter.call();
|
125
|
+
$('#stage').fadeIn(200, function() {
|
126
|
+
leave.call();
|
127
|
+
})
|
128
|
+
})
|
129
|
+
break;
|
130
|
+
case 'slide':
|
131
|
+
$('#stage').animate(
|
132
|
+
{ opacity: 0, marginLeft: '-200' },
|
133
|
+
200,
|
134
|
+
function() {
|
135
|
+
enter.call();
|
136
|
+
$('#stage')
|
137
|
+
.css({ marginLeft: null, marginRight: '-200px' })
|
138
|
+
.animate({ opacity: 1, marginRight: '0' }, 200, function() {
|
139
|
+
leave.call();
|
140
|
+
})
|
141
|
+
}
|
142
|
+
);
|
143
|
+
break;
|
144
|
+
case 'slice':
|
145
|
+
var width = $('#stage').width() / 10;
|
146
|
+
for (var i = 0; i <= 10; i++) {
|
147
|
+
$('#stage').append(
|
148
|
+
$('<div class="slice"></div>').css({
|
149
|
+
backgroundColor: $('body').css('background-color'),
|
150
|
+
left: (i * width) - 10
|
151
|
+
}).delay(i * 50).animate({width: width + 1})
|
152
|
+
);
|
153
|
+
}
|
154
|
+
setTimeout(enter, 900);
|
155
|
+
var reversed = Array.prototype.reverse.call($('#stage .slice'));
|
156
|
+
for (var i = 0; i < reversed.length; i++) {
|
157
|
+
$(reversed[i]).delay(i * 50).animate({width: '0'})
|
158
|
+
}
|
159
|
+
setTimeout(leave, 4200);
|
160
|
+
break;
|
161
|
+
default:
|
162
|
+
enter();
|
163
|
+
setTimeout(leave, 200);
|
164
|
+
break;
|
165
|
+
}
|
166
|
+
}
|
167
|
+
|
168
|
+
// For the "slice" transition
|
169
|
+
function slice() {
|
170
|
+
var width = $('#stage').width() / 10;
|
171
|
+
for (var i = 0; i <= 10; i++) {
|
172
|
+
$('#stage').append(
|
173
|
+
$('<div class="slice"></div>').css({
|
174
|
+
backgroundColor: $('body').css('background-color'),
|
175
|
+
left: (i * width) - 10
|
176
|
+
}).delay(i * 100).animate({width: width + 1})
|
177
|
+
);
|
178
|
+
}
|
179
|
+
}
|
180
|
+
|
181
|
+
function unslice() {
|
182
|
+
var reversed = Array.prototype.reverse.call($('#stage .slice'));
|
183
|
+
for (var i = 0; i < reversed.length; i++) {
|
184
|
+
$(reversed[i]).delay(i * 100).animate({width: '0'})
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
function help(message, duration) {
|
189
|
+
if (Shining.config.help == false) return false;
|
190
|
+
var duration = duration || 500;
|
191
|
+
$('#help').remove();
|
192
|
+
$('<div id="help"></div>')
|
193
|
+
.html(message)
|
194
|
+
.css({display: 'inline-block'})
|
195
|
+
.appendTo('body')
|
196
|
+
.animate({opacity: 1})
|
197
|
+
.delay(duration)
|
198
|
+
.fadeOut(200, function() { $('#help').remove() })
|
199
|
+
}
|
200
|
+
|
201
|
+
function local() { document.location.protocol == 'file:' }
|
202
|
+
|
203
|
+
function init() {
|
204
|
+
$(document).ready(function() {
|
205
|
+
$(window).resize(function(){
|
206
|
+
$('#stage').css({
|
207
|
+
position: 'absolute',
|
208
|
+
left: ($(window).width() - $('#stage').outerWidth()) / 2,
|
209
|
+
top: ($(window).height() - $('#stage').outerHeight()) / 2
|
210
|
+
});
|
211
|
+
});
|
212
|
+
bindKeys();
|
213
|
+
when('previous', function() { help('←') });
|
214
|
+
when('next', function() { help('→') });
|
215
|
+
loadConfig(function() {
|
216
|
+
loadPlugins();
|
217
|
+
var startAt = document.location.hash.replace('#', ''),
|
218
|
+
first = startAt ? startAt : Shining.slides.current();
|
219
|
+
loadSlide(first, function() { playSlide(first) });
|
220
|
+
if (!local() && !(Shining.config.help == false)) preloadSlides();
|
221
|
+
setTitle(Shining.config.title);
|
222
|
+
setTheme(Shining.config.theme);
|
223
|
+
trigger('init.shining');
|
224
|
+
help('← (previous slide), → or SPACE BAR (next slide)', 3000);
|
225
|
+
});
|
226
|
+
});
|
227
|
+
}
|
228
|
+
|
229
|
+
function trigger(event, data) { $(document).trigger(event + '.shining', data) }
|
230
|
+
function when(event, method) { $(document).bind(event + '.shining', method) }
|
231
|
+
|
232
|
+
function applyEffect(element, name) {
|
233
|
+
$(element).addClass(name);
|
234
|
+
}
|
235
|
+
|
236
|
+
function getSlide(name) {
|
237
|
+
if (!name) return false;
|
238
|
+
applyTransition(
|
239
|
+
function() { loadSlide(name, function() { playSlide(name) }) },
|
240
|
+
function() { Shining.scripts.run(Shining.slides._loaded[Shining.slides.current()].script) }
|
241
|
+
)
|
242
|
+
}
|
243
|
+
|
244
|
+
function setTitle(title) {
|
245
|
+
if (!title || title == '') return false;
|
246
|
+
$.browser.msie ? document.title = title : $('title').text(title);
|
247
|
+
}
|
248
|
+
|
249
|
+
function setTheme(name) {
|
250
|
+
if (!name || name == "default") { return false };
|
251
|
+
var path = $('link.theme').attr('href').replace('default.css', name + 'css');
|
252
|
+
return $('link.theme').attr('href', path);
|
253
|
+
}
|
254
|
+
|
255
|
+
function slide(name) {
|
256
|
+
return 'slides/' + name;
|
257
|
+
}
|
258
|
+
|
259
|
+
function loadSlide(name, afterLoad) {
|
260
|
+
if (!Shining.slides.loaded(name)) {
|
261
|
+
$.get(
|
262
|
+
slide(name).markup(),
|
263
|
+
function(data) {
|
264
|
+
Shining.slides._loaded[name] = {};
|
265
|
+
Shining.slides._loaded[name].markup = data;
|
266
|
+
if (data) {
|
267
|
+
loadSlideScript(name, afterLoad);
|
268
|
+
loadSlideStyle(name);
|
269
|
+
}
|
270
|
+
}
|
271
|
+
);
|
272
|
+
} else {
|
273
|
+
if ($.isFunction(afterLoad)) afterLoad.call();
|
274
|
+
loadSlideStyle(name);
|
275
|
+
}
|
276
|
+
}
|
277
|
+
|
278
|
+
function preloadSlides() {
|
279
|
+
$(Shining.config.slides).each(function() { loadSlide(this) })
|
280
|
+
}
|
281
|
+
|
282
|
+
function playSlide(name) {
|
283
|
+
var slide = Shining.slides._loaded[name];
|
284
|
+
Shining.slides.current(name);
|
285
|
+
$('#stage .contents').html(slide.markup);
|
286
|
+
trigger('slideplay');
|
287
|
+
$(window).trigger('resize');
|
288
|
+
Shining.scripts.run(slide.script);
|
289
|
+
}
|
290
|
+
|
291
|
+
function loadPlugins() {
|
292
|
+
if (Shining.config.plugins && Shining.config.plugins.length) {
|
293
|
+
$(Shining.config.plugins).each(function() {
|
294
|
+
$('head').append('<script type="text/javascript" src="' + pluginPath(this) + '"></script>');
|
295
|
+
})
|
296
|
+
}
|
297
|
+
}
|
298
|
+
|
299
|
+
function installPath() { return $('script[src$=shining.js]').attr('src').replace('/shining.js', '') }
|
300
|
+
function pluginPath(name) { return installPath() + '/plugins/' + name + '.js' }
|
301
|
+
|
302
|
+
function loadSlideScript(name, afterLoad) {
|
303
|
+
$.ajax({
|
304
|
+
url: slide(name).script(),
|
305
|
+
type: 'GET',
|
306
|
+
success: function(script) { Shining.slides._loaded[name].script = script },
|
307
|
+
complete: function() { if ($.isFunction(afterLoad)) afterLoad.call() }
|
308
|
+
})
|
309
|
+
}
|
310
|
+
|
311
|
+
function loadSlideStyle(name) {
|
312
|
+
$('link.slide').remove();
|
313
|
+
$('head').append('<link rel="stylesheet" type="text/css" href="' + slide(name).style() + '" media="all" class="slide"/>')
|
314
|
+
}
|
315
|
+
|
316
|
+
function loadConfig(callback) {
|
317
|
+
$.getJSON('config.json', function(config) {
|
318
|
+
Shining.config = config;
|
319
|
+
Shining.slides.add(config.slides);
|
320
|
+
callback.call();
|
321
|
+
});
|
322
|
+
}
|
323
|
+
|
324
|
+
function bindKeys() {
|
325
|
+
$(document).keydown(function(event) {
|
326
|
+
switch(event.keyCode) {
|
327
|
+
case KEY.RIGHT:
|
328
|
+
case KEY.SPACE:
|
329
|
+
Shining.nextSlide();
|
330
|
+
break;
|
331
|
+
case KEY.LEFT:
|
332
|
+
Shining.previousSlide();
|
333
|
+
break;
|
334
|
+
}
|
335
|
+
})
|
336
|
+
}
|
337
|
+
|
338
|
+
Shining.init();
|
339
|
+
})(jQuery);
|
340
|
+
|
341
|
+
// Dependencies!!
|
342
|
+
/*
|
343
|
+
* jQuery hashchange event - v1.2 - 2/11/2010
|
344
|
+
* http://benalman.com/projects/jquery-hashchange-plugin/
|
345
|
+
*
|
346
|
+
* Copyright (c) 2010 "Cowboy" Ben Alman
|
347
|
+
* Dual licensed under the MIT and GPL licenses.
|
348
|
+
* http://benalman.com/about/license/
|
349
|
+
*/
|
350
|
+
(function($,i,b){var j,k=$.event.special,c="location",d="hashchange",l="href",f=$.browser,g=document.documentMode,h=f.msie&&(g===b||g<8),e="on"+d in i&&!h;function a(m){m=m||i[c][l];return m.replace(/^[^#]*#?(.*)$/,"$1")}$[d+"Delay"]=100;k[d]=$.extend(k[d],{setup:function(){if(e){return false}$(j.start)},teardown:function(){if(e){return false}$(j.stop)}});j=(function(){var m={},r,n,o,q;function p(){o=q=function(s){return s};if(h){n=$('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this);
|
351
|
+
|
352
|
+
$(window).bind('hashchange', function(event) {
|
353
|
+
var slide = document.location.hash.replace('#', '');
|
354
|
+
if (slide) { Shining.getSlide(slide) };
|
355
|
+
});
|
356
|
+
|
357
|
+
// IE Array.prototype.indexOf fix
|
358
|
+
if(!Array.prototype.indexOf){Array.prototype.indexOf=function(elt,from){var len=this.length;var from=Number(arguments[1])||0;from=(from<0)?Math.ceil(from):Math.floor(from);if(from<0)from+=len;for(;from<len;from++){if(from in this&&this[from]===elt)return from;} return-1;};}
|
data/lib/shining.rb
CHANGED
@@ -8,7 +8,6 @@ require 'shining/player'
|
|
8
8
|
require 'shining/heroku'
|
9
9
|
|
10
10
|
module Shining
|
11
|
-
|
12
11
|
class << self
|
13
12
|
def say something
|
14
13
|
STDOUT.puts(something) unless defined?(Spec) # shush when running tests
|
@@ -16,7 +15,7 @@ module Shining
|
|
16
15
|
end
|
17
16
|
|
18
17
|
def error message
|
19
|
-
STDERR.puts
|
18
|
+
STDERR.puts message
|
20
19
|
end
|
21
20
|
|
22
21
|
def root
|
@@ -47,4 +46,4 @@ This is a new slide. It needs some lovin'!
|
|
47
46
|
end
|
48
47
|
end
|
49
48
|
end
|
50
|
-
end
|
49
|
+
end
|
data/lib/shining/preso.rb
CHANGED
@@ -16,6 +16,7 @@ class Preso
|
|
16
16
|
if fresh
|
17
17
|
new_dir dir
|
18
18
|
copy_templates
|
19
|
+
vendorize!
|
19
20
|
end
|
20
21
|
@config = json(@path/'config.json')
|
21
22
|
end
|
@@ -38,10 +39,9 @@ class Preso
|
|
38
39
|
end
|
39
40
|
|
40
41
|
def copy_templates
|
41
|
-
%w(config.json slides).each do |template|
|
42
|
+
%w(config.json slides index.html).each do |template|
|
42
43
|
copy Shining.templates_path/template, @path + '/'
|
43
44
|
end
|
44
|
-
new_file @path/'index.html' do erb(Shining.templates_path/'index.html') end
|
45
45
|
true
|
46
46
|
end
|
47
47
|
|
@@ -81,28 +81,14 @@ class Preso
|
|
81
81
|
|
82
82
|
def vendorize!
|
83
83
|
new_dir @path/'vendor'
|
84
|
-
|
84
|
+
new_dir @path/'vendor'/'lib'
|
85
|
+
copy Shining.root/'lib'/'*.js', @path/'vendor'/'lib'
|
86
|
+
copy Shining.root/'lib'/'plugins', @path/'vendor'/'lib/'
|
87
|
+
%w(css images themes).each do |required|
|
85
88
|
copy Shining.root/required, @path/'vendor/'
|
86
89
|
end
|
87
|
-
new_file @path/'index.html' do erb(Shining.templates_path/'index.html') end
|
88
90
|
true
|
89
91
|
end
|
90
|
-
|
91
|
-
def vendorized?
|
92
|
-
dir? @path/'vendor'
|
93
|
-
end
|
94
|
-
|
95
|
-
def unvendorize!
|
96
|
-
delete! @path/'vendor'
|
97
|
-
copy_templates
|
98
|
-
end
|
99
|
-
|
100
|
-
def vendorized?
|
101
|
-
dir? @path/'vendor'/'lib' and
|
102
|
-
dir? @path/'vendor'/'themes' and
|
103
|
-
dir? @path/'vendor'/'css' and
|
104
|
-
dir? @path/'vendor'/'images'
|
105
|
-
end
|
106
92
|
end
|
107
93
|
|
108
94
|
end
|
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.
|
8
|
+
s.version = "1.3.0"
|
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-05-10}
|
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"]
|
@@ -35,16 +35,18 @@ Gem::Specification.new do |s|
|
|
35
35
|
"lib/ext/filemethods.rb",
|
36
36
|
"lib/ext/string.rb",
|
37
37
|
"lib/jquery-1.4.1.min.js",
|
38
|
-
"lib/
|
39
|
-
"lib/plugins/
|
38
|
+
"lib/plugins/resize.js",
|
39
|
+
"lib/plugins/syntaxhighlighter.js",
|
40
40
|
"lib/shBrushAll.js",
|
41
41
|
"lib/shCore.js",
|
42
|
+
"lib/shining.js",
|
42
43
|
"lib/shining.rb",
|
43
44
|
"lib/shining/heroku.rb",
|
44
45
|
"lib/shining/player.rb",
|
45
46
|
"lib/shining/preso.rb",
|
46
47
|
"shining.gemspec",
|
47
48
|
"spec/cli_spec.rb",
|
49
|
+
"spec/filemethods_spec.rb",
|
48
50
|
"spec/generators_spec.rb",
|
49
51
|
"spec/javascripts/dom.html",
|
50
52
|
"spec/javascripts/rhino.js",
|
@@ -84,6 +86,7 @@ Gem::Specification.new do |s|
|
|
84
86
|
s.summary = %q{Webkit + CSS + Javascript = awesome presos}
|
85
87
|
s.test_files = [
|
86
88
|
"spec/cli_spec.rb",
|
89
|
+
"spec/filemethods_spec.rb",
|
87
90
|
"spec/generators_spec.rb",
|
88
91
|
"spec/preso_spec.rb",
|
89
92
|
"spec/spec_helper.rb"
|
data/spec/cli_spec.rb
CHANGED
@@ -62,20 +62,13 @@ describe 'shine' do
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
it "vendorizes Shining to #{PRESO/'vendor'} with the 'vendor' option" do
|
66
|
-
vendorize
|
67
|
-
%w(lib themes css).each do |required|
|
68
|
-
File.exists?(PRESO/'vendor'/required).should be_true
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
65
|
it "compiles a Haml template if there is one in #{'PRESO_ROOT'/'slides'/'test.haml'} with the 'compile' option" do
|
73
66
|
make_haml_template! 'test'
|
74
67
|
compile_templates
|
75
68
|
File.read(PRESO/'slides'/'test.html').should == "<p>LOOK MA</p>\n"
|
76
69
|
end
|
77
70
|
|
78
|
-
|
71
|
+
context 'go' do
|
79
72
|
it "for now it only works on Mac OSX" do
|
80
73
|
player = Shining::Player.new Shining::Preso.open(PRESO)
|
81
74
|
player.should_receive(:osx?).and_return(false)
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
+
|
3
|
+
describe Shining::FileMethods do
|
4
|
+
include Shining::FileMethods
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
TMP = Dir.tmpdir/'shining-tmp' unless defined?(TMP)
|
8
|
+
FileUtils.rm_rf TMP
|
9
|
+
FileUtils.mkdir_p TMP
|
10
|
+
end
|
11
|
+
|
12
|
+
before :each do
|
13
|
+
FileUtils.rm_rf TMP/'temp'
|
14
|
+
@preso = Shining::Preso.new TMP/'temp'
|
15
|
+
end
|
16
|
+
|
17
|
+
it '#file? returns true if the argument is a file' do
|
18
|
+
FileUtils.touch TMP/'temp'/'moo'
|
19
|
+
file?(TMP/'temp'/'moo').should be_true
|
20
|
+
end
|
21
|
+
|
22
|
+
it '#dir? returns true if the argument is a directory' do
|
23
|
+
FileUtils.mkdir TMP/'temp'/'adir'
|
24
|
+
dir?(TMP/'temp'/'adir').should be_true
|
25
|
+
end
|
26
|
+
|
27
|
+
context '#move and #copy' do
|
28
|
+
before do
|
29
|
+
FileUtils.mkdir TMP/'temp'/'dir1'
|
30
|
+
FileUtils.mkdir TMP/'temp'/'dir2'
|
31
|
+
FileUtils.touch TMP/'temp'/'dir1'/'jquery.js'
|
32
|
+
FileUtils.touch TMP/'temp'/'dir1'/'shining.js'
|
33
|
+
FileUtils.touch TMP/'temp'/'dir1'/'shining.rb'
|
34
|
+
end
|
35
|
+
|
36
|
+
it '#move moves specific files or directories from one directory to another' do
|
37
|
+
move TMP/'temp'/'dir1'/'jquery.js', TMP/'temp'/'dir2/'
|
38
|
+
File.exists?(TMP/'temp'/'dir2'/'jquery.js').should be_true
|
39
|
+
end
|
40
|
+
|
41
|
+
it '#move moves files by wildcard from another directory to another' do
|
42
|
+
move TMP/'temp'/'dir1'/'*.js', TMP/'temp'/'dir2/'
|
43
|
+
File.exists?(TMP/'temp'/'dir2'/'shining.js').should be_true
|
44
|
+
end
|
45
|
+
|
46
|
+
it '#copy copies specific files or directories from one directory to another' do
|
47
|
+
copy TMP/'temp'/'dir1'/'jquery.js', TMP/'temp'/'dir2/'
|
48
|
+
File.exists?(TMP/'temp'/'dir2'/'jquery.js').should be_true
|
49
|
+
end
|
50
|
+
|
51
|
+
it '#copy copies files by wildcard from another directory to another' do
|
52
|
+
copy TMP/'temp'/'dir1'/'*.js', TMP/'temp'/'dir2/'
|
53
|
+
File.exists?(TMP/'temp'/'dir2'/'shining.js').should be_true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
data/spec/javascripts/dom.html
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
<script src="../../lib/jquery-1.4.1.min.js"></script>
|
8
8
|
<script src="../../lib/shCore.js"></script>
|
9
9
|
<script src="../../lib/shBrushAll.js"></script>
|
10
|
-
<script src="../../lib/
|
10
|
+
<script src="../../lib/shining.js"></script>
|
11
11
|
<script>
|
12
12
|
function runSuites() {
|
13
13
|
JSpec
|
@@ -23,36 +23,36 @@ describe 'Shining'
|
|
23
23
|
|
24
24
|
describe "config file"
|
25
25
|
it 'gets read when shining gets loaded'
|
26
|
-
|
26
|
+
Shining.config.constructor.should.be Object
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
describe "slides"
|
31
31
|
it '#current() returns the first slide by default'
|
32
|
-
|
32
|
+
Shining.slides.current().should.be 'welcome'
|
33
33
|
end
|
34
34
|
|
35
35
|
it '#current("slide1") sets the current slide to "slide1"'
|
36
|
-
|
37
|
-
|
36
|
+
Shining.slides.current('slide1')
|
37
|
+
Shining.slides.current().should.be 'slide1'
|
38
38
|
end
|
39
39
|
|
40
40
|
it "#last() returns the last slide in the slides array"
|
41
|
-
|
41
|
+
Shining.slides.last().should.be 'slide2'
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
describe 'navigating slides'
|
46
|
-
it 'navigates to slide1 on
|
47
|
-
|
46
|
+
it 'navigates to slide1 on Shining.nextSlide()'
|
47
|
+
Shining.slides.current('welcome')
|
48
48
|
mockRequest().and_return('<h1>Slide1</h1>');
|
49
|
-
|
49
|
+
Shining.nextSlide();
|
50
50
|
$('#stage .contents h1').text().should.be 'Slide1'
|
51
51
|
end
|
52
52
|
|
53
|
-
it 'navigates to slide2 on
|
53
|
+
it 'navigates to slide2 on Shining.nextSlide()'
|
54
54
|
mockRequest().and_return('<h1>Slide2</h1>');
|
55
|
-
|
55
|
+
Shining.nextSlide();
|
56
56
|
$('#stage .contents h1').text().should.be 'Slide2'
|
57
57
|
end
|
58
58
|
end
|
data/spec/preso_spec.rb
CHANGED
@@ -18,11 +18,13 @@ describe 'Shining::Preso' do
|
|
18
18
|
File.directory?(TMP/'temp').should be_true
|
19
19
|
end
|
20
20
|
|
21
|
-
it "copies
|
22
|
-
(
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
it "copies everything necessary to run the preso to the target folder" do
|
22
|
+
%w(lib themes css).each do |required|
|
23
|
+
File.directory?(TMP/'temp'/'vendor'/required).should be_true
|
24
|
+
end
|
25
|
+
%w(config.json index.html slides/welcome.html).each do |required|
|
26
|
+
File.exists?(TMP/'temp'/required).should be_true
|
27
|
+
end
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
@@ -37,33 +39,6 @@ describe 'Shining::Preso' do
|
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
40
|
-
describe 'vendorization' do
|
41
|
-
before do
|
42
|
-
@preso.vendorize!
|
43
|
-
end
|
44
|
-
|
45
|
-
it "#vendorize! copies everything necessary for the presentation to run without the gem being installed" do
|
46
|
-
(File.directory?(@preso.path/'vendor'/'lib') and
|
47
|
-
File.directory?(@preso.path/'vendor'/'themes') and
|
48
|
-
File.directory?(@preso.path/'vendor'/'css') and
|
49
|
-
File.directory?(@preso.path/'vendor'/'images')).should be_true
|
50
|
-
end
|
51
|
-
|
52
|
-
it "returns true on #vendorized? if a presentation is vendorized, false when not" do
|
53
|
-
@preso.vendorized?.should be_true
|
54
|
-
File.read(@preso.path/'index.html').should =~ /vendor\/lib/
|
55
|
-
end
|
56
|
-
|
57
|
-
it "\"unvendorizes\" a gem on #unvendorize!" do
|
58
|
-
@preso.unvendorize!
|
59
|
-
(File.directory?(@preso.path/'vendor'/'lib') and
|
60
|
-
File.directory?(@preso.path/'vendor'/'themes') and
|
61
|
-
File.directory?(@preso.path/'vendor'/'css') and
|
62
|
-
File.directory?(@preso.path/'vendor'/'images')).should be_false
|
63
|
-
File.read(@preso.path/'index.html').should_not =~ /vendor\/lib/
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
42
|
describe 'config' do
|
68
43
|
it "#config(true) force loads from config.json" do
|
69
44
|
@preso.should_receive :json
|
data/templates/config.json
CHANGED
data/templates/index.html
CHANGED
@@ -2,20 +2,20 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
5
|
-
<title>
|
6
|
-
<link rel="stylesheet" type="text/css" href="
|
7
|
-
<link rel="stylesheet" type="text/css" href="
|
8
|
-
<link rel="stylesheet" type="text/css" href="
|
9
|
-
<link rel="stylesheet" type="text/css" href="
|
10
|
-
<link rel="stylesheet" type="text/css" href="
|
11
|
-
<script type="text/javascript" charset="utf-8" src="
|
12
|
-
<script type="text/javascript" charset="utf-8" src="
|
13
|
-
<script type="text/javascript" charset="utf-8" src="
|
14
|
-
<script type="text/javascript" charset="utf-8" src="
|
5
|
+
<title>Your presentation</title>
|
6
|
+
<link rel="stylesheet" type="text/css" href="vendor/css/base.css" media="all"/>
|
7
|
+
<link rel="stylesheet" type="text/css" href="vendor/css/effects.css" media="all"/>
|
8
|
+
<link rel="stylesheet" type="text/css" href="vendor/css/shCore.css" media="all"/>
|
9
|
+
<link rel="stylesheet" type="text/css" href="vendor/css/shThemeFadeToGrey.css" media="all"/>
|
10
|
+
<link rel="stylesheet" type="text/css" href="vendor/themes/default.css" media="all" class="theme"/>
|
11
|
+
<script type="text/javascript" charset="utf-8" src="vendor/lib/jquery-1.4.1.min.js"></script>
|
12
|
+
<script type="text/javascript" charset="utf-8" src="vendor/lib/shCore.js"></script>
|
13
|
+
<script type="text/javascript" charset="utf-8" src="vendor/lib/shBrushAll.js"></script>
|
14
|
+
<script type="text/javascript" charset="utf-8" src="vendor/lib/shining.js"></script>
|
15
15
|
</head>
|
16
16
|
<body>
|
17
17
|
<div id="stage">
|
18
18
|
<div class="contents"></div>
|
19
19
|
</div>
|
20
20
|
</body>
|
21
|
-
</html>
|
21
|
+
</html>
|
data/themes/default.css
CHANGED
@@ -10,15 +10,8 @@ body {
|
|
10
10
|
border-radius: 5px;
|
11
11
|
}
|
12
12
|
|
13
|
-
h1, h2, h3, p, li {
|
14
|
-
|
15
|
-
|
16
|
-
}
|
17
|
-
|
18
|
-
color: #499DFF;
|
19
|
-
text-decoration: none
|
20
|
-
}
|
21
|
-
ul { list-style-type: disc }
|
22
|
-
|
23
|
-
em { color: rgb(73, 255, 80) }
|
24
|
-
strong { color: rgb(255, 171, 73); font-weight: bold }
|
13
|
+
h1, h2, h3, p, li { color: #EEEEEE; text-shadow: #000 2px 2px 4px }
|
14
|
+
a { color: #499DFF; text-decoration: none }
|
15
|
+
ul { list-style-type: disc }
|
16
|
+
em { color: #4BFF50 }
|
17
|
+
strong { color: #FFAB49; font-weight: bold }
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
-
-
|
7
|
+
- 3
|
8
8
|
- 0
|
9
|
-
version: 1.
|
9
|
+
version: 1.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Julio Cesar Ody
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-05-10 00:00:00 +10:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -156,16 +156,18 @@ files:
|
|
156
156
|
- lib/ext/filemethods.rb
|
157
157
|
- lib/ext/string.rb
|
158
158
|
- lib/jquery-1.4.1.min.js
|
159
|
-
- lib/
|
160
|
-
- lib/plugins/
|
159
|
+
- lib/plugins/resize.js
|
160
|
+
- lib/plugins/syntaxhighlighter.js
|
161
161
|
- lib/shBrushAll.js
|
162
162
|
- lib/shCore.js
|
163
|
+
- lib/shining.js
|
163
164
|
- lib/shining.rb
|
164
165
|
- lib/shining/heroku.rb
|
165
166
|
- lib/shining/player.rb
|
166
167
|
- lib/shining/preso.rb
|
167
168
|
- shining.gemspec
|
168
169
|
- spec/cli_spec.rb
|
170
|
+
- spec/filemethods_spec.rb
|
169
171
|
- spec/generators_spec.rb
|
170
172
|
- spec/javascripts/dom.html
|
171
173
|
- spec/javascripts/rhino.js
|
@@ -229,6 +231,7 @@ specification_version: 3
|
|
229
231
|
summary: Webkit + CSS + Javascript = awesome presos
|
230
232
|
test_files:
|
231
233
|
- spec/cli_spec.rb
|
234
|
+
- spec/filemethods_spec.rb
|
232
235
|
- spec/generators_spec.rb
|
233
236
|
- spec/preso_spec.rb
|
234
237
|
- spec/spec_helper.rb
|
data/lib/jquery.shining.js
DELETED
@@ -1,361 +0,0 @@
|
|
1
|
-
(function($) {
|
2
|
-
$.shining = function() {
|
3
|
-
$.shining.slides = {
|
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() {
|
17
|
-
window.sli = this._slides;
|
18
|
-
return this._slides[ this._slides.indexOf(this.current()) + 1 ]
|
19
|
-
},
|
20
|
-
previous: function() {
|
21
|
-
var previous = this._slides[ this._slides.indexOf(this.current()) - 1 ];
|
22
|
-
return previous ? previous : this.first();
|
23
|
-
},
|
24
|
-
add: function(slides) { return Array.prototype.push.apply(this._slides, slides) },
|
25
|
-
loaded: function(name) { return !!$.shining.slides._loaded[name] },
|
26
|
-
_slides: [],
|
27
|
-
_loaded: {},
|
28
|
-
_current: 0
|
29
|
-
};
|
30
|
-
|
31
|
-
function applyTransition(enter, leave) {
|
32
|
-
switch($.shining.config.transitions) {
|
33
|
-
case 'fade':
|
34
|
-
$('#stage').fadeOut(200, function() {
|
35
|
-
enter.call();
|
36
|
-
$('#stage').fadeIn(200, function() {
|
37
|
-
leave.call();
|
38
|
-
})
|
39
|
-
})
|
40
|
-
break;
|
41
|
-
case 'slide':
|
42
|
-
$('#stage').animate(
|
43
|
-
{ opacity: 0, marginLeft: '-200' },
|
44
|
-
200,
|
45
|
-
function() {
|
46
|
-
enter.call();
|
47
|
-
$('#stage')
|
48
|
-
.css({ marginLeft: null, marginRight: '-200px' })
|
49
|
-
.animate({ opacity: 1, marginRight: '0' }, 200, function() {
|
50
|
-
leave.call();
|
51
|
-
})
|
52
|
-
}
|
53
|
-
);
|
54
|
-
break;
|
55
|
-
case 'slice':
|
56
|
-
var width = $('#stage').width() / 10;
|
57
|
-
for (var i = 0; i <= 10; i++) {
|
58
|
-
$('#stage').append(
|
59
|
-
$('<div class="slice"></div>').css({
|
60
|
-
backgroundColor: $('body').css('background-color'),
|
61
|
-
left: (i * width) - 10
|
62
|
-
}).delay(i * 50).animate({width: width + 1})
|
63
|
-
);
|
64
|
-
}
|
65
|
-
setTimeout(enter, 900);
|
66
|
-
var reversed = Array.prototype.reverse.call($('#stage .slice'));
|
67
|
-
for (var i = 0; i < reversed.length; i++) {
|
68
|
-
$(reversed[i]).delay(i * 50).animate({width: '0'})
|
69
|
-
}
|
70
|
-
setTimeout(leave, 4200);
|
71
|
-
break;
|
72
|
-
default:
|
73
|
-
enter();
|
74
|
-
setTimeout(leave, 200);
|
75
|
-
break;
|
76
|
-
}
|
77
|
-
}
|
78
|
-
|
79
|
-
function slice() {
|
80
|
-
var width = $('#stage').width() / 10;
|
81
|
-
for (var i = 0; i <= 10; i++) {
|
82
|
-
$('#stage').append(
|
83
|
-
$('<div class="slice"></div>').css({
|
84
|
-
backgroundColor: $('body').css('background-color'),
|
85
|
-
left: (i * width) - 10
|
86
|
-
}).delay(i * 100).animate({width: width + 1})
|
87
|
-
);
|
88
|
-
}
|
89
|
-
}
|
90
|
-
|
91
|
-
function unslice() {
|
92
|
-
var reversed = Array.prototype.reverse.call($('#stage .slice'));
|
93
|
-
for (var i = 0; i < reversed.length; i++) {
|
94
|
-
$(reversed[i]).delay(i * 100).animate({width: '0'})
|
95
|
-
}
|
96
|
-
}
|
97
|
-
|
98
|
-
String.prototype.markup = function() { return this + '.html' };
|
99
|
-
String.prototype.script = function() { return this + '.js' };
|
100
|
-
String.prototype.style = function() { return this + '.css' };
|
101
|
-
|
102
|
-
var KEY = { SPACE: 32, RIGHT: 39, LEFT: 37 };
|
103
|
-
|
104
|
-
$.fn.effect = function(name) { return this.each(function() { applyEffect(this, name) }); };
|
105
|
-
$.fn.hasClasses = function(classes) {
|
106
|
-
var classes = classes.split(/\s+/), yes = true, element = this.get(0);
|
107
|
-
for (var i = 0; i < classes.length && yes; i++) { yes = $(element).hasClass(classes[i]) }
|
108
|
-
return yes;
|
109
|
-
}
|
110
|
-
|
111
|
-
$.extend($.shining, {
|
112
|
-
firstSlide: function() { getSlide($.shining.slides.first()) },
|
113
|
-
lastSlide: function() { getSlide($.shining.slides.last() ) },
|
114
|
-
nextSlide: function() {
|
115
|
-
if ($.shining.slides.next()) {
|
116
|
-
document.location.hash = $.shining.slides.next();
|
117
|
-
trigger('next');
|
118
|
-
}
|
119
|
-
},
|
120
|
-
previousSlide: function() {
|
121
|
-
if ($.shining.slides.previous()) {
|
122
|
-
document.location.hash = $.shining.slides.previous();
|
123
|
-
trigger('previous');
|
124
|
-
}
|
125
|
-
},
|
126
|
-
getSlide: function(slide) { getSlide(slide) },
|
127
|
-
help: help
|
128
|
-
});
|
129
|
-
|
130
|
-
var FILTERS = {
|
131
|
-
// reads: "fades-out" can be achieved by removing "fades-in" if the element hasClass "transparent"
|
132
|
-
'fades-out': { remove: 'fades-in', when: 'fades-in transparent' }
|
133
|
-
}
|
134
|
-
|
135
|
-
function init() {
|
136
|
-
$(document).ready(function() {
|
137
|
-
$(window).resize(function() { $('#stage').centralize() });
|
138
|
-
$('#stage').centralize();
|
139
|
-
bindKeys();
|
140
|
-
loadConfig(function() {
|
141
|
-
var startAt = document.location.hash.replace('#', ''),
|
142
|
-
first = startAt ? startAt : $.shining.slides.current();
|
143
|
-
loadSlide(first, function() { playSlide(first) });
|
144
|
-
if (!local() && !($.shining.config.help == false)) preloadSlides();
|
145
|
-
setTitle($.shining.config.title);
|
146
|
-
setTheme($.shining.config.theme);
|
147
|
-
trigger('init.shining');
|
148
|
-
help('← (previous slide), → or SPACE BAR (next slide)', 3000);
|
149
|
-
});
|
150
|
-
});
|
151
|
-
}
|
152
|
-
|
153
|
-
function trigger(event, data) {
|
154
|
-
$(document).trigger(event + '.shining', data);
|
155
|
-
}
|
156
|
-
|
157
|
-
function bind(event, method) {
|
158
|
-
$(document).bind(event + '.shining', method);
|
159
|
-
}
|
160
|
-
|
161
|
-
function applyEffect(element, name) {
|
162
|
-
if (name in FILTERS) {
|
163
|
-
if ($(element).hasClasses(FILTERS[name].when)) $(element).removeClass(FILTERS[name].remove)
|
164
|
-
} else {
|
165
|
-
$(element).addClass(name);
|
166
|
-
}
|
167
|
-
}
|
168
|
-
|
169
|
-
function getSlide(name) {
|
170
|
-
if (!name) return false;
|
171
|
-
applyTransition(
|
172
|
-
function() { loadSlide(name, function() { playSlide(name) }) },
|
173
|
-
function() {
|
174
|
-
$.shining.scripts.run($.shining.slides._loaded[$.shining.slides.current()].script)
|
175
|
-
}
|
176
|
-
)
|
177
|
-
}
|
178
|
-
|
179
|
-
function setTitle(title) {
|
180
|
-
if (!title || title == '') return false;
|
181
|
-
$.browser.msie ? document.title = title : $('title').text(title);
|
182
|
-
}
|
183
|
-
|
184
|
-
function setTheme(name) {
|
185
|
-
if (!name || name == "default") { return false };
|
186
|
-
var path = $('link.theme').attr('href').replace('default.css', name + 'css');
|
187
|
-
return $('link.theme').attr('href', path);
|
188
|
-
}
|
189
|
-
|
190
|
-
function slide(name) {
|
191
|
-
return 'slides/' + name;
|
192
|
-
}
|
193
|
-
|
194
|
-
function loadSlide(name, afterLoad) {
|
195
|
-
if (!$.shining.slides.loaded(name)) {
|
196
|
-
$.get(
|
197
|
-
slide(name).markup(),
|
198
|
-
function(data) {
|
199
|
-
$.shining.slides._loaded[name] = {};
|
200
|
-
$.shining.slides._loaded[name].markup = data;
|
201
|
-
if (data) {
|
202
|
-
loadSlideScript(name, afterLoad);
|
203
|
-
loadSlideStyle(name);
|
204
|
-
}
|
205
|
-
}
|
206
|
-
);
|
207
|
-
} else {
|
208
|
-
if ($.isFunction(afterLoad)) afterLoad.call();
|
209
|
-
loadSlideStyle(name);
|
210
|
-
}
|
211
|
-
}
|
212
|
-
|
213
|
-
function preloadSlides() {
|
214
|
-
$($.shining.config.slides).each(function() {
|
215
|
-
loadSlide(this);
|
216
|
-
})
|
217
|
-
}
|
218
|
-
|
219
|
-
function playSlide(name) {
|
220
|
-
var slide = $.shining.slides._loaded[name];
|
221
|
-
$('#stage .contents').html(slide.markup);
|
222
|
-
$.shining.scripts.run(slide.script);
|
223
|
-
}
|
224
|
-
|
225
|
-
function loadSlideScript(name, afterLoad) {
|
226
|
-
$.ajax({
|
227
|
-
url: slide(name).script(),
|
228
|
-
type: 'GET',
|
229
|
-
success: function(script) {
|
230
|
-
$.shining.slides._loaded[name].script = script;
|
231
|
-
},
|
232
|
-
complete: function() {
|
233
|
-
if ($.isFunction(afterLoad)) afterLoad.call();
|
234
|
-
}
|
235
|
-
})
|
236
|
-
}
|
237
|
-
|
238
|
-
function loadSlideStyle(name) {
|
239
|
-
$('link.slide').remove();
|
240
|
-
$('head').append('<link rel="stylesheet" type="text/css" href="' + slide(name).style() + '" media="all" class="slide"/>')
|
241
|
-
}
|
242
|
-
|
243
|
-
function loadConfig(callback) {
|
244
|
-
$.getJSON('config.json', function(config) {
|
245
|
-
$.shining.config = config;
|
246
|
-
$.shining.slides.add(config.slides);
|
247
|
-
callback.call();
|
248
|
-
});
|
249
|
-
}
|
250
|
-
|
251
|
-
function bindKeys() {
|
252
|
-
$(document).keydown(function(event) {
|
253
|
-
switch(event.keyCode) {
|
254
|
-
case KEY.RIGHT:
|
255
|
-
case KEY.SPACE:
|
256
|
-
$.shining.nextSlide();
|
257
|
-
break;
|
258
|
-
case KEY.LEFT:
|
259
|
-
$.shining.previousSlide();
|
260
|
-
break;
|
261
|
-
}
|
262
|
-
})
|
263
|
-
}
|
264
|
-
|
265
|
-
function help(message, duration) {
|
266
|
-
if ($.shining.config.help == false) return false;
|
267
|
-
var duration = duration || 500;
|
268
|
-
$('#help').remove();
|
269
|
-
$('<div id="help"></div>')
|
270
|
-
.html(message)
|
271
|
-
.css({display: 'inline-block'})
|
272
|
-
.appendTo('body')
|
273
|
-
.animate({opacity: 1})
|
274
|
-
.delay(duration)
|
275
|
-
.fadeOut(200, function() { $('#help').remove() })
|
276
|
-
}
|
277
|
-
|
278
|
-
function local() {
|
279
|
-
document.location.protocol == 'file:'
|
280
|
-
}
|
281
|
-
|
282
|
-
$.shining.scripts = {
|
283
|
-
LINE: /^(\d[.\d]*),[\s]*(.*)/,
|
284
|
-
parsed: [], processes: [],
|
285
|
-
nextSlide: function() { $.shining.nextSlide() },
|
286
|
-
previousSlide: function() { $.shining.previousSlide() },
|
287
|
-
at: function(seconds, method) {
|
288
|
-
$.shining.scripts.processes.push(setTimeout(method, parseFloat(seconds) * 1000))
|
289
|
-
},
|
290
|
-
parse: function(script) {
|
291
|
-
var lines = script.split("\n"), tokens, parsed = [];
|
292
|
-
for (var i = 0; lines.length > i; i++) {
|
293
|
-
if ($.shining.scripts.LINE.test(lines[i])) {
|
294
|
-
var tokens = lines[i].match($.shining.scripts.LINE);
|
295
|
-
var time = tokens[1], code = tokens[2];
|
296
|
-
parsed.push(time);
|
297
|
-
if (code.length) parsed.push(code);
|
298
|
-
} else {
|
299
|
-
if (isNaN(parsed[parsed.length - 1])) {
|
300
|
-
parsed[parsed.length - 1] += ("; " + lines[i]);
|
301
|
-
} else {
|
302
|
-
parsed.push(lines[i]);
|
303
|
-
}
|
304
|
-
}
|
305
|
-
}
|
306
|
-
return parsed;
|
307
|
-
},
|
308
|
-
run: function(script) {
|
309
|
-
if (typeof script == 'undefined' || script == '') return false;
|
310
|
-
var parsed = $.shining.scripts.parse(script), all = [];
|
311
|
-
for (var i = 0; parsed.length > i; i += 2) {
|
312
|
-
all.push(["at(", parsed[i], ", function() { ", parsed[i+1], " })"].join(''));
|
313
|
-
}
|
314
|
-
with($.shining.scripts) { eval(all.join(';')) };
|
315
|
-
},
|
316
|
-
reap: function() {
|
317
|
-
$($.shining.scripts.processes).each(function() { clearTimeout(this) });
|
318
|
-
return $.shining.scripts.processes = [];
|
319
|
-
}
|
320
|
-
}
|
321
|
-
|
322
|
-
bind('previous', function() { help('←') });
|
323
|
-
bind('next', function() { help('→') });
|
324
|
-
|
325
|
-
init();
|
326
|
-
}
|
327
|
-
// boots!
|
328
|
-
$.shining();
|
329
|
-
})(jQuery);
|
330
|
-
|
331
|
-
// Dependencies!!
|
332
|
-
|
333
|
-
/*
|
334
|
-
* JSizes - JQuery plugin v0.33
|
335
|
-
*
|
336
|
-
* Licensed under the revised BSD License.
|
337
|
-
* Copyright 2008-2010 Bram Stein
|
338
|
-
* All rights reserved.
|
339
|
-
*/
|
340
|
-
(function(b){var a=function(c){return parseInt(c,10)||0};b.each(["min","max"],function(d,c){b.fn[c+"Size"]=function(g){var f,e;if(g){if(g.width!==undefined){this.css(c+"-width",g.width)}if(g.height!==undefined){this.css(c+"-height",g.height)}return this}else{f=this.css(c+"-width");e=this.css(c+"-height");return{width:(c==="max"&&(f===undefined||f==="none"||a(f)===-1)&&Number.MAX_VALUE)||a(f),height:(c==="max"&&(e===undefined||e==="none"||a(e)===-1)&&Number.MAX_VALUE)||a(e)}}}});b.fn.isVisible=function(){return this.is(":visible")};b.each(["border","margin","padding"],function(d,c){b.fn[c]=function(e){if(e){if(e.top!==undefined){this.css(c+"-top"+(c==="border"?"-width":""),e.top)}if(e.bottom!==undefined){this.css(c+"-bottom"+(c==="border"?"-width":""),e.bottom)}if(e.left!==undefined){this.css(c+"-left"+(c==="border"?"-width":""),e.left)}if(e.right!==undefined){this.css(c+"-right"+(c==="border"?"-width":""),e.right)}return this}else{return{top:a(this.css(c+"-top"+(c==="border"?"-width":""))),bottom:a(this.css(c+"-bottom"+(c==="border"?"-width":""))),left:a(this.css(c+"-left"+(c==="border"?"-width":""))),right:a(this.css(c+"-right"+(c==="border"?"-width":"")))}}}})})(jQuery);
|
341
|
-
|
342
|
-
// centralizes an element vertically
|
343
|
-
(function($){$.fn.centralize=function(){var self=this.get(0);windowHeight=document.documentElement.clientHeight,elementHeight=(self.offsetHeight+$(self).padding().top+$(self).padding().bottom);$(self).css('position','relative').css('top',(windowHeight/2)-(elementHeight/2)+'px');};})(jQuery);
|
344
|
-
|
345
|
-
/*
|
346
|
-
* jQuery hashchange event - v1.2 - 2/11/2010
|
347
|
-
* http://benalman.com/projects/jquery-hashchange-plugin/
|
348
|
-
*
|
349
|
-
* Copyright (c) 2010 "Cowboy" Ben Alman
|
350
|
-
* Dual licensed under the MIT and GPL licenses.
|
351
|
-
* http://benalman.com/about/license/
|
352
|
-
*/
|
353
|
-
(function($,i,b){var j,k=$.event.special,c="location",d="hashchange",l="href",f=$.browser,g=document.documentMode,h=f.msie&&(g===b||g<8),e="on"+d in i&&!h;function a(m){m=m||i[c][l];return m.replace(/^[^#]*#?(.*)$/,"$1")}$[d+"Delay"]=100;k[d]=$.extend(k[d],{setup:function(){if(e){return false}$(j.start)},teardown:function(){if(e){return false}$(j.stop)}});j=(function(){var m={},r,n,o,q;function p(){o=q=function(s){return s};if(h){n=$('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this);
|
354
|
-
|
355
|
-
// IE Array.prototype.indexOf fix
|
356
|
-
if(!Array.prototype.indexOf){Array.prototype.indexOf=function(elt,from){var len=this.length;var from=Number(arguments[1])||0;from=(from<0)?Math.ceil(from):Math.floor(from);if(from<0)from+=len;for(;from<len;from++){if(from in this&&this[from]===elt)return from;} return-1;};}
|
357
|
-
|
358
|
-
$(window).bind('hashchange', function(event) {
|
359
|
-
var slide = document.location.hash.replace('#', '');
|
360
|
-
if (slide) { $.shining.getSlide(slide) };
|
361
|
-
});
|
File without changes
|