diff options
author | Eric Bidelman | 2012-04-14 18:43:06 -0700 |
---|---|---|
committer | Eric Bidelman | 2012-04-14 18:43:06 -0700 |
commit | 04153b7c8a3332c8008408227f6d71b8ef392c35 (patch) | |
tree | e509dace2cc9e441b7bd8f5793d422823c86de74 | |
parent | 7054806c29c3eae0ed4b4176047b92bddcdcd0cc (diff) | |
download | io-slides-remote-04153b7c8a3332c8008408227f6d71b8ef392c35.tar.gz |
Moving slide config to its own file. eval is bad
-rw-r--r-- | js/slides.js | 41 | ||||
-rw-r--r-- | slide_config.js | 35 | ||||
-rw-r--r-- | template.html | 50 |
3 files changed, 63 insertions, 63 deletions
diff --git a/js/slides.js b/js/slides.js index 784d122..a28fd55 100644 --- a/js/slides.js +++ b/js/slides.js | |||
@@ -65,7 +65,7 @@ SlideDeck.prototype.onDomLoaded_ = function(e) { | |||
65 | } | 65 | } |
66 | 66 | ||
67 | // Load config. | 67 | // Load config. |
68 | this.loadConfig_(); | 68 | this.loadConfig_(SLIDE_CONFIG); |
69 | this.addEventListeners_(); | 69 | this.addEventListeners_(); |
70 | this.updateSlides_(); | 70 | this.updateSlides_(); |
71 | 71 | ||
@@ -174,14 +174,13 @@ SlideDeck.prototype.onBodyKeyDown_ = function(e) { | |||
174 | /** | 174 | /** |
175 | * @private | 175 | * @private |
176 | */ | 176 | */ |
177 | SlideDeck.prototype.loadConfig_ = function() { | 177 | SlideDeck.prototype.loadConfig_ = function(config) { |
178 | var configScripts = | 178 | if (!config) { |
179 | document.querySelector('script[type="text/slide-config"]'); | 179 | return; |
180 | if (configScripts) { | ||
181 | eval(configScripts.innerHTML); | ||
182 | this.config_ = slideConfig; | ||
183 | } | 180 | } |
184 | 181 | ||
182 | this.config_ = config; | ||
183 | |||
185 | var settings = this.config_.settings; | 184 | var settings = this.config_.settings; |
186 | 185 | ||
187 | this.loadTheme_(settings.theme || []); | 186 | this.loadTheme_(settings.theme || []); |
@@ -190,6 +189,7 @@ SlideDeck.prototype.loadConfig_ = function() { | |||
190 | this.addFavIcon_(settings.favIcon); | 189 | this.addFavIcon_(settings.favIcon); |
191 | } | 190 | } |
192 | 191 | ||
192 | // Prettyprint. Default to on. | ||
193 | if (!!!('usePrettify' in settings) || settings.usePrettify) { | 193 | if (!!!('usePrettify' in settings) || settings.usePrettify) { |
194 | prettyPrint(); | 194 | prettyPrint(); |
195 | } | 195 | } |
@@ -202,6 +202,7 @@ SlideDeck.prototype.loadConfig_ = function() { | |||
202 | this.addFonts_(settings.fonts); | 202 | this.addFonts_(settings.fonts); |
203 | } | 203 | } |
204 | 204 | ||
205 | // Builds. Default to on. | ||
205 | if (!!!('useBuilds' in settings) || settings.useBuilds) { | 206 | if (!!!('useBuilds' in settings) || settings.useBuilds) { |
206 | this.makeBuildLists_(); | 207 | this.makeBuildLists_(); |
207 | } | 208 | } |
@@ -249,18 +250,20 @@ SlideDeck.prototype.loadConfig_ = function() { | |||
249 | 250 | ||
250 | var slides = document.querySelector('slides'); | 251 | var slides = document.querySelector('slides'); |
251 | 252 | ||
252 | /* Clicking and tapping */ | 253 | /* Left/Right tap areas. Default to including. */ |
253 | var el = document.createElement('div'); | 254 | if (!!!('enableSideAreas' in settings) || settings.enableSideAreas) { |
254 | el.classList.add('slide-area'); | 255 | var el = document.createElement('div'); |
255 | el.id = 'prev-slide-area'; | 256 | el.classList.add('slide-area'); |
256 | el.addEventListener('click', this.prevSlide.bind(this), false); | 257 | el.id = 'prev-slide-area'; |
257 | slides.appendChild(el); | 258 | el.addEventListener('click', this.prevSlide.bind(this), false); |
258 | 259 | slides.appendChild(el); | |
259 | var el = document.createElement('div'); | 260 | |
260 | el.classList.add('slide-area'); | 261 | var el = document.createElement('div'); |
261 | el.id = 'next-slide-area'; | 262 | el.classList.add('slide-area'); |
262 | el.addEventListener('click', this.nextSlide.bind(this), false); | 263 | el.id = 'next-slide-area'; |
263 | slides.appendChild(el); | 264 | el.addEventListener('click', this.nextSlide.bind(this), false); |
265 | slides.appendChild(el); | ||
266 | } | ||
264 | 267 | ||
265 | if (!!!('enableTouch' in settings) || settings.enableTouch) { | 268 | if (!!!('enableTouch' in settings) || settings.enableTouch) { |
266 | var self = this; | 269 | var self = this; |
diff --git a/slide_config.js b/slide_config.js new file mode 100644 index 0000000..e8ff552 --- /dev/null +++ b/slide_config.js | |||
@@ -0,0 +1,35 @@ | |||
1 | var SLIDE_CONFIG = { | ||
2 | // Slide settings | ||
3 | settings: { | ||
4 | title: 'Title Goes Here<br>Up To Two Lines', | ||
5 | subtitle: 'Subtitle Goes Here', | ||
6 | //theme: ['mytheme'], | ||
7 | hashtag: '#html5', //TODO | ||
8 | useBuilds: true, | ||
9 | usePrettify: true, | ||
10 | enableSideAreas: true, | ||
11 | enableTouch: true, // TODO: base this on media query instead. | ||
12 | analytics: 'UA-XXXXXXXX-1', | ||
13 | favIcon: 'http://bleedinghtml5.appspot.com/images/chrome-logo-tiny2.png', | ||
14 | onLoad: null, // TODO. function to call onload | ||
15 | fonts: [ | ||
16 | 'Open Sans:regular,semibold,italic,italicsemibold', | ||
17 | 'Inconsolata' | ||
18 | ] | ||
19 | }, | ||
20 | |||
21 | // Author information | ||
22 | presenters: [{ | ||
23 | name: 'Firstname Lastname', | ||
24 | company: 'Job Title, Google', | ||
25 | gplus: 'http://plus.google.com/1234567890', | ||
26 | twitter: '@yourhandle', | ||
27 | www: 'http://www.you.com' | ||
28 | }/*, { | ||
29 | name: 'Eric Bidelman', | ||
30 | gplus: 'http://plus.ericbidelman.com', | ||
31 | company: 'Senior Developer Programs Engineer, Google Chrome', | ||
32 | twitter: '@ebidel', | ||
33 | www: 'http://www.ericbidelman.com' | ||
34 | }*/] | ||
35 | }; | ||
diff --git a/template.html b/template.html index ce03ecf..c0a6bcd 100644 --- a/template.html +++ b/template.html | |||
@@ -29,11 +29,11 @@ URL: https://code.google.com/p/io-2012-slides | |||
29 | 29 | ||
30 | <slide class="title-slide segue nobackground"> | 30 | <slide class="title-slide segue nobackground"> |
31 | <aside class="gdbar"><img src="images/google_developers_icon_128.png"></aside> | 31 | <aside class="gdbar"><img src="images/google_developers_icon_128.png"></aside> |
32 | <!-- The content of this hgroup is replaced programmatically through the config. --> | 32 | <!-- The content of this hgroup is replaced programmatically through the slide_config.js. --> |
33 | <hgroup class="auto-fadein"> | 33 | <hgroup class="auto-fadein"> |
34 | <h1 data-config-title><!-- populated from config --></h1> | 34 | <h1 data-config-title><!-- populated from slide_config.js --></h1> |
35 | <h2 data-config-subtitle><!-- populated from config --></h2> | 35 | <h2 data-config-subtitle><!-- populated from slide_config.js --></h2> |
36 | <p data-config-presenter><!-- populated from config --></p> | 36 | <p data-config-presenter><!-- populated from slide_config.js --></p> |
37 | </hgroup> | 37 | </hgroup> |
38 | </slide> | 38 | </slide> |
39 | 39 | ||
@@ -352,7 +352,7 @@ function helloWorld(world) { | |||
352 | <p>Important contact information goes here.</p> | 352 | <p>Important contact information goes here.</p> |
353 | </article> | 353 | </article> |
354 | <p class="auto-fadein" data-config-contact> | 354 | <p class="auto-fadein" data-config-contact> |
355 | <!-- populated from config --> | 355 | <!-- populated from slide_config.js --> |
356 | </p> | 356 | </p> |
357 | </slide> | 357 | </slide> |
358 | 358 | ||
@@ -366,50 +366,12 @@ function helloWorld(world) { | |||
366 | 366 | ||
367 | </slides> | 367 | </slides> |
368 | 368 | ||
369 | <script type="text/slide-config"> | 369 | <script src="slide_config.js" defer></script> |
370 | var slideConfig = { | ||
371 | // Slide settings | ||
372 | settings: { | ||
373 | title: 'Title Goes Here<br>Up To Two Lines', | ||
374 | subtitle: 'Subtitle Goes Here', | ||
375 | //theme: ['mytheme'], | ||
376 | hashtag: '#html5', //TODO | ||
377 | useBuilds: true, | ||
378 | usePrettify: true, | ||
379 | //enableSideAreas: true, //TODO | ||
380 | enableTouch: true, // TODO: base this on media query instead. | ||
381 | analytics: 'UA-XXXXXXXX-1', | ||
382 | favIcon: 'http://bleedinghtml5.appspot.com/images/chrome-logo-tiny2.png', | ||
383 | onLoad: null, // TODO. function to call onload | ||
384 | fonts: [ | ||
385 | 'Open Sans:regular,semibold,italic,italicsemibold', | ||
386 | 'Inconsolata' | ||
387 | ] | ||
388 | }, | ||
389 | |||
390 | // Author information | ||
391 | presenters: [{ | ||
392 | name: 'Firstname Lastname', | ||
393 | company: 'Job Title, Google', | ||
394 | gplus: 'http://plus.google.com/1234567890', | ||
395 | twitter: '@yourhandle', | ||
396 | www: 'http://www.you.com' | ||
397 | }/*, { | ||
398 | name: 'Eric Bidelman', | ||
399 | gplus: 'http://plus.ericbidelman.com', | ||
400 | company: 'Senior Developer Programs Engineer, Google Chrome', | ||
401 | twitter: '@ebidel', | ||
402 | www: 'http://www.ericbidelman.com' | ||
403 | }*/] | ||
404 | }; | ||
405 | </script> | ||
406 | |||
407 | <script src="js/prettify/prettify.js" defer></script> | 370 | <script src="js/prettify/prettify.js" defer></script> |
408 | <script src="js/yepnope.1.5.3-min.js" defer></script> | 371 | <script src="js/yepnope.1.5.3-min.js" defer></script> |
409 | <script src="js/hammer.js" defer></script> | 372 | <script src="js/hammer.js" defer></script> |
410 | <script src="js/slides.js" defer></script> | 373 | <script src="js/slides.js" defer></script> |
411 | 374 | ||
412 | <!-- TODO: Add to slides.js --> | ||
413 | <!--[if IE]> | 375 | <!--[if IE]> |
414 | <script src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script> | 376 | <script src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script> |
415 | <script>CFInstall.check({mode: 'overlay'});</script> | 377 | <script>CFInstall.check({mode: 'overlay'});</script> |