eggplant 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +66 -0
- data/README.md +30 -0
- data/Rakefile +8 -0
- data/bin/eggplant +5 -0
- data/eggplant.gemspec +34 -0
- data/lib/eggplant.rb +8 -0
- data/lib/eggplant/assets/css/eggplant/main.css +77 -0
- data/lib/eggplant/assets/css/vendor/deck.core.css +393 -0
- data/lib/eggplant/assets/css/vendor/extensions/deck.codemirror.css +89 -0
- data/lib/eggplant/assets/css/vendor/extensions/deck.goto.css +41 -0
- data/lib/eggplant/assets/css/vendor/extensions/deck.hash.css +13 -0
- data/lib/eggplant/assets/css/vendor/extensions/deck.menu.css +24 -0
- data/lib/eggplant/assets/css/vendor/extensions/deck.navigation.css +43 -0
- data/lib/eggplant/assets/css/vendor/extensions/deck.scale.css +16 -0
- data/lib/eggplant/assets/css/vendor/extensions/deck.status.css +14 -0
- data/lib/eggplant/assets/css/vendor/extensions/deck.subslides.css +9 -0
- data/lib/eggplant/assets/css/vendor/themes/neon.css +114 -0
- data/lib/eggplant/assets/css/vendor/themes/swiss.css +75 -0
- data/lib/eggplant/assets/css/vendor/themes/web-2.0.css +187 -0
- data/lib/eggplant/assets/css/vendor/transitions/fade.css +43 -0
- data/lib/eggplant/assets/css/vendor/transitions/horizontal-slide.css +79 -0
- data/lib/eggplant/assets/css/vendor/transitions/vertical-slide.css +97 -0
- data/lib/eggplant/assets/js/eggplant/main.js +38 -0
- data/lib/eggplant/assets/js/eggplant/remote.js +0 -0
- data/lib/eggplant/assets/js/vendor/coffee-script.js +8 -0
- data/lib/eggplant/assets/js/vendor/deck.core.js +457 -0
- data/lib/eggplant/assets/js/vendor/extensions/deck.goto.js +118 -0
- data/lib/eggplant/assets/js/vendor/extensions/deck.hash.js +113 -0
- data/lib/eggplant/assets/js/vendor/extensions/deck.menu.js +127 -0
- data/lib/eggplant/assets/js/vendor/extensions/deck.navigation.js +83 -0
- data/lib/eggplant/assets/js/vendor/extensions/deck.scale.js +155 -0
- data/lib/eggplant/assets/js/vendor/extensions/deck.status.js +42 -0
- data/lib/eggplant/assets/js/vendor/extensions/deck.subslides.js +50 -0
- data/lib/eggplant/assets/js/vendor/jquery.js +9046 -0
- data/lib/eggplant/assets/js/vendor/less.js +2769 -0
- data/lib/eggplant/assets/js/vendor/modernizr.js +1116 -0
- data/lib/eggplant/cli.rb +113 -0
- data/lib/eggplant/markdown.rb +76 -0
- data/lib/eggplant/server.rb +168 -0
- data/lib/eggplant/slides.rb +65 -0
- data/lib/eggplant/version.rb +3 -0
- data/lib/eggplant/views/remote.slim +17 -0
- data/lib/eggplant/views/show.slim +47 -0
- metadata +281 -0
@@ -0,0 +1,118 @@
|
|
1
|
+
/*!
|
2
|
+
Deck JS - deck.goto - v1.0
|
3
|
+
Copyright (c) 2011 Caleb Troughton
|
4
|
+
Dual licensed under the MIT license and GPL license.
|
5
|
+
https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt
|
6
|
+
https://github.com/imakewebthings/deck.js/blob/master/GPL-license.txt
|
7
|
+
*/
|
8
|
+
|
9
|
+
/*
|
10
|
+
This module adds the necessary methods and key bindings to show and hide a form
|
11
|
+
for jumping to any slide number in the deck (and processes that form
|
12
|
+
accordingly). The form-showing state is indicated by the presence of a class on
|
13
|
+
the deck container.
|
14
|
+
*/
|
15
|
+
(function($, deck, undefined) {
|
16
|
+
var $d = $(document);
|
17
|
+
|
18
|
+
/*
|
19
|
+
Extends defaults/options.
|
20
|
+
|
21
|
+
options.classes.goto
|
22
|
+
This class is added to the deck container when showing the Go To Slide
|
23
|
+
form.
|
24
|
+
|
25
|
+
options.selectors.gotoForm
|
26
|
+
The element that matches this selector is the form that is submitted
|
27
|
+
when a user hits enter after typing a slide number in the gotoInput
|
28
|
+
element.
|
29
|
+
|
30
|
+
options.selectors.gotoInput
|
31
|
+
The element that matches this selector is the text input field for
|
32
|
+
entering a slide number in the Go To Slide form.
|
33
|
+
|
34
|
+
options.keys.goto
|
35
|
+
The numeric keycode used to toggle between showing and hiding the Go To
|
36
|
+
Slide form.
|
37
|
+
*/
|
38
|
+
$.extend(true, $[deck].defaults, {
|
39
|
+
classes: {
|
40
|
+
goto: 'deck-goto'
|
41
|
+
},
|
42
|
+
|
43
|
+
selectors: {
|
44
|
+
gotoForm: '.goto-form',
|
45
|
+
gotoInput: '#goto-slide'
|
46
|
+
},
|
47
|
+
|
48
|
+
keys: {
|
49
|
+
goto: 71 // g
|
50
|
+
}
|
51
|
+
});
|
52
|
+
|
53
|
+
/*
|
54
|
+
jQuery.deck('showGoTo')
|
55
|
+
|
56
|
+
Shows the Go To Slide form by adding the class specified by the goto class
|
57
|
+
option to the deck container.
|
58
|
+
*/
|
59
|
+
$[deck]('extend', 'showGoTo', function() {
|
60
|
+
$[deck]('getContainer').addClass($[deck]('getOptions').classes.goto);
|
61
|
+
$($[deck]('getOptions').selectors.gotoInput).focus();
|
62
|
+
});
|
63
|
+
|
64
|
+
/*
|
65
|
+
jQuery.deck('hideGoTo')
|
66
|
+
|
67
|
+
Hides the Go To Slide form by removing the class specified by the goto class
|
68
|
+
option from the deck container.
|
69
|
+
*/
|
70
|
+
$[deck]('extend', 'hideGoTo', function() {
|
71
|
+
$[deck]('getContainer').removeClass($[deck]('getOptions').classes.goto);
|
72
|
+
$($[deck]('getOptions').selectors.gotoInput).blur();
|
73
|
+
});
|
74
|
+
|
75
|
+
/*
|
76
|
+
jQuery.deck('toggleGoTo')
|
77
|
+
|
78
|
+
Toggles between showing and hiding the Go To Slide form.
|
79
|
+
*/
|
80
|
+
$[deck]('extend', 'toggleGoTo', function() {
|
81
|
+
$[deck]($[deck]('getContainer').hasClass($[deck]('getOptions').classes.goto) ? 'hideGoTo' : 'showGoTo');
|
82
|
+
});
|
83
|
+
|
84
|
+
$d.bind('deck.init', function() {
|
85
|
+
// Bind key events
|
86
|
+
$d.unbind('keydown.deckgoto').bind('keydown.deckgoto', function(e) {
|
87
|
+
var key = $[deck]('getOptions').keys.goto;
|
88
|
+
|
89
|
+
if (e.which === key ||$.inArray(e.which, key) > -1) {
|
90
|
+
e.preventDefault();
|
91
|
+
$[deck]('toggleGoTo');
|
92
|
+
}
|
93
|
+
});
|
94
|
+
|
95
|
+
// Process form submittal, go to the slide entered
|
96
|
+
$($[deck]('getOptions').selectors.gotoForm)
|
97
|
+
.unbind('submit.deckgoto')
|
98
|
+
.bind('submit.deckgoto', function(e) {
|
99
|
+
var $field = ($($[deck]('getOptions').selectors.gotoInput)),
|
100
|
+
i = parseInt($field.val(), 10);
|
101
|
+
|
102
|
+
if (!($.isNaN(i) || i < 1 || i > $[deck]('getSlides').length)) {
|
103
|
+
$[deck]('go', i - 1);
|
104
|
+
$[deck]('hideGoTo');
|
105
|
+
$field.val('');
|
106
|
+
}
|
107
|
+
|
108
|
+
e.preventDefault();
|
109
|
+
});
|
110
|
+
|
111
|
+
$($[deck]('getOptions').selectors.gotoInput)
|
112
|
+
.unbind('keydown.deckgoto')
|
113
|
+
.bind('keydown.deckgoto', function(e) {
|
114
|
+
e.stopPropagation();
|
115
|
+
});
|
116
|
+
});
|
117
|
+
})(jQuery, 'deck');
|
118
|
+
|
@@ -0,0 +1,113 @@
|
|
1
|
+
/*!
|
2
|
+
Deck JS - deck.hash - v1.0
|
3
|
+
Copyright (c) 2011 Caleb Troughton
|
4
|
+
Dual licensed under the MIT license and GPL license.
|
5
|
+
https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt
|
6
|
+
https://github.com/imakewebthings/deck.js/blob/master/GPL-license.txt
|
7
|
+
*/
|
8
|
+
|
9
|
+
/*
|
10
|
+
This module adds deep linking to individual slides, enables internal links
|
11
|
+
to slides within decks, and updates the address bar with the hash as the user
|
12
|
+
moves through the deck. A permalink anchor is also updated. Standard themes
|
13
|
+
hide this link in browsers that support the History API, and show it for
|
14
|
+
those that do not. Slides that do not have an id are assigned one according to
|
15
|
+
the hashPrefix option.
|
16
|
+
*/
|
17
|
+
(function ($, deck, window, undefined) {
|
18
|
+
var $d = $(document),
|
19
|
+
$window = $(window),
|
20
|
+
|
21
|
+
/* Collection of internal fragment links in the deck */
|
22
|
+
$internals,
|
23
|
+
|
24
|
+
/*
|
25
|
+
Internal only function. Given a string, extracts the id from the hash,
|
26
|
+
matches it to the appropriate slide, and navigates there.
|
27
|
+
*/
|
28
|
+
goByHash = function(str) {
|
29
|
+
var id = str.substr(str.indexOf("#") + 1),
|
30
|
+
slides = $[deck]('getSlides');
|
31
|
+
|
32
|
+
$.each(slides, function(i, $el) {
|
33
|
+
if ($el.attr('id') === id) {
|
34
|
+
$[deck]('go', i);
|
35
|
+
return false;
|
36
|
+
}
|
37
|
+
});
|
38
|
+
|
39
|
+
// If we don't set these to 0 the container scrolls due to hashchange
|
40
|
+
$[deck]('getContainer').scrollLeft(0).scrollTop(0);
|
41
|
+
};
|
42
|
+
|
43
|
+
/*
|
44
|
+
Extends defaults/options.
|
45
|
+
|
46
|
+
options.selectors.hashLink
|
47
|
+
The element matching this selector has its href attribute updated to
|
48
|
+
the hash of the current slide as the user navigates through the deck.
|
49
|
+
|
50
|
+
options.hashPrefix
|
51
|
+
Every slide that does not have an id is assigned one at initialization.
|
52
|
+
Assigned ids take the form of hashPrefix + slideIndex, e.g., slide-0,
|
53
|
+
slide-12, etc.
|
54
|
+
*/
|
55
|
+
$.extend(true, $[deck].defaults, {
|
56
|
+
selectors: {
|
57
|
+
hashLink: '.deck-permalink'
|
58
|
+
},
|
59
|
+
|
60
|
+
hashPrefix: 'slide-'
|
61
|
+
});
|
62
|
+
|
63
|
+
|
64
|
+
$d.bind('deck.init', function() {
|
65
|
+
$internals = $();
|
66
|
+
|
67
|
+
$.each($[deck]('getSlides'), function(i, $el) {
|
68
|
+
var hash;
|
69
|
+
|
70
|
+
/* Hand out ids to the unfortunate slides born without them */
|
71
|
+
if (!$el.attr('id')) {
|
72
|
+
$el.attr('id', $[deck]('getOptions').hashPrefix + i);
|
73
|
+
}
|
74
|
+
|
75
|
+
hash ='#' + $el.attr('id');
|
76
|
+
|
77
|
+
/* Deep link to slides on init */
|
78
|
+
if (hash === window.location.hash) {
|
79
|
+
$[deck]('go', i);
|
80
|
+
}
|
81
|
+
|
82
|
+
/* Add internal links to this slide */
|
83
|
+
$internals = $internals.add('a[href="' + hash + '"]');
|
84
|
+
});
|
85
|
+
|
86
|
+
if (!Modernizr.hashchange) {
|
87
|
+
/* Set up internal links using click for the poor browsers
|
88
|
+
without a hashchange event. */
|
89
|
+
$internals.unbind('click.deckhash').bind('click.deckhash', function(e) {
|
90
|
+
goByHash($(this).attr('href'));
|
91
|
+
});
|
92
|
+
}
|
93
|
+
})
|
94
|
+
/* Update permalink and address bar on a slide change */
|
95
|
+
.bind('deck.change', function(e, from, to) {
|
96
|
+
var hash = '#' + $[deck]('getSlide', to).attr('id');
|
97
|
+
|
98
|
+
$($[deck]('getOptions').selectors.hashLink).attr('href', hash);
|
99
|
+
if (Modernizr.history) {
|
100
|
+
window.history.replaceState({}, "", hash);
|
101
|
+
}
|
102
|
+
});
|
103
|
+
|
104
|
+
/* Deals with internal links in modern browsers */
|
105
|
+
$window.bind('hashchange.deckhash', function(e) {
|
106
|
+
if (e.originalEvent && e.originalEvent.newURL) {
|
107
|
+
goByHash(e.originalEvent.newURL);
|
108
|
+
}
|
109
|
+
else {
|
110
|
+
goByHash(window.location.hash);
|
111
|
+
}
|
112
|
+
});
|
113
|
+
})(jQuery, 'deck', this);
|
@@ -0,0 +1,127 @@
|
|
1
|
+
/*!
|
2
|
+
Deck JS - deck.menu - v1.0
|
3
|
+
Copyright (c) 2011 Caleb Troughton
|
4
|
+
Dual licensed under the MIT license and GPL license.
|
5
|
+
https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt
|
6
|
+
https://github.com/imakewebthings/deck.js/blob/master/GPL-license.txt
|
7
|
+
*/
|
8
|
+
|
9
|
+
/*
|
10
|
+
This module adds the methods and key binding to show and hide a menu of all
|
11
|
+
slides in the deck. The deck menu state is indicated by the presence of a class
|
12
|
+
on the deck container.
|
13
|
+
*/
|
14
|
+
(function($, deck, undefined) {
|
15
|
+
var $d = $(document);
|
16
|
+
|
17
|
+
/*
|
18
|
+
Extends defaults/options.
|
19
|
+
|
20
|
+
options.classes.menu
|
21
|
+
This class is added to the deck container when showing the slide menu.
|
22
|
+
|
23
|
+
options.keys.menu
|
24
|
+
The numeric keycode used to toggle between showing and hiding the slide
|
25
|
+
menu.
|
26
|
+
|
27
|
+
options.touch.doubletapWindow
|
28
|
+
Two consecutive touch events within this number of milliseconds will
|
29
|
+
be considered a double tap, and will toggle the menu on touch devices.
|
30
|
+
*/
|
31
|
+
$.extend(true, $[deck].defaults, {
|
32
|
+
classes: {
|
33
|
+
menu: 'deck-menu'
|
34
|
+
},
|
35
|
+
|
36
|
+
keys: {
|
37
|
+
menu: 77 // m
|
38
|
+
},
|
39
|
+
|
40
|
+
touch: {
|
41
|
+
doubletapWindow: 400
|
42
|
+
}
|
43
|
+
});
|
44
|
+
|
45
|
+
/*
|
46
|
+
jQuery.deck('showMenu')
|
47
|
+
|
48
|
+
Shows the slide menu by adding the class specified by the menu class option
|
49
|
+
to the deck container.
|
50
|
+
*/
|
51
|
+
$[deck]('extend', 'showMenu', function() {
|
52
|
+
$[deck]('getContainer').addClass($[deck]('getOptions').classes.menu);
|
53
|
+
$[deck]('getContainer').scrollTop($[deck]('getSlide').offset().top);
|
54
|
+
});
|
55
|
+
|
56
|
+
/*
|
57
|
+
jQuery.deck('hideMenu')
|
58
|
+
|
59
|
+
Hides the slide menu by removing the class specified by the menu class
|
60
|
+
option from the deck container.
|
61
|
+
*/
|
62
|
+
$[deck]('extend', 'hideMenu', function() {
|
63
|
+
$[deck]('getContainer').removeClass($[deck]('getOptions').classes.menu);
|
64
|
+
$[deck]('getContainer').scrollTop(0);
|
65
|
+
});
|
66
|
+
|
67
|
+
/*
|
68
|
+
jQuery.deck('toggleMenu')
|
69
|
+
|
70
|
+
Toggles between showing and hiding the slide menu.
|
71
|
+
*/
|
72
|
+
$[deck]('extend', 'toggleMenu', function() {
|
73
|
+
$[deck]('getContainer').hasClass($[deck]('getOptions').classes.menu) ?
|
74
|
+
$[deck]('hideMenu') : $[deck]('showMenu');
|
75
|
+
});
|
76
|
+
|
77
|
+
$d.bind('deck.init', function() {
|
78
|
+
var opts = $[deck]('getOptions'),
|
79
|
+
touchEndTime = 0,
|
80
|
+
currentSlide;
|
81
|
+
|
82
|
+
// Bind key events
|
83
|
+
$d.unbind('keydown.deckmenu').bind('keydown.deckmenu', function(e) {
|
84
|
+
if (e.which === opts.keys.menu || $.inArray(e.which, opts.keys.menu) > -1) {
|
85
|
+
$[deck]('toggleMenu');
|
86
|
+
e.preventDefault();
|
87
|
+
}
|
88
|
+
});
|
89
|
+
|
90
|
+
// Double tap to toggle slide menu for touch devices
|
91
|
+
$[deck]('getContainer').unbind('touchstart.deckmenu').bind('touchstart.deckmenu', function(e) {
|
92
|
+
currentSlide = $[deck]('getSlide');
|
93
|
+
})
|
94
|
+
.unbind('touchend.deckmenu').bind('touchend.deckmenu', function(e) {
|
95
|
+
var now = Date.now();
|
96
|
+
|
97
|
+
// Ignore this touch event if it caused a nav change (swipe)
|
98
|
+
if (currentSlide !== $[deck]('getSlide')) return;
|
99
|
+
|
100
|
+
if (now - touchEndTime < opts.touch.doubletapWindow) {
|
101
|
+
$[deck]('toggleMenu');
|
102
|
+
e.preventDefault();
|
103
|
+
}
|
104
|
+
touchEndTime = now;
|
105
|
+
});
|
106
|
+
|
107
|
+
// Selecting slides from the menu
|
108
|
+
$.each($[deck]('getSlides'), function(i, $s) {
|
109
|
+
$s.unbind('click.deckmenu').bind('click.deckmenu', function(e) {
|
110
|
+
if (!$[deck]('getContainer').hasClass(opts.classes.menu)) return;
|
111
|
+
|
112
|
+
$[deck]('go', i);
|
113
|
+
$[deck]('hideMenu');
|
114
|
+
e.stopPropagation();
|
115
|
+
e.preventDefault();
|
116
|
+
});
|
117
|
+
});
|
118
|
+
})
|
119
|
+
.bind('deck.change', function(e, from, to) {
|
120
|
+
var container = $[deck]('getContainer');
|
121
|
+
|
122
|
+
if (container.hasClass($[deck]('getOptions').classes.menu)) {
|
123
|
+
container.scrollTop($[deck]('getSlide', to).offset().top);
|
124
|
+
}
|
125
|
+
});
|
126
|
+
})(jQuery, 'deck');
|
127
|
+
|
@@ -0,0 +1,83 @@
|
|
1
|
+
/*!
|
2
|
+
Deck JS - deck.navigation - v1.0
|
3
|
+
Copyright (c) 2011 Caleb Troughton
|
4
|
+
Dual licensed under the MIT license and GPL license.
|
5
|
+
https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt
|
6
|
+
https://github.com/imakewebthings/deck.js/blob/master/GPL-license.txt
|
7
|
+
*/
|
8
|
+
|
9
|
+
/*
|
10
|
+
This module adds clickable previous and next links to the deck.
|
11
|
+
*/
|
12
|
+
(function($, deck, undefined) {
|
13
|
+
var $d = $(document);
|
14
|
+
|
15
|
+
/*
|
16
|
+
Extends defaults/options.
|
17
|
+
|
18
|
+
options.classes.navDisabled
|
19
|
+
This class is added to a navigation link when that action is disabled.
|
20
|
+
It is added to the previous link when on the first slide, and to the
|
21
|
+
next link when on the last slide.
|
22
|
+
|
23
|
+
options.selectors.nextLink
|
24
|
+
The elements that match this selector will move the deck to the next
|
25
|
+
slide when clicked.
|
26
|
+
|
27
|
+
options.selectors.previousLink
|
28
|
+
The elements that match this selector will move to deck to the previous
|
29
|
+
slide when clicked.
|
30
|
+
*/
|
31
|
+
$.extend(true, $[deck].defaults, {
|
32
|
+
classes: {
|
33
|
+
navDisabled: 'deck-nav-disabled'
|
34
|
+
},
|
35
|
+
|
36
|
+
selectors: {
|
37
|
+
nextLink: '.deck-next-link',
|
38
|
+
previousLink: '.deck-prev-link'
|
39
|
+
}
|
40
|
+
});
|
41
|
+
|
42
|
+
$d.bind('deck.init', function() {
|
43
|
+
var opts = $[deck]('getOptions'),
|
44
|
+
nextSlide = $[deck]('getSlide', 1),
|
45
|
+
nextId = nextSlide ? nextSlide.attr('id') : undefined;
|
46
|
+
|
47
|
+
// Setup prev/next link events
|
48
|
+
$(opts.selectors.previousLink)
|
49
|
+
.unbind('click.decknavigation')
|
50
|
+
.bind('click.decknavigation', function(e) {
|
51
|
+
$[deck]('prev');
|
52
|
+
e.preventDefault();
|
53
|
+
});
|
54
|
+
|
55
|
+
$(opts.selectors.nextLink)
|
56
|
+
.unbind('click.decknavigation')
|
57
|
+
.bind('click.decknavigation', function(e) {
|
58
|
+
$[deck]('next');
|
59
|
+
e.preventDefault();
|
60
|
+
});
|
61
|
+
|
62
|
+
// Start on first slide, previous link is disabled, set next link href
|
63
|
+
$(opts.selectors.previousLink).addClass(opts.classes.navDisabled);
|
64
|
+
$(opts.selectors.nextLink).attr('href', '#' + (nextId ? nextId : ''));
|
65
|
+
})
|
66
|
+
/* Updates link hrefs, and disabled states if last/first slide */
|
67
|
+
.bind('deck.change', function(e, from, to) {
|
68
|
+
var opts = $[deck]('getOptions'),
|
69
|
+
last = $[deck]('getSlides').length - 1,
|
70
|
+
prevSlide = $[deck]('getSlide', to - 1),
|
71
|
+
nextSlide = $[deck]('getSlide', to + 1),
|
72
|
+
prevId = prevSlide ? prevSlide.attr('id') : undefined;
|
73
|
+
nextId = nextSlide ? nextSlide.attr('id') : undefined;
|
74
|
+
|
75
|
+
$(opts.selectors.previousLink)
|
76
|
+
.toggleClass(opts.classes.navDisabled, !to)
|
77
|
+
.attr('href', '#' + (prevId ? prevId : ''));
|
78
|
+
$(opts.selectors.nextLink)
|
79
|
+
.toggleClass(opts.classes.navDisabled, to === last)
|
80
|
+
.attr('href', '#' + (nextId ? nextId : ''));
|
81
|
+
});
|
82
|
+
})(jQuery, 'deck');
|
83
|
+
|
@@ -0,0 +1,155 @@
|
|
1
|
+
/*!
|
2
|
+
Deck JS - deck.scale - v1.0
|
3
|
+
Copyright (c) 2011 Caleb Troughton
|
4
|
+
Dual licensed under the MIT license and GPL license.
|
5
|
+
https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt
|
6
|
+
https://github.com/imakewebthings/deck.js/blob/master/GPL-license.txt
|
7
|
+
*/
|
8
|
+
|
9
|
+
/*
|
10
|
+
This module adds automatic scaling to the deck. It should only be used on
|
11
|
+
standalone decks where the body is the deck container. Slides are scaled down
|
12
|
+
using CSS transforms to fit within the browser window. If the browser window
|
13
|
+
is big enough to hold the slides without scaling, no scaling occurs. The user
|
14
|
+
can disable and enable scaling with a keyboard shortcut.
|
15
|
+
|
16
|
+
Note: CSS transforms make Flash videos render incorrectly. Presenters that
|
17
|
+
need to use video will want to disable scaling to play them. HTML5 video
|
18
|
+
works fine.
|
19
|
+
*/
|
20
|
+
(function($, deck, window, undefined) {
|
21
|
+
var $d = $(document),
|
22
|
+
$w = $(window),
|
23
|
+
baseHeight, // Value to scale against
|
24
|
+
timer, // Timeout id for debouncing
|
25
|
+
|
26
|
+
/*
|
27
|
+
Internal function to do all the dirty work of scaling the deck container.
|
28
|
+
*/
|
29
|
+
scaleDeck = function() {
|
30
|
+
var obh = $[deck]('getOptions').baseHeight,
|
31
|
+
$container = $[deck]('getContainer'),
|
32
|
+
height = $w.height(),
|
33
|
+
slides = $[deck]('getSlides'),
|
34
|
+
scale,
|
35
|
+
transform;
|
36
|
+
|
37
|
+
// Don't scale if scaling disabled
|
38
|
+
if (!$container.hasClass($[deck]('getOptions').classes.scale)) {
|
39
|
+
scale = 1;
|
40
|
+
}
|
41
|
+
else {
|
42
|
+
// Use tallest slide as base height if not set manually
|
43
|
+
baseHeight = obh ? obh : (function() {
|
44
|
+
var greatest = 0;
|
45
|
+
|
46
|
+
$.each(slides, function(i, $slide) {
|
47
|
+
greatest = Math.max(greatest, $slide.outerHeight());
|
48
|
+
});
|
49
|
+
|
50
|
+
return greatest;
|
51
|
+
})();
|
52
|
+
|
53
|
+
scale = height / baseHeight;
|
54
|
+
}
|
55
|
+
|
56
|
+
// Scale, but don't scale up
|
57
|
+
transform = scale >= 1 ? 'none' : 'scale(' + scale + ')';
|
58
|
+
$.each('Webkit Moz O ms Khtml'.split(' '), function(i, prefix) {
|
59
|
+
$container.css(prefix + 'Transform', transform);
|
60
|
+
});
|
61
|
+
};
|
62
|
+
|
63
|
+
/*
|
64
|
+
Extends defaults/options.
|
65
|
+
|
66
|
+
options.classes.scale
|
67
|
+
This class is added to the deck container when scaling is enabled.
|
68
|
+
It is enabled by default when the module is included.
|
69
|
+
|
70
|
+
options.keys.scale
|
71
|
+
The numeric keycode used to toggle enabling and disabling scaling.
|
72
|
+
|
73
|
+
options.baseHeight
|
74
|
+
When baseheight is falsy, as it is by default, the deck is scaled
|
75
|
+
in proportion to the height of the slides. You may instead specify
|
76
|
+
a height, and the deck will be scaled against this height regardless
|
77
|
+
of the actual content height.
|
78
|
+
|
79
|
+
options.scaleDebounce
|
80
|
+
Scaling on the browser resize event is debounced. This number is the
|
81
|
+
threshold in milliseconds. You can learn more about debouncing here:
|
82
|
+
http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
|
83
|
+
|
84
|
+
*/
|
85
|
+
$.extend(true, $[deck].defaults, {
|
86
|
+
classes: {
|
87
|
+
scale: 'deck-scale'
|
88
|
+
},
|
89
|
+
|
90
|
+
keys: {
|
91
|
+
scale: 83 // s
|
92
|
+
},
|
93
|
+
|
94
|
+
baseHeight: null,
|
95
|
+
scaleDebounce: 200
|
96
|
+
});
|
97
|
+
|
98
|
+
/*
|
99
|
+
jQuery.deck('disableScale')
|
100
|
+
|
101
|
+
Disables scaling and removes the scale class from the deck container.
|
102
|
+
*/
|
103
|
+
$[deck]('extend', 'disableScale', function() {
|
104
|
+
$[deck]('getContainer').removeClass($[deck]('getOptions').classes.scale);
|
105
|
+
scaleDeck();
|
106
|
+
});
|
107
|
+
|
108
|
+
/*
|
109
|
+
jQuery.deck('enableScale')
|
110
|
+
|
111
|
+
Enables scaling and adds the scale class to the deck container.
|
112
|
+
*/
|
113
|
+
$[deck]('extend', 'enableScale', function() {
|
114
|
+
$[deck]('getContainer').addClass($[deck]('getOptions').classes.scale);
|
115
|
+
scaleDeck();
|
116
|
+
});
|
117
|
+
|
118
|
+
/*
|
119
|
+
jQuery.deck('toggleScale')
|
120
|
+
|
121
|
+
Toggles between enabling and disabling scaling.
|
122
|
+
*/
|
123
|
+
$[deck]('extend', 'toggleScale', function() {
|
124
|
+
var $c = $[deck]('getContainer');
|
125
|
+
$[deck]($c.hasClass($[deck]('getOptions').classes.scale) ?
|
126
|
+
'disableScale' : 'enableScale');
|
127
|
+
});
|
128
|
+
|
129
|
+
$d.bind('deck.init', function() {
|
130
|
+
var opts = $[deck]('getOptions');
|
131
|
+
|
132
|
+
// Scaling enabled at start
|
133
|
+
$[deck]('getContainer').addClass(opts.classes.scale);
|
134
|
+
|
135
|
+
// Debounce the resize scaling
|
136
|
+
$w.unbind('resize.deckscale').bind('resize.deckscale', function() {
|
137
|
+
window.clearTimeout(timer);
|
138
|
+
timer = window.setTimeout(scaleDeck, opts.scaleDebounce);
|
139
|
+
})
|
140
|
+
// Scale once on load, in case images or something change layout
|
141
|
+
.unbind('load.deckscale').bind('load.deckscale', scaleDeck);
|
142
|
+
|
143
|
+
// Bind key events
|
144
|
+
$d.unbind('keydown.deckscale').bind('keydown.deckscale', function(e) {
|
145
|
+
if (e.which === opts.keys.scale || $.inArray(e.which, opts.keys.scale) > -1) {
|
146
|
+
$[deck]('toggleScale');
|
147
|
+
e.preventDefault();
|
148
|
+
}
|
149
|
+
});
|
150
|
+
|
151
|
+
// Scale once on init
|
152
|
+
scaleDeck();
|
153
|
+
});
|
154
|
+
})(jQuery, 'deck', this);
|
155
|
+
|