diff options
Diffstat (limited to 'js/slides.js')
-rw-r--r-- | js/slides.js | 69 |
1 files changed, 19 insertions, 50 deletions
diff --git a/js/slides.js b/js/slides.js index 7afe0cf..cd9e646 100644 --- a/js/slides.js +++ b/js/slides.js | |||
@@ -13,8 +13,7 @@ function SlideDeck() { | |||
13 | this.prevSlide_ = 0; | 13 | this.prevSlide_ = 0; |
14 | this.slides = []; | 14 | this.slides = []; |
15 | this.config_ = null; | 15 | this.config_ = null; |
16 | this.controller_ = null; | 16 | this.controller = null; |
17 | this.IS_POPUP_ = window.opener; | ||
18 | 17 | ||
19 | this.getCurrentSlideFromHash_(); | 18 | this.getCurrentSlideFromHash_(); |
20 | 19 | ||
@@ -50,39 +49,6 @@ SlideDeck.prototype.getCurrentSlideFromHash_ = function() { | |||
50 | } | 49 | } |
51 | }; | 50 | }; |
52 | 51 | ||
53 | SlideDeck.prototype.loadPresenterMode = function() { | ||
54 | var params = location.search.substring(1).split('&').map(function(el) { | ||
55 | return el.split('='); | ||
56 | }); | ||
57 | |||
58 | var presentMe = null; | ||
59 | for (var i = 0, param; param = params[i]; ++i) { | ||
60 | if (param[0].toLowerCase() == 'presentme') { | ||
61 | presentMe = param[1] == 'true'; | ||
62 | break; | ||
63 | } | ||
64 | } | ||
65 | |||
66 | if (presentMe !== null) { | ||
67 | localStorage.ENABLE_PRESENTOR_MODE = presentMe; | ||
68 | location.href = location.pathname; | ||
69 | } | ||
70 | |||
71 | // Turn on presenter mode? | ||
72 | if (localStorage.getItem('ENABLE_PRESENTOR_MODE') && | ||
73 | JSON.parse(localStorage.getItem('ENABLE_PRESENTOR_MODE'))) { | ||
74 | this.controller_ = new SlideController(this); | ||
75 | |||
76 | // Loading in the popup? Trigger the hotkey for turning presenter mode on. | ||
77 | if (this.IS_POPUP_) { | ||
78 | var evt = document.createEvent('Event'); | ||
79 | evt.initEvent('keydown', true, true); | ||
80 | evt.keyCode = 'P'.charCodeAt(0); | ||
81 | document.dispatchEvent(evt); | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | |||
86 | /** | 52 | /** |
87 | * @private | 53 | * @private |
88 | */ | 54 | */ |
@@ -120,8 +86,11 @@ SlideDeck.prototype.onDomLoaded_ = function(e) { | |||
120 | }); | 86 | }); |
121 | 87 | ||
122 | // Note: this needs to come after addEventListeners_(), which adds a | 88 | // Note: this needs to come after addEventListeners_(), which adds a |
123 | // 'keydown' listener that this method relies on. | 89 | // 'keydown' listener that this controller relies on. |
124 | this.loadPresenterMode(); | 90 | // Also, no need to set this up if we're on mobile. |
91 | if (!Modernizr.touch) { | ||
92 | this.controller = new SlideController(this); | ||
93 | } | ||
125 | }; | 94 | }; |
126 | 95 | ||
127 | /** | 96 | /** |
@@ -152,9 +121,9 @@ SlideDeck.prototype.onBodyKeyDown_ = function(e) { | |||
152 | return; | 121 | return; |
153 | } | 122 | } |
154 | 123 | ||
155 | // Forward keydown to the main slides if we're the popup. | 124 | // Forward keydowns to the main slides if we're the popup. |
156 | if (this.controller_ && this.IS_POPUP_) { | 125 | if (this.controller && this.controller.isPopup) { |
157 | this.controller_.sendMsg({keyCode: e.keyCode}); | 126 | this.controller.sendMsg({keyCode: e.keyCode}); |
158 | } | 127 | } |
159 | 128 | ||
160 | switch (e.keyCode) { | 129 | switch (e.keyCode) { |
@@ -195,9 +164,9 @@ SlideDeck.prototype.onBodyKeyDown_ = function(e) { | |||
195 | break; | 164 | break; |
196 | 165 | ||
197 | case 80: // P | 166 | case 80: // P |
198 | if (this.controller_ && this.IS_POPUP_) { | 167 | if (this.controller && this.controller.isPopup) { |
199 | document.body.classList.toggle('with-notes'); | 168 | document.body.classList.toggle('with-notes'); |
200 | } else if (!this.controller_) { | 169 | } else if (this.controller && !this.controller.popup) { |
201 | document.body.classList.toggle('with-notes'); | 170 | document.body.classList.toggle('with-notes'); |
202 | } | 171 | } |
203 | break; | 172 | break; |
@@ -392,14 +361,14 @@ SlideDeck.prototype.prevSlide = function(opt_dontPush) { | |||
392 | 361 | ||
393 | // Toggle off speaker notes if they're showing when we move backwards on the | 362 | // Toggle off speaker notes if they're showing when we move backwards on the |
394 | // main slides. If we're the speaker notes popup, leave them up. | 363 | // main slides. If we're the speaker notes popup, leave them up. |
395 | if (this.controller_ && !this.IS_POPUP_) { | 364 | if (this.controller && !this.controller.isPopup) { |
396 | bodyClassList.remove('with-notes'); | 365 | bodyClassList.remove('with-notes'); |
397 | } else if (!this.controller_) { | 366 | } else if (!this.controller) { |
398 | bodyClassList.remove('with-notes'); | 367 | bodyClassList.remove('with-notes'); |
399 | } | 368 | } |
400 | 369 | ||
401 | // if (this.controller_) { | 370 | // if (this.controller) { |
402 | // this.controller_.sendMsg({slideDirection: SlideController.MOVE_LEFT}); | 371 | // this.controller.sendMsg({slideDirection: SlideController.MOVE_LEFT}); |
403 | // } | 372 | // } |
404 | 373 | ||
405 | this.prevSlide_ = this.curSlide_; | 374 | this.prevSlide_ = this.curSlide_; |
@@ -414,8 +383,8 @@ SlideDeck.prototype.prevSlide = function(opt_dontPush) { | |||
414 | */ | 383 | */ |
415 | SlideDeck.prototype.nextSlide = function(opt_dontPush) { | 384 | SlideDeck.prototype.nextSlide = function(opt_dontPush) { |
416 | // | 385 | // |
417 | // if (this.controller_) { | 386 | // if (this.controller) { |
418 | // this.controller_.sendMsg({slideDirection: SlideController.MOVE_RIGHT}); | 387 | // this.controller.sendMsg({slideDirection: SlideController.MOVE_RIGHT}); |
419 | // } | 388 | // } |
420 | 389 | ||
421 | if (this.buildNextItem_()) { | 390 | if (this.buildNextItem_()) { |
@@ -428,9 +397,9 @@ SlideDeck.prototype.nextSlide = function(opt_dontPush) { | |||
428 | 397 | ||
429 | // Toggle off speaker notes if they're showing when we advanced on the main | 398 | // Toggle off speaker notes if they're showing when we advanced on the main |
430 | // slides. If we're the speaker notes popup, leave them up. | 399 | // slides. If we're the speaker notes popup, leave them up. |
431 | if (this.controller_ && !this.IS_POPUP_) { | 400 | if (this.controller && !this.controller.isPopup) { |
432 | bodyClassList.remove('with-notes'); | 401 | bodyClassList.remove('with-notes'); |
433 | } else if (!this.controller_) { | 402 | } else if (!this.controller) { |
434 | bodyClassList.remove('with-notes'); | 403 | bodyClassList.remove('with-notes'); |
435 | } | 404 | } |
436 | 405 | ||