diff options
author | Eric Bidelman | 2012-04-17 18:59:07 -0700 |
---|---|---|
committer | Eric Bidelman | 2012-04-17 18:59:07 -0700 |
commit | 64c8d6328a9d0e4fe68a5899e3e8710342f3b7dd (patch) | |
tree | cc30183c85cbdadac0607b4c370f94e981708564 /js/slides.js | |
parent | 5a15dcab5fd3bf90915f811bc7072f6ef8c34a07 (diff) | |
download | io-slides-remote-64c8d6328a9d0e4fe68a5899e3e8710342f3b7dd.tar.gz |
Basic presenter mode working
Diffstat (limited to 'js/slides.js')
-rw-r--r-- | js/slides.js | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/js/slides.js b/js/slides.js index 20bb1bd..0faf06b 100644 --- a/js/slides.js +++ b/js/slides.js | |||
@@ -13,6 +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 | 17 | ||
17 | this.getCurrentSlideFromHash_(); | 18 | this.getCurrentSlideFromHash_(); |
18 | 19 | ||
@@ -52,6 +53,9 @@ SlideDeck.prototype.getCurrentSlideFromHash_ = function() { | |||
52 | * @private | 53 | * @private |
53 | */ | 54 | */ |
54 | SlideDeck.prototype.onDomLoaded_ = function(e) { | 55 | SlideDeck.prototype.onDomLoaded_ = function(e) { |
56 | // Fade in deck. | ||
57 | document.body.classList.add('loaded'); | ||
58 | |||
55 | this.slides_ = document.querySelectorAll('slide:not([hidden]):not(.backdrop)'); | 59 | this.slides_ = document.querySelectorAll('slide:not([hidden]):not(.backdrop)'); |
56 | 60 | ||
57 | // If we're on a smartphone device, load phone.css. | 61 | // If we're on a smartphone device, load phone.css. |
@@ -148,11 +152,11 @@ SlideDeck.prototype.onBodyKeyDown_ = function(e) { | |||
148 | document.body.classList.toggle('highlight-code'); | 152 | document.body.classList.toggle('highlight-code'); |
149 | break; | 153 | break; |
150 | 154 | ||
151 | case 78: // N | 155 | case 80: // P |
152 | // If this slide contains notes, toggle them. | 156 | // If this slide contains notes, toggle them. |
153 | if (this.slides_[this.curSlide_].querySelector('.note')) { | 157 | //if (this.slides_[this.curSlide_].querySelector('.note')) { |
154 | document.body.classList.toggle('with-notes'); | 158 | document.body.classList.toggle('with-notes'); |
155 | } | 159 | //} |
156 | break; | 160 | break; |
157 | 161 | ||
158 | case 27: // ESC | 162 | case 27: // ESC |
@@ -283,6 +287,10 @@ SlideDeck.prototype.loadConfig_ = function(config) { | |||
283 | } | 287 | } |
284 | }; | 288 | }; |
285 | } | 289 | } |
290 | |||
291 | if (!!('enableSpeakerNotes' in settings) && settings.enableSpeakerNotes) { | ||
292 | this.controller_ = new SlideController(this); | ||
293 | } | ||
286 | }; | 294 | }; |
287 | 295 | ||
288 | /** | 296 | /** |
@@ -335,10 +343,17 @@ SlideDeck.prototype.buildNextItem_ = function() { | |||
335 | */ | 343 | */ |
336 | SlideDeck.prototype.prevSlide = function(opt_dontPush) { | 344 | SlideDeck.prototype.prevSlide = function(opt_dontPush) { |
337 | if (this.curSlide_ > 0) { | 345 | if (this.curSlide_ > 0) { |
338 | // Toggle off speaker notes and/or highlighted code if they're showing. | 346 | // Toggle off speaker notes and/or highlighted code if they're showing |
339 | var bodyClassList = document.body.classList; | 347 | // when we advanced. If we're the speaker notes popup, leave this put. |
340 | bodyClassList.remove('with-notes'); | 348 | if (this.controller_ && !window.opener) { |
341 | bodyClassList.remove('highlight-code'); | 349 | var bodyClassList = document.body.classList; |
350 | bodyClassList.remove('with-notes'); | ||
351 | bodyClassList.remove('highlight-code'); | ||
352 | } | ||
353 | |||
354 | if (this.controller_) { | ||
355 | this.controller_.sendMsg({slideDirection: SlideController.MOVE_LEFT}); | ||
356 | } | ||
342 | 357 | ||
343 | this.prevSlide_ = this.curSlide_; | 358 | this.prevSlide_ = this.curSlide_; |
344 | this.curSlide_--; | 359 | this.curSlide_--; |
@@ -352,15 +367,22 @@ SlideDeck.prototype.prevSlide = function(opt_dontPush) { | |||
352 | */ | 367 | */ |
353 | SlideDeck.prototype.nextSlide = function(opt_dontPush) { | 368 | SlideDeck.prototype.nextSlide = function(opt_dontPush) { |
354 | 369 | ||
370 | if (this.controller_) { | ||
371 | this.controller_.sendMsg({slideDirection: SlideController.MOVE_RIGHT}); | ||
372 | } | ||
373 | |||
355 | if (this.buildNextItem_()) { | 374 | if (this.buildNextItem_()) { |
356 | return; | 375 | return; |
357 | } | 376 | } |
358 | 377 | ||
359 | if (this.curSlide_ < this.slides_.length - 1) { | 378 | if (this.curSlide_ < this.slides_.length - 1) { |
360 | // Toggle off speaker notes and/or highlighted code if they're showing. | 379 | // Toggle off speaker notes and/or highlighted code if they're showing |
361 | var bodyClassList = document.body.classList; | 380 | // when we advanced. If we're the speaker notes popup, leave this put. |
362 | bodyClassList.remove('with-notes'); | 381 | if (this.controller_ && !window.opener) { |
363 | bodyClassList.remove('highlight-code'); | 382 | var bodyClassList = document.body.classList; |
383 | bodyClassList.remove('with-notes'); | ||
384 | bodyClassList.remove('highlight-code'); | ||
385 | } | ||
364 | 386 | ||
365 | this.prevSlide_ = this.curSlide_; | 387 | this.prevSlide_ = this.curSlide_; |
366 | this.curSlide_++; | 388 | this.curSlide_++; |