From 6729ee22e103cd68ec5826e63b6c02befb553b11 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 13 May 2014 00:09:28 +0200 Subject: Load prettify and hammer only on demand --- js/slide-deck.js | 41 +++++++++++++++++++++++------------------ 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) { // Prettyprint. Default to on. if (!!!('usePrettify' in settings) || settings.usePrettify) { - prettyPrint(); + require([ 'prettify' ], function() { + prettyPrint(); + }); } if (settings.analytics) { @@ -423,24 +425,27 @@ SlideDeck.prototype.loadConfig_ = function(config) { e.preventDefault(); }, false); - var hammer = new Hammer(this.container); - hammer.ondragend = function(e) { - var evt = document.createEvent('Event'); - evt.initEvent('keydown', true, true); - - switch (e.direction) { - case 'right': - // previous slide - evt.keyCode = 37; - break; - case 'left': - // next slide - evt.keyCode = 39; - break; - } + require([ 'hammer' ], function() { + var hammer = new Hammer(this.container); + hammer.ondragend = function(e) { + var evt = document.createEvent('Event'); + evt.initEvent('keydown', true, true); + + switch (e.direction) { + case 'right': + // previous slide + evt.keyCode = 37; + break; + case 'left': + // next slide + evt.keyCode = 39; + break; + } + + document.dispatchEvent(evt); + }; + }); - document.dispatchEvent(evt); - }; } }; 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({ shim : { 'slide-deck' : { - deps : ['slide_config', 'slide-controller', 'modernizr', 'hammer'] + deps : ['slide_config', 'slide-controller', 'modernizr'] } } }); -require(['slide-deck', 'prettify'], function(someModule) { +require(['slide-deck'], function(someModule) { }); -- cgit v1.2.3