From 04153b7c8a3332c8008408227f6d71b8ef392c35 Mon Sep 17 00:00:00 2001
From: Eric Bidelman
Date: Sat, 14 Apr 2012 18:43:06 -0700
Subject: Moving slide config to its own file. eval is bad
---
js/slides.js | 41 ++++++++++++++++++++++-------------------
slide_config.js | 35 +++++++++++++++++++++++++++++++++++
template.html | 50 ++++++--------------------------------------------
3 files changed, 63 insertions(+), 63 deletions(-)
create mode 100644 slide_config.js
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) {
}
// Load config.
- this.loadConfig_();
+ this.loadConfig_(SLIDE_CONFIG);
this.addEventListeners_();
this.updateSlides_();
@@ -174,14 +174,13 @@ SlideDeck.prototype.onBodyKeyDown_ = function(e) {
/**
* @private
*/
-SlideDeck.prototype.loadConfig_ = function() {
- var configScripts =
- document.querySelector('script[type="text/slide-config"]');
- if (configScripts) {
- eval(configScripts.innerHTML);
- this.config_ = slideConfig;
+SlideDeck.prototype.loadConfig_ = function(config) {
+ if (!config) {
+ return;
}
+ this.config_ = config;
+
var settings = this.config_.settings;
this.loadTheme_(settings.theme || []);
@@ -190,6 +189,7 @@ SlideDeck.prototype.loadConfig_ = function() {
this.addFavIcon_(settings.favIcon);
}
+ // Prettyprint. Default to on.
if (!!!('usePrettify' in settings) || settings.usePrettify) {
prettyPrint();
}
@@ -202,6 +202,7 @@ SlideDeck.prototype.loadConfig_ = function() {
this.addFonts_(settings.fonts);
}
+ // Builds. Default to on.
if (!!!('useBuilds' in settings) || settings.useBuilds) {
this.makeBuildLists_();
}
@@ -249,18 +250,20 @@ SlideDeck.prototype.loadConfig_ = function() {
var slides = document.querySelector('slides');
- /* Clicking and tapping */
- var el = document.createElement('div');
- el.classList.add('slide-area');
- el.id = 'prev-slide-area';
- el.addEventListener('click', this.prevSlide.bind(this), false);
- slides.appendChild(el);
-
- var el = document.createElement('div');
- el.classList.add('slide-area');
- el.id = 'next-slide-area';
- el.addEventListener('click', this.nextSlide.bind(this), false);
- slides.appendChild(el);
+ /* Left/Right tap areas. Default to including. */
+ if (!!!('enableSideAreas' in settings) || settings.enableSideAreas) {
+ var el = document.createElement('div');
+ el.classList.add('slide-area');
+ el.id = 'prev-slide-area';
+ el.addEventListener('click', this.prevSlide.bind(this), false);
+ slides.appendChild(el);
+
+ var el = document.createElement('div');
+ el.classList.add('slide-area');
+ el.id = 'next-slide-area';
+ el.addEventListener('click', this.nextSlide.bind(this), false);
+ slides.appendChild(el);
+ }
if (!!!('enableTouch' in settings) || settings.enableTouch) {
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 @@
+var SLIDE_CONFIG = {
+ // Slide settings
+ settings: {
+ title: 'Title Goes Here
Up To Two Lines',
+ subtitle: 'Subtitle Goes Here',
+ //theme: ['mytheme'],
+ hashtag: '#html5', //TODO
+ useBuilds: true,
+ usePrettify: true,
+ enableSideAreas: true,
+ enableTouch: true, // TODO: base this on media query instead.
+ analytics: 'UA-XXXXXXXX-1',
+ favIcon: 'http://bleedinghtml5.appspot.com/images/chrome-logo-tiny2.png',
+ onLoad: null, // TODO. function to call onload
+ fonts: [
+ 'Open Sans:regular,semibold,italic,italicsemibold',
+ 'Inconsolata'
+ ]
+ },
+
+ // Author information
+ presenters: [{
+ name: 'Firstname Lastname',
+ company: 'Job Title, Google',
+ gplus: 'http://plus.google.com/1234567890',
+ twitter: '@yourhandle',
+ www: 'http://www.you.com'
+ }/*, {
+ name: 'Eric Bidelman',
+ gplus: 'http://plus.ericbidelman.com',
+ company: 'Senior Developer Programs Engineer, Google Chrome',
+ twitter: '@ebidel',
+ www: 'http://www.ericbidelman.com'
+ }*/]
+};
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
Important contact information goes here.
- +
@@ -366,50 +366,12 @@ function helloWorld(world) { - - + -