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,464 @@
1
+ (function() {
2
+ var doc = document;
3
+ var disableBuilds = false;
4
+
5
+ var ctr = 0;
6
+ var spaces = /\s+/, a1 = [''];
7
+
8
+ var toArray = function(list) {
9
+ return Array.prototype.slice.call(list || [], 0);
10
+ };
11
+
12
+ var byId = function(id) {
13
+ if (typeof id == 'string') { return doc.getElementById(id); }
14
+ return id;
15
+ };
16
+
17
+ var query = function(query, root) {
18
+ return queryAll(query, root)[0];
19
+ }
20
+
21
+ var queryAll = function(query, root) {
22
+ if (!query) { return []; }
23
+ if (typeof query != 'string') { return toArray(query); }
24
+ if (typeof root == 'string') {
25
+ root = byId(root);
26
+ if(!root){ return []; }
27
+ }
28
+
29
+ root = root || document;
30
+ var rootIsDoc = (root.nodeType == 9);
31
+ var doc = rootIsDoc ? root : (root.ownerDocument || document);
32
+
33
+ // rewrite the query to be ID rooted
34
+ if (!rootIsDoc || ('>~+'.indexOf(query.charAt(0)) >= 0)) {
35
+ root.id = root.id || ('qUnique' + (ctr++));
36
+ query = '#' + root.id + ' ' + query;
37
+ }
38
+ // don't choke on something like ".yada.yada >"
39
+ if ('>~+'.indexOf(query.slice(-1)) >= 0) { query += ' *'; }
40
+ return toArray(doc.querySelectorAll(query));
41
+ };
42
+
43
+ var strToArray = function(s) {
44
+ if (typeof s == 'string' || s instanceof String) {
45
+ if (s.indexOf(' ') < 0) {
46
+ a1[0] = s;
47
+ return a1;
48
+ } else {
49
+ return s.split(spaces);
50
+ }
51
+ }
52
+ return s;
53
+ };
54
+
55
+ // Needed for browsers that don't support String.trim() (e.g. iPad)
56
+ var trim = function(str) {
57
+ return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
58
+ };
59
+
60
+ var addClass = function(node, classStr) {
61
+ classStr = strToArray(classStr);
62
+ var cls = ' ' + node.className + ' ';
63
+ for (var i = 0, len = classStr.length, c; i < len; ++i) {
64
+ c = classStr[i];
65
+ if (c && cls.indexOf(' ' + c + ' ') < 0) {
66
+ cls += c + ' ';
67
+ }
68
+ }
69
+ node.className = trim(cls);
70
+ };
71
+
72
+ var removeClass = function(node, classStr) {
73
+ var cls;
74
+ if (classStr !== undefined) {
75
+ classStr = strToArray(classStr);
76
+ cls = ' ' + node.className + ' ';
77
+ for (var i = 0, len = classStr.length; i < len; ++i) {
78
+ cls = cls.replace(' ' + classStr[i] + ' ', ' ');
79
+ }
80
+ cls = trim(cls);
81
+ } else {
82
+ cls = '';
83
+ }
84
+ if (node.className != cls) {
85
+ node.className = cls;
86
+ }
87
+ };
88
+
89
+ var toggleClass = function(node, classStr) {
90
+ var cls = ' ' + node.className + ' ';
91
+ if (cls.indexOf(' ' + trim(classStr) + ' ') >= 0) {
92
+ removeClass(node, classStr);
93
+ } else {
94
+ addClass(node, classStr);
95
+ }
96
+ };
97
+
98
+
99
+ // modernizr lite via https://gist.github.com/598008
100
+ var testStyle = function(style) {
101
+
102
+ var elem = document.createElement('div');
103
+ var prefixes = ['Webkit', 'Moz', 'O', 'ms', 'Khtml'];
104
+ var bool;
105
+ var bump = function(all, letter) {
106
+ return letter.toUpperCase();
107
+ };
108
+ var prop;
109
+
110
+ bool = style in elem.style;
111
+ prop = style.replace(/^(.)/, bump).replace(/-([a-z])/ig, bump);
112
+
113
+ for (var len = prefixes.length; len--; ){
114
+ if (bool) {
115
+ break;
116
+ }
117
+ bool = prefixes[len] + prop in elem.style;
118
+ }
119
+
120
+ document.documentElement.className += ' ' + (bool ? '' : 'no-') + style.replace(/-/g, '');
121
+ return bool;
122
+ };
123
+
124
+ var canTransition = testStyle('transition');
125
+
126
+ //
127
+ // Slide class
128
+ //
129
+ var Slide = function(node, idx) {
130
+ this._node = node;
131
+ if (idx >= 0) {
132
+ this._count = idx + 1;
133
+ }
134
+ if (this._node) {
135
+ addClass(this._node, 'slide distant-slide');
136
+ }
137
+ this._makeCounter();
138
+ this._makeBuildList();
139
+ };
140
+
141
+ Slide.prototype = {
142
+ _node: null,
143
+ _count: 0,
144
+ _buildList: [],
145
+ _visited: false,
146
+ _currentState: '',
147
+ _states: [ 'distant-slide', 'far-past',
148
+ 'past', 'current', 'future',
149
+ 'far-future', 'distant-slide' ],
150
+ setState: function(state) {
151
+ if (typeof state != 'string') {
152
+ state = this._states[state];
153
+ }
154
+ if (state == 'current' && !this._visited) {
155
+ this._visited = true;
156
+ this._makeBuildList();
157
+ }
158
+ removeClass(this._node, this._states);
159
+ addClass(this._node, state);
160
+ this._currentState = state;
161
+
162
+ // delay first auto run. Really wish this were in CSS.
163
+ /*
164
+ this._runAutos();
165
+ */
166
+ var _t = this;
167
+ setTimeout(function(){ _t._runAutos(); } , 400);
168
+
169
+ if (state == 'current') {
170
+ this._onLoad();
171
+ } else {
172
+ this._onUnload();
173
+ }
174
+ },
175
+ _onLoad: function() {
176
+ this._fireEvent('onload');
177
+ this._showFrames();
178
+ },
179
+ _onUnload: function() {
180
+ this._fireEvent('onunload');
181
+ this._hideFrames();
182
+ },
183
+ _fireEvent: function(name) {
184
+ var eventSrc = this._node.getAttribute(name);
185
+ if (eventSrc) {
186
+ eventSrc = '(function() { ' + eventSrc + ' })';
187
+ var fn = eval(eventSrc);
188
+ fn.call(this._node);
189
+ }
190
+ },
191
+ _showFrames: function() {
192
+ var frames = queryAll('iframe', this._node);
193
+ function show() {
194
+ frames.forEach(function(el) {
195
+ var _src = el.getAttribute('_src');
196
+ if (_src && _src.length) {
197
+ el.src = _src;
198
+ }
199
+ });
200
+ }
201
+ setTimeout(show, 0);
202
+ },
203
+ _hideFrames: function() {
204
+ var frames = queryAll('iframe', this._node);
205
+ function hide() {
206
+ frames.forEach(function(el) {
207
+ var _src = el.getAttribute('_src');
208
+ if (_src && _src.length) {
209
+ el.src = '';
210
+ }
211
+ });
212
+ }
213
+ setTimeout(hide, 250);
214
+ },
215
+ _makeCounter: function() {
216
+ if(!this._count || !this._node) { return; }
217
+ var c = doc.createElement('span');
218
+ c.textContent = this._count;
219
+ c.className = 'counter';
220
+ this._node.appendChild(c);
221
+ },
222
+ _makeBuildList: function() {
223
+ this._buildList = [];
224
+ if (disableBuilds) { return; }
225
+ if (this._node) {
226
+ this._buildList = queryAll('[data-build] > *', this._node);
227
+ }
228
+ this._buildList.forEach(function(el) {
229
+ addClass(el, 'to-build');
230
+ });
231
+ },
232
+ _runAutos: function() {
233
+ if (this._currentState != 'current') {
234
+ return;
235
+ }
236
+ // find the next auto, slice it out of the list, and run it
237
+ var idx = -1;
238
+ this._buildList.some(function(n, i) {
239
+ if (n.hasAttribute('data-auto')) {
240
+ idx = i;
241
+ return true;
242
+ }
243
+ return false;
244
+ });
245
+ if (idx >= 0) {
246
+ var elem = this._buildList.splice(idx, 1)[0];
247
+
248
+ var _t = this;
249
+ if (canTransition) {
250
+ var l = function(evt) {
251
+ elem.parentNode.removeEventListener('webkitTransitionEnd', l, false);
252
+ elem.parentNode.removeEventListener('transitionend', l, false); // moz
253
+ elem.parentNode.removeEventListener('oTransitionEnd', l, false);
254
+ _t._runAutos();
255
+ };
256
+ elem.parentNode.addEventListener('webkitTransitionEnd', l, false);
257
+ elem.parentNode.addEventListener('transitionend', l, false);
258
+ elem.parentNode.addEventListener('oTransitionEnd', l, false);
259
+ removeClass(elem, 'to-build');
260
+ } else {
261
+ setTimeout(function() {
262
+ removeClass(elem, 'to-build');
263
+ _t._runAutos();
264
+ }, 400);
265
+ }
266
+ }
267
+ },
268
+ buildNext: function() {
269
+ if (!this._buildList.length) {
270
+ return false;
271
+ }
272
+ removeClass(this._buildList.shift(), 'to-build');
273
+ return true;
274
+ },
275
+ };
276
+
277
+ //
278
+ // SlideShow class
279
+ //
280
+ var SlideShow = function(slides) {
281
+ this._slides = (slides || []).map(function(el, idx) {
282
+ return new Slide(el, idx);
283
+ });
284
+ var h = window.location.hash;
285
+ try {
286
+ this.current = h;
287
+ } catch (e) { /* squeltch */ }
288
+ this.current = (!this.current) ? "landing-slide" : this.current.replace('#', '');
289
+ if (!query('#' + this.current)) {
290
+ // if this happens is very likely that someone is coming from
291
+ // a link with the old permalink format, i.e. #slide24
292
+ alert('The format of the permalinks have recently changed. If you are coming ' +
293
+ 'here from an old external link it\'s very likely you will land to the wrong slide');
294
+ this.current = "landing-slide";
295
+ }
296
+ var _t = this;
297
+ doc.addEventListener('keydown',
298
+ function(e) { _t.handleKeys(e); }, false);
299
+ doc.addEventListener('touchstart',
300
+ function(e) { _t.handleTouchStart(e); }, false);
301
+ doc.addEventListener('touchend',
302
+ function(e) { _t.handleTouchEnd(e); }, false);
303
+ window.addEventListener('popstate',
304
+ function(e) { if (e.state) { _t.go(e.state); } }, false);
305
+ query('#left-init-key').addEventListener('click',
306
+ function() { _t.next(); }, false);
307
+ window.setTimeout(function() {
308
+ this._startEventSource('/remote/sub/events');
309
+ }, 100);
310
+ this._update();
311
+ };
312
+
313
+ SlideShow.prototype = {
314
+ _presentationCounter: query('#presentation-counter'),
315
+ _slides: [],
316
+ _getCurrentIndex: function() {
317
+ var me = this;
318
+ var slideCount = null;
319
+ queryAll('.slide').forEach(function(slide, i) {
320
+ if (slide.id == me.current) {
321
+ slideCount = i;
322
+ }
323
+ });
324
+ return slideCount + 1;
325
+ },
326
+ _startEventSource: function(uri) {
327
+ if (window['EventSource'] == undefined) return ;
328
+
329
+ var source = new EventSource(uri);
330
+ var _t = this;
331
+ source.onmessage = function(e) {
332
+ switch(e.data){
333
+ case 'next':
334
+ _t.next(); break;
335
+ case 'prev':
336
+ _t.prev(); break;
337
+ case 'up':
338
+ _t.showNotes(); break;
339
+ case 'down':
340
+ _t.switch3D(); break;
341
+ default:
342
+ console.log(e);
343
+ };
344
+ };
345
+ },
346
+ _update: function(dontPush) {
347
+ // in order to delay the time where the counter shows the slide number we check if
348
+ // the slides are already loaded (so we show the loading... instead)
349
+ // the technique to test visibility is taken from here
350
+ // http://stackoverflow.com/questions/704758/how-to-check-if-an-element-is-really-visible-with-javascript
351
+ var docElem = document.documentElement;
352
+ var elem = document.elementFromPoint( docElem.clientWidth / 2, docElem.clientHeight / 2);
353
+ var currentIndex = this._getCurrentIndex();
354
+ if (elem && elem.className != 'presentation') {
355
+ this._presentationCounter.textContent = currentIndex;
356
+ }
357
+ if (history.pushState) {
358
+ if (!dontPush) {
359
+ history.replaceState(this.current, 'Slide ' + this.current, '#' + this.current);
360
+ }
361
+ } else {
362
+ window.location.hash = this.current;
363
+ }
364
+ for (var x = currentIndex-1; x < currentIndex + 7; x++) {
365
+ if (this._slides[x-4]) {
366
+ this._slides[x-4].setState(Math.max(0, x-currentIndex));
367
+ }
368
+ }
369
+ },
370
+
371
+ current: 0,
372
+ next: function() {
373
+ if (!this._slides[this._getCurrentIndex() - 1].buildNext()) {
374
+ var next = query('#' + this.current + ' + .slide');
375
+ this.current = (next) ? next.id : this.current;
376
+ this._update();
377
+ }
378
+ },
379
+ prev: function() {
380
+ var prev = query('.slide:nth-child(' + (this._getCurrentIndex() - 1) + ')');
381
+ this.current = (prev) ? prev.id : this.current;
382
+ this._update();
383
+ },
384
+ go: function(slideId) {
385
+ this.current = slideId;
386
+ this._update(true);
387
+ },
388
+
389
+ _notesOn: false,
390
+ showNotes: function() {
391
+ var isOn = this._notesOn = !this._notesOn;
392
+ queryAll('.notes').forEach(function(el) {
393
+ el.style.display = (notesOn) ? 'block' : 'none';
394
+ });
395
+ },
396
+ switch3D: function() {
397
+ toggleClass(document.body, 'three-d');
398
+ },
399
+ changeTheme: function() {
400
+ var linkEls = queryAll('link.theme');
401
+ var sheetIndex = 0;
402
+ linkEls.forEach(function(stylesheet, i) {
403
+ if (!stylesheet.disabled) {
404
+ sheetIndex = i;
405
+ }
406
+ });
407
+ linkEls[sheetIndex].disabled = true;
408
+ linkEls[(sheetIndex + 1) % linkEls.length].disabled = false;
409
+ sessionStorage['theme'] = linkEls[(sheetIndex + 1) % linkEls.length].href;
410
+ },
411
+ handleKeys: function(e) {
412
+
413
+ if (/^(input|textarea)$/i.test(e.target.nodeName) || e.target.isContentEditable) {
414
+ return;
415
+ }
416
+
417
+ switch (e.keyCode) {
418
+ case 37: // left arrow
419
+ this.prev(); e.preventDefault(); break;
420
+ case 39: // right arrow
421
+ case 32: // space
422
+ this.next(); e.preventDefault(); break;
423
+ case 50: // 2
424
+ this.showNotes(); e.preventDefault(); break;
425
+ case 51: // 3
426
+ this.switch3D(); e.preventDefault(); break;
427
+ case 84: // T
428
+ this.changeTheme(); e.preventDefault(); break;
429
+ }
430
+ },
431
+ _touchStartX: 0,
432
+ handleTouchStart: function(e) {
433
+ this._touchStartX = e.touches[0].pageX;
434
+ },
435
+ handleTouchEnd: function(e) {
436
+ var delta = this._touchStartX - e.changedTouches[0].pageX;
437
+ var SWIPE_SIZE = 150;
438
+ if (delta > SWIPE_SIZE) {
439
+ this.next();
440
+ } else if (delta< -SWIPE_SIZE) {
441
+ this.prev();
442
+ }
443
+ },
444
+ };
445
+
446
+ // disable style theme stylesheets
447
+ var linkEls = queryAll('link.theme');
448
+ var stylesheetPath = sessionStorage['theme'] || 'css/default.css';
449
+ linkEls.forEach(function(stylesheet) {
450
+ stylesheet.disabled = !(stylesheet.href.indexOf(stylesheetPath) != -1);
451
+ });
452
+
453
+ // Initialize
454
+ var slideshow = new SlideShow(queryAll('.slide'));
455
+
456
+ document.addEventListener('DOMContentLoaded', function() {
457
+ query('.slides').style.display = 'block';
458
+ }, false);
459
+
460
+ queryAll('pre').forEach(function(el) {
461
+ addClass(el, 'prettyprint');
462
+ });
463
+
464
+ })();
@@ -0,0 +1,2 @@
1
+ HTML5 slides for Google I/O 2012
2
+ https://code.google.com/p/io-2012-slides/