aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2014-05-12 21:40:42 +0200
committerPacien TRAN-GIRARD2014-05-12 21:40:42 +0200
commit765d63c299db8b75217b578b3a295fbce5d7abd3 (patch)
treeb055b96d69467a696c5a062c69b8886b8c6ea4b5
parenta94a99dad32b86e04d70f18f5b49401e43fc0a1d (diff)
downloadio-slides-remote-765d63c299db8b75217b578b3a295fbce5d7abd3.tar.gz
Import and format code
-rw-r--r--.project17
-rw-r--r--js/slide-controller.js213
-rw-r--r--js/slide-deck.js1229
-rw-r--r--js/slides.js6
-rw-r--r--scripts/md/base.html179
-rw-r--r--slide_config.js74
6 files changed, 895 insertions, 823 deletions
diff --git a/.project b/.project
new file mode 100644
index 0000000..a024966
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<projectDescription>
3 <name>pacientrangirard-io-2012-slides-remote</name>
4 <comment></comment>
5 <projects>
6 </projects>
7 <buildSpec>
8 <buildCommand>
9 <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
10 <arguments>
11 </arguments>
12 </buildCommand>
13 </buildSpec>
14 <natures>
15 <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
16 </natures>
17</projectDescription>
diff --git a/js/slide-controller.js b/js/slide-controller.js
index 571317b..9dcb4df 100644
--- a/js/slide-controller.js
+++ b/js/slide-controller.js
@@ -1,109 +1,112 @@
1(function(window) { 1(function(window) {
2 2
3var ORIGIN_ = location.protocol + '//' + location.host; 3 var ORIGIN_ = location.protocol + '//' + location.host;
4 4
5function SlideController() { 5 function SlideController() {
6 this.popup = null; 6 this.popup = null;
7 this.isPopup = window.opener; 7 this.isPopup = window.opener;
8 8
9 if (this.setupDone()) { 9 if (this.setupDone()) {
10 window.addEventListener('message', this.onMessage_.bind(this), false); 10 window.addEventListener('message', this.onMessage_.bind(this),
11 11 false);
12 // Close popups if we reload the main window. 12
13 window.addEventListener('beforeunload', function(e) { 13 // Close popups if we reload the main window.
14 if (this.popup) { 14 window.addEventListener('beforeunload', function(e) {
15 this.popup.close(); 15 if (this.popup) {
16 } 16 this.popup.close();
17 }.bind(this), false); 17 }
18 } 18 }.bind(this), false);
19} 19 }
20 20 }
21SlideController.PRESENTER_MODE_PARAM = 'presentme'; 21
22 22 SlideController.PRESENTER_MODE_PARAM = 'presentme';
23SlideController.prototype.setupDone = function() { 23
24 var params = location.search.substring(1).split('&').map(function(el) { 24 SlideController.prototype.setupDone = function() {
25 return el.split('='); 25 var params = location.search.substring(1).split('&').map(function(el) {
26 }); 26 return el.split('=');
27 27 });
28 var presentMe = null; 28
29 for (var i = 0, param; param = params[i]; ++i) { 29 var presentMe = null;
30 if (param[0].toLowerCase() == SlideController.PRESENTER_MODE_PARAM) { 30 for (var i = 0, param; param = params[i]; ++i) {
31 presentMe = param[1] == 'true'; 31 if (param[0].toLowerCase() == SlideController.PRESENTER_MODE_PARAM) {
32 break; 32 presentMe = param[1] == 'true';
33 } 33 break;
34 } 34 }
35 35 }
36 if (presentMe !== null) { 36
37 localStorage.ENABLE_PRESENTOR_MODE = presentMe; 37 if (presentMe !== null) {
38 // TODO: use window.history.pushState to update URL instead of the redirect. 38 localStorage.ENABLE_PRESENTOR_MODE = presentMe;
39 if (window.history.replaceState) { 39 // TODO: use window.history.pushState to update URL instead of the
40 window.history.replaceState({}, '', location.pathname); 40 // redirect.
41 } else { 41 if (window.history.replaceState) {
42 location.replace(location.pathname); 42 window.history.replaceState({}, '', location.pathname);
43 return false; 43 } else {
44 } 44 location.replace(location.pathname);
45 } 45 return false;
46 46 }
47 var enablePresenterMode = localStorage.getItem('ENABLE_PRESENTOR_MODE'); 47 }
48 if (enablePresenterMode && JSON.parse(enablePresenterMode)) { 48
49 // Only open popup from main deck. Don't want recursive popup opening! 49 var enablePresenterMode = localStorage.getItem('ENABLE_PRESENTOR_MODE');
50 if (!this.isPopup) { 50 if (enablePresenterMode && JSON.parse(enablePresenterMode)) {
51 var opts = 'menubar=no,location=yes,resizable=yes,scrollbars=no,status=no'; 51 // Only open popup from main deck. Don't want recursive popup
52 this.popup = window.open(location.href, 'mywindow', opts); 52 // opening!
53 53 if (!this.isPopup) {
54 // Loading in the popup? Trigger the hotkey for turning presenter mode on. 54 var opts = 'menubar=no,location=yes,resizable=yes,scrollbars=no,status=no';
55 this.popup.addEventListener('load', function(e) { 55 this.popup = window.open(location.href, 'mywindow', opts);
56 var evt = this.popup.document.createEvent('Event'); 56
57 evt.initEvent('keydown', true, true); 57 // Loading in the popup? Trigger the hotkey for turning
58 evt.keyCode = 'P'.charCodeAt(0); 58 // presenter mode on.
59 this.popup.document.dispatchEvent(evt); 59 this.popup.addEventListener('load', function(e) {
60 // this.popup.document.body.classList.add('with-notes'); 60 var evt = this.popup.document.createEvent('Event');
61 // document.body.classList.add('popup'); 61 evt.initEvent('keydown', true, true);
62 }.bind(this), false); 62 evt.keyCode = 'P'.charCodeAt(0);
63 } 63 this.popup.document.dispatchEvent(evt);
64 } 64 // this.popup.document.body.classList.add('with-notes');
65 65 // document.body.classList.add('popup');
66 return true; 66 }.bind(this), false);
67} 67 }
68 68 }
69SlideController.prototype.onMessage_ = function(e) { 69
70 var data = e.data; 70 return true;
71 71 }
72 // Restrict messages to being from this origin. Allow local developmet 72
73 // from file:// though. 73 SlideController.prototype.onMessage_ = function(e) {
74 // TODO: It would be dope if FF implemented location.origin! 74 var data = e.data;
75 if (e.origin != ORIGIN_ && ORIGIN_.indexOf('file://') != 0) { 75
76 alert('Someone tried to postMessage from an unknown origin'); 76 // Restrict messages to being from this origin. Allow local developmet
77 return; 77 // from file:// though.
78 } 78 // TODO: It would be dope if FF implemented location.origin!
79 79 if (e.origin != ORIGIN_ && ORIGIN_.indexOf('file://') != 0) {
80 // if (e.source.location.hostname != 'localhost') { 80 alert('Someone tried to postMessage from an unknown origin');
81 // alert('Someone tried to postMessage from an unknown origin'); 81 return;
82 // return; 82 }
83 // } 83
84 84 // if (e.source.location.hostname != 'localhost') {
85 if ('keyCode' in data) { 85 // alert('Someone tried to postMessage from an unknown origin');
86 var evt = document.createEvent('Event'); 86 // return;
87 evt.initEvent('keydown', true, true); 87 // }
88 evt.keyCode = data.keyCode; 88
89 document.dispatchEvent(evt); 89 if ('keyCode' in data) {
90 } 90 var evt = document.createEvent('Event');
91}; 91 evt.initEvent('keydown', true, true);
92 92 evt.keyCode = data.keyCode;
93SlideController.prototype.sendMsg = function(msg) { 93 document.dispatchEvent(evt);
94 // // Send message to popup window. 94 }
95 // if (this.popup) { 95 };
96 // this.popup.postMessage(msg, ORIGIN_); 96
97 // } 97 SlideController.prototype.sendMsg = function(msg) {
98 98 // // Send message to popup window.
99 // Send message to main window. 99 // if (this.popup) {
100 if (this.isPopup) { 100 // this.popup.postMessage(msg, ORIGIN_);
101 // TODO: It would be dope if FF implemented location.origin. 101 // }
102 window.opener.postMessage(msg, '*'); 102
103 } 103 // Send message to main window.
104}; 104 if (this.isPopup) {
105 105 // TODO: It would be dope if FF implemented location.origin.
106window.SlideController = SlideController; 106 window.opener.postMessage(msg, '*');
107 }
108 };
109
110 window.SlideController = SlideController;
107 111
108})(window); 112})(window);
109
diff --git a/js/slide-deck.js b/js/slide-deck.js
index d792ddd..67aa4f2 100644
--- a/js/slide-deck.js
+++ b/js/slide-deck.js
@@ -3,32 +3,32 @@
3 * @authors Eric Bidelman 3 * @authors Eric Bidelman
4 * @fileoverview TODO 4 * @fileoverview TODO
5 */ 5 */
6document.cancelFullScreen = document.webkitCancelFullScreen || 6document.cancelFullScreen = document.webkitCancelFullScreen
7 document.mozCancelFullScreen; 7 || document.mozCancelFullScreen;
8 8
9/** 9/**
10 * @constructor 10 * @constructor
11 */ 11 */
12function SlideDeck(el) { 12function SlideDeck(el) {
13 this.curSlide_ = 0; 13 this.curSlide_ = 0;
14 this.prevSlide_ = 0; 14 this.prevSlide_ = 0;
15 this.config_ = null; 15 this.config_ = null;
16 this.container = el || document.querySelector('slides'); 16 this.container = el || document.querySelector('slides');
17 this.slides = []; 17 this.slides = [];
18 this.controller = null; 18 this.controller = null;
19 19
20 this.getCurrentSlideFromHash_(); 20 this.getCurrentSlideFromHash_();
21 21
22 // Call this explicitly. Modernizr.load won't be done until after DOM load. 22