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 /js | |
parent | 7054806c29c3eae0ed4b4176047b92bddcdcd0cc (diff) | |
download | io-slides-remote-04153b7c8a3332c8008408227f6d71b8ef392c35.tar.gz |
Moving slide config to its own file. eval is bad
Diffstat (limited to 'js')
-rw-r--r-- | js/slides.js | 41 |
1 files changed, 22 insertions, 19 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; |