deckrb 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/README.md +84 -25
  2. data/bin/deck +3 -4
  3. data/lib/deck/rack_app.rb +39 -7
  4. data/lib/deck/slide.rb +9 -2
  5. data/lib/deck/slide_deck.rb +10 -13
  6. data/lib/deck/version.rb +1 -1
  7. data/public/coderay.css +84 -0
  8. data/public/deck.js/GPL-license.txt +278 -0
  9. data/public/deck.js/MIT-license.txt +21 -0
  10. data/public/deck.js/README.md +57 -0
  11. data/public/deck.js/core/deck.core.css +404 -0
  12. data/public/deck.js/core/deck.core.html +39 -0
  13. data/public/deck.js/core/deck.core.js +498 -0
  14. data/public/deck.js/core/deck.core.scss +447 -0
  15. data/public/deck.js/extensions/goto/deck.goto.css +41 -0
  16. data/public/deck.js/extensions/goto/deck.goto.html +7 -0
  17. data/public/deck.js/extensions/goto/deck.goto.js +134 -0
  18. data/public/deck.js/extensions/goto/deck.goto.scss +46 -0
  19. data/public/deck.js/extensions/hash/deck.hash.css +13 -0
  20. data/public/deck.js/extensions/hash/deck.hash.html +2 -0
  21. data/public/deck.js/extensions/hash/deck.hash.js +129 -0
  22. data/public/deck.js/extensions/hash/deck.hash.scss +15 -0
  23. data/public/deck.js/extensions/menu/deck.menu.css +47 -0
  24. data/public/deck.js/extensions/menu/deck.menu.js +187 -0
  25. data/public/deck.js/extensions/menu/deck.menu.scss +58 -0
  26. data/public/deck.js/extensions/navigation/deck.navigation.css +43 -0
  27. data/public/deck.js/extensions/navigation/deck.navigation.html +3 -0
  28. data/public/deck.js/extensions/navigation/deck.navigation.js +91 -0
  29. data/public/deck.js/extensions/navigation/deck.navigation.scss +56 -0
  30. data/public/deck.js/extensions/scale/deck.scale.css +16 -0
  31. data/public/deck.js/extensions/scale/deck.scale.js +156 -0
  32. data/public/deck.js/extensions/scale/deck.scale.scss +17 -0
  33. data/public/deck.js/extensions/status/deck.status.css +18 -0
  34. data/public/deck.js/extensions/status/deck.status.html +6 -0
  35. data/public/deck.js/extensions/status/deck.status.js +95 -0
  36. data/public/deck.js/extensions/status/deck.status.scss +22 -0
  37. data/public/deck.js/extensions/theme-picker/deck.theme-picker.css +55 -0
  38. data/public/deck.js/extensions/theme-picker/deck.theme-picker.js +13 -0
  39. data/public/deck.js/introduction/index.html +221 -0
  40. data/public/deck.js/introduction/index.rb +101 -0
  41. data/public/deck.js/jquery-1.7.min.js +4 -0
  42. data/public/deck.js/modernizr.custom.js +4 -0
  43. data/public/deck.js/test/fixtures/complex.html +24 -0
  44. data/public/deck.js/test/fixtures/empty.html +19 -0
  45. data/public/deck.js/test/fixtures/iframe_simple.html +10 -0
  46. data/public/deck.js/test/fixtures/iframes.html +32 -0
  47. data/public/deck.js/test/fixtures/nesteds.html +36 -0
  48. data/public/deck.js/test/fixtures/standard.html +42 -0
  49. data/public/deck.js/test/index.html +39 -0
  50. data/public/deck.js/test/lib/jasmine-html.js +190 -0
  51. data/public/deck.js/test/lib/jasmine-jquery.js +288 -0
  52. data/public/deck.js/test/lib/jasmine.css +166 -0
  53. data/public/deck.js/test/lib/jasmine.js +2477 -0
  54. data/public/deck.js/test/settings.js +3 -0
  55. data/public/deck.js/test/spec.core.js +434 -0
  56. data/public/deck.js/test/spec.goto.js +119 -0
  57. data/public/deck.js/test/spec.hash.js +81 -0
  58. data/public/deck.js/test/spec.menu.js +66 -0
  59. data/public/deck.js/test/spec.navigation.js +51 -0
  60. data/public/deck.js/test/spec.scale.js +57 -0
  61. data/public/deck.js/test/spec.status.js +58 -0
  62. data/public/deck.js/themes/style/neon.css +114 -0
  63. data/public/deck.js/themes/style/neon.scss +139 -0
  64. data/public/deck.js/themes/style/swiss.css +75 -0
  65. data/public/deck.js/themes/style/swiss.scss +91 -0
  66. data/public/deck.js/themes/style/web-2.0.css +205 -0
  67. data/public/deck.js/themes/style/web-2.0.scss +236 -0
  68. data/public/deck.js/themes/transition/fade.css +44 -0
  69. data/public/deck.js/themes/transition/fade.scss +70 -0
  70. data/public/deck.js/themes/transition/horizontal-slide.css +79 -0
  71. data/public/deck.js/themes/transition/horizontal-slide.scss +94 -0
  72. data/public/deck.js/themes/transition/vertical-slide.css +97 -0
  73. data/public/deck.js/themes/transition/vertical-slide.scss +116 -0
  74. data/public/favicon.ico +0 -0
  75. data/spec/rack_app_spec.rb +101 -33
  76. data/spec/slide_deck_spec.rb +6 -7
  77. data/spec/slide_spec.rb +19 -0
  78. metadata +95 -16
@@ -0,0 +1,7 @@
1
+ <!-- Place the following snippet at the bottom of the deck container. -->
2
+ <form action="." method="get" class="goto-form">
3
+ <label for="goto-slide">Go to slide:</label>
4
+ <input type="text" name="slidenum" id="goto-slide" list="goto-datalist">
5
+ <datalist id="goto-datalist"></datalist>
6
+ <input type="submit" value="Go">
7
+ </form>
@@ -0,0 +1,134 @@
1
+ /*!
2
+ Deck JS - deck.goto
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/id 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.gotoDatalist
26
+ The element that matches this selector is the datalist element that will
27
+ be populated with options for each of the slide ids. In browsers that
28
+ support the datalist element, this provides a drop list of slide ids to
29
+ aid the user in selecting a slide.
30
+
31
+ options.selectors.gotoForm
32
+ The element that matches this selector is the form that is submitted
33
+ when a user hits enter after typing a slide number/id in the gotoInput
34
+ element.
35
+
36
+ options.selectors.gotoInput
37
+ The element that matches this selector is the text input field for
38
+ entering a slide number/id in the Go To Slide form.
39
+
40
+ options.keys.goto
41
+ The numeric keycode used to show the Go To Slide form.
42
+ */
43
+ $.extend(true, $[deck].defaults, {
44
+ classes: {
45
+ goto: 'deck-goto'
46
+ },
47
+
48
+ selectors: {
49
+ gotoDatalist: '#goto-datalist',
50
+ gotoForm: '.goto-form',
51
+ gotoInput: '#goto-slide'
52
+ },
53
+
54
+ keys: {
55
+ goto: 71 // g
56
+ }
57
+ });
58
+
59
+ /*
60
+ jQuery.deck('showGoTo')
61
+
62
+ Shows the Go To Slide form by adding the class specified by the goto class
63
+ option to the deck container.
64
+ */
65
+ $[deck]('extend', 'showGoTo', function() {
66
+ $[deck]('getContainer').addClass($[deck]('getOptions').classes.goto);
67
+ $($[deck]('getOptions').selectors.gotoInput).focus();
68
+ });
69
+
70
+ /*
71
+ jQuery.deck('hideGoTo')
72
+
73
+ Hides the Go To Slide form by removing the class specified by the goto class
74
+ option from the deck container.
75
+ */
76
+ $[deck]('extend', 'hideGoTo', function() {
77
+ $($[deck]('getOptions').selectors.gotoInput).blur();
78
+ $[deck]('getContainer').removeClass($[deck]('getOptions').classes.goto);
79
+ });
80
+
81
+ /*
82
+ jQuery.deck('toggleGoTo')
83
+
84
+ Toggles between showing and hiding the Go To Slide form.
85
+ */
86
+ $[deck]('extend', 'toggleGoTo', function() {
87
+ $[deck]($[deck]('getContainer').hasClass($[deck]('getOptions').classes.goto) ? 'hideGoTo' : 'showGoTo');
88
+ });
89
+
90
+ $d.bind('deck.init', function() {
91
+ var opts = $[deck]('getOptions'),
92
+ $datalist = $(opts.selectors.gotoDatalist);
93
+
94
+ // Bind key events
95
+ $d.unbind('keydown.deckgoto').bind('keydown.deckgoto', function(e) {
96
+ var key = $[deck]('getOptions').keys.goto;
97
+
98
+ if (e.which === key || $.inArray(e.which, key) > -1) {
99
+ e.preventDefault();
100
+ $[deck]('toggleGoTo');
101
+ }
102
+ });
103
+
104
+ /* Populate datalist */
105
+ $.each($[deck]('getSlides'), function(i, $slide) {
106
+ var id = $slide.attr('id');
107
+
108
+ if (id) {
109
+ $datalist.append('<option value="' + id + '">');
110
+ }
111
+ });
112
+
113
+ // Process form submittal, go to the slide entered
114
+ $(opts.selectors.gotoForm)
115
+ .unbind('submit.deckgoto')
116
+ .bind('submit.deckgoto', function(e) {
117
+ var $field = $($[deck]('getOptions').selectors.gotoInput),
118
+ i = parseInt($field.val(), 10);
119
+
120
+ $[deck]('go', isNaN(i) ? $field.val() : i - 1);
121
+ $[deck]('hideGoTo');
122
+ $field.val('');
123
+
124
+ e.preventDefault();
125
+ });
126
+
127
+ $(opts.selectors.gotoInput)
128
+ .unbind('keydown.deckgoto')
129
+ .bind('keydown.deckgoto', function(e) {
130
+ e.stopPropagation();
131
+ });
132
+ });
133
+ })(jQuery, 'deck');
134
+
@@ -0,0 +1,46 @@
1
+ .deck-container {
2
+ .goto-form {
3
+ position:absolute;
4
+ z-index:3;
5
+ bottom:10px;
6
+ left:50%;
7
+ height:1.75em;
8
+ margin:0 0 0 -9.125em;
9
+ line-height:1.75em;
10
+ padding:0.625em;
11
+ display:none;
12
+ background:#ccc;
13
+ overflow:hidden;
14
+
15
+ .borderradius & {
16
+ -webkit-border-radius:10px;
17
+ -moz-border-radius:10px;
18
+ border-radius:10px;
19
+ }
20
+
21
+ label {
22
+ font-weight:bold;
23
+ }
24
+
25
+ label, input {
26
+ display:inline-block;
27
+ font-family:inherit;
28
+ }
29
+ }
30
+ }
31
+
32
+ .deck-goto .goto-form {
33
+ display:block;
34
+ }
35
+
36
+ #goto-slide {
37
+ width:8.375em;
38
+ margin:0 0.625em;
39
+ height:1.4375em;
40
+ }
41
+
42
+ @media print {
43
+ .goto-form, #goto-slide {
44
+ display:none !important;
45
+ }
46
+ }
@@ -0,0 +1,13 @@
1
+ .deck-container .deck-permalink {
2
+ display: none;
3
+ position: absolute;
4
+ z-index: 4;
5
+ bottom: 30px;
6
+ right: 0;
7
+ width: 48px;
8
+ text-align: center;
9
+ }
10
+
11
+ .no-history .deck-container:hover .deck-permalink {
12
+ display: block;
13
+ }
@@ -0,0 +1,2 @@
1
+ <!-- Place the following snippet at the bottom of the deck container. -->
2
+ <a href="." title="Permalink to this slide" class="deck-permalink">#</a>
@@ -0,0 +1,129 @@
1
+ /*!
2
+ Deck JS - deck.hash
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. In addition to the on-slide container state class
16
+ kept by core, this module adds an on-slide state class that uses the id of each
17
+ slide.
18
+ */
19
+ (function ($, deck, window, undefined) {
20
+ var $d = $(document),
21
+ $window = $(window),
22
+
23
+ /* Collection of internal fragment links in the deck */
24
+ $internals,
25
+
26
+ /*
27
+ Internal only function. Given a string, extracts the id from the hash,
28
+ matches it to the appropriate slide, and navigates there.
29
+ */
30
+ goByHash = function(str) {
31
+ var id = str.substr(str.indexOf("#") + 1),
32
+ slides = $[deck]('getSlides');
33
+
34
+ $.each(slides, function(i, $el) {
35
+ if ($el.attr('id') === id) {
36
+ $[deck]('go', i);
37
+ return false;
38
+ }
39
+ });
40
+
41
+ // If we don't set these to 0 the container scrolls due to hashchange
42
+ $[deck]('getContainer').scrollLeft(0).scrollTop(0);
43
+ };
44
+
45
+ /*
46
+ Extends defaults/options.
47
+
48
+ options.selectors.hashLink
49
+ The element matching this selector has its href attribute updated to
50
+ the hash of the current slide as the user navigates through the deck.
51
+
52
+ options.hashPrefix
53
+ Every slide that does not have an id is assigned one at initialization.
54
+ Assigned ids take the form of hashPrefix + slideIndex, e.g., slide-0,
55
+ slide-12, etc.
56
+ */
57
+ $.extend(true, $[deck].defaults, {
58
+ selectors: {
59
+ hashLink: '.deck-permalink'
60
+ },
61
+
62
+ hashPrefix: 'slide-'
63
+ });
64
+
65
+
66
+ $d.bind('deck.init', function() {
67
+ var opts = $[deck]('getOptions');
68
+ $internals = $(),
69
+ slides = $[deck]('getSlides');
70
+
71
+ $.each(slides, function(i, $el) {
72
+ var hash;
73
+
74
+ /* Hand out ids to the unfortunate slides born without them */
75
+ if (!$el.attr('id') || $el.data('deckAssignedId') === $el.attr('id')) {
76
+ $el.attr('id', opts.hashPrefix + i);
77
+ $el.data('deckAssignedId', opts.hashPrefix + i);
78
+ }
79
+
80
+ hash ='#' + $el.attr('id');
81
+
82
+ /* Deep link to slides on init */
83
+ if (hash === window.location.hash) {
84
+ $[deck]('go', i);
85
+ }
86
+
87
+ /* Add internal links to this slide */
88
+ $internals = $internals.add('a[href="' + hash + '"]');
89
+ });
90
+
91
+ if (!Modernizr.hashchange) {
92
+ /* Set up internal links using click for the poor browsers
93
+ without a hashchange event. */
94
+ $internals.unbind('click.deckhash').bind('click.deckhash', function(e) {
95
+ goByHash($(this).attr('href'));
96
+ });
97
+ }
98
+
99
+ /* Set up first id container state class */
100
+ if (slides.length) {
101
+ $[deck]('getContainer').addClass(opts.classes.onPrefix + $[deck]('getSlide').attr('id'));
102
+ };
103
+ })
104
+ /* Update permalink, address bar, and state class on a slide change */
105
+ .bind('deck.change', function(e, from, to) {
106
+ var hash = '#' + $[deck]('getSlide', to).attr('id'),
107
+ opts = $[deck]('getOptions'),
108
+ osp = opts.classes.onPrefix,
109
+ $c = $[deck]('getContainer');
110
+
111
+ $c.removeClass(osp + $[deck]('getSlide', from).attr('id'));
112
+ $c.addClass(osp + $[deck]('getSlide', to).attr('id'));
113
+
114
+ $(opts.selectors.hashLink).attr('href', hash);
115
+ if (Modernizr.history) {
116
+ window.history.replaceState({}, "", hash);
117
+ }
118
+ });
119
+
120
+ /* Deals with internal links in modern browsers */
121
+ $window.bind('hashchange.deckhash', function(e) {
122
+ if (e.originalEvent && e.originalEvent.newURL) {
123
+ goByHash(e.originalEvent.newURL);
124
+ }
125
+ else {
126
+ goByHash(window.location.hash);
127
+ }
128
+ });
129
+ })(jQuery, 'deck', this);
@@ -0,0 +1,15 @@
1
+ .deck-container {
2
+ .deck-permalink {
3
+ display:none;
4
+ position:absolute;
5
+ z-index:4;
6
+ bottom:30px;
7
+ right:0;
8
+ width:48px;
9
+ text-align:center;
10
+ }
11
+ }
12
+
13
+ .no-history .deck-container:hover .deck-permalink {
14
+ display:block;
15
+ }
@@ -0,0 +1,47 @@
1
+ .deck-menu .slide {
2
+ background: #eee;
3
+ position: relative;
4
+ left: 0;
5
+ top: 0;
6
+ visibility: visible;
7
+ cursor: pointer;
8
+ }
9
+ .no-csstransforms .deck-menu > .slide {
10
+ float: left;
11
+ width: 22%;
12
+ height: 22%;
13
+ min-height: 0;
14
+ margin: 1%;
15
+ font-size: 0.22em;
16
+ overflow: hidden;
17
+ padding: 0 0.5%;
18
+ }
19
+ .csstransforms .deck-menu > .slide {
20
+ -webkit-transform: scale(0.22);
21
+ -moz-transform: scale(0.22);
22
+ -o-transform: scale(0.22);
23
+ -ms-transform: scale(0.22);
24
+ transform: scale(0.22);
25
+ -webkit-transform-origin: 0 0;
26
+ -moz-transform-origin: 0 0;
27
+ -o-transform-origin: 0 0;
28
+ -ms-transform-origin: 0 0;
29
+ transform-origin: 0 0;
30
+ -webkit-box-sizing: border-box;
31
+ -moz-box-sizing: border-box;
32
+ box-sizing: border-box;
33
+ width: 100%;
34
+ height: 100%;
35
+ overflow: hidden;
36
+ padding: 0 48px;
37
+ margin: 12px;
38
+ }
39
+ .deck-menu iframe, .deck-menu img, .deck-menu video {
40
+ max-width: 100%;
41
+ }
42
+ .deck-menu .deck-current, .no-touch .deck-menu .slide:hover {
43
+ background: #ddf;
44
+ }
45
+ .deck-menu.deck-container:hover .deck-prev-link, .deck-menu.deck-container:hover .deck-next-link {
46
+ display: none;
47
+ }
@@ -0,0 +1,187 @@
1
+ /*!
2
+ Deck JS - deck.menu
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
+ rootSlides; // Array of top level slides
17
+
18
+ /*
19
+ Extends defaults/options.
20
+
21
+ options.classes.menu
22
+ This class is added to the deck container when showing the slide menu.
23
+
24
+ options.keys.menu
25
+ The numeric keycode used to toggle between showing and hiding the slide
26
+ menu.
27
+
28
+ options.touch.doubletapWindow
29
+ Two consecutive touch events within this number of milliseconds will
30
+ be considered a double tap, and will toggle the menu on touch devices.
31
+ */
32
+ $.extend(true, $[deck].defaults, {
33
+ classes: {
34
+ menu: 'deck-menu'
35
+ },
36
+
37
+ keys: {
38
+ menu: 77 // m
39
+ },
40
+
41
+ touch: {
42
+ doubletapWindow: 400
43
+ }
44
+ });
45
+
46
+ /*
47
+ jQuery.deck('showMenu')
48
+
49
+ Shows the slide menu by adding the class specified by the menu class option
50
+ to the deck container.
51
+ */
52
+ $[deck]('extend', 'showMenu', function() {
53
+ var $c = $[deck]('getContainer'),
54
+ opts = $[deck]('getOptions');
55
+
56
+ if ($c.hasClass(opts.classes.menu)) return;
57
+
58
+ // Hide through loading class to short-circuit transitions (perf)
59
+ $c.addClass([opts.classes.loading, opts.classes.menu].join(' '));
60
+
61
+ /* Forced to do this in JS until CSS learns second-grade math. Save old
62
+ style value for restoration when menu is hidden. */
63
+ if (Modernizr.csstransforms) {
64
+ $.each(rootSlides, function(i, $slide) {
65
+ $slide.data('oldStyle', $slide.attr('style'));
66
+ $slide.css({
67
+ 'position': 'absolute',
68
+ 'left': ((i % 4) * 25) + '%',
69
+ 'top': (Math.floor(i / 4) * 25) + '%'
70
+ });
71
+ });
72
+ }
73
+
74
+ // Need to ensure the loading class renders first, then remove
75
+ window.setTimeout(function() {
76
+ $c.removeClass(opts.classes.loading)
77
+ .scrollTop($[deck]('getSlide').offset().top);
78
+ }, 0);
79
+ });
80
+
81
+ /*
82
+ jQuery.deck('hideMenu')
83
+
84
+ Hides the slide menu by removing the class specified by the menu class
85
+ option from the deck container.
86
+ */
87
+ $[deck]('extend', 'hideMenu', function() {
88
+ var $c = $[deck]('getContainer'),
89
+ opts = $[deck]('getOptions');
90
+
91
+ if (!$c.hasClass(opts.classes.menu)) return;
92
+
93
+ $c.removeClass(opts.classes.menu);
94
+ $c.addClass(opts.classes.loading);
95
+
96
+ /* Restore old style value */
97
+ if (Modernizr.csstransforms) {
98
+ $.each(rootSlides, function(i, $slide) {
99
+ var oldStyle = $slide.data('oldStyle');
100
+
101
+ $slide.attr('style', oldStyle ? oldStyle : '');
102
+ });
103
+ }
104
+
105
+ window.setTimeout(function() {
106
+ $c.removeClass(opts.classes.loading).scrollTop(0);
107
+ }, 0);
108
+ });
109
+
110
+ /*
111
+ jQuery.deck('toggleMenu')
112
+
113
+ Toggles between showing and hiding the slide menu.
114
+ */
115
+ $[deck]('extend', 'toggleMenu', function() {
116
+ $[deck]('getContainer').hasClass($[deck]('getOptions').classes.menu) ?
117
+ $[deck]('hideMenu') : $[deck]('showMenu');
118
+ });
119
+
120
+ $d.bind('deck.init', function() {
121
+ var opts = $[deck]('getOptions'),
122
+ touchEndTime = 0,
123
+ currentSlide,
124
+ slideTest = $.map([
125
+ opts.classes.before,
126
+ opts.classes.previous,
127
+ opts.classes.current,
128
+ opts.classes.next,
129
+ opts.classes.after
130
+ ], function(el, i) {
131
+ return '.' + el;
132
+ }).join(', ');
133
+
134
+ // Build top level slides array
135
+ rootSlides = [];
136
+ $.each($[deck]('getSlides'), function(i, $el) {
137
+ if (!$el.parentsUntil(opts.selectors.container, slideTest).length) {
138
+ rootSlides.push($el);
139
+ }
140
+ });
141
+
142
+ // Bind key events
143
+ $d.unbind('keydown.deckmenu').bind('keydown.deckmenu', function(e) {
144
+ if (e.which === opts.keys.menu || $.inArray(e.which, opts.keys.menu) > -1) {
145
+ $[deck]('toggleMenu');
146
+ e.preventDefault();
147
+ }
148
+ });
149
+
150
+ // Double tap to toggle slide menu for touch devices
151
+ $[deck]('getContainer').unbind('touchstart.deckmenu').bind('touchstart.deckmenu', function(e) {
152
+ currentSlide = $[deck]('getSlide');
153
+ })
154
+ .unbind('touchend.deckmenu').bind('touchend.deckmenu', function(e) {
155
+ var now = Date.now();
156
+
157
+ // Ignore this touch event if it caused a nav change (swipe)
158
+ if (currentSlide !== $[deck]('getSlide')) return;
159
+
160
+ if (now - touchEndTime < opts.touch.doubletapWindow) {
161
+ $[deck]('toggleMenu');
162
+ e.preventDefault();
163
+ }
164
+ touchEndTime = now;
165
+ });
166
+
167
+ // Selecting slides from the menu
168
+ $.each($[deck]('getSlides'), function(i, $s) {
169
+ $s.unbind('click.deckmenu').bind('click.deckmenu', function(e) {
170
+ if (!$[deck]('getContainer').hasClass(opts.classes.menu)) return;
171
+
172
+ $[deck]('go', i);
173
+ $[deck]('hideMenu');
174
+ e.stopPropagation();
175
+ e.preventDefault();
176
+ });
177
+ });
178
+ })
179
+ .bind('deck.change', function(e, from, to) {
180
+ var container = $[deck]('getContainer');
181
+
182
+ if (container.hasClass($[deck]('getOptions').classes.menu)) {
183
+ container.scrollTop($[deck]('getSlide', to).offset().top);
184
+ }
185
+ });
186
+ })(jQuery, 'deck');
187
+