slideoff 0.1

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.
Files changed (214) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +3 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.md +218 -0
  5. data/bin/slideoff +127 -0
  6. data/lib/slideoff/config_builder.rb +60 -0
  7. data/lib/slideoff/flickr_api.rb +50 -0
  8. data/lib/slideoff/flickr_image.rb +92 -0
  9. data/lib/slideoff/markdown.rb +145 -0
  10. data/lib/slideoff/presentation.rb +90 -0
  11. data/lib/slideoff/remote_api.rb +53 -0
  12. data/lib/slideoff/routes.rb +20 -0
  13. data/lib/slideoff/server.rb +50 -0
  14. data/lib/slideoff/slides_api.rb +59 -0
  15. data/lib/slideoff/utils.rb +453 -0
  16. data/lib/slideoff.rb +15 -0
  17. data/themes/3d_slideshow/README +2 -0
  18. data/themes/3d_slideshow/css/main.css +232 -0
  19. data/themes/3d_slideshow/css/reset.css +57 -0
  20. data/themes/3d_slideshow/index.erb +31 -0
  21. data/themes/3d_slideshow/js/slideshow.js +288 -0
  22. data/themes/CSSS/README +2 -0
  23. data/themes/CSSS/css/slideshow.css +304 -0
  24. data/themes/CSSS/css/theme.css +250 -0
  25. data/themes/CSSS/images/rainbow-wood.jpg +0 -0
  26. data/themes/CSSS/index.erb +36 -0
  27. data/themes/CSSS/js/classList.js +116 -0
  28. data/themes/CSSS/js/prefixfree.min.js +5 -0
  29. data/themes/CSSS/js/slideshow.js +621 -0
  30. data/themes/common/css/pygments/colorful.css +62 -0
  31. data/themes/common/css/pygments/manni.css +61 -0
  32. data/themes/common/css/pygments/native.css +70 -0
  33. data/themes/common/css/pygments/solarized.css +66 -0
  34. data/themes/common/fonts/DroidSansMono.svg +626 -0
  35. data/themes/common/fonts/DroidSansMono.ttf +0 -0
  36. data/themes/common/fonts/Lato-BoldItalic.woff +0 -0
  37. data/themes/common/fonts/Lato-Italic.woff +0 -0
  38. data/themes/common/fonts/Lato-bold.woff +0 -0
  39. data/themes/common/fonts/Lato.woff +0 -0
  40. data/themes/common/fonts/OpenSans-Bold.woff +0 -0
  41. data/themes/common/fonts/OpenSans-BoldItalic.woff +0 -0
  42. data/themes/common/fonts/OpenSans-Italic.woff +0 -0
  43. data/themes/common/fonts/OpenSans.woff +0 -0
  44. data/themes/common/fonts/PTMono.woff +0 -0
  45. data/themes/common/fonts/PTSans.Bold.Italic.woff +0 -0
  46. data/themes/common/fonts/PTSans.Bold.woff +0 -0
  47. data/themes/common/fonts/PTSans.Italic.woff +0 -0
  48. data/themes/common/fonts/PTSans.Narrow.Bold.woff +0 -0
  49. data/themes/common/fonts/PTSans.Narrow.woff +0 -0
  50. data/themes/common/fonts/PTSans.woff +0 -0
  51. data/themes/common/fonts/TargetBlank.otf +0 -0
  52. data/themes/common/fonts/TargetBlank.svg +14 -0
  53. data/themes/common/fonts/YanoneKaffeesatz-Bold.woff +0 -0
  54. data/themes/common/fonts/YanoneKaffeesatz-Regular.woff +0 -0
  55. data/themes/common/fonts/crimson_text.ttf +0 -0
  56. data/themes/common/fonts/crimson_text_bold.ttf +0 -0
  57. data/themes/common/fonts/crimson_text_semibold.ttf +0 -0
  58. data/themes/common/fonts/league_gothic-webfont.ttf +0 -0
  59. data/themes/html5rocks/README +2 -0
  60. data/themes/html5rocks/css/default.css +501 -0
  61. data/themes/html5rocks/css/moon.css +543 -0
  62. data/themes/html5rocks/css/sand.css +508 -0
  63. data/themes/html5rocks/css/sea_wave.css +492 -0
  64. data/themes/html5rocks/index.erb +64 -0
  65. data/themes/html5rocks/js/slides.js +464 -0
  66. data/themes/io2012/README +2 -0
  67. data/themes/io2012/css/default.css +1481 -0
  68. data/themes/io2012/css/fonts.css +24 -0
  69. data/themes/io2012/css/phone.css +27 -0
  70. data/themes/io2012/images/google_developers_icon_128.png +0 -0
  71. data/themes/io2012/images/io2012_logo.png +0 -0
  72. data/themes/io2012/index.erb +73 -0
  73. data/themes/io2012/js/hammer.js +586 -0
  74. data/themes/io2012/js/modernizr.custom.45394.js +4 -0
  75. data/themes/io2012/js/order.js +8 -0
  76. data/themes/io2012/js/polyfills/classList.min.js +2 -0
  77. data/themes/io2012/js/polyfills/dataset.min.js +2 -0
  78. data/themes/io2012/js/polyfills/history.min.js +1 -0
  79. data/themes/io2012/js/prettify/lang-apollo.js +2 -0
  80. data/themes/io2012/js/prettify/lang-clj.js +18 -0
  81. data/themes/io2012/js/prettify/lang-css.js +2 -0
  82. data/themes/io2012/js/prettify/lang-go.js +1 -0
  83. data/themes/io2012/js/prettify/lang-hs.js +2 -0
  84. data/themes/io2012/js/prettify/lang-lisp.js +3 -0
  85. data/themes/io2012/js/prettify/lang-lua.js +2 -0
  86. data/themes/io2012/js/prettify/lang-ml.js +2 -0
  87. data/themes/io2012/js/prettify/lang-n.js +4 -0
  88. data/themes/io2012/js/prettify/lang-proto.js +1 -0
  89. data/themes/io2012/js/prettify/lang-scala.js +2 -0
  90. data/themes/io2012/js/prettify/lang-sql.js +2 -0
  91. data/themes/io2012/js/prettify/lang-tex.js +1 -0
  92. data/themes/io2012/js/prettify/lang-vb.js +2 -0
  93. data/themes/io2012/js/prettify/lang-vhdl.js +3 -0
  94. data/themes/io2012/js/prettify/lang-wiki.js +2 -0
  95. data/themes/io2012/js/prettify/lang-xq.js +3 -0
  96. data/themes/io2012/js/prettify/lang-yaml.js +2 -0
  97. data/themes/io2012/js/prettify/prettify.css +1 -0
  98. data/themes/io2012/js/prettify/prettify.js +28 -0
  99. data/themes/io2012/js/require-1.0.8.min.js +33 -0
  100. data/themes/io2012/js/slide-controller.js +109 -0
  101. data/themes/io2012/js/slide-deck.js +768 -0
  102. data/themes/io2012/js/slides.js +5 -0
  103. data/themes/memories/README +5 -0
  104. data/themes/memories/css/fonts.css +25 -0
  105. data/themes/memories/css/slideshow.css +286 -0
  106. data/themes/memories/css/theme.css +183 -0
  107. data/themes/memories/index.erb +37 -0
  108. data/themes/memories/js/prefixfree.min.js +13 -0
  109. data/themes/memories/js/slideshow.js +577 -0
  110. data/themes/modern/LICENSE +20 -0
  111. data/themes/modern/README.md +52 -0
  112. data/themes/modern/css/GENERATED_CONTENT +0 -0
  113. data/themes/modern/css/defaults.css +0 -0
  114. data/themes/modern/css/fonts.css +166 -0
  115. data/themes/modern/css/pygments/colorful.css +215 -0
  116. data/themes/modern/css/pygments/github.css +208 -0
  117. data/themes/modern/css/pygments/solarized-dark.css +213 -0
  118. data/themes/modern/css/pygments/solarized-light.css +213 -0
  119. data/themes/modern/css/reset.css +41 -0
  120. data/themes/modern/css/screen.css +1183 -0
  121. data/themes/modern/fonts/Collegiate.woff +0 -0
  122. data/themes/modern/fonts/GoudyBookletter.1911.woff +0 -0
  123. data/themes/modern/fonts/Inconsolata.Bold.woff +0 -0
  124. data/themes/modern/fonts/Inconsolata.woff +0 -0
  125. data/themes/modern/fonts/Junction.woff +0 -0
  126. data/themes/modern/fonts/LiberationMono.Bold.woff +0 -0
  127. data/themes/modern/fonts/LiberationMono.BoldItalic.woff +0 -0
  128. data/themes/modern/fonts/LiberationMono.Italic.woff +0 -0
  129. data/themes/modern/fonts/LiberationMono.Regular.woff +0 -0
  130. data/themes/modern/fonts/OpenSans.Bold.woff +0 -0
  131. data/themes/modern/fonts/OpenSans.BoldItalic.woff +0 -0
  132. data/themes/modern/fonts/OpenSans.ExtraBold.woff +0 -0
  133. data/themes/modern/fonts/OpenSans.ExtraBoldItalic.woff +0 -0
  134. data/themes/modern/fonts/OpenSans.Italic.woff +0 -0
  135. data/themes/modern/fonts/OpenSans.Light.woff +0 -0
  136. data/themes/modern/fonts/OpenSans.LightItalic.woff +0 -0
  137. data/themes/modern/fonts/OpenSans.Regular.woff +0 -0
  138. data/themes/modern/fonts/OpenSans.Semibold.woff +0 -0
  139. data/themes/modern/fonts/OpenSans.SemiboldItalic.woff +0 -0
  140. data/themes/modern/fonts/PTMono.woff +0 -0
  141. data/themes/modern/fonts/PTSans.Bold.Italic.woff +0 -0
  142. data/themes/modern/fonts/PTSans.Bold.woff +0 -0
  143. data/themes/modern/fonts/PTSans.Italic.woff +0 -0
  144. data/themes/modern/fonts/PTSans.Narrow.Bold.woff +0 -0
  145. data/themes/modern/fonts/PTSans.woff +0 -0
  146. data/themes/modern/fonts/Raleway.Thin.woff +0 -0
  147. data/themes/modern/fonts/STIXGeneral.Bold.woff +0 -0
  148. data/themes/modern/fonts/STIXGeneral.BoldItalic.woff +0 -0
  149. data/themes/modern/fonts/STIXGeneral.Italic.woff +0 -0
  150. data/themes/modern/fonts/STIXGeneral.Regular.woff +0 -0
  151. data/themes/modern/fonts/YanoneKaffeesatz.Bold.woff +0 -0
  152. data/themes/modern/fonts/YanoneKaffeesatz.ExtraLight.woff +0 -0
  153. data/themes/modern/fonts/YanoneKaffeesatz.Light.woff +0 -0
  154. data/themes/modern/fonts/YanoneKaffeesatz.Regular.woff +0 -0
  155. data/themes/modern/images/cc/by.svg +29 -0
  156. data/themes/modern/images/cc/cc-white.svg +23 -0
  157. data/themes/modern/images/cc/cc.svg +23 -0
  158. data/themes/modern/images/cc/nc-eu.svg +21 -0
  159. data/themes/modern/images/cc/nc-jp.svg +18 -0
  160. data/themes/modern/images/cc/nc.svg +23 -0
  161. data/themes/modern/images/cc/nd.svg +20 -0
  162. data/themes/modern/images/cc/pd.svg +24 -0
  163. data/themes/modern/images/cc/remix.svg +20 -0
  164. data/themes/modern/images/cc/sa.svg +22 -0
  165. data/themes/modern/images/cc/sampling.plus.svg +33 -0
  166. data/themes/modern/images/cc/sampling.svg +36 -0
  167. data/themes/modern/images/cc/share.svg +22 -0
  168. data/themes/modern/images/cc/zero.svg +24 -0
  169. data/themes/modern/images/flickr.svg +65 -0
  170. data/themes/modern/images/mesh.png +0 -0
  171. data/themes/modern/images/mesh@2x.png +0 -0
  172. data/themes/modern/images/progress-grayDark.svg +55 -0
  173. data/themes/modern/images/progress.svg +3 -0
  174. data/themes/modern/index.erb +76 -0
  175. data/themes/modern/js/highcharts.js +294 -0
  176. data/themes/modern/js/jquery-2.1.0.min.js +4 -0
  177. data/themes/modern/js/script.coffee +480 -0
  178. data/themes/modern/js/script.js +678 -0
  179. data/themes/modern/styles/_box.scss +89 -0
  180. data/themes/modern/styles/_figure.scss +81 -0
  181. data/themes/modern/styles/_full.scss +74 -0
  182. data/themes/modern/styles/_increment.scss +38 -0
  183. data/themes/modern/styles/_list.scss +129 -0
  184. data/themes/modern/styles/_progress.scss +19 -0
  185. data/themes/modern/styles/defaults.scss +46 -0
  186. data/themes/modern/styles/fonts.scss +197 -0
  187. data/themes/modern/styles/pygments/_solarized.scss +82 -0
  188. data/themes/modern/styles/pygments/colorful.scss +67 -0
  189. data/themes/modern/styles/pygments/github.scss +67 -0
  190. data/themes/modern/styles/pygments/solarized-dark.scss +15 -0
  191. data/themes/modern/styles/pygments/solarized-light.scss +15 -0
  192. data/themes/modern/styles/reset.scss +46 -0
  193. data/themes/modern/styles/screen.scss +841 -0
  194. data/themes/reveal/README +2 -0
  195. data/themes/reveal/css/main.css +1029 -0
  196. data/themes/reveal/css/reset.css +57 -0
  197. data/themes/reveal/index.erb +102 -0
  198. data/themes/reveal/js/classList.js +2 -0
  199. data/themes/reveal/js/head.min.js +8 -0
  200. data/themes/reveal/js/reveal.js +951 -0
  201. data/themes/shower/README +2 -0
  202. data/themes/shower/css/fonts.css +50 -0
  203. data/themes/shower/css/reset.css +42 -0
  204. data/themes/shower/css/style.css +418 -0
  205. data/themes/shower/images/grid.png +0 -0
  206. data/themes/shower/images/linen.png +0 -0
  207. data/themes/shower/images/ribbon.svg +4 -0
  208. data/themes/shower/index.erb +35 -0
  209. data/themes/shower/js/script.js +325 -0
  210. data/themes/template/README +5 -0
  211. data/themes/template/css/reset.css +42 -0
  212. data/themes/template/index.erb +35 -0
  213. data/themes/template/js/prefixfree.min.js +13 -0
  214. metadata +343 -0
@@ -0,0 +1,621 @@
1
+ /**
2
+ * CSSS javascript code
3
+ * @author Lea Verou (http://leaverou.me)
4
+ * @version 2.0
5
+ */
6
+
7
+ /**
8
+ * Make the environment a bit friendlier
9
+ */
10
+ function $(expr, con) { return (con || document).querySelector(expr); }
11
+ function $$(expr, con) { return [].slice.call((con || document).querySelectorAll(expr)); }
12
+
13
+ (function(head, body, html){
14
+
15
+ // Check for classList support and include the polyfill if it's not supported
16
+ if(!('classList' in body)) {
17
+ var thisScript = $('script[src$="slideshow.js"]'),
18
+ script = document.createElement('script');
19
+ script.src = thisScript.src.replace(/\bslideshow\.js/, 'classList.js');
20
+ thisScript.parentNode.insertBefore(script, thisScript);
21
+ }
22
+
23
+ // Cache <title> element, we may need it for slides that don't have titles
24
+ var documentTitle = document.title + '';
25
+
26
+ var self = window.SlideShow = function(slide) {
27
+ var me = this;
28
+
29
+ // Set instance
30
+ if(!window.slideshow) {
31
+ window.slideshow = this;
32
+ }
33
+
34
+ // Current slide
35
+ this.index = this.slide = slide || 0;
36
+
37
+ // Current .delayed item in the slide
38
+ this.item = 0;
39
+
40
+ // Create timer, if needed
41
+ this.duration = body.getAttribute('data-duration');
42
+
43
+ if(this.duration > 0) {
44
+ var timer = document.createElement('div');
45
+
46
+ timer.id = 'timer';
47
+ timer.setAttribute('style', PrefixFree.prefixCSS('transition-duration: ' + this.duration * 60 + 's;'));
48
+ body.appendChild(timer);
49
+
50
+ addEventListener('load', function() {
51
+ timer.className = 'end';
52
+
53
+ setTimeout(function() {
54
+ timer.classList.add('overtime');
55
+ }, me.duration * 60000);
56
+ });
57
+ }
58
+
59
+ // Create slide indicator
60
+ this.indicator = document.createElement('div');
61
+
62
+ this.indicator.id = 'indicator';
63
+ body.appendChild(this.indicator);
64
+
65
+ // Get the slide elements into an array
66
+ this.slides = $$('.slide', body);
67
+
68
+ // Get the overview
69
+ this.overview = function(evt) {
70
+ if(body.classList.contains('show-thumbnails')) {
71
+ body.classList.remove('show-thumbnails');
72
+ body.classList.remove('headers-only');
73
+ }
74
+ else {
75
+ body.classList.add('show-thumbnails');
76
+
77
+ if(evt && (!evt.shiftKey || !evt.ctrlKey)) {
78
+ body.classList.add('headers-only');
79
+ }
80
+
81
+ body.addEventListener('click', function(evt) {
82
+ var slide = evt.target;
83
+
84
+ while(slide && !slide.classList.contains('slide')) {
85
+ slide = slide.parentNode;
86
+ }
87
+
88
+ if(slide) {
89
+ me.goto(slide.id);
90
+ setTimeout(function() { me.adjustFontSize(); }, 1000); // for Opera
91
+ }
92
+
93
+ body.classList.remove('show-thumbnails');
94
+ body.classList.remove('headers-only');
95
+
96
+ body.removeEventListener('click', arguments.callee);
97
+ }, false);
98
+ }
99
+ };
100
+
101
+ // Order of the slides
102
+ this.order = [];
103
+
104
+ for(var i=0; i<this.slides.length; i++) {
105
+ var slide = this.slides[i]; // to speed up references
106
+
107
+ // Asign ids to slides that don't have one
108
+ if(!slide.id) {
109
+ slide.id = 'slide' + (i+1);
110
+ }
111
+
112
+ // Set data-title attribute to the title of the slide
113
+ if(!slide.title) {
114
+ // no title attribute, fetch title from heading(s)
115
+ var heading = $('hgroup', slide) || $('h1,h2,h3,h4,h5,h6', slide);
116
+
117
+ if(heading && heading.textContent.trim()) {
118
+ slide.setAttribute('data-title', heading.textContent);
119
+ }
120
+ }
121
+ else {
122
+ // The title attribute is set, use that
123
+ slide.setAttribute('data-title', slide.title);
124
+ slide.removeAttribute('title');
125
+ }
126
+
127
+ slide.setAttribute('data-index', i);
128
+
129
+ var imp = slide.getAttribute('data-import'),
130
+ imported = imp? this.getSlideById(imp) : null;
131
+
132
+ this.order.push(imported? +imported.getAttribute('data-index') : i);
133
+ }
134
+
135
+ if(window.name === 'projector' && window.opener && opener.slideshow) {
136
+ body.classList.add('projector');
137
+ this.presenter = opener.slideshow;
138
+ this.presenter.projector = this;
139
+ }
140
+
141
+ // Adjust the font-size when the window is resized
142
+ addEventListener('resize', this, false);
143
+
144
+ // In some browsers DOMContentLoaded is too early, so try again onload
145
+ addEventListener('load', this, false);
146
+
147
+ addEventListener('hashchange', this, false);
148
+
149
+ // If there's already a hash, update current slide number...
150
+ this.handleEvent({type: 'hashchange'});
151
+
152
+ document.addEventListener('keyup', this, false);
153
+ document.addEventListener('keydown', this, false);
154
+
155
+ document.addEventListener('touchstart', this, false);
156
+ document.addEventListener('touchmove', this, false);
157
+ document.addEventListener('touchend', this, false);
158
+ document.addEventListener('touchcancel', this, false);
159
+
160
+ window.setTimeout(function() {
161
+ this.startEventSourceHandler('/remote/sub/events');
162
+ }, 100);
163
+
164
+ // Process iframe slides
165
+ $$('.slide[data-src]:empty').forEach(function(slide) {
166
+ var iframe = document.createElement('iframe');
167
+
168
+ iframe.setAttribute('data-src', slide.getAttribute('data-src'));
169
+ slide.removeAttribute('data-src');
170
+
171
+ slide.appendChild(iframe);
172
+ });
173
+
174
+ $$('.slide > iframe:only-child').forEach(function(iframe) {
175
+ var slide = iframe.parentNode,
176
+ src = iframe.src || iframe.getAttribute('data-src');
177
+
178
+ slide.classList.add('iframe');
179
+
180
+ if(!slide.classList.contains('notitle')) {
181
+ var h = document.createElement('h1'),
182
+ a = document.createElement('a'),
183
+ title = iframe.title || slide.title || slide.getAttribute('data-title') || src.replace(/\/#?$/, '')
184
+ .replace(/^\w+:\/\/w{0,3}\.?/, '');
185
+
186
+ a.href = src;
187
+ a.target = '_blank';
188
+ a.textContent = title;
189
+ h.appendChild(a);
190
+
191
+ slide.appendChild(h);
192
+ }
193
+ else {
194
+ var b = document.createElement('button');
195
+ b.className = 'onscreen-nav next';
196
+ b.textContent = 'Next ▶';
197
+ b.type = 'button';
198
+ b.onclick = function() { me.next(); };
199
+
200
+ slide.appendChild(b);
201
+ }
202
+ });
203
+ };
204
+
205
+ var horizontalDistanceThreshold = 30, // Swipe horizontal displacement must be more than this.
206
+ verticalDistanceThreshold = 75, // Swipe vertical displacement must be less than this.
207
+ startTouch,
208
+ stopTouch;
209
+
210
+ self.prototype = {
211
+ handleEvent: function(evt) {
212
+
213
+ switch(evt.type) {
214
+ /**
215
+ Keyboard navigation
216
+ Ctrl+G : Go to slide...
217
+ Ctrl+H : Show thumbnails and go to slide
218
+ Ctrl+P : Presenter view
219
+ (Shift instead of Ctrl works too)
220
+ */
221
+ case 'keyup':
222
+ if((evt.ctrlKey || evt.shiftKey) && !evt.altKey && !/^(?:input|textarea)$/i.test(document.activeElement.nodeName)) {
223
+ switch(evt.keyCode) {
224
+ case 71: // G
225
+ var slide = prompt('Which slide?');
226
+ this.goto(+slide? slide - 1 : slide);
227
+ break;
228
+ case 72: // H
229
+ this.overview(evt);
230
+ break;
231
+ case 74: // J
232
+ if(body.classList.contains('hide-elements')) {
233
+ body.classList.remove('hide-elements');
234
+ }
235
+ else {
236
+ body.classList.add('hide-elements');
237
+ }
238
+ break;
239
+ case 80: // P
240
+ // Open new window for attendee view
241
+ this.projector = open(location, 'projector');
242
+
243
+ // Get the focus back
244
+ window.focus();
245
+
246
+ // Switch this one to presenter view
247
+ body.classList.add('presenter');
248
+ }
249
+ }
250
+ break;
251
+ case 'keydown':
252
+ /**
253
+ Keyboard navigation
254
+ Home : First slide
255
+ End : Last slide
256
+ Space/Up/Right arrow : Next item/slide
257
+ Ctrl + Space/Up/Right arrow : Next slide
258
+ Down/Left arrow : Previous item/slide
259
+ Ctrl + Down/Left arrow : Previous slide
260
+ (Shift instead of Ctrl works too)
261
+ */
262
+ if((evt.target === body || evt.target === body.parentNode) && !evt.altKey) {
263
+ if(evt.keyCode >= 32 && evt.keyCode <= 40) {
264
+ evt.preventDefault();
265
+ }
266
+
267
+ switch(evt.keyCode) {
268
+ case 33: //page up
269
+ this.previous();
270
+ break;
271
+ case 34: //page down
272
+ this.next();
273
+ break;
274
+ case 35: // end
275
+ this.end();
276
+ break;
277
+ case 36: // home
278
+ this.start();
279
+ break;
280
+ case 37: // <-
281
+ case 38: // up arrow
282
+ this.previous(evt.ctrlKey || evt.shiftKey);
283
+ break;
284
+ case 32: // space
285
+ case 39: // ->
286
+ case 40: // down arrow
287
+ this.next(evt.ctrlKey || evt.shiftKey);
288
+ break;
289
+ }
290
+ }
291
+ break;
292
+ case 'touchstart':
293
+ evt.preventDefault(); // prevent image drag
294
+ data = evt.touches ? evt.touches[0] : evt;
295
+ startTouch = { X: data.pageX, Y: data.pageY };
296
+ break;
297
+ case 'touchmove':
298
+ data = evt.touches ? evt.touches[0] : evt;
299
+ stopTouch = { X: data.pageX, Y: data.pageY };
300
+ break;
301
+ case 'touchend':
302
+ if (!startTouch || !stopTouch) break;
303
+ if (Math.abs(startTouch.X - stopTouch.X) < horizontalDistanceThreshold) break;
304
+ if (Math.abs(startTouch.Y - stopTouch.Y) > verticalDistanceThreshold) break;
305
+ if (startTouch.X > stopTouch.X) {
306
+ this.previous();
307
+ } else {
308
+ this.next();
309
+ }
310
+ startTouch = stopTouch = null;
311
+ break;
312
+ case 'touchcancel':
313
+ startTouch = stopTouch = null;
314
+ break;
315
+ case 'load':
316
+ case 'resize':
317
+ this.adjustFontSize();
318
+ break;
319
+ case 'hashchange':
320
+ this.goto(location.hash.substr(1) || 0);
321
+ }
322
+ },
323
+
324
+ start: function() {
325
+ this.goto(0);
326
+ },
327
+
328
+ end: function() {
329
+ this.goto(this.slides.length - 1);
330
+ },
331
+
332
+ /**
333
+ @param hard {Boolean} Whether to advance to the next slide (true) or
334
+ just the next step (which could very well be showing a list item)
335
+ */
336
+ next: function(hard) {
337
+ if(!hard && this.items.length) {
338
+ this.nextItem();
339
+ }
340
+ else {
341
+ this.goto(this.index + 1);
342
+
343
+ this.item = 0;
344
+
345
+ // Mark all items as not displayed, if there are any
346
+ if(this.items.length) {
347
+ for (var i=0; i<this.items.length; i++) {
348
+ if(this.items[i].classList) {
349
+ this.items[i].classList.remove('displayed');
350
+ this.items[i].classList.remove('current');
351
+ }
352
+ }
353
+ }
354
+ }
355
+ },
356
+
357
+ nextItem: function() {
358
+ if(this.item < this.items.length) {
359
+ this.gotoItem(++this.item);
360
+ }
361
+ else {
362
+ this.item = 0;
363
+ this.next(true);
364
+ }
365
+ },
366
+
367
+ previous: function(hard) {
368
+ if(!hard && this.item > 0) {
369
+ this.previousItem();
370
+ }
371
+ else {
372
+ this.goto(this.index - 1);
373
+
374
+ this.item = this.items.length;
375
+
376
+ // Mark all items as displayed, if there are any
377
+ if(this.items.length) {
378
+ for (var i=0; i<this.items.length; i++) {
379
+ if(this.items[i].classList) {
380
+ this.items[i].classList.add('displayed');
381
+ }
382
+ }
383
+
384
+ // Mark the last one as current
385
+ var lastItem = this.items[this.items.length - 1];
386
+
387
+ lastItem.classList.remove('displayed');
388
+ lastItem.classList.add('current');
389
+ }
390
+ }
391
+ },
392
+
393
+ previousItem: function() {
394
+ this.gotoItem(--this.item);
395
+ },
396
+
397
+ getSlideById: function(id) {
398
+ return $('.slide#' + id);
399
+ },
400
+
401
+ /**
402
+ Go to an aribtary slide
403
+ @param which {String|Integer} Which slide (identifier or slide number)
404
+ */
405
+ goto: function(which) {
406
+ var slide;
407
+
408
+ // We have to remove it to prevent multiple calls to goto messing up
409
+ // our current item (and there's no point either, so we save on performance)
410
+ window.removeEventListener('hashchange', this, false);
411
+
412
+ if(which + 0 === which && which in this.slides) {
413
+ // Argument is a valid slide number
414
+ this.index = which;
415
+ this.slide = this.order[which];
416
+
417
+ slide = this.slides[this.slide];
418
+
419
+ location.hash = '#' + slide.id;
420
+ }
421
+ else if(which + '' === which) { // Argument is a slide id
422
+ slide = this.getSlideById(which);
423
+
424
+ if(slide) {
425
+ this.slide = this.index = +slide.getAttribute('data-index');
426
+ location.hash = '#' + which;
427
+ }
428
+ }
429
+
430
+ if(slide) { // Slide actually changed, perform any other tasks needed
431
+ document.title = slide.getAttribute('data-title') || documentTitle;
432
+
433
+ if(slide.classList.contains('iframe')) {
434
+ var iframe = $('iframe', slide), src;
435
+
436
+ if(!iframe.hasAttribute('src') && (src = iframe.getAttribute('data-src'))) {
437
+ iframe.setAttribute('src', src);
438
+ }
439
+ }
440
+ else {
441
+ this.adjustFontSize();
442
+ }
443
+
444
+ this.indicator.textContent = this.index + 1;
445
+
446
+ // Update items collection
447
+ this.items = $$('.delayed, .delayed-children > *', this.slides[this.slide]);
448
+ this.items.sort(function(a, b){
449
+ return (a.getAttribute('data-index') || 0) - (b.getAttribute('data-index') || 0);
450
+ });
451
+ this.item = 0;
452
+
453
+ this.projector && this.projector.goto(which);
454
+
455
+ // Update next/previous
456
+ for (var i=this.slides.length; i--;) {
457
+ this.slides[i].classList.remove('previous');
458
+ this.slides[i].classList.remove('next');
459
+ }
460
+
461
+ this.slides.previous = this.slides[this.order[this.index - 1]];
462
+ this.slides.next = this.slides[this.order[this.index + 1]];
463
+
464
+ this.slides.previous && this.slides.previous.classList.add('previous');
465
+ this.slides.next && this.slides.next.classList.add('next');
466
+ }
467
+
468
+ // If you attach the listener immediately again then it will catch the event
469
+ // We have to do it asynchronously
470
+ var me = this;
471
+ setTimeout(function() {
472
+ addEventListener('hashchange', me, false);
473
+ }, 1000);
474
+ },
475
+
476
+ gotoItem: function(which) {
477
+ this.item = which;
478
+
479
+ var items = this.items, classes;
480
+
481
+ for(var i=items.length; i-- > 0;) {
482
+ classes = this.items[i].classList;
483
+
484
+ classes.remove('current');
485
+ classes.remove('displayed');
486
+ }
487
+
488
+ for(var i=this.item - 1; i-- > 0;) {
489
+ this.items[i].classList.add('displayed');
490
+ }
491
+
492
+ if(this.item > 0) {
493
+ this.items[this.item - 1].classList.add('current');
494
+ }
495
+
496
+ this.projector && this.projector.gotoItem(which);
497
+ },
498
+
499
+ adjustFontSize: function() {
500
+ // Cache long lookup chains, for performance
501
+ var htmlStyle = html.style,
502
+ scrollRoot = html.scrollHeight? html : body,
503
+ innerHeight = window.innerHeight,
504
+ innerWidth = window.innerWidth,
505
+ slide = this.slides[this.slide];
506
+
507
+ // Clear previous styles
508
+ htmlStyle.fontSize = '';
509
+
510
+ if(body.classList.contains('show-thumbnails')
511
+ || slide.classList.contains('dont-resize')) {
512
+ return;
513
+ }
514
+
515
+ for(
516
+ var percent = 100;
517
+ (scrollRoot.scrollHeight > innerHeight || scrollRoot.scrollWidth > innerWidth) && percent >= 35;
518
+ percent-=5
519
+ ) {
520
+ htmlStyle.fontSize = percent + '%';
521
+ }
522
+
523
+ // Individual slide
524
+
525
+ if(slide.clientHeight && slide.clientWidth) {
526
+ // Strange FF bug: scrollHeight doesn't work properly with overflow:hidden
527
+ var previousStyle = slide.getAttribute('style');
528
+ slide.style.overflow = 'auto';
529
+
530
+ for(
531
+ ;
532
+ (slide.scrollHeight > slide.clientHeight || slide.scrollWidth > slide.clientWidth) && percent >= 35;
533
+ percent--
534
+ ) {
535
+ htmlStyle.fontSize = percent + '%';
536
+ }
537
+
538
+ slide.setAttribute('style', previousStyle);
539
+ }
540
+
541
+ if(percent <= 35) {
542
+ // Something probably went wrong, so just give up altogether
543
+ htmlStyle.fontSize = '';
544
+ }
545
+ },
546
+
547
+ // Is the element on the current slide?
548
+ onCurrent: function(element) {
549
+ var slide = self.getSlide(element);
550
+
551
+ if(slide) {
552
+ return '#' + slide.id === location.hash;
553
+ }
554
+
555
+ return false;
556
+ },
557
+
558
+ startEventSourceHandler: function(uri) {
559
+ if (window['EventSource'] == undefined) return ;
560
+
561
+ var source = new EventSource(uri);
562
+
563
+ var me = this;
564
+
565
+ source.onmessage = function(e) {
566
+ switch(e.data){
567
+ case 'next':
568
+ me.next();
569
+ break;
570
+ case 'prev':
571
+ me.previous();
572
+ break;
573
+ case 'up':
574
+ me.end();
575
+ break;
576
+ case 'down':
577
+ me.start();
578
+ break;
579
+ default:
580
+ console.log(e);
581
+ };
582
+ };
583
+ }
584
+ };
585
+
586
+ /**********************************************
587
+ * Static methods
588
+ **********************************************/
589
+
590
+ // Helper method for plugins
591
+ self.getSlide = function(element) {
592
+ var slide = element;
593
+
594
+ while (slide && slide.classList && !slide.classList.contains('slide')) {
595
+ slide = slide.parentNode;
596
+ }
597
+
598
+ return slide;
599
+ };
600
+
601
+ })(document.head || document.getElementsByTagName('head')[0], document.body, document.documentElement);
602
+
603
+ // Rudimentary style[scoped] polyfill
604
+ addEventListener('load', function(){ // no idea why the timeout is needed
605
+ $$('style[scoped]').forEach(function(style) {
606
+ var rulez = style.sheet.cssRules,
607
+ parentid = style.parentNode.id || self.getSlide(style).id || style.parentNode.parentNode.id;
608
+
609
+ for(var j=rulez.length; j--;) {
610
+ var selector = rulez[j].selectorText.replace(/^|,/g, function($0) {
611
+ return '#' + parentid + ' ' + $0;
612
+ });
613
+
614
+ var cssText = rulez[j].cssText.replace(/^.+?{/, selector + '{');
615
+
616
+ style.sheet.deleteRule(j);
617
+ style.sheet.insertRule(cssText, j);
618
+ }
619
+
620
+ });
621
+ });
@@ -0,0 +1,62 @@
1
+ code .hll { background-color: #ffffcc }
2
+ code { background: #ffffff; }
3
+ code .c { color: #808080 } /* Comment */
4
+ code .err { color: #F00000; background-color: #F0A0A0 } /* Error */
5
+ code .k { color: #008000; font-weight: bold } /* Keyword */
6
+ code .o { color: #303030 } /* Operator */
7
+ code .cm { color: #808080 } /* Comment.Multiline */
8
+ code .cp { color: #507090 } /* Comment.Preproc */
9
+ code .c1 { color: #808080 } /* Comment.Single */
10
+ code .cs { color: #cc0000; font-weight: bold } /* Comment.Special */
11
+ code .gd { color: #A00000 } /* Generic.Deleted */
12
+ code .ge { font-style: italic } /* Generic.Emph */
13
+ code .gr { color: #FF0000 } /* Generic.Error */
14
+ code .gh { color: #000080; font-weight: bold } /* Generic.Heading */
15
+ code .gi { color: #00A000 } /* Generic.Inserted */
16
+ code .go { color: #808080 } /* Generic.Output */
17
+ code .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
18
+ code .gs { font-weight: bold } /* Generic.Strong */
19
+ code .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
20
+ code .gt { color: #0040D0 } /* Generic.Traceback */
21
+ code .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
22
+ code .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
23
+ code .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
24
+ code .kp { color: #003080; font-weight: bold } /* Keyword.Pseudo */
25
+ code .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
26
+ code .kt { color: #303090; font-weight: bold } /* Keyword.Type */
27
+ code .m { color: #6000E0; font-weight: bold } /* Literal.Number */
28
+ code .s { background-color: #fff0f0 } /* Literal.String */
29
+ code .na { color: #0000C0 } /* Name.Attribute */
30
+ code .nb { color: #007020 } /* Name.Builtin */
31
+ code .nc { color: #B00060; font-weight: bold } /* Name.Class */
32
+ code .no { color: #003060; font-weight: bold } /* Name.Constant */
33
+ code .nd { color: #505050; font-weight: bold } /* Name.Decorator */
34
+ code .ni { color: #800000; font-weight: bold } /* Name.Entity */
35
+ code .ne { color: #F00000; font-weight: bold } /* Name.Exception */
36
+ code .nf { color: #0060B0; font-weight: bold } /* Name.Function */
37
+ code .nl { color: #907000; font-weight: bold } /* Name.Label */
38
+ code .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
39
+ code .nt { color: #007000 } /* Name.Tag */
40
+ code .nv { color: #906030 } /* Name.Variable */
41
+ code .ow { color: #000000; font-weight: bold } /* Operator.Word */
42
+ code .w { color: #bbbbbb } /* Text.Whitespace */
43
+ code .mf { color: #6000E0; font-weight: bold } /* Literal.Number.Float */
44
+ code .mh { color: #005080; font-weight: bold } /* Literal.Number.Hex */
45
+ code .mi { color: #0000D0; font-weight: bold } /* Literal.Number.Integer */
46
+ code .mo { color: #4000E0; font-weight: bold } /* Literal.Number.Oct */
47
+ code .sb { background-color: #fff0f0 } /* Literal.String.Backtick */
48
+ code .sc { color: #0040D0 } /* Literal.String.Char */
49
+ code .sd { color: #D04020 } /* Literal.String.Doc */
50
+ code .s2 { background-color: #fff0f0 } /* Literal.String.Double */
51
+ code .se { color: #606060; font-weight: bold; background-color: #fff0f0 } /* Literal.String.Escape */
52
+ code .sh { background-color: #fff0f0 } /* Literal.String.Heredoc */
53
+ code .si { background-color: #e0e0e0 } /* Literal.String.Interpol */
54
+ code .sx { color: #D02000; background-color: #fff0f0 } /* Literal.String.Other */
55
+ code .sr { color: #000000; background-color: #fff0ff } /* Literal.String.Regex */
56
+ code .s1 { background-color: #fff0f0 } /* Literal.String.Single */
57
+ code .ss { color: #A06000 } /* Literal.String.Symbol */
58
+ code .bp { color: #007020 } /* Name.Builtin.Pseudo */
59
+ code .vc { color: #306090 } /* Name.Variable.Class */
60
+ code .vg { color: #d07000; font-weight: bold } /* Name.Variable.Global */
61
+ code .vi { color: #3030B0 } /* Name.Variable.Instance */
62
+ code .il { color: #0000D0; font-weight: bold } /* Literal.Number.Integer.Long */