diff options
author | Pacien TRAN-GIRARD | 2014-05-13 00:09:28 +0200 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2014-05-13 00:09:28 +0200 |
commit | 6729ee22e103cd68ec5826e63b6c02befb553b11 (patch) | |
tree | 84264c459e295914c06e4c23841bbfe0c9b7e837 | |
parent | b052018648c367186b03d5ed75f7c0b72995f22e (diff) | |
download | io-slides-remote-6729ee22e103cd68ec5826e63b6c02befb553b11.tar.gz |
Load prettify and hammer only on demand
-rw-r--r-- | js/slide-deck.js | 41 | ||||
-rw-r--r-- | js/slides.js | 4 |
2 files changed, 25 insertions, 20 deletions
diff --git a/js/slide-deck.js b/js/slide-deck.js index 61fe1c0..559b761 100644 --- a/js/slide-deck.js +++ b/js/slide-deck.js | |||
@@ -315,7 +315,9 @@ SlideDeck.prototype.loadConfig_ = function(config) { | |||
315 | 315 | ||
316 | // Prettyprint. Default to on. | 316 | // Prettyprint. Default to on. |
317 | if (!!!('usePrettify' in settings) || settings.usePrettify) { | 317 | if (!!!('usePrettify' in settings) || settings.usePrettify) { |
318 | prettyPrint(); | 318 | require([ 'prettify' ], function() { |
319 | prettyPrint(); | ||
320 | }); | ||
319 | } | 321 | } |
320 | 322 | ||
321 | if (settings.analytics) { | 323 | if (settings.analytics) { |
@@ -423,24 +425,27 @@ SlideDeck.prototype.loadConfig_ = function(config) { | |||
423 | e.preventDefault(); | 425 | e.preventDefault(); |
424 | }, false); | 426 | }, false); |
425 | 427 | ||
426 | var hammer = new Hammer(this.container); | 428 | require([ 'hammer' ], function() { |
427 | hammer.ondragend = function(e) { | 429 | var hammer = new Hammer(this.container); |
428 | var evt = document.createEvent('Event'); | 430 | hammer.ondragend = function(e) { |
429 | evt.initEvent('keydown', true, true); | 431 | var evt = document.createEvent('Event'); |
430 | 432 | evt.initEvent('keydown', true, true); | |
431 | switch (e.direction) { | 433 | |
432 | case 'right': | 434 | switch (e.direction) { |
433 | // previous slide | 435 | case 'right': |
434 | evt.keyCode = 37; | 436 | // previous slide |
435 | break; | 437 | evt.keyCode = 37; |
436 | case 'left': | 438 | break; |
437 | // next slide | 439 | case 'left': |
438 | evt.keyCode = 39; | 440 | // next slide |
439 | break; | 441 | evt.keyCode = 39; |
440 | } | 442 | break; |
443 | } | ||
444 | |||
445 | document.dispatchEvent(evt); | ||
446 | }; | ||
447 | }); | ||
441 | 448 | ||
442 | document.dispatchEvent(evt); | ||
443 | }; | ||
444 | } | 449 | } |
445 | }; | 450 | }; |
446 | 451 | ||
diff --git a/js/slides.js b/js/slides.js index c09d220..c2d0b5c 100644 --- a/js/slides.js +++ b/js/slides.js | |||
@@ -11,11 +11,11 @@ require.config({ | |||
11 | 11 | ||
12 | shim : { | 12 | shim : { |
13 | 'slide-deck' : { | 13 | 'slide-deck' : { |
14 | deps : ['slide_config', 'slide-controller', 'modernizr', 'hammer'] | 14 | deps : ['slide_config', 'slide-controller', 'modernizr'] |
15 | } | 15 | } |
16 | } | 16 | } |
17 | }); | 17 | }); |
18 | 18 | ||
19 | require(['slide-deck', 'prettify'], function(someModule) { | 19 | require(['slide-deck'], function(someModule) { |
20 | 20 | ||
21 | }); | 21 | }); |