slippery 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (212) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -0
  3. data/assets/deck.js/core/deck.core.css +60 -0
  4. data/assets/deck.js/core/deck.core.js +728 -0
  5. data/assets/deck.js/core/deck.core.scss +65 -0
  6. data/assets/deck.js/core/print.css +25 -0
  7. data/assets/deck.js/core/print.scss +14 -0
  8. data/assets/deck.js/css/common.css +216 -0
  9. data/assets/deck.js/css/common.scss +233 -0
  10. data/assets/deck.js/css/home.css +790 -0
  11. data/assets/deck.js/css/home.scss +892 -0
  12. data/assets/deck.js/extensions/goto/deck.goto.css +36 -0
  13. data/assets/deck.js/extensions/goto/deck.goto.html +7 -0
  14. data/assets/deck.js/extensions/goto/deck.goto.js +190 -0
  15. data/assets/deck.js/extensions/goto/deck.goto.scss +39 -0
  16. data/assets/deck.js/extensions/hash/deck.hash.css +13 -0
  17. data/assets/deck.js/extensions/hash/deck.hash.html +2 -0
  18. data/assets/deck.js/extensions/hash/deck.hash.js +145 -0
  19. data/assets/deck.js/extensions/hash/deck.hash.scss +13 -0
  20. data/assets/deck.js/extensions/menu/deck.menu.css +45 -0
  21. data/assets/deck.js/extensions/menu/deck.menu.js +225 -0
  22. data/assets/deck.js/extensions/menu/deck.menu.scss +55 -0
  23. data/assets/deck.js/extensions/navigation/deck.navigation.css +42 -0
  24. data/assets/deck.js/extensions/navigation/deck.navigation.html +5 -0
  25. data/assets/deck.js/extensions/navigation/deck.navigation.js +94 -0
  26. data/assets/deck.js/extensions/navigation/deck.navigation.scss +44 -0
  27. data/assets/deck.js/extensions/scale/deck.scale.css +20 -0
  28. data/assets/deck.js/extensions/scale/deck.scale.js +190 -0
  29. data/assets/deck.js/extensions/scale/deck.scale.scss +22 -0
  30. data/assets/deck.js/extensions/status/deck.status.css +18 -0
  31. data/assets/deck.js/extensions/status/deck.status.html +6 -0
  32. data/assets/deck.js/extensions/status/deck.status.js +108 -0
  33. data/assets/deck.js/extensions/status/deck.status.scss +18 -0
  34. data/assets/deck.js/modernizr.custom.js +4 -0
  35. data/assets/deck.js/themes/style/_reset.scss +300 -0
  36. data/assets/deck.js/themes/style/neon.css +421 -0
  37. data/assets/deck.js/themes/style/neon.scss +148 -0
  38. data/assets/deck.js/themes/style/swiss.css +389 -0
  39. data/assets/deck.js/themes/style/swiss.scss +109 -0
  40. data/assets/deck.js/themes/style/web-2.0.css +500 -0
  41. data/assets/deck.js/themes/style/web-2.0.scss +228 -0
  42. data/assets/deck.js/themes/transition/fade.css +35 -0
  43. data/assets/deck.js/themes/transition/fade.scss +59 -0
  44. data/assets/deck.js/themes/transition/horizontal-slide.css +53 -0
  45. data/assets/deck.js/themes/transition/horizontal-slide.scss +72 -0
  46. data/assets/deck.js/themes/transition/vertical-slide.css +67 -0
  47. data/assets/deck.js/themes/transition/vertical-slide.scss +92 -0
  48. data/assets/highlight.js/CHANGES.md +953 -0
  49. data/assets/highlight.js/LICENSE +24 -0
  50. data/assets/highlight.js/README.md +101 -0
  51. data/assets/highlight.js/README.ru.md +101 -0
  52. data/assets/highlight.js/highlight-0.8.default.min.css +1 -0
  53. data/assets/highlight.js/highlight-0.8.min.js +1 -0
  54. data/assets/highlight.js/highlight.pack.js +1 -0
  55. data/assets/highlight.js/styles/arta.css +141 -0
  56. data/assets/highlight.js/styles/ascetic.css +53 -0
  57. data/assets/highlight.js/styles/atelier-dune.dark.css +95 -0
  58. data/assets/highlight.js/styles/atelier-dune.light.css +95 -0
  59. data/assets/highlight.js/styles/atelier-forest.dark.css +95 -0
  60. data/assets/highlight.js/styles/atelier-forest.light.css +95 -0
  61. data/assets/highlight.js/styles/atelier-heath.dark.css +95 -0
  62. data/assets/highlight.js/styles/atelier-heath.light.css +95 -0
  63. data/assets/highlight.js/styles/atelier-lakeside.dark.css +95 -0
  64. data/assets/highlight.js/styles/atelier-lakeside.light.css +95 -0
  65. data/assets/highlight.js/styles/atelier-seaside.dark.css +95 -0
  66. data/assets/highlight.js/styles/atelier-seaside.light.css +95 -0
  67. data/assets/highlight.js/styles/brown_paper.css +105 -0
  68. data/assets/highlight.js/styles/brown_papersq.png +0 -0
  69. data/assets/highlight.js/styles/codepen-embed.css +108 -0
  70. data/assets/highlight.js/styles/color-brewer.css +169 -0
  71. data/assets/highlight.js/styles/dark.css +105 -0
  72. data/assets/highlight.js/styles/default.css +153 -0
  73. data/assets/highlight.js/styles/docco.css +136 -0
  74. data/assets/highlight.js/styles/far.css +112 -0
  75. data/assets/highlight.js/styles/foundation.css +136 -0
  76. data/assets/highlight.js/styles/github.css +127 -0
  77. data/assets/highlight.js/styles/googlecode.css +148 -0
  78. data/assets/highlight.js/styles/hybrid.css +171 -0
  79. data/assets/highlight.js/styles/idea.css +126 -0
  80. data/assets/highlight.js/styles/ir_black.css +110 -0
  81. data/assets/highlight.js/styles/kimbie.dark.css +96 -0
  82. data/assets/highlight.js/styles/kimbie.light.css +96 -0
  83. data/assets/highlight.js/styles/magula.css +122 -0
  84. data/assets/highlight.js/styles/mono-blue.css +70 -0
  85. data/assets/highlight.js/styles/monokai.css +127 -0
  86. data/assets/highlight.js/styles/monokai_sublime.css +148 -0
  87. data/assets/highlight.js/styles/obsidian.css +154 -0
  88. data/assets/highlight.js/styles/paraiso.dark.css +95 -0
  89. data/assets/highlight.js/styles/paraiso.light.css +95 -0
  90. data/assets/highlight.js/styles/pojoaque.css +108 -0
  91. data/assets/highlight.js/styles/pojoaque.jpg +0 -0
  92. data/assets/highlight.js/styles/railscasts.css +185 -0
  93. data/assets/highlight.js/styles/rainbow.css +109 -0
  94. data/assets/highlight.js/styles/school_book.css +113 -0
  95. data/assets/highlight.js/styles/school_book.png +0 -0
  96. data/assets/highlight.js/styles/solarized_dark.css +109 -0
  97. data/assets/highlight.js/styles/solarized_light.css +109 -0
  98. data/assets/highlight.js/styles/sunburst.css +165 -0
  99. data/assets/highlight.js/styles/tomorrow-night-blue.css +95 -0
  100. data/assets/highlight.js/styles/tomorrow-night-bright.css +94 -0
  101. data/assets/highlight.js/styles/tomorrow-night-eighties.css +94 -0
  102. data/assets/highlight.js/styles/tomorrow-night.css +95 -0
  103. data/assets/highlight.js/styles/tomorrow.css +92 -0
  104. data/assets/highlight.js/styles/vs.css +94 -0
  105. data/assets/highlight.js/styles/xcode.css +159 -0
  106. data/assets/highlight.js/styles/zenburn.css +119 -0
  107. data/assets/jquery/jquery-2.1.0.min.js +4 -0
  108. data/assets/reveal.js/css/print/paper.css +1 -1
  109. data/assets/reveal.js/css/print/pdf.css +2 -2
  110. data/assets/reveal.js/css/reveal.css +372 -108
  111. data/assets/reveal.js/css/reveal.min.css +2 -2
  112. data/assets/reveal.js/css/theme/README.md +3 -1
  113. data/assets/reveal.js/css/theme/beige.css +7 -1
  114. data/assets/reveal.js/css/theme/blood.css +175 -0
  115. data/assets/reveal.js/css/theme/default.css +7 -1
  116. data/assets/reveal.js/css/theme/moon.css +7 -1
  117. data/assets/reveal.js/css/theme/night.css +7 -1
  118. data/assets/reveal.js/css/theme/serif.css +7 -1
  119. data/assets/reveal.js/css/theme/simple.css +7 -1
  120. data/assets/reveal.js/css/theme/sky.css +7 -1
  121. data/assets/reveal.js/css/theme/solarized.css +7 -1
  122. data/assets/reveal.js/css/theme/source/blood.scss +91 -0
  123. data/assets/reveal.js/css/theme/template/settings.scss +1 -0
  124. data/assets/reveal.js/css/theme/template/theme.scss +9 -2
  125. data/assets/reveal.js/js/reveal.js +1238 -433
  126. data/assets/reveal.js/js/reveal.min.js +4 -3
  127. data/assets/reveal.js/lib/css/zenburn.css +16 -17
  128. data/assets/reveal.js/plugin/highlight/highlight.js +3 -2
  129. data/assets/reveal.js/plugin/leap/leap.js +3 -0
  130. data/assets/reveal.js/plugin/markdown/example.html +37 -5
  131. data/assets/reveal.js/plugin/markdown/example.md +2 -0
  132. data/assets/reveal.js/plugin/markdown/markdown.js +373 -171
  133. data/assets/reveal.js/plugin/math/math.js +64 -0
  134. data/assets/reveal.js/plugin/multiplex/master.js +2 -1
  135. data/assets/reveal.js/plugin/notes/notes.html +33 -19
  136. data/assets/reveal.js/plugin/notes/notes.js +25 -47
  137. data/assets/reveal.js/plugin/remotes/remotes.js +4 -4
  138. data/assets/reveal.js/plugin/zoom-js/zoom.js +3 -1
  139. data/assets/reveal.old/css/print/paper.css +176 -0
  140. data/assets/reveal.old/css/print/pdf.css +190 -0
  141. data/assets/reveal.old/css/reveal.css +1616 -0
  142. data/assets/reveal.old/css/reveal.min.css +7 -0
  143. data/assets/reveal.old/css/theme/README.md +23 -0
  144. data/assets/reveal.old/css/theme/beige.css +142 -0
  145. data/assets/reveal.old/css/theme/default.css +142 -0
  146. data/assets/reveal.old/css/theme/moon.css +142 -0
  147. data/assets/reveal.old/css/theme/night.css +130 -0
  148. data/assets/reveal.old/css/theme/serif.css +132 -0
  149. data/assets/reveal.old/css/theme/simple.css +132 -0
  150. data/assets/reveal.old/css/theme/sky.css +139 -0
  151. data/assets/reveal.old/css/theme/solarized.css +142 -0
  152. data/assets/reveal.old/css/theme/source/beige.scss +50 -0
  153. data/assets/reveal.old/css/theme/source/default.scss +42 -0
  154. data/assets/reveal.old/css/theme/source/moon.scss +68 -0
  155. data/assets/reveal.old/css/theme/source/night.scss +35 -0
  156. data/assets/reveal.old/css/theme/source/serif.scss +35 -0
  157. data/assets/reveal.old/css/theme/source/simple.scss +38 -0
  158. data/assets/reveal.old/css/theme/source/sky.scss +46 -0
  159. data/assets/reveal.old/css/theme/source/solarized.scss +74 -0
  160. data/assets/reveal.old/css/theme/template/mixins.scss +29 -0
  161. data/assets/reveal.old/css/theme/template/settings.scss +33 -0
  162. data/assets/reveal.old/css/theme/template/theme.scss +163 -0
  163. data/assets/{reveal.js → reveal.old}/js/head.min.js +0 -0
  164. data/assets/reveal.old/js/reveal.js +2577 -0
  165. data/assets/reveal.old/js/reveal.min.js +8 -0
  166. data/assets/reveal.old/lib/css/zenburn.css +115 -0
  167. data/assets/reveal.old/lib/font/league_gothic-webfont.eot +0 -0
  168. data/assets/reveal.old/lib/font/league_gothic-webfont.svg +230 -0
  169. data/assets/reveal.old/lib/font/league_gothic-webfont.ttf +0 -0
  170. data/assets/reveal.old/lib/font/league_gothic-webfont.woff +0 -0
  171. data/assets/reveal.old/lib/font/league_gothic_license +2 -0
  172. data/assets/reveal.old/lib/js/classList.js +2 -0
  173. data/assets/reveal.old/lib/js/head.min.js +8 -0
  174. data/assets/reveal.old/lib/js/html5shiv.js +7 -0
  175. data/assets/reveal.old/plugin/highlight/highlight.js +31 -0
  176. data/assets/reveal.old/plugin/leap/leap.js +154 -0
  177. data/assets/reveal.old/plugin/markdown/example.html +97 -0
  178. data/assets/reveal.old/plugin/markdown/example.md +29 -0
  179. data/assets/reveal.old/plugin/markdown/markdown.js +190 -0
  180. data/assets/reveal.old/plugin/markdown/marked.js +37 -0
  181. data/assets/reveal.old/plugin/multiplex/client.js +13 -0
  182. data/assets/reveal.old/plugin/multiplex/index.js +56 -0
  183. data/assets/reveal.old/plugin/multiplex/master.js +50 -0
  184. data/assets/reveal.old/plugin/notes-server/client.js +57 -0
  185. data/assets/reveal.old/plugin/notes-server/index.js +59 -0
  186. data/assets/reveal.old/plugin/notes-server/notes.html +142 -0
  187. data/assets/reveal.old/plugin/notes/notes.html +253 -0
  188. data/assets/reveal.old/plugin/notes/notes.js +100 -0
  189. data/assets/reveal.old/plugin/postmessage/example.html +39 -0
  190. data/assets/reveal.old/plugin/postmessage/postmessage.js +42 -0
  191. data/assets/reveal.old/plugin/print-pdf/print-pdf.js +44 -0
  192. data/assets/reveal.old/plugin/remotes/remotes.js +39 -0
  193. data/assets/reveal.old/plugin/search/search.js +196 -0
  194. data/assets/reveal.old/plugin/zoom-js/zoom.js +256 -0
  195. data/bin/slippery +1 -0
  196. data/code_of_conduct.md +32 -0
  197. data/lib/slippery.rb +5 -3
  198. data/lib/slippery/document.rb +2 -2
  199. data/lib/slippery/presentation.rb +10 -1
  200. data/lib/slippery/processor.rb +18 -0
  201. data/lib/slippery/processor_helpers.rb +16 -2
  202. data/lib/slippery/processors/add_highlight.rb +9 -2
  203. data/lib/slippery/processors/deck_js.rb +81 -0
  204. data/lib/slippery/processors/fathom_js.rb +31 -0
  205. data/lib/slippery/processors/impress_js/add_impress_js.rb +2 -2
  206. data/lib/slippery/processors/jquery.rb +12 -0
  207. data/lib/slippery/processors/reveal_js/add_reveal_js.rb +12 -9
  208. data/lib/slippery/rake_tasks.rb +59 -31
  209. data/lib/slippery/version.rb +1 -1
  210. data/slippery.gemspec +5 -4
  211. metadata +215 -33
  212. data/lib/slippery/converter.rb +0 -132
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1491dbf26924ecc74cedaa9844aeb852879859b9
4
- data.tar.gz: d9b12a2e1d14577735431745372c87d3081287d2
3
+ metadata.gz: a33c6a5cdeb602e16ef4c7d0c1ceb5fe763bb811
4
+ data.tar.gz: b5c409cac6a708f574c3e420da283e5a2eec009a
5
5
  SHA512:
6
- metadata.gz: 28f97b9e0817227b2a0a968122036302ad9c88fe44e131846637014aa23df2ac784c0e765730ec8752605f5de261b77781f7bce7c75297b14e538529dcae3051
7
- data.tar.gz: b5c424106415ce8cbe20b2f2431faae70af09452b4d9b62991f37a768cb1c20a24451dd73a5533e480ea10666146ec92838d7e5858a369fde18111a7e3e26545
6
+ metadata.gz: 0abfe01bb453a3aba48525cb9bbabfa0cd45080af9182f6ce7c307ca2279a66e4c2763b9c2663ec3b35f6efab09a4a24220a0607f17c6098a2dc7e5bfd9b59b8
7
+ data.tar.gz: f9966e83b34989a70ecf431e0dde7d20371a7427a2a2b9916135455aea15fc03f2d696f30196c6b41e335ebaad2ae918e701384dfcab0995de1daa788f0fa7d4
data/README.md CHANGED
@@ -117,6 +117,8 @@ end
117
117
 
118
118
  And the result:
119
119
 
120
+ (this is an SVG inside a Markdown file, Github used to do this just fine, but not any more)
121
+
120
122
  <svg width="305pt" height="432pt"
121
123
  viewBox="0.00 0.00 305.00 432.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
122
124
  <g id="graph1" class="graph" transform="scale(1 1) rotate(0) translate(4 428)">
@@ -0,0 +1,60 @@
1
+ html, body {
2
+ height: 100%;
3
+ padding: 0;
4
+ margin: 0;
5
+ }
6
+
7
+ .deck-container {
8
+ position: relative;
9
+ min-height: 100%;
10
+ margin: 0 auto;
11
+ overflow: hidden;
12
+ overflow-y: auto;
13
+ }
14
+ .js .deck-container {
15
+ visibility: hidden;
16
+ }
17
+ .ready .deck-container {
18
+ visibility: visible;
19
+ }
20
+ .touch .deck-container {
21
+ -webkit-text-size-adjust: none;
22
+ -moz-text-size-adjust: none;
23
+ }
24
+
25
+ .deck-loading {
26
+ display: none;
27
+ }
28
+
29
+ .slide {
30
+ width: auto;
31
+ min-height: 100%;
32
+ position: relative;
33
+ }
34
+
35
+ .deck-before, .deck-previous, .deck-next, .deck-after {
36
+ position: absolute;
37
+ left: -999em;
38
+ top: -999em;
39
+ }
40
+
41
+ .deck-current {
42
+ z-index: 2;
43
+ }
44
+
45
+ .slide .slide {
46
+ visibility: hidden;
47
+ position: static;
48
+ min-height: 0;
49
+ }
50
+
51
+ .deck-child-current {
52
+ position: static;
53
+ z-index: 2;
54
+ }
55
+ .deck-child-current .slide {
56
+ visibility: hidden;
57
+ }
58
+ .deck-child-current .deck-previous, .deck-child-current .deck-before, .deck-child-current .deck-current {
59
+ visibility: visible;
60
+ }
@@ -0,0 +1,728 @@
1
+ /*!
2
+ Deck JS - deck.core
3
+ Copyright (c) 2011-2014 Caleb Troughton
4
+ Dual licensed under the MIT license.
5
+ https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt
6
+ */
7
+
8
+ /*
9
+ The deck.core module provides all the basic functionality for creating and
10
+ moving through a deck. It does so by applying classes to indicate the state of
11
+ the deck and its slides, allowing CSS to take care of the visual representation
12
+ of each state. It also provides methods for navigating the deck and inspecting
13
+ its state, as well as basic key bindings for going to the next and previous
14
+ slides. More functionality is provided by wholly separate extension modules
15
+ that use the API provided by core.
16
+ */
17
+ (function($, undefined) {
18
+ var slides, currentIndex, $container, $fragmentLinks;
19
+
20
+ var events = {
21
+ /*
22
+ This event fires at the beginning of a slide change, before the actual
23
+ change occurs. Its purpose is to give extension authors a way to prevent
24
+ the slide change from occuring. This is done by calling preventDefault
25
+ on the event object within this event. If that is done, the deck.change
26
+ event will never be fired and the slide will not change.
27
+ */
28
+ beforeChange: 'deck.beforeChange',
29
+
30
+ /*
31
+ This event fires whenever the current slide changes, whether by way of
32
+ next, prev, or go. The callback function is passed two parameters, from
33
+ and to, equal to the indices of the old slide and the new slide
34
+ respectively. If preventDefault is called on the event within this handler
35
+ the slide change does not occur.
36
+
37
+ $(document).bind('deck.change', function(event, from, to) {
38
+ alert('Moving from slide ' + from + ' to ' + to);
39
+ });
40
+ */
41
+ change: 'deck.change',
42
+
43
+ /*
44
+ This event fires at the beginning of deck initialization, after the options
45
+ are set but before the slides array is created. This event makes a good hook
46
+ for preprocessing extensions looking to modify the deck.
47
+ */
48
+ beforeInitialize: 'deck.beforeInit',
49
+
50
+ /*
51
+ This event fires at the end of deck initialization. Extensions should
52
+ implement any code that relies on user extensible options (key bindings,
53
+ element selectors, classes) within a handler for this event. Native
54
+ events associated with Deck JS should be scoped under a .deck event
55
+ namespace, as with the example below:
56
+
57
+ var $d = $(document);
58
+ $.deck.defaults.keys.myExtensionKeycode = 70; // 'h'
59
+ $d.bind('deck.init', function() {
60
+ $d.bind('keydown.deck', function(event) {
61
+ if (event.which === $.deck.getOptions().keys.myExtensionKeycode) {
62
+ // Rock out
63
+ }
64
+ });
65
+ });
66
+ */
67
+ initialize: 'deck.init'
68
+ };
69
+
70
+ var options = {};
71
+ var $document = $(document);
72
+ var $window = $(window);
73
+ var stopPropagation = function(event) {
74
+ event.stopPropagation();
75
+ };
76
+
77
+ var updateContainerState = function() {
78
+ var oldIndex = $container.data('onSlide');
79
+ $container.removeClass(options.classes.onPrefix + oldIndex);
80
+ $container.addClass(options.classes.onPrefix + currentIndex);
81
+ $container.data('onSlide', currentIndex);
82
+ };
83
+
84
+ var updateChildCurrent = function() {
85
+ var $oldCurrent = $('.' + options.classes.current);
86
+ var $oldParents = $oldCurrent.parentsUntil(options.selectors.container);
87
+ var $newCurrent = slides[currentIndex];
88
+ var $newParents = $newCurrent.parentsUntil(options.selectors.container);
89
+ $oldParents.removeClass(options.classes.childCurrent);
90
+ $newParents.addClass(options.classes.childCurrent);
91
+ };
92
+
93
+ var removeOldSlideStates = function() {
94
+ var $all = $();
95
+ $.each(slides, function(i, el) {
96
+ $all = $all.add(el);
97
+ });
98
+ $all.removeClass([
99
+ options.classes.before,
100
+ options.classes.previous,
101
+ options.classes.current,
102
+ options.classes.next,
103
+ options.classes.after
104
+ ].join(' '));
105
+ };
106
+
107
+ var addNewSlideStates = function() {
108
+ slides[currentIndex].addClass(options.classes.current);
109
+ if (currentIndex > 0) {
110
+ slides[currentIndex-1].addClass(options.classes.previous);
111
+ }
112
+ if (currentIndex + 1 < slides.length) {
113
+ slides[currentIndex+1].addClass(options.classes.next);
114
+ }
115
+ if (currentIndex > 1) {
116
+ $.each(slides.slice(0, currentIndex - 1), function(i, $slide) {
117
+ $slide.addClass(options.classes.before);
118
+ });
119
+ }
120
+ if (currentIndex + 2 < slides.length) {
121
+ $.each(slides.slice(currentIndex+2), function(i, $slide) {
122
+ $slide.addClass(options.classes.after);
123
+ });
124
+ }
125
+ };
126
+
127
+ var setAriaHiddens = function() {
128
+ $(options.selectors.slides).each(function() {
129
+ var $slide = $(this);
130
+ var isSub = $slide.closest('.' + options.classes.childCurrent).length;
131
+ var isBefore = $slide.hasClass(options.classes.before) && !isSub;
132
+ var isPrevious = $slide.hasClass(options.classes.previous) && !isSub;
133
+ var isNext = $slide.hasClass(options.classes.next);
134
+ var isAfter = $slide.hasClass(options.classes.after);
135
+ var ariaHiddenValue = isBefore || isPrevious || isNext || isAfter;
136
+ $slide.attr('aria-hidden', ariaHiddenValue);
137
+ });
138
+ };
139
+
140
+ var updateStates = function() {
141
+ updateContainerState();
142
+ updateChildCurrent();
143
+ removeOldSlideStates();
144
+ addNewSlideStates();
145
+ if (options.setAriaHiddens) {
146
+ setAriaHiddens();
147
+ }
148
+ };
149
+
150
+ var initSlidesArray = function(elements) {
151
+ if ($.isArray(elements)) {
152
+ $.each(elements, function(i, element) {
153
+ slides.push($(element));
154
+ });
155
+ }
156
+ else {
157
+ $(elements).each(function(i, element) {
158
+ slides.push($(element));
159
+ });
160
+ }
161
+ };
162
+
163
+ var bindKeyEvents = function() {
164
+ var editables = [
165
+ 'input',
166
+ 'textarea',
167
+ 'select',
168
+ 'button',
169
+ 'meter',
170
+ 'progress',
171
+ '[contentEditable]'
172
+ ].join(', ');
173
+
174
+ $document.unbind('keydown.deck').bind('keydown.deck', function(event) {
175
+ var isNext = event.which === options.keys.next;
176
+ var isPrev = event.which === options.keys.previous;
177
+ isNext = isNext || $.inArray(event.which, options.keys.next) > -1;
178
+ isPrev = isPrev || $.inArray(event.which, options.keys.previous) > -1;
179
+
180
+ if (isNext) {
181
+ methods.next();
182
+ event.preventDefault();
183
+ }
184
+ else if (isPrev) {
185
+ methods.prev();
186
+ event.preventDefault();
187
+ }
188
+ });
189
+
190
+ $document.undelegate(editables, 'keydown.deck', stopPropagation);
191
+ $document.delegate(editables, 'keydown.deck', stopPropagation);
192
+ };
193
+
194
+ var bindTouchEvents = function() {
195
+ var startTouch;
196
+ var direction = options.touch.swipeDirection;
197
+ var tolerance = options.touch.swipeTolerance;
198
+ var listenToHorizontal = ({ both: true, horizontal: true })[direction];
199
+ var listenToVertical = ({ both: true, vertical: true })[direction];
200
+
201
+ $container.unbind('touchstart.deck');
202
+ $container.bind('touchstart.deck', function(event) {
203
+ if (!startTouch) {
204
+ startTouch = $.extend({}, event.originalEvent.targetTouches[0]);
205
+ }
206
+ });
207
+
208
+ $container.unbind('touchmove.deck');
209
+ $container.bind('touchmove.deck', function(event) {
210
+ $.each(event.originalEvent.changedTouches, function(i, touch) {
211
+ if (!startTouch || touch.identifier !== startTouch.identifier) {
212
+ return true;
213
+ }
214
+ var xDistance = touch.screenX - startTouch.screenX;
215
+ var yDistance = touch.screenY - startTouch.screenY;
216
+ var leftToRight = xDistance > tolerance && listenToHorizontal;
217
+ var rightToLeft = xDistance < -tolerance && listenToHorizontal;
218
+ var topToBottom = yDistance > tolerance && listenToVertical;
219
+ var bottomToTop = yDistance < -tolerance && listenToVertical;
220
+
221
+ if (leftToRight || topToBottom) {
222
+ $.deck('prev');
223
+ startTouch = undefined;
224
+ }
225
+ else if (rightToLeft || bottomToTop) {
226
+ $.deck('next');
227
+ startTouch = undefined;
228
+ }
229
+ return false;
230
+ });
231
+
232
+ if (listenToVertical) {
233
+ event.preventDefault();
234
+ }
235
+ });
236
+
237
+ $container.unbind('touchend.deck');
238
+ $container.bind('touchend.deck', function(event) {
239
+ $.each(event.originalEvent.changedTouches, function(i, touch) {
240
+ if (startTouch && touch.identifier === startTouch.identifier) {
241
+ startTouch = undefined;
242
+ }
243
+ });
244
+ });
245
+ };
246
+
247
+ var indexInBounds = function(index) {
248
+ return typeof index === 'number' && index >=0 && index < slides.length;
249
+ };
250
+
251
+ var createBeforeInitEvent = function() {
252
+ var event = $.Event(events.beforeInitialize);
253
+ event.locks = 0;
254
+ event.done = $.noop;
255
+ event.lockInit = function() {
256
+ ++event.locks;
257
+ };
258
+ event.releaseInit = function() {
259
+ --event.locks;
260
+ if (!event.locks) {
261
+ event.done();
262
+ }
263
+ };
264
+ return event;
265
+ };
266
+
267
+ var goByHash = function(str) {
268
+ var id = str.substr(str.indexOf("#") + 1);
269
+
270
+ $.each(slides, function(i, $slide) {
271
+ if ($slide.attr('id') === id) {
272
+ $.deck('go', i);
273
+ return false;
274
+ }
275
+ });
276
+
277
+ // If we don't set these to 0 the container scrolls due to hashchange
278
+ if (options.preventFragmentScroll) {
279
+ $.deck('getContainer').scrollLeft(0).scrollTop(0);
280
+ }
281
+ };
282
+
283
+ var assignSlideId = function(i, $slide) {
284
+ var currentId = $slide.attr('id');
285
+ var previouslyAssigned = $slide.data('deckAssignedId') === currentId;
286
+ if (!currentId || previouslyAssigned) {
287
+ $slide.attr('id', options.hashPrefix + i);
288
+ $slide.data('deckAssignedId', options.hashPrefix + i);
289
+ }
290
+ };
291
+
292
+ var removeContainerHashClass = function(id) {
293
+ $container.removeClass(options.classes.onPrefix + id);
294
+ };
295
+
296
+ var addContainerHashClass = function(id) {
297
+ $container.addClass(options.classes.onPrefix + id);
298
+ };
299
+
300
+ var setupHashBehaviors = function() {
301
+ $fragmentLinks = $();
302
+ $.each(slides, function(i, $slide) {
303
+ var hash;
304
+
305
+ assignSlideId(i, $slide);
306
+ hash = '#' + $slide.attr('id');
307
+ if (hash === window.location.hash) {
308
+ setTimeout(function() {
309
+ $.deck('go', i);
310
+ }, 1);
311
+ }
312
+ $fragmentLinks = $fragmentLinks.add('a[href="' + hash + '"]');
313
+ });
314
+
315
+ if (slides.length) {
316
+ addContainerHashClass($.deck('getSlide').attr('id'));
317
+ };
318
+ };
319
+
320
+ var changeHash = function(from, to) {
321
+ var hash = '#' + $.deck('getSlide', to).attr('id');
322
+ var hashPath = window.location.href.replace(/#.*/, '') + hash;
323
+
324
+ removeContainerHashClass($.deck('getSlide', from).attr('id'));
325
+ addContainerHashClass($.deck('getSlide', to).attr('id'));
326
+ if (Modernizr.history) {
327
+ window.history.replaceState({}, "", hashPath);
328
+ }
329
+ };
330
+
331
+ /* Methods exposed in the jQuery.deck namespace */
332
+ var methods = {
333
+
334
+ /*
335
+ jQuery.deck(selector, options)
336
+
337
+ selector: string | jQuery | array
338
+ options: object, optional
339
+
340
+ Initializes the deck, using each element matched by selector as a slide.
341
+ May also be passed an array of string selectors or jQuery objects, in
342
+ which case each selector in the array is considered a slide. The second
343
+ parameter is an optional options object which will extend the default
344
+ values.
345
+
346
+ $.deck('.slide');
347
+
348
+ or
349
+
350
+ $.deck([
351
+ '#first-slide',
352
+ '#second-slide',
353
+ '#etc'
354
+ ]);
355
+ */
356
+ init: function(opts) {
357
+ var beforeInitEvent = createBeforeInitEvent();
358
+ var overrides = opts;
359
+
360
+ if (!$.isPlainObject(opts)) {
361
+ overrides = arguments[1] || {};
362
+ $.extend(true, overrides, {
363
+ selectors: {
364
+ slides: arguments[0]
365
+ }
366
+ });
367
+ }
368
+
369
+ options = $.extend(true, {}, $.deck.defaults, overrides);
370
+ slides = [];
371
+ currentIndex = 0;
372
+ $container = $(options.selectors.container);
373
+
374
+ // Hide the deck while states are being applied to kill transitions
375
+ $container.addClass(options.classes.loading);
376
+
377
+ // populate the array of slides for pre-init
378
+ initSlidesArray(options.selectors.slides);
379
+ // Pre init event for preprocessing hooks
380
+ beforeInitEvent.done = function() {
381
+ // re-populate the array of slides
382
+ slides = [];
383
+ initSlidesArray(options.selectors.slides);
384
+ setupHashBehaviors();
385
+ bindKeyEvents();
386
+ bindTouchEvents();
387
+ $container.scrollLeft(0).scrollTop(0);
388
+
389
+ if (slides.length) {
390
+ updateStates();
391
+ }
392
+
393
+ // Show deck again now that slides are in place
394
+ $container.removeClass(options.classes.loading);
395
+ $document.trigger(events.initialize);
396
+ };
397
+
398
+ $document.trigger(beforeInitEvent);
399
+ if (!beforeInitEvent.locks) {
400
+ beforeInitEvent.done();
401
+ }
402
+ window.setTimeout(function() {
403
+ if (beforeInitEvent.locks) {
404
+ if (window.console) {
405
+ window.console.warn('Something locked deck initialization\
406
+ without releasing it before the timeout. Proceeding with\
407
+ initialization anyway.');
408
+ }
409
+ beforeInitEvent.done();
410
+ }
411
+ }, options.initLockTimeout);
412
+ },
413
+
414
+ /*
415
+ jQuery.deck('go', index)
416
+
417
+ index: integer | string
418
+
419
+ Moves to the slide at the specified index if index is a number. Index is
420
+ 0-based, so $.deck('go', 0); will move to the first slide. If index is a
421
+ string this will move to the slide with the specified id. If index is out
422
+ of bounds or doesn't match a slide id the call is ignored.
423
+ */
424
+ go: function(indexOrId) {
425
+ var beforeChangeEvent = $.Event(events.beforeChange);
426
+ var index;
427
+
428
+ /* Number index, easy. */
429
+ if (indexInBounds(indexOrId)) {
430
+ index = indexOrId;
431
+ }
432
+ /* Id string index, search for it and set integer index */
433
+ else if (typeof indexOrId === 'string') {
434
+ $.each(slides, function(i, $slide) {
435
+ if ($slide.attr('id') === indexOrId) {
436
+ index = i;
437
+ return false;
438
+ }
439
+ });
440
+ }
441
+ if (typeof index === 'undefined') {
442
+ return;
443
+ }
444
+
445
+ /* Trigger beforeChange. If nothing prevents the change, trigger
446
+ the slide change. */
447
+ $document.trigger(beforeChangeEvent, [currentIndex, index]);
448
+ if (!beforeChangeEvent.isDefaultPrevented()) {
449
+ $document.trigger(events.change, [currentIndex, index]);
450
+ changeHash(currentIndex, index);
451
+ currentIndex = index;
452
+ updateStates();
453
+ }
454
+ },
455
+
456
+ /*
457
+ jQuery.deck('next')
458
+
459
+ Moves to the next slide. If the last slide is already active, the call
460
+ is ignored.
461
+ */
462
+ next: function() {
463
+ methods.go(currentIndex+1);
464
+ },
465
+
466
+ /*
467
+ jQuery.deck('prev')
468
+
469
+ Moves to the previous slide. If the first slide is already active, the
470
+ call is ignored.
471
+ */
472
+ prev: function() {
473
+ methods.go(currentIndex-1);
474
+ },
475
+
476
+ /*
477
+ jQuery.deck('getSlide', index)
478
+
479
+ index: integer, optional
480
+
481
+ Returns a jQuery object containing the slide at index. If index is not
482
+ specified, the current slide is returned.
483
+ */
484
+ getSlide: function(index) {
485
+ index = typeof index !== 'undefined' ? index : currentIndex;
486
+ if (!indexInBounds(index)) {
487
+ return null;
488
+ }
489
+ return slides[index];
490
+ },
491
+
492
+ /*
493
+ jQuery.deck('getSlides')
494
+
495
+ Returns all slides as an array of jQuery objects.
496
+ */
497
+ getSlides: function() {
498
+ return slides;
499
+ },
500
+
501
+ /*
502
+ jQuery.deck('getTopLevelSlides')
503
+
504
+ Returns all slides that are not subslides.
505
+ */
506
+ getTopLevelSlides: function() {
507
+ var topLevelSlides = [];
508
+ var slideSelector = options.selectors.slides;
509
+ var subSelector = [slideSelector, slideSelector].join(' ');
510
+ $.each(slides, function(i, $slide) {
511
+ if (!$slide.is(subSelector)) {
512
+ topLevelSlides.push($slide);
513
+ }
514
+ });
515
+ return topLevelSlides;
516
+ },
517
+
518
+ /*
519
+ jQuery.deck('getNestedSlides', index)
520
+
521
+ index: integer, optional
522
+
523
+ Returns all the nested slides of the current slide. If index is
524
+ specified it returns the nested slides of the slide at that index.
525
+ If there are no nested slides this will return an empty array.
526
+ */
527
+ getNestedSlides: function(index) {
528
+ var targetIndex = index == null ? currentIndex : index;
529
+ var $targetSlide = $.deck('getSlide', targetIndex);
530
+ var $nesteds = $targetSlide.find(options.selectors.slides);
531
+ var nesteds = $nesteds.get();
532
+ return $.map(nesteds, function(slide, i) {
533
+ return $(slide);
534
+ });
535
+ },
536
+
537
+
538
+ /*
539
+ jQuery.deck('getContainer')
540
+
541
+ Returns a jQuery object containing the deck container as defined by the
542
+ container option.
543
+ */
544
+ getContainer: function() {
545
+ return $container;
546
+ },
547
+
548
+ /*
549
+ jQuery.deck('getOptions')
550
+
551
+ Returns the options object for the deck, including any overrides that
552
+ were defined at initialization.
553
+ */
554
+ getOptions: function() {
555
+ return options;
556
+ },
557
+
558
+ /*
559
+ jQuery.deck('extend', name, method)
560
+
561
+ name: string
562
+ method: function
563
+
564
+ Adds method to the deck namespace with the key of name. This doesn’t
565
+ give access to any private member data — public methods must still be
566
+ used within method — but lets extension authors piggyback on the deck
567
+ namespace rather than pollute jQuery.
568
+
569
+ $.deck('extend', 'alert', function(msg) {
570
+ alert(msg);
571
+ });
572
+
573
+ // Alerts 'boom'
574
+ $.deck('alert', 'boom');
575
+ */
576
+ extend: function(name, method) {
577
+ methods[name] = method;
578
+ }
579
+ };
580
+
581
+ /* jQuery extension */
582
+ $.deck = function(method, arg) {
583
+ var args = Array.prototype.slice.call(arguments, 1);
584
+ if (methods[method]) {
585
+ return methods[method].apply(this, args);
586
+ }
587
+ else {
588
+ return methods.init(method, arg);
589
+ }
590
+ };
591
+
592
+ /*
593
+ The default settings object for a deck. All deck extensions should extend
594
+ this object to add defaults for any of their options.
595
+
596
+ options.classes.after
597
+ This class is added to all slides that appear after the 'next' slide.
598
+
599
+ options.classes.before
600
+ This class is added to all slides that appear before the 'previous'
601
+ slide.
602
+
603
+ options.classes.childCurrent
604
+ This class is added to all elements in the DOM tree between the
605
+ 'current' slide and the deck container. For standard slides, this is
606
+ mostly seen and used for nested slides.
607
+
608
+ options.classes.current
609
+ This class is added to the current slide.
610
+
611
+ options.classes.loading
612
+ This class is applied to the deck container during loading phases and is
613
+ primarily used as a way to short circuit transitions between states
614
+ where such transitions are distracting or unwanted. For example, this
615
+ class is applied during deck initialization and then removed to prevent
616
+ all the slides from appearing stacked and transitioning into place
617
+ on load.
618
+
619
+ options.classes.next
620
+ This class is added to the slide immediately following the 'current'
621
+ slide.
622
+
623
+ options.classes.onPrefix
624
+ This prefix, concatenated with the current slide index, is added to the
625
+ deck container as you change slides.
626
+
627
+ options.classes.previous
628
+ This class is added to the slide immediately preceding the 'current'
629
+ slide.
630
+
631
+ options.selectors.container
632
+ Elements matched by this CSS selector will be considered the deck
633
+ container. The deck container is used to scope certain states of the
634
+ deck, as with the onPrefix option, or with extensions such as deck.goto
635
+ and deck.menu.
636
+
637
+ options.selectors.slides
638
+ Elements matched by this selector make up the individual deck slides.
639
+ If a user chooses to pass the slide selector as the first argument to
640
+ $.deck() on initialization it does the same thing as passing in this
641
+ option and this option value will be set to the value of that parameter.
642
+
643
+ options.keys.next
644
+ The numeric keycode used to go to the next slide.
645
+
646
+ options.keys.previous
647
+ The numeric keycode used to go to the previous slide.
648
+
649
+ options.touch.swipeDirection
650
+ The direction swipes occur to cause slide changes. Can be 'horizontal',
651
+ 'vertical', or 'both'. Any other value or a falsy value will disable
652
+ swipe gestures for navigation.
653
+
654
+ options.touch.swipeTolerance
655
+ The number of pixels the users finger must travel to produce a swipe
656
+ gesture.
657
+
658
+ options.hashPrefix
659
+ Every slide that does not have an id is assigned one at initialization.
660
+ Assigned ids take the form of hashPrefix + slideIndex, e.g., slide-0,
661
+ slide-12, etc.
662
+
663
+ options.preventFragmentScroll
664
+ When deep linking to a hash of a nested slide, this scrolls the deck
665
+ container to the top, undoing the natural browser behavior of scrolling
666
+ to the document fragment on load.
667
+
668
+ options.setAriaHiddens
669
+ When set to true, deck.js will set aria hidden attributes for slides
670
+ that do not appear offscreen according to a typical heirarchical
671
+ deck structure. You may want to turn this off if you are using a theme
672
+ where slides besides the current slide are visible on screen and should
673
+ be accessible to screenreaders.
674
+ */
675
+ $.deck.defaults = {
676
+ classes: {
677
+ after: 'deck-after',
678
+ before: 'deck-before',
679
+ childCurrent: 'deck-child-current',
680
+ current: 'deck-current',
681
+ loading: 'deck-loading',
682
+ next: 'deck-next',
683
+ onPrefix: 'on-slide-',
684
+ previous: 'deck-previous'
685
+ },
686
+
687
+ selectors: {
688
+ container: '.deck-container',
689
+ slides: '.slide'
690
+ },
691
+
692
+ keys: {
693
+ // enter, space, page down, right arrow, down arrow,
694
+ next: [13, 32, 34, 39, 40],
695
+ // backspace, page up, left arrow, up arrow
696
+ previous: [8, 33, 37, 38]
697
+ },
698
+
699
+ touch: {
700
+ swipeDirection: 'horizontal',
701
+ swipeTolerance: 60
702
+ },
703
+
704
+ initLockTimeout: 10000,
705
+ hashPrefix: 'slide-',
706
+ preventFragmentScroll: true,
707
+ setAriaHiddens: true
708
+ };
709
+
710
+ $document.ready(function() {
711
+ $('html').addClass('ready');
712
+ });
713
+
714
+ $window.bind('hashchange.deck', function(event) {
715
+ if (event.originalEvent && event.originalEvent.newURL) {
716
+ goByHash(event.originalEvent.newURL);
717
+ }
718
+ else {
719
+ goByHash(window.location.hash);
720
+ }
721
+ });
722
+
723
+ $window.bind('load.deck', function() {
724
+ if (options.preventFragmentScroll) {
725
+ $container.scrollLeft(0).scrollTop(0);
726
+ }
727
+ });
728
+ })(jQuery);