From 6e09f0eaa1a5acef27038c85a9ee9d5700719b01 Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Tue, 8 Jul 2014 13:41:13 +0200 Subject: [PATCH] Renamed directive to more general "presentation", updated internal API to match this change. --- html/main.html | 6 +- .../{_pdfviewer.scss => _presentation.scss} | 10 +- src/styles/main.scss | 2 +- static/js/directives/directives.js | 4 +- .../{pdfviewer.js => presentation.js} | 94 +++++++++---------- static/js/mediastream/api.js | 14 +-- .../{pdfviewer.html => presentation.html} | 6 +- 7 files changed, 68 insertions(+), 68 deletions(-) rename src/styles/components/{_pdfviewer.scss => _presentation.scss} (90%) rename static/js/directives/{pdfviewer.js => presentation.js} (74%) rename static/partials/{pdfviewer.html => presentation.html} (81%) diff --git a/html/main.html b/html/main.html index 8fcb4391..7253379e 100644 --- a/html/main.html +++ b/html/main.html @@ -14,7 +14,7 @@
- + @@ -35,8 +35,8 @@
-
- +
+
diff --git a/src/styles/components/_pdfviewer.scss b/src/styles/components/_presentation.scss similarity index 90% rename from src/styles/components/_pdfviewer.scss rename to src/styles/components/_presentation.scss index 94a4a357..15c77d5d 100644 --- a/src/styles/components/_pdfviewer.scss +++ b/src/styles/components/_presentation.scss @@ -19,7 +19,7 @@ * */ -.pdfviewer { +.presentation { bottom: 0; left: 0; position: absolute; @@ -27,11 +27,11 @@ top: 0; } -.mainPdfviewer #pdfviewer { +.mainPresentation #presentation { display: block; } -.pdfviewerpane { +.presentationpane { background: black; bottom: 0; left: 0; @@ -41,13 +41,13 @@ top: 0; } -.pdfviewerpane { +.presentationpane { canvas { position: relative; } } -.pdfviewer .overlaybar { +.presentation .overlaybar { bottom: 0; left: 0; right: 0; diff --git a/src/styles/main.scss b/src/styles/main.scss index 9adc3033..b1f6c4ea 100644 --- a/src/styles/main.scss +++ b/src/styles/main.scss @@ -49,6 +49,6 @@ @import "components/roombar"; @import "components/social"; @import "components/contactsmanager"; -@import "components/pdfviewer"; +@import "components/presentation"; @import "shame"; diff --git a/static/js/directives/directives.js b/static/js/directives/directives.js index de78b0a8..ef9bbb0a 100644 --- a/static/js/directives/directives.js +++ b/static/js/directives/directives.js @@ -39,7 +39,7 @@ define([ 'directives/contactrequest', 'directives/defaultdialog', 'directives/pdfcanvas', - 'directives/pdfviewer'], function(_, onEnter, onEscape, statusMessage, buddyList, buddyPicture, settings, chat, audioVideo, usability, audioLevel, fileInfo, screenshare, roomBar, socialShare, page, contactRequest, defaultDialog, pdfcanvas, pdfviewer) { + 'directives/presentation'], function(_, onEnter, onEscape, statusMessage, buddyList, buddyPicture, settings, chat, audioVideo, usability, audioLevel, fileInfo, screenshare, roomBar, socialShare, page, contactRequest, defaultDialog, pdfcanvas, presentation) { var directives = { onEnter: onEnter, @@ -60,7 +60,7 @@ define([ contactRequest: contactRequest, defaultDialog: defaultDialog, pdfcanvas: pdfcanvas, - pdfviewer: pdfviewer + presentation: presentation }; var initialize = function(angModule) { diff --git a/static/js/directives/pdfviewer.js b/static/js/directives/presentation.js similarity index 74% rename from static/js/directives/pdfviewer.js rename to static/js/directives/presentation.js index e1d61412..998872f3 100644 --- a/static/js/directives/pdfviewer.js +++ b/static/js/directives/presentation.js @@ -18,16 +18,16 @@ * along with this program. If not, see . * */ -define(['jquery', 'underscore', 'text!partials/pdfviewer.html'], function($, _, template) { +define(['jquery', 'underscore', 'text!partials/presentation.html'], function($, _, template) { return ["$window", "mediaStream", "fileUpload", "fileDownload", "alertify", "translation", "randomGen", function($window, mediaStream, fileUpload, fileDownload, alertify, translation, randomGen) { var controller = ['$scope', '$element', '$attrs', function($scope, $element, $attrs) { - var pdfViewerCount = 0; - var pane = $element.find(".pdfviewerpane"); + var presentationsCount = 0; + var pane = $element.find(".presentationpane"); - $scope.layout.pdfviewer = false; + $scope.layout.presentation = false; $scope.isPresenter = false; $scope.hideControlsBar = false; @@ -42,7 +42,7 @@ define(['jquery', 'underscore', 'text!partials/pdfviewer.html'], function($, _, var downloadScope = $scope.$new(); downloadScope.$on("downloadComplete", function(event) { event.stopPropagation(); - finishDownloadPdf(); + finishDownloadPresentation(); }); downloadScope.$on("writeComplete", function(event, url, fileInfo) { @@ -56,7 +56,7 @@ define(['jquery', 'underscore', 'text!partials/pdfviewer.html'], function($, _, } }); - var finishDownloadPdf = function() { + var finishDownloadPresentation = function() { if (downloadScope.info) { mediaStream.tokens.off(downloadScope.info.id, downloadScope.handler); downloadScope.info = null; @@ -64,13 +64,13 @@ define(['jquery', 'underscore', 'text!partials/pdfviewer.html'], function($, _, } }; - var downloadPdf = function(fileInfo, from) { - finishDownloadPdf(); + var downloadPresentation = function(fileInfo, from) { + finishDownloadPresentation(); var token = fileInfo.id; downloadScope.info = fileInfo; downloadScope.handler = mediaStream.tokens.on(token, function(event, currenttoken, to, data, type, to2, from, xfer) { - //console.log("PdfViewer token request", currenttoken, data, type); + //console.log("Presentation token request", currenttoken, data, type); fileDownload.handleRequest($scope, xfer, data); }, "xfer"); @@ -79,7 +79,7 @@ define(['jquery', 'underscore', 'text!partials/pdfviewer.html'], function($, _, var uploadScope = $scope.$new(); - var finishUploadPdf = function() { + var finishUploadPresentation = function() { if (uploadScope.info) { uploadScope.$emit("cancelUpload"); mediaStream.tokens.off(uploadScope.info.id, uploadScope.handler); @@ -88,47 +88,47 @@ define(['jquery', 'underscore', 'text!partials/pdfviewer.html'], function($, _, } }; - var uploadPdf = function(fileInfo) { - finishUploadPdf(); + var uploadPresentation = function(fileInfo) { + finishUploadPresentation(); var token = fileInfo.id; uploadScope.info = fileInfo; var session = fileUpload.startUpload(uploadScope, token); // This binds the token to transfer and ui. uploadScope.handler = mediaStream.tokens.on(token, function(event, currenttoken, to, data, type, to2, from, xfer) { - //console.log("PdfViewer token request", currenttoken, data, type); + //console.log("Presentation token request", currenttoken, data, type); session.handleRequest(uploadScope, xfer, data); }, "xfer"); }; - mediaStream.api.e.on("received.pdfviewer", function(event, id, from, data, p2p) { + mediaStream.api.e.on("received.presentation", function(event, id, from, data, p2p) { if (!p2p) { - console.warn("Received pdfviewer info without p2p. This should not happen!"); + console.warn("Received presentation info without p2p. This should not happen!"); return; } - $scope.$emit("mainview", "pdfviewer", true); + $scope.$emit("mainview", "presentation", true); if (data.Type) { switch (data.Type) { case "FileInfo": - console.log("Received PdfViewer file request", data); - downloadPdf(data.FileInfo, from); + console.log("Received presentation file request", data); + downloadPresentation(data.FileInfo, from); break; case "Page": - console.log("Received PdfViewer page request", data); + console.log("Received presentation page request", data); $scope.$emit("showPdfPage", data.Page); break; default: - console.log("Received unknown PdfViewer event", data); + console.log("Received unknown presentation event", data); } } }); var peers = {}; - var pdfviewers = []; + var presentations = []; var currentToken = null; var tokenHandler = null; @@ -139,7 +139,7 @@ define(['jquery', 'underscore', 'text!partials/pdfviewer.html'], function($, _, return; } peers[peercall.id] = true; - mediaStream.api.apply("sendPdfViewer", { + mediaStream.api.apply("sendPresentation", { send: function(type, data) { return peercall.peerconnection.send(data); } @@ -157,9 +157,9 @@ define(['jquery', 'underscore', 'text!partials/pdfviewer.html'], function($, _, case "closed": delete peers[currentcall.id]; if (!peers.length) { - console.log("All peers disconnected, stopping sharing"); + console.log("All peers disconnected, stopping presentation"); $scope.$apply(function(scope) { - scope.hidePDFViewer(); + scope.hidePresentation(); }); } break; @@ -173,7 +173,7 @@ define(['jquery', 'underscore', 'text!partials/pdfviewer.html'], function($, _, _.each(peers, function(ignore, peerId) { var peercall = mediaStream.webrtc.findTargetCall(peerId); - mediaStream.api.apply("sendPdfViewer", { + mediaStream.api.apply("sendPresentation", { send: function(type, data) { return peercall.peerconnection.send(data); } @@ -184,14 +184,14 @@ define(['jquery', 'underscore', 'text!partials/pdfviewer.html'], function($, _, }); }); - $scope.showPDFViewer = function() { - console.log("PDF viewer active"); - if ($scope.layout.pdfviewer) { - $scope.hidePDFViewer(); + $scope.showPresentation = function() { + console.log("Presentation active"); + if ($scope.layout.presentation) { + $scope.hidePresentation(); } - $scope.layout.pdfviewer = true; - $scope.$emit("mainview", "pdfviewer", true); + $scope.layout.presentation = true; + $scope.$emit("mainview", "presentation", true); if (currentToken) { mediaStream.tokens.off(currentToken, tokenHandler); @@ -199,14 +199,14 @@ define(['jquery', 'underscore', 'text!partials/pdfviewer.html'], function($, _, // Create token to register with us and send token out to all peers. // Peers when connect to us with the token and we answer. - currentToken = "pdfviewer_" + $scope.id + "_" + (pdfViewerCount++); + currentToken = "presentation_" + $scope.id + "_" + (presentationsCount++); // Create callbacks are called for each incoming connections. - tokenHandler = mediaStream.tokens.create(currentToken, function(event, currenttoken, to, data, type, to2, from, peerpdfviewer) { - console.log("PDF viewer create", currenttoken, data, type, peerpdfviewer); - pdfviewers.push(peerpdfviewer); + tokenHandler = mediaStream.tokens.create(currentToken, function(event, currenttoken, to, data, type, to2, from, peerpresentation) { + console.log("Presentation create", currenttoken, data, type, peerpresentation); + presentations.push(peerpresentation); //usermedia.addToPeerConnection(peerscreenshare.peerconnection); - }, "pdfviewer"); + }, "presentation"); // Connect all current calls. mediaStream.webrtc.callForEachCall(function(peercall) { @@ -237,7 +237,7 @@ define(['jquery', 'underscore', 'text!partials/pdfviewer.html'], function($, _, // TODO(fancycode): other peers should either request the file or subscribe rendered images (e.g. for mobile app), for now we send the whole file _.each(peers, function(ignore, peerId) { var peercall = mediaStream.webrtc.findTargetCall(peerId); - mediaStream.api.apply("sendPdfViewer", { + mediaStream.api.apply("sendPresentation", { send: function(type, data) { return peercall.peerconnection.send(data); } @@ -246,7 +246,7 @@ define(['jquery', 'underscore', 'text!partials/pdfviewer.html'], function($, _, FileInfo: info }); }); - uploadPdf(info); + uploadPresentation(info); $scope.isPresenter = true; $scope.$emit("openPdf", f); }, this)); @@ -258,21 +258,21 @@ define(['jquery', 'underscore', 'text!partials/pdfviewer.html'], function($, _, }; - $scope.hidePDFViewer = function() { - console.log("PDF viewer disabled"); + $scope.hidePresentation = function() { + console.log("Presentation disabled"); $scope.$emit("closePdf"); - finishUploadPdf(); - finishDownloadPdf(); - $scope.layout.pdfviewer = false; + finishUploadPresentation(); + finishDownloadPresentation(); + $scope.layout.presentation = false; $scope.isPresenter = false; - $scope.$emit("mainview", "pdfviewer", false); + $scope.$emit("mainview", "presentation", false); }; - $scope.$watch("layout.pdfviewer", function(newval, oldval) { + $scope.$watch("layout.presentation", function(newval, oldval) { if (newval && !oldval) { - $scope.showPDFViewer(); + $scope.showPresentation(); } else if (!newval && oldval) { - $scope.hidePDFViewer(); + $scope.hidePresentation(); } }); diff --git a/static/js/mediastream/api.js b/static/js/mediastream/api.js index b2d10108..1b11d2b6 100644 --- a/static/js/mediastream/api.js +++ b/static/js/mediastream/api.js @@ -189,8 +189,8 @@ define(['jquery', 'underscore'], function($, _) { case "Screenshare": this.e.triggerHandler("received.screenshare", [d.To, d.From, data.Screenshare, d.p2p]); break; - case "PdfViewer": - this.e.triggerHandler("received.pdfviewer", [d.To, d.From, data.PdfViewer, d.p2p]); + case "Presentation": + this.e.triggerHandler("received.presentation", [d.To, d.From, data.Presentation, d.p2p]); break; case "Alive": // Do nothing. @@ -343,20 +343,20 @@ define(['jquery', 'underscore'], function($, _) { }; - Api.prototype.sendPdfViewer = function(id, viewer_id, viewer_data) { + Api.prototype.sendPresentation = function(id, viewer_id, viewer_data) { var data = { Id: id, - Type: "PdfViewer", - PdfViewer: { + Type: "Presentation", + Presentation: { id: viewer_id } } if (viewer_data) { - data.PdfViewer = _.extend(data.PdfViewer, viewer_data); + data.Presentation = _.extend(data.Presentation, viewer_data); } - return this.send("PdfViewer", data); + return this.send("Presentation", data); }; diff --git a/static/partials/pdfviewer.html b/static/partials/presentation.html similarity index 81% rename from static/partials/pdfviewer.html rename to static/partials/presentation.html index 81ec03bf..bcf3d649 100644 --- a/static/partials/pdfviewer.html +++ b/static/partials/presentation.html @@ -1,9 +1,9 @@ -
-
+
+
- +