From f208307cbdd403d3fa92a1aae1dc9c094c7ec9d8 Mon Sep 17 00:00:00 2001
From: Eric Bidelman
Date: Wed, 11 Jul 2012 10:43:37 -0700
Subject: Bringing in upstream changes
---
js/slide-deck.js | 116 +++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 88 insertions(+), 28 deletions(-)
(limited to 'js/slide-deck.js')
diff --git a/js/slide-deck.js b/js/slide-deck.js
index a5308b9..50b9dc5 100644
--- a/js/slide-deck.js
+++ b/js/slide-deck.js
@@ -1,5 +1,6 @@
/**
- * @authors TODO
+ * @authors Luke Mahe
+ * @authors Eric Bidelman
* @fileoverview TODO
*/
document.cancelFullScreen = document.webkitCancelFullScreen ||
@@ -48,6 +49,16 @@ SlideDeck.prototype.getCurrentSlideFromHash_ = function() {
}
};
+/**
+ * @param {number} slideNo
+ */
+SlideDeck.prototype.loadSlide = function(slideNo) {
+ if (slideNo) {
+ this.curSlide_ = slideNo - 1;
+ this.updateSlides_();
+ }
+};
+
/**
* @private
*/
@@ -73,9 +84,20 @@ SlideDeck.prototype.onDomLoaded_ = function(e) {
this.updateSlides_();
// Add slide numbers and total slide count metadata to each slide.
+ var that = this;
for (var i = 0, slide; slide = this.slides[i]; ++i) {
slide.dataset.slideNum = i + 1;
slide.dataset.totalSlides = this.slides.length;
+
+ slide.addEventListener('click', function(e) {
+ if (document.body.classList.contains('overview')) {
+ that.loadSlide(this.dataset.slideNum);
+ e.preventDefault();
+ window.setTimeout(function() {
+ that.toggleOverview();
+ }, 500);
+ }
+ }, false);
}
// Note: this needs to come after addEventListeners_(), which adds a
@@ -152,6 +174,12 @@ SlideDeck.prototype.onBodyKeyDown_ = function(e) {
}
switch (e.keyCode) {
+ case 13: // Enter
+ if (document.body.classList.contains('overview')) {
+ this.toggleOverview();
+ }
+ break;
+
case 39: // right arrow
case 32: // space
case 34: // PgDn
@@ -167,20 +195,12 @@ SlideDeck.prototype.onBodyKeyDown_ = function(e) {
break;
case 40: // down arrow
- //if (this.isChromeVoxActive()) {
- // speakNextItem();
- //} else {
- this.nextSlide();
- //}
+ this.nextSlide();
e.preventDefault();
break;
case 38: // up arrow
- //if (this.isChromeVoxActive()) {
- // speakPrevItem();
- //} else {
- this.prevSlide();
- //}
+ this.prevSlide();
e.preventDefault();
break;
@@ -188,6 +208,10 @@ SlideDeck.prototype.onBodyKeyDown_ = function(e) {
document.body.classList.toggle('highlight-code');
break;
+ case 79: // O: Toggle overview
+ this.toggleOverview();
+ break;
+
case 80: // P
if (this.controller && this.controller.isPopup) {
document.body.classList.toggle('with-notes');
@@ -203,6 +227,10 @@ SlideDeck.prototype.onBodyKeyDown_ = function(e) {
case 27: // ESC: Hide notes and highlighting
document.body.classList.remove('with-notes');
document.body.classList.remove('highlight-code');
+
+ if (document.body.classList.contains('overview')) {
+ this.toggleOverview();
+ }
break;
case 70: // F: Toggle fullscreen
@@ -229,6 +257,27 @@ SlideDeck.prototype.onBodyKeyDown_ = function(e) {
}
};
+/**
+ *
+ */
+SlideDeck.prototype.focusOverview_ = function() {
+ var overview = document.body.classList.contains('overview');
+
+ for (var i = 0, slide; slide = this.slides[i]; i++) {
+ slide.style[Modernizr.prefixed('transform')] = overview ?
+ 'translateZ(-2500px) translate(' + (( i - this.curSlide_ ) * 105) +
+ '%, 0%)' : '';
+ }
+};
+
+/**
+ */
+SlideDeck.prototype.toggleOverview = function() {
+ document.body.classList.toggle('overview');
+
+ this.focusOverview_();
+};
+
/**
* @private
*/
@@ -276,34 +325,46 @@ SlideDeck.prototype.loadConfig_ = function(config) {
if (this.config_.presenters) {
var presenters = this.config_.presenters;
+ var dataConfigContact = document.querySelector('[data-config-contact]');
var html = [];
if (presenters.length == 1) {
- var p = presenters[0]
+ var p = presenters[0];
html = [p.name, p.company].join('
');
var gplus = p.gplus ? 'g+' + p.gplus.replace('http://', '') + '' : '';
+ '">' + p.gplus.replace(/https?:\/\//, '') + '' : '';
var twitter = p.twitter ? 'twitter' +
'' +
p.twitter + '' : '';
- var www = p.www ? 'www' + p.www.replace('http://', '') + '' : '';
+ var www = p.www ? 'www' + p.www.replace(/https?:\/\//, '') + '' : '';
- var html2 = [gplus, twitter, www].join('
');
+ var github = p.github ? 'github' + p.github.replace(/https?:\/\//, '') + '' : '';
- document.querySelector('[data-config-contact]').innerHTML = html2;
+ var html2 = [gplus, twitter, www, github].join('
');
+
+ if (dataConfigContact) {
+ dataConfigContact.innerHTML = html2;
+ }
} else {
for (var i = 0, p; p = presenters[i]; ++i) {
html.push(p.name + ' - ' + p.company);
}
html = html.join('
');
+ if (dataConfigContact) {
+ dataConfigContact.innerHTML = html;
+ }
}
- document.querySelector('[data-config-presenter]').innerHTML = html;
+ var dataConfigPresenter = document.querySelector('[data-config-presenter]');
+ if (dataConfigPresenter) {
+ document.querySelector('[data-config-presenter]').innerHTML = html;
+ }
}
/* Left/Right tap areas. Default to including. */
@@ -349,7 +410,8 @@ SlideDeck.prototype.loadConfig_ = function(config) {
SlideDeck.prototype.addFonts_ = function(fonts) {
var el = document.createElement('link');
el.rel = 'stylesheet';
- el.href = 'http://fonts.googleapis.com/css?family=' + fonts.join('|') + '&v2';
+ el.href = ('https:' == document.location.protocol ? 'https' : 'http') +
+ '://fonts.googleapis.com/css?family=' + fonts.join('|') + '&v2';
document.querySelector('head').appendChild(el);
};
@@ -379,10 +441,6 @@ SlideDeck.prototype.buildNextItem_ = function() {
toBuild.classList.remove('to-build');
toBuild.classList.add('build-current');
- /*if (isChromeVoxActive()) {
- speakAndSyncToNode(toBuild);
- }*/
-
return true;
};
@@ -412,7 +470,7 @@ SlideDeck.prototype.prevSlide = function(opt_dontPush) {
* @param {boolean=} opt_dontPush
*/
SlideDeck.prototype.nextSlide = function(opt_dontPush) {
- if (this.buildNextItem_()) {
+ if (!document.body.classList.contains('overview') && this.buildNextItem_()) {
return;
}
@@ -510,11 +568,13 @@ SlideDeck.prototype.updateSlides_ = function(opt_dontPush) {
// Give ourselves a good buffer to preload the next slide's iframes.
window.setTimeout(this.enableSlideFrames_.bind(this, curSlide + 2), 1000);
- /*if (isChromeVoxActive()) {
- speakAndSyncToNode(slideEls[curSlide]);
- }*/
-
this.updateHash_(dontPush);
+
+ if (document.body.classList.contains('overview')) {
+ this.focusOverview_();
+ return;
+ }
+
};
/**
--
cgit v1.2.3