deckr 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +7 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +9 -0
- data/bin/deckr +3 -0
- data/lib/deckr.rb +7 -0
- data/lib/deckr/cli.rb +22 -0
- data/lib/deckr/deck.rb +64 -0
- data/lib/deckr/package.rb +22 -0
- data/lib/deckr/resource.rb +37 -0
- data/lib/deckr/templates/Gemfile +5 -0
- data/lib/deckr/templates/config.ru +12 -0
- data/lib/deckr/templates/deck/GPL-license.txt +278 -0
- data/lib/deckr/templates/deck/MIT-license.txt +21 -0
- data/lib/deckr/templates/deck/README.md +64 -0
- data/lib/deckr/templates/deck/boilerplate.html +96 -0
- data/lib/deckr/templates/deck/core/deck.core.css +407 -0
- data/lib/deckr/templates/deck/core/deck.core.js +498 -0
- data/lib/deckr/templates/deck/core/deck.core.scss +450 -0
- data/lib/deckr/templates/deck/extensions/goto/deck.goto.css +41 -0
- data/lib/deckr/templates/deck/extensions/goto/deck.goto.html +7 -0
- data/lib/deckr/templates/deck/extensions/goto/deck.goto.js +170 -0
- data/lib/deckr/templates/deck/extensions/goto/deck.goto.scss +46 -0
- data/lib/deckr/templates/deck/extensions/hash/deck.hash.css +13 -0
- data/lib/deckr/templates/deck/extensions/hash/deck.hash.html +2 -0
- data/lib/deckr/templates/deck/extensions/hash/deck.hash.js +142 -0
- data/lib/deckr/templates/deck/extensions/hash/deck.hash.scss +15 -0
- data/lib/deckr/templates/deck/extensions/menu/deck.menu.css +47 -0
- data/lib/deckr/templates/deck/extensions/menu/deck.menu.js +187 -0
- data/lib/deckr/templates/deck/extensions/menu/deck.menu.scss +58 -0
- data/lib/deckr/templates/deck/extensions/navigation/deck.navigation.css +43 -0
- data/lib/deckr/templates/deck/extensions/navigation/deck.navigation.html +3 -0
- data/lib/deckr/templates/deck/extensions/navigation/deck.navigation.js +92 -0
- data/lib/deckr/templates/deck/extensions/navigation/deck.navigation.scss +56 -0
- data/lib/deckr/templates/deck/extensions/scale/deck.scale.css +28 -0
- data/lib/deckr/templates/deck/extensions/scale/deck.scale.js +170 -0
- data/lib/deckr/templates/deck/extensions/scale/deck.scale.scss +31 -0
- data/lib/deckr/templates/deck/extensions/status/deck.status.css +18 -0
- data/lib/deckr/templates/deck/extensions/status/deck.status.html +6 -0
- data/lib/deckr/templates/deck/extensions/status/deck.status.js +95 -0
- data/lib/deckr/templates/deck/extensions/status/deck.status.scss +22 -0
- data/lib/deckr/templates/deck/introduction/index.html +215 -0
- data/lib/deckr/templates/deck/jquery-1.7.2.min.js +4 -0
- data/lib/deckr/templates/deck/modernizr.custom.js +4 -0
- data/lib/deckr/templates/deck/test/fixtures/complex.html +24 -0
- data/lib/deckr/templates/deck/test/fixtures/empty.html +19 -0
- data/lib/deckr/templates/deck/test/fixtures/iframe_simple.html +10 -0
- data/lib/deckr/templates/deck/test/fixtures/iframes.html +32 -0
- data/lib/deckr/templates/deck/test/fixtures/nesteds.html +36 -0
- data/lib/deckr/templates/deck/test/fixtures/standard.html +42 -0
- data/lib/deckr/templates/deck/test/index.html +39 -0
- data/lib/deckr/templates/deck/test/lib/jasmine-html.js +190 -0
- data/lib/deckr/templates/deck/test/lib/jasmine-jquery.js +288 -0
- data/lib/deckr/templates/deck/test/lib/jasmine.css +166 -0
- data/lib/deckr/templates/deck/test/lib/jasmine.js +2477 -0
- data/lib/deckr/templates/deck/test/settings.js +3 -0
- data/lib/deckr/templates/deck/test/spec.core.js +436 -0
- data/lib/deckr/templates/deck/test/spec.goto.js +142 -0
- data/lib/deckr/templates/deck/test/spec.hash.js +81 -0
- data/lib/deckr/templates/deck/test/spec.menu.js +66 -0
- data/lib/deckr/templates/deck/test/spec.navigation.js +51 -0
- data/lib/deckr/templates/deck/test/spec.scale.js +57 -0
- data/lib/deckr/templates/deck/test/spec.status.js +58 -0
- data/lib/deckr/templates/deck/themes/style/neon.css +123 -0
- data/lib/deckr/templates/deck/themes/style/neon.scss +155 -0
- data/lib/deckr/templates/deck/themes/style/swiss.css +84 -0
- data/lib/deckr/templates/deck/themes/style/swiss.scss +107 -0
- data/lib/deckr/templates/deck/themes/style/web-2.0.css +214 -0
- data/lib/deckr/templates/deck/themes/style/web-2.0.scss +250 -0
- data/lib/deckr/templates/deck/themes/transition/fade.css +43 -0
- data/lib/deckr/templates/deck/themes/transition/fade.scss +69 -0
- data/lib/deckr/templates/deck/themes/transition/horizontal-slide.css +76 -0
- data/lib/deckr/templates/deck/themes/transition/horizontal-slide.scss +90 -0
- data/lib/deckr/templates/deck/themes/transition/vertical-slide.css +94 -0
- data/lib/deckr/templates/deck/themes/transition/vertical-slide.scss +112 -0
- data/lib/deckr/templates/views/index.slim +13 -0
- data/lib/deckr/templates/views/layout.slim +48 -0
- data/lib/deckr/version.rb +3 -0
- data/lib/rack/deckr.rb +31 -0
- data/lib/sinatra/deckr.rb +17 -0
- data/spec/deck_spec.rb +118 -0
- data/spec/fixtures/foo.txt +1 -0
- data/spec/fixtures/foo/bar.txt +1 -0
- data/spec/package_spec.rb +45 -0
- data/spec/rack/deckr_spec.rb +38 -0
- data/spec/resource_spec.rb +62 -0
- data/spec/sinatra/deckr_spec.rb +32 -0
- data/spec/spec_helper.rb +27 -0
- metadata +161 -0
@@ -0,0 +1,436 @@
|
|
1
|
+
// Go tests, go
|
2
|
+
describe('Deck JS', function() {
|
3
|
+
describe('standard html structure', function() {
|
4
|
+
beforeEach(function() {
|
5
|
+
loadFixtures('standard.html');
|
6
|
+
if (Modernizr.history) {
|
7
|
+
history.replaceState({}, "", "#")
|
8
|
+
}
|
9
|
+
else {
|
10
|
+
window.location.hash = '#';
|
11
|
+
}
|
12
|
+
});
|
13
|
+
|
14
|
+
describe('init(selector)', function() {
|
15
|
+
it('should create slides', function() {
|
16
|
+
$.deck('.slide');
|
17
|
+
expect($.deck('getSlides').length).toEqual($('.slide').length);
|
18
|
+
});
|
19
|
+
});
|
20
|
+
|
21
|
+
describe('init([selectors])', function() {
|
22
|
+
it('should create slides', function() {
|
23
|
+
$.deck([
|
24
|
+
'.slide1',
|
25
|
+
'.slide2',
|
26
|
+
'.slide3',
|
27
|
+
'.slide4',
|
28
|
+
'.slide5'
|
29
|
+
]);
|
30
|
+
expect($.deck('getSlides').length).toEqual($('.slide').length);
|
31
|
+
});
|
32
|
+
});
|
33
|
+
|
34
|
+
describe('navigation functions', function() {
|
35
|
+
beforeEach(function() {
|
36
|
+
$.deck('.slide');
|
37
|
+
});
|
38
|
+
|
39
|
+
describe('go(i)', function() {
|
40
|
+
it('should go to the i slide (0 based index)', function() {
|
41
|
+
$.deck('go', 3);
|
42
|
+
expect($.deck('getSlide')).toHaveClass('slide4');
|
43
|
+
});
|
44
|
+
|
45
|
+
it('should go to the slide with specified id', function() {
|
46
|
+
$.deck('go', 'custom-id');
|
47
|
+
expect($.deck('getSlide')).toHaveId('custom-id');
|
48
|
+
});
|
49
|
+
|
50
|
+
it('should go nowhere if i is out of bounds', function() {
|
51
|
+
$.deck('go', 5);
|
52
|
+
expect($.deck('getSlide')).toHaveClass('slide1');
|
53
|
+
});
|
54
|
+
|
55
|
+
it('should go nowhere if id does not exist', function() {
|
56
|
+
$.deck('go', 'i-dont-exist');
|
57
|
+
expect($.deck('getSlide')).toHaveClass('slide1');
|
58
|
+
});
|
59
|
+
});
|
60
|
+
|
61
|
+
describe('next()', function() {
|
62
|
+
it('should go to the next slide', function() {
|
63
|
+
$.deck('next');
|
64
|
+
expect($.deck('getSlide')).toHaveClass('slide2');
|
65
|
+
});
|
66
|
+
|
67
|
+
it('should go nowhere if on the last slide', function() {
|
68
|
+
$.deck('go', 4);
|
69
|
+
$.deck('next');
|
70
|
+
expect($.deck('getSlide')).toHaveClass('slide5');
|
71
|
+
});
|
72
|
+
});
|
73
|
+
|
74
|
+
describe('prev()', function() {
|
75
|
+
it('should go to the previous slide', function() {
|
76
|
+
$.deck('go', 2);
|
77
|
+
$.deck('prev');
|
78
|
+
expect($.deck('getSlide')).toHaveClass('slide2');
|
79
|
+
});
|
80
|
+
|
81
|
+
it('should go nowhere if on the first slide', function() {
|
82
|
+
$.deck('prev');
|
83
|
+
expect($.deck('getSlide')).toHaveClass('slide1');
|
84
|
+
});
|
85
|
+
});
|
86
|
+
});
|
87
|
+
|
88
|
+
describe('getters', function() {
|
89
|
+
beforeEach(function() {
|
90
|
+
$.deck('.slide');
|
91
|
+
});
|
92
|
+
|
93
|
+
describe('getSlide()', function() {
|
94
|
+
it('should get the current slide', function() {
|
95
|
+
expect($.deck('getSlide')).toHaveClass('slide1');
|
96
|
+
$.deck('go', 2);
|
97
|
+
expect($.deck('getSlide')).toHaveClass('slide3');
|
98
|
+
});
|
99
|
+
});
|
100
|
+
|
101
|
+
describe('getSlide(i)', function() {
|
102
|
+
it('should get slide number i (0 based index)', function() {
|
103
|
+
expect($.deck('getSlide', 1)).toHaveClass('slide2');
|
104
|
+
expect($.deck('getSlide', 3)).toHaveClass('slide4');
|
105
|
+
});
|
106
|
+
|
107
|
+
it('should return null if i is NaN', function() {
|
108
|
+
expect($.deck('getSlide', 'barfoo')).toBeNull();
|
109
|
+
});
|
110
|
+
|
111
|
+
it('should return null if i is out of bounds', function() {
|
112
|
+
expect($.deck('getSlide', 6)).toBeNull();
|
113
|
+
});
|
114
|
+
});
|
115
|
+
|
116
|
+
describe('getSlides()', function() {
|
117
|
+
it('should return an array of jQuery objects for each slide', function() {
|
118
|
+
var expectation = [],
|
119
|
+
slides = $.deck('getSlides');
|
120
|
+
$('.slide').each(function() {
|
121
|
+
expectation.push($(this));
|
122
|
+
});
|
123
|
+
expect(slides).toEqual(expectation);
|
124
|
+
});
|
125
|
+
});
|
126
|
+
|
127
|
+
describe('getContainer()', function() {
|
128
|
+
it('should return a jQuery object with the container element(s)', function() {
|
129
|
+
expect($.deck('getContainer')).toBe(defaults.selectors.container);
|
130
|
+
});
|
131
|
+
});
|
132
|
+
|
133
|
+
describe('getOptions()', function() {
|
134
|
+
it('should return the current options object', function() {
|
135
|
+
expect($.deck('getOptions')).toEqual(defaults);
|
136
|
+
});
|
137
|
+
});
|
138
|
+
});
|
139
|
+
|
140
|
+
describe('container states', function() {
|
141
|
+
beforeEach(function() {
|
142
|
+
$.deck('.slide');
|
143
|
+
});
|
144
|
+
|
145
|
+
it('should start at state 0', function() {
|
146
|
+
expect($(defaults.selectors.container)).toHaveClass(defaults.classes.onPrefix + '0');
|
147
|
+
});
|
148
|
+
|
149
|
+
it('should change states with the slide number', function() {
|
150
|
+
$.deck('next');
|
151
|
+
expect($(defaults.selectors.container)).toHaveClass(defaults.classes.onPrefix + '1');
|
152
|
+
$.deck('go', 3);
|
153
|
+
expect($(defaults.selectors.container)).toHaveClass(defaults.classes.onPrefix + '3');
|
154
|
+
$.deck('prev');
|
155
|
+
expect($(defaults.selectors.container)).toHaveClass(defaults.classes.onPrefix + '2');
|
156
|
+
});
|
157
|
+
});
|
158
|
+
|
159
|
+
describe('options object', function() {
|
160
|
+
var $d = $(document);
|
161
|
+
|
162
|
+
beforeEach(function() {
|
163
|
+
$.deck('.alt-slide', {
|
164
|
+
classes: {
|
165
|
+
after: 'alt-after',
|
166
|
+
before: 'alt-before',
|
167
|
+
current: 'alt-current',
|
168
|
+
onPrefix: 'alt-on-',
|
169
|
+
next: 'alt-next',
|
170
|
+
previous: 'alt-prev'
|
171
|
+
},
|
172
|
+
|
173
|
+
selectors: {
|
174
|
+
container: '.alt-container'
|
175
|
+
},
|
176
|
+
|
177
|
+
keys: {
|
178
|
+
next: 87,
|
179
|
+
previous: 69
|
180
|
+
}
|
181
|
+
});
|
182
|
+
});
|
183
|
+
|
184
|
+
describe('classes', function() {
|
185
|
+
it('should use the specified after class', function() {
|
186
|
+
expect($('.alt-slide3, .alt-slide4, .alt-slide5')).toHaveClass('alt-after');
|
187
|
+
});
|
188
|
+
|
189
|
+
it('should use the specified before class', function() {
|
190
|
+
$.deck('go', 4);
|
191
|
+
expect($('.alt-slide1, .alt-slide2, .alt-slide3')).toHaveClass('alt-before');
|
192
|
+
});
|
193
|
+
|
194
|
+
it('should use the specified container class', function() {
|
195
|
+
$.deck('go', 2);
|
196
|
+
expect($('.alt-container')).toHaveClass('alt-on-2');
|
197
|
+
});
|
198
|
+
|
199
|
+
it('should use the specified current class', function() {
|
200
|
+
expect($.deck('getSlide')).toHaveClass('alt-current');
|
201
|
+
});
|
202
|
+
|
203
|
+
it('should use the specified next class', function() {
|
204
|
+
expect($('.alt-slide2')).toHaveClass('alt-next');
|
205
|
+
});
|
206
|
+
|
207
|
+
it('should use the specified previous class', function() {
|
208
|
+
$.deck('next');
|
209
|
+
expect($('.alt-slide1')).toHaveClass('alt-prev');
|
210
|
+
});
|
211
|
+
});
|
212
|
+
|
213
|
+
describe('key bindings', function() {
|
214
|
+
var e;
|
215
|
+
|
216
|
+
beforeEach(function() {
|
217
|
+
e = jQuery.Event('keydown.deck');
|
218
|
+
});
|
219
|
+
|
220
|
+
it('should go to the next slide using the specified key', function() {
|
221
|
+
e.which = 87; // 'w'
|
222
|
+
$d.trigger(e);
|
223
|
+
expect($.deck('getSlide')).toHaveClass('alt-slide2');
|
224
|
+
});
|
225
|
+
|
226
|
+
it('should go to the previous slide using the specified key', function() {
|
227
|
+
$.deck('next');
|
228
|
+
e.which = 69; // 'e'
|
229
|
+
$d.trigger(e);
|
230
|
+
expect($.deck('getSlide')).toHaveClass('alt-slide1');
|
231
|
+
});
|
232
|
+
|
233
|
+
it('should not trigger events that originate within editable elements', function() {
|
234
|
+
var $outside = $('<input type="text" />').appendTo('body');
|
235
|
+
e = jQuery.Event('keydown');
|
236
|
+
e.which = 87;
|
237
|
+
$outside.trigger(e);
|
238
|
+
expect($.deck('getSlide')).toHaveClass('alt-slide1');
|
239
|
+
$outside.remove();
|
240
|
+
});
|
241
|
+
});
|
242
|
+
});
|
243
|
+
|
244
|
+
describe('events', function() {
|
245
|
+
var $d = $(document);
|
246
|
+
|
247
|
+
beforeEach(function() {
|
248
|
+
spyOnEvent($d, 'deck.init');
|
249
|
+
spyOnEvent($d, 'deck.beforeInit');
|
250
|
+
$.deck('.slide');
|
251
|
+
$.deck('go', 1);
|
252
|
+
spyOnEvent($d, 'deck.change');
|
253
|
+
});
|
254
|
+
|
255
|
+
describe('deck.change', function() {
|
256
|
+
it('should fire on go(i)', function() {
|
257
|
+
$.deck('go', 3);
|
258
|
+
expect('deck.change').toHaveBeenTriggeredOn($d);
|
259
|
+
});
|
260
|
+
|
261
|
+
it('should fire on next()', function() {
|
262
|
+
$.deck('next');
|
263
|
+
expect('deck.change').toHaveBeenTriggeredOn($d);
|
264
|
+
});
|
265
|
+
|
266
|
+
it('should fire on prev()', function() {
|
267
|
+
$.deck('prev');
|
268
|
+
expect('deck.change').toHaveBeenTriggeredOn($d);
|
269
|
+
});
|
270
|
+
|
271
|
+
it('should pass parameters with from and to indices', function() {
|
272
|
+
var f = function(e, from, to) {
|
273
|
+
expect(from).toEqual(1);
|
274
|
+
expect(to).toEqual(3);
|
275
|
+
};
|
276
|
+
|
277
|
+
$d.bind('deck.change', f);
|
278
|
+
$.deck('go', 3);
|
279
|
+
$d.unbind('deck.change', f);
|
280
|
+
});
|
281
|
+
|
282
|
+
it('should not change slides if default prevented', function() {
|
283
|
+
$d.bind('deck.change', false);
|
284
|
+
$.deck('go', 3);
|
285
|
+
expect($.deck('getSlide')).toEqual($.deck('getSlide', 1));
|
286
|
+
$d.unbind('deck.change', false);
|
287
|
+
});
|
288
|
+
});
|
289
|
+
|
290
|
+
describe('deck.init', function() {
|
291
|
+
it('should fire on deck initialization', function() {
|
292
|
+
expect('deck.init').toHaveBeenTriggeredOn($d);
|
293
|
+
});
|
294
|
+
|
295
|
+
it('should have already populated the slides array', function() {
|
296
|
+
var f = function() {
|
297
|
+
expect($.deck('getSlides').length).toBeGreaterThan(0);
|
298
|
+
};
|
299
|
+
|
300
|
+
$d.bind('deck.init', f);
|
301
|
+
$.deck('.slide');
|
302
|
+
$d.unbind('deck.init', f);
|
303
|
+
});
|
304
|
+
});
|
305
|
+
|
306
|
+
describe('deck.beforeInit', function() {
|
307
|
+
it('should fire on deck initialization', function() {
|
308
|
+
expect('deck.beforeInit').toHaveBeenTriggeredOn($d);
|
309
|
+
});
|
310
|
+
|
311
|
+
it('should have not populated the slides array', function() {
|
312
|
+
var f = function() {
|
313
|
+
expect($.deck('getSlides').length).toEqual(0);
|
314
|
+
};
|
315
|
+
|
316
|
+
$d.bind('deck.beforeInit', f);
|
317
|
+
$.deck('.slide');
|
318
|
+
$d.unbind('deck.beforeInit', f);
|
319
|
+
});
|
320
|
+
});
|
321
|
+
});
|
322
|
+
});
|
323
|
+
|
324
|
+
describe('complex html structure', function() {
|
325
|
+
beforeEach(function() {
|
326
|
+
loadFixtures('complex.html');
|
327
|
+
if (Modernizr.history) {
|
328
|
+
history.replaceState({}, "", "#")
|
329
|
+
}
|
330
|
+
$.deck([
|
331
|
+
'.slide1',
|
332
|
+
'.slide2',
|
333
|
+
'.slide3',
|
334
|
+
'.slide4',
|
335
|
+
'.slide5',
|
336
|
+
'.slide6',
|
337
|
+
'.slide7',
|
338
|
+
'.slide8',
|
339
|
+
'.slide9',
|
340
|
+
'.slide10',
|
341
|
+
]);
|
342
|
+
$.deck('go', 2);
|
343
|
+
});
|
344
|
+
|
345
|
+
describe('compound state classes', function() {
|
346
|
+
it('should apply current class', function() {
|
347
|
+
$('.slide3').each(function(i, el) {
|
348
|
+
expect($(el)).toHaveClass(defaults.classes.current);
|
349
|
+
});
|
350
|
+
});
|
351
|
+
|
352
|
+
it('should apply previous class', function() {
|
353
|
+
$('.slide2').each(function(i, el) {
|
354
|
+
expect($(el)).toHaveClass(defaults.classes.previous);
|
355
|
+
});
|
356
|
+
});
|
357
|
+
|
358
|
+
it('should apply next class', function() {
|
359
|
+
$('.slide4').each(function(i, el) {
|
360
|
+
expect($(el)).toHaveClass(defaults.classes.next);
|
361
|
+
});
|
362
|
+
});
|
363
|
+
|
364
|
+
it('should apply before class', function() {
|
365
|
+
$('.slide1').each(function(i, el) {
|
366
|
+
expect($(el)).toHaveClass(defaults.classes.before);
|
367
|
+
});
|
368
|
+
});
|
369
|
+
|
370
|
+
it('should apply after class', function() {
|
371
|
+
$('.slide5, .slide6, .slide7, .slide8, .slide9, .slide10').each(function(i, el) {
|
372
|
+
expect($(el)).toHaveClass(defaults.classes.after);
|
373
|
+
});
|
374
|
+
});
|
375
|
+
|
376
|
+
it('should apply child-current class', function() {
|
377
|
+
expect($('.slide2').not('.slide10')).toHaveClass(defaults.classes.childCurrent);
|
378
|
+
});
|
379
|
+
});
|
380
|
+
|
381
|
+
it('should remove old state classes', function() {
|
382
|
+
$.deck('go', 4);
|
383
|
+
expect($('.slide3').not('.slide5')).not.toHaveClass(defaults.classes.current);
|
384
|
+
expect($('.slide2').not('.slide4')).not.toHaveClass(defaults.classes.previous);
|
385
|
+
expect($('.slide4').not('.slide6')).not.toHaveClass(defaults.classes.next);
|
386
|
+
});
|
387
|
+
});
|
388
|
+
|
389
|
+
describe('iframes', function() {
|
390
|
+
beforeEach(function() {
|
391
|
+
loadFixtures('iframes.html');
|
392
|
+
if (Modernizr.history) {
|
393
|
+
history.replaceState({}, "", "#")
|
394
|
+
}
|
395
|
+
$.deck([
|
396
|
+
'.slide1',
|
397
|
+
'.slide2',
|
398
|
+
'.slide3',
|
399
|
+
'.slide4',
|
400
|
+
'.slide5',
|
401
|
+
'.slide6',
|
402
|
+
'.slide7',
|
403
|
+
'.slide8',
|
404
|
+
'.slide9',
|
405
|
+
'.slide10',
|
406
|
+
]);
|
407
|
+
|
408
|
+
});
|
409
|
+
|
410
|
+
it('should remove/restore iframe sources when leaving/entering a slide', function() {
|
411
|
+
$.deck('go', 4);
|
412
|
+
expect($.deck('getSlide').find('iframe').attr('src')).toEqual('fixtures/iframe_simple.html');
|
413
|
+
$.deck('next');
|
414
|
+
expect($('.slide5').find('iframe').attr('src')).toEqual('');
|
415
|
+
$.deck('prev');
|
416
|
+
expect($('.slide5').find('iframe').attr('src')).toEqual('fixtures/iframe_simple.html');
|
417
|
+
});
|
418
|
+
|
419
|
+
it('should not store blank iframe sources', function() {
|
420
|
+
$.deck('go', 6);
|
421
|
+
$.deck('next');
|
422
|
+
expect($.deck('getSlide').find('iframe').data('src')).toBeUndefined();
|
423
|
+
});
|
424
|
+
});
|
425
|
+
|
426
|
+
describe('empty deck', function() {
|
427
|
+
beforeEach(function() {
|
428
|
+
loadFixtures('empty.html');
|
429
|
+
$.deck('.slide');
|
430
|
+
});
|
431
|
+
|
432
|
+
describe('getSlide()', function() {
|
433
|
+
it('should not error on init', $.noop);
|
434
|
+
});
|
435
|
+
});
|
436
|
+
});
|
@@ -0,0 +1,142 @@
|
|
1
|
+
describe('Deck JS Quick Go-To', function() {
|
2
|
+
var $d = $(document);
|
3
|
+
|
4
|
+
beforeEach(function() {
|
5
|
+
loadFixtures('standard.html');
|
6
|
+
if (Modernizr.history) {
|
7
|
+
history.replaceState({}, "", "#")
|
8
|
+
}
|
9
|
+
else {
|
10
|
+
window.location.hash = '#';
|
11
|
+
}
|
12
|
+
$.deck('.slide');
|
13
|
+
});
|
14
|
+
|
15
|
+
describe('showGoTo()', function() {
|
16
|
+
it('should show the go-to helper', function() {
|
17
|
+
expect($(defaults.selectors.container)).not.toHaveClass(defaults.classes.goto);
|
18
|
+
$.deck('showGoTo');
|
19
|
+
expect($(defaults.selectors.container)).toHaveClass(defaults.classes.goto);
|
20
|
+
});
|
21
|
+
|
22
|
+
it('should focus the go-to input', function() {
|
23
|
+
$.deck('showGoTo');
|
24
|
+
expect($(defaults.selectors.gotoInput)[0]).toEqual(document.activeElement);
|
25
|
+
});
|
26
|
+
});
|
27
|
+
|
28
|
+
describe('hideGoTo()', function() {
|
29
|
+
beforeEach(function() {
|
30
|
+
$.deck('showGoTo');
|
31
|
+
$.deck('hideGoTo');
|
32
|
+
});
|
33
|
+
|
34
|
+
it('should hide the go-to helper', function() {
|
35
|
+
expect($(defaults.selectors.container)).not.toHaveClass(defaults.classes.goto);
|
36
|
+
});
|
37
|
+
|
38
|
+
it('should blur the go-to input', function() {
|
39
|
+
expect($(defaults.selectors.gotoInput)[0]).not.toEqual(document.activeElement);
|
40
|
+
});
|
41
|
+
});
|
42
|
+
|
43
|
+
describe('toggleGoTo()', function() {
|
44
|
+
it('should toggle the go-to helper on and off', function() {
|
45
|
+
expect($(defaults.selectors.container)).not.toHaveClass(defaults.classes.goto);
|
46
|
+
$.deck('toggleGoTo');
|
47
|
+
expect($(defaults.selectors.container)).toHaveClass(defaults.classes.goto);
|
48
|
+
$.deck('toggleGoTo');
|
49
|
+
expect($(defaults.selectors.container)).not.toHaveClass(defaults.classes.goto);
|
50
|
+
});
|
51
|
+
});
|
52
|
+
|
53
|
+
describe('Go-To submit', function() {
|
54
|
+
beforeEach(function() {
|
55
|
+
$.deck('showGoTo');
|
56
|
+
});
|
57
|
+
|
58
|
+
it('should hide the go-to helper', function() {
|
59
|
+
$(defaults.selectors.gotoInput).val('3');
|
60
|
+
$(defaults.selectors.gotoForm).submit();
|
61
|
+
expect($(defaults.selectors.container)).not.toHaveClass(defaults.classes.goto);
|
62
|
+
});
|
63
|
+
|
64
|
+
it('should go to the slide number entered', function() {
|
65
|
+
$(defaults.selectors.gotoInput).val('3');
|
66
|
+
$(defaults.selectors.gotoForm).submit();
|
67
|
+
expect($.deck('getSlide')).toEqual($.deck('getSlide'), 2);
|
68
|
+
});
|
69
|
+
|
70
|
+
it('should go to the slide id entered', function() {
|
71
|
+
$(defaults.selectors.gotoInput).val('custom-id');
|
72
|
+
$(defaults.selectors.gotoForm).submit();
|
73
|
+
expect($.deck('getSlide')).toEqual($.deck('getSlide'), 1);
|
74
|
+
});
|
75
|
+
|
76
|
+
it('should go nowhere if the number is negative', function() {
|
77
|
+
$(defaults.selectors.gotoInput).val('-2');
|
78
|
+
$(defaults.selectors.gotoForm).submit();
|
79
|
+
expect($.deck('getSlide')).toEqual($.deck('getSlide'), 0);
|
80
|
+
});
|
81
|
+
|
82
|
+
it('should go nowhere if the number is greater than the number of slides', function() {
|
83
|
+
$(defaults.selectors.gotoInput).val('9');
|
84
|
+
$(defaults.selectors.gotoForm).submit();
|
85
|
+
expect($.deck('getSlide')).toEqual($.deck('getSlide'), 0);
|
86
|
+
});
|
87
|
+
|
88
|
+
it('should go nowhere if the id does not exist', function() {
|
89
|
+
$(defaults.selectors.gotoInput).val('do-not-exist');
|
90
|
+
$(defaults.selectors.gotoForm).submit();
|
91
|
+
expect($.deck('getSlide')).toEqual($.deck('getSlide'), 0);
|
92
|
+
});
|
93
|
+
});
|
94
|
+
|
95
|
+
describe('Datalist population', function() {
|
96
|
+
it('should fill in options with all the slide ids', function() {
|
97
|
+
var $dataOptions = $(defaults.selectors.gotoDatalist).find('option');
|
98
|
+
expect($dataOptions.length).toEqual(5);
|
99
|
+
expect($dataOptions.eq(0).attr('value')).toEqual('slide-0');
|
100
|
+
expect($dataOptions.eq(1).attr('value')).toEqual('custom-id');
|
101
|
+
});
|
102
|
+
});
|
103
|
+
|
104
|
+
describe('key bindings', function() {
|
105
|
+
var e;
|
106
|
+
|
107
|
+
beforeEach(function() {
|
108
|
+
e = jQuery.Event('keydown.deckgoto');
|
109
|
+
});
|
110
|
+
|
111
|
+
it('should toggle the go-to helper if the specified key is pressed', function() {
|
112
|
+
e.which = 71; // g
|
113
|
+
$d.trigger(e);
|
114
|
+
expect($(defaults.selectors.container)).toHaveClass(defaults.classes.goto);
|
115
|
+
$d.trigger(e);
|
116
|
+
expect($(defaults.selectors.container)).not.toHaveClass(defaults.classes.goto);
|
117
|
+
});
|
118
|
+
});
|
119
|
+
|
120
|
+
describe('countNested false', function() {
|
121
|
+
beforeEach(function() {
|
122
|
+
loadFixtures('nesteds.html');
|
123
|
+
$.deck('.slide', {
|
124
|
+
countNested: false
|
125
|
+
});
|
126
|
+
$.deck('showGoTo');
|
127
|
+
});
|
128
|
+
|
129
|
+
it('should ignore nested slides when given a slide number', function() {
|
130
|
+
$(defaults.selectors.gotoInput).val('4');
|
131
|
+
$(defaults.selectors.gotoForm).submit();
|
132
|
+
expect($.deck('getSlide')).toHaveId('after');
|
133
|
+
});
|
134
|
+
|
135
|
+
it('should respect top side of new slide range', function() {
|
136
|
+
$.deck('go', 0);
|
137
|
+
$(defaults.selectors.gotoInput).val('6');
|
138
|
+
$(defaults.selectors.gotoForm).submit();
|
139
|
+
expect($.deck('getSlide')).toHaveId('slide-0');
|
140
|
+
});
|
141
|
+
});
|
142
|
+
});
|