diff options
Diffstat (limited to 'js/slides.js')
-rw-r--r-- | js/slides.js | 57 |
1 files changed, 44 insertions, 13 deletions
diff --git a/js/slides.js b/js/slides.js index 66aaa51..d1b094b 100644 --- a/js/slides.js +++ b/js/slides.js | |||
@@ -1,3 +1,8 @@ | |||
1 | // Function.bind polyfill for Safari < 5.1.4 and iOS. | ||
2 | // From https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind | ||
3 | Function.prototype.bind||(Function.prototype.bind=function(c){if("function"!==typeof this)throw new TypeError("Function.prototype.bind - binding an object that is not callable");var d=Array.prototype.slice.call(arguments,1),e=this,a=function(){},b=function(){return e.apply(this instanceof a?this:c||window,d.concat(Array.prototype.slice.call(arguments)))};a.prototype=this.prototype;b.prototype=new a;return b}); | ||
4 | |||
5 | |||
1 | /** | 6 | /** |
2 | * @constructor | 7 | * @constructor |
3 | */ | 8 | */ |
@@ -9,8 +14,10 @@ function SlideDeck() { | |||
9 | 14 | ||
10 | this.getCurrentSlideFromHash_(); | 15 | this.getCurrentSlideFromHash_(); |
11 | 16 | ||
12 | document.addEventListener('DOMContentLoaded', | 17 | /*document.addEventListener('DOMContentLoaded', |
13 | this.onDomLoaded_.bind(this), false); | 18 | this.onDomLoaded_.bind(this), false);*/ |
19 | // Introducing yepnopejs causes DOMContentLoaded before the deck is setup. | ||
20 | this.onDomLoaded_.bind(this)(); | ||
14 | } | 21 | } |
15 | 22 | ||
16 | /** | 23 | /** |
@@ -42,7 +49,7 @@ SlideDeck.prototype.getCurrentSlideFromHash_ = function() { | |||
42 | /** | 49 | /** |
43 | * @private | 50 | * @private |
44 | */ | 51 | */ |
45 | SlideDeck.prototype.onDomLoaded_ = function() { | 52 | SlideDeck.prototype.onDomLoaded_ = function(e) { |
46 | this.slides_ = document.querySelectorAll('slide:not([hidden])'); | 53 | this.slides_ = document.querySelectorAll('slide:not([hidden])'); |
47 | 54 | ||
48 | // Load config. | 55 | // Load config. |
@@ -227,6 +234,23 @@ SlideDeck.prototype.loadConfig_ = function() { | |||
227 | 234 | ||
228 | document.querySelector('[data-config-presenter]').innerHTML = html; | 235 | document.querySelector('[data-config-presenter]').innerHTML = html; |
229 | } | 236 | } |
237 | |||
238 | /* Clicking and tapping */ | ||
239 | var el = document.createElement('div'); | ||
240 | el.classList.add('slide-area'); | ||
241 | el.id = 'prev-slide-area'; | ||
242 | el.addEventListener('click', this.prevSlide.bind(this), false); | ||
243 | document.querySelector('slides').appendChild(el); | ||
244 | |||
245 | var el = document.createElement('div'); | ||
246 | el.classList.add('slide-area'); | ||
247 | el.id = 'next-slide-area'; | ||
248 | el.addEventListener('click', this.nextSlide.bind(this), false); | ||
249 | document.querySelector('slides').appendChild(el); | ||
250 | |||
251 | if (!!!('enableTouch' in settings) || settings.enableTouch) { | ||
252 | var toucher = new TouchManager(this); | ||
253 | } | ||
230 | }; | 254 | }; |
231 | 255 | ||
232 | /** | 256 | /** |
@@ -489,13 +513,6 @@ SlideDeck.prototype.makeBuildLists_ = function () { | |||
489 | } | 513 | } |
490 | } | 514 | } |
491 | } | 515 | } |
492 | // // Setup Google Developer icon slide out bars. | ||
493 | // var bars = slide.querySelectorAll('.gdbar'); | ||
494 | // for (var j = 0, bar; bar = bars[j]; ++j) { | ||
495 | // if (bar.classList) { | ||
496 | // bar.classList.add('to-build'); | ||
497 | // } | ||
498 | // } | ||
499 | } | 516 | } |
500 | }; | 517 | }; |
501 | 518 | ||
@@ -513,7 +530,8 @@ SlideDeck.prototype.updateHash_ = function(dontPush) { | |||
513 | window.location.replace(hash); | 530 | window.location.replace(hash); |
514 | } | 531 | } |
515 | 532 | ||
516 | window['_gaq'] && window['_gaq'].push(['_trackPageview', document.location.href]); | 533 | window['_gaq'] && window['_gaq'].push(['_trackPageview', |
534 | document.location.href]); | ||
517 | } | 535 | } |
518 | }; | 536 | }; |
519 | 537 | ||
@@ -575,5 +593,18 @@ SlideDeck.prototype.loadAnalytics_ = function() { | |||
575 | })(); | 593 | })(); |
576 | }; | 594 | }; |
577 | 595 | ||
578 | // Create the slidedeck | 596 | |
579 | var slidedeck = new SlideDeck(); | 597 | // Polyfill missing APIs (if we need to), then create the slide deck. |
598 | // iOS < 5 needs all of these! #dislike | ||
599 | (function() { | ||
600 | var body = document.body; | ||
601 | |||
602 | yepnope({ | ||
603 | test: !!body.classList && !!body.dataset, | ||
604 | nope: ['js/polyfills/classList.min.js', 'js/polyfills/dataset.min.js'], | ||
605 | complete: function() { | ||
606 | window.slidedeck = new SlideDeck(); | ||
607 | } | ||
608 | }); | ||
609 | |||
610 | })(); | ||