From 194dbb4a501f2912ac9f46e7e2cfc6e99e3c7246 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 13 May 2014 16:34:31 +0200 Subject: Load GA tracker with requirejs --- js/slide-deck.js | 19 +- js/slides.js | 6 +- scripts/md/base.html | 39 +-- slide_config.js | 10 +- template.html | 899 ++++++++++++++++++++++++++++++--------------------- 5 files changed, 552 insertions(+), 421 deletions(-) diff --git a/js/slide-deck.js b/js/slide-deck.js index 266de5c..f5d21c6 100644 --- a/js/slide-deck.js +++ b/js/slide-deck.js @@ -808,20 +808,11 @@ SlideDeck.prototype.loadTheme_ = function(theme) { * @private */ SlideDeck.prototype.loadAnalytics_ = function() { - var _gaq = window['_gaq'] || []; - _gaq.push([ '_setAccount', this.config_.settings.analytics ]); - _gaq.push([ '_trackPageview' ]); - - (function() { - var ga = document.createElement('script'); - ga.type = 'text/javascript'; - ga.async = true; - ga.src = ('https:' == document.location.protocol ? 'https://ssl' - : 'http://www') - + '.google-analytics.com/ga.js'; - var s = document.getElementsByTagName('script')[0]; - s.parentNode.insertBefore(ga, s); - })(); + window._gaq = window['_gaq'] || []; + window._gaq.push([ '_setAccount', this.config_.settings.analytics ]); + window._gaq.push([ '_trackPageview' ]); + + requirejs([ 'analytics' ]); }; // Polyfill missing APIs (if we need to), then create the slide deck. diff --git a/js/slides.js b/js/slides.js index bfef324..143dac2 100644 --- a/js/slides.js +++ b/js/slides.js @@ -7,6 +7,8 @@ require.config({ 'modernizr' : 'modernizr.custom.56571', 'prettify' : 'prettify/prettify', 'hammer' : 'hammer.min', + + 'analytics' : 'https://www.google-analytics.com/ga' }, shim : { @@ -16,6 +18,4 @@ require.config({ } }); -require(['slide-deck'], function(someModule) { - -}); +require(['slide-deck']); diff --git a/scripts/md/base.html b/scripts/md/base.html index 638dbb8..84f6aa9 100644 --- a/scripts/md/base.html +++ b/scripts/md/base.html @@ -9,7 +9,7 @@ URL: https://code.google.com/p/io-2012-slides - Google IO 2012 + @@ -19,7 +19,8 @@ URL: https://code.google.com/p/io-2012-slides - + @@ -27,7 +28,6 @@ URL: https://code.google.com/p/io-2012-slides - -