Browse Source

Renamed directive to more general "presentation", updated internal API to match this change.

pull/70/head
Joachim Bauch 11 years ago
parent
commit
6e09f0eaa1
  1. 6
      html/main.html
  2. 10
      src/styles/components/_presentation.scss
  3. 2
      src/styles/main.scss
  4. 4
      static/js/directives/directives.js
  5. 94
      static/js/directives/presentation.js
  6. 14
      static/js/mediastream/api.js
  7. 6
      static/partials/presentation.html

6
html/main.html

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
</div>
<status-message></status-message>
<div class="ng-cloak right">
<button title="{{_('PDF')}}" class="btn aenablebtn" ng-show="status=='connected' || status=='conference' || layout.pdfviewer" ng-model="layout.pdfviewer" btn-checkbox><i class="fa fa-file-pdf-o"></i></button>
<button title="{{_('Presentation')}}" class="btn aenablebtn" ng-show="status=='connected' || status=='conference' || layout.presentation" ng-model="layout.presentation" btn-checkbox><i class="fa fa-file-pdf-o"></i></button>
<button title="{{_('Share your screen')}}" class="btn aenablebtn" ng-show="isChrome && webrtcDetectedVersion >= 32 && (status=='connected' || status=='conference' || layout.screenshare)" ng-model="layout.screenshare" btn-checkbox><i class="fa fa-desktop"></i></button>
<button title="{{_('Chat')}}" class="btn" ng-class="{messagesunseen: chatMessagesUnseen>0}" ng-model="layout.chat" btn-checkbox btn-checkbox-true="true" btn-checkbox-false="false"><i class="fa fa-comments-o"></i><span class="badge" ng-show="chatMessagesUnseen">{{chatMessagesUnseen}}</span></button>
<button title="{{_('Mute microphone')}}" class="btn amutebtn" ng-model="microphoneMute" btn-checkbox btn-checkbox-true="true" btn-checkbox-false="false"><i class="fa fa-microphone-slash"></i></button>
@ -35,8 +35,8 @@ @@ -35,8 +35,8 @@
<div id="screenshare" class="ng-cloak mainview">
<screenshare/>
</div>
<div id="pdfviewer" class="ng-cloak mainview">
<pdfviewer/>
<div id="presentation" class="ng-cloak mainview">
<presentation/>
</div>
<div class="ng-cloak" id="rightslide">
<div class="rightslidepane">

10
src/styles/components/_pdfviewer.scss → src/styles/components/_presentation.scss

@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
*
*/
.pdfviewer {
.presentation {
bottom: 0;
left: 0;
position: absolute;
@ -27,11 +27,11 @@ @@ -27,11 +27,11 @@
top: 0;
}
.mainPdfviewer #pdfviewer {
.mainPresentation #presentation {
display: block;
}
.pdfviewerpane {
.presentationpane {
background: black;
bottom: 0;
left: 0;
@ -41,13 +41,13 @@ @@ -41,13 +41,13 @@
top: 0;
}
.pdfviewerpane {
.presentationpane {
canvas {
position: relative;
}
}
.pdfviewer .overlaybar {
.presentation .overlaybar {
bottom: 0;
left: 0;
right: 0;

2
src/styles/main.scss

@ -49,6 +49,6 @@ @@ -49,6 +49,6 @@
@import "components/roombar";
@import "components/social";
@import "components/contactsmanager";
@import "components/pdfviewer";
@import "components/presentation";
@import "shame";

4
static/js/directives/directives.js

@ -39,7 +39,7 @@ define([ @@ -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([ @@ -60,7 +60,7 @@ define([
contactRequest: contactRequest,
defaultDialog: defaultDialog,
pdfcanvas: pdfcanvas,
pdfviewer: pdfviewer
presentation: presentation
};
var initialize = function(angModule) {

94
static/js/directives/pdfviewer.js → static/js/directives/presentation.js

@ -18,16 +18,16 @@ @@ -18,16 +18,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
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($, _, @@ -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($, _, @@ -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($, _, @@ -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($, _, @@ -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($, _, @@ -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($, _, @@ -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($, _, @@ -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($, _, @@ -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($, _, @@ -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($, _, @@ -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($, _, @@ -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($, _, @@ -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($, _, @@ -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();
}
});

14
static/js/mediastream/api.js

@ -189,8 +189,8 @@ define(['jquery', 'underscore'], function($, _) { @@ -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($, _) { @@ -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);
};

6
static/partials/pdfviewer.html → static/partials/presentation.html

@ -1,9 +1,9 @@ @@ -1,9 +1,9 @@
<div class="pdfviewer">
<div class="pdfviewerpane nicescroll">
<div class="presentation">
<div class="presentationpane nicescroll">
<pdfcanvas/>
</div>
<div class="overlaybar form-horizontal" ng-class="{notvisible: hideControlsBar}" ng-show="isPresenter">
<a class="overlaybar-button" ng-model="hideControlsBar" btn-checkbox btn-checkbox btn-checkbox-true="0" btn-checkbox-false="1" title="{{_('PDF controls')}}"><i class="fa fa-cogs"></i></a>
<a class="overlaybar-button" ng-model="hideControlsBar" btn-checkbox btn-checkbox btn-checkbox-true="0" btn-checkbox-false="1" title="{{_('Presentation controls')}}"><i class="fa fa-cogs"></i></a>
<form class="overlaybar-content form-group">
<a class="btn" ng-click="prevPage()" ng-show="currentPageNumber &gt; 1" title="{{_('Prev')}}"><i class="fa fa-backward"></i></a>
<a class="btn" ng-click="nextPage()" ng-show="currentPageNumber &lt; maxPageNumber" title="{{_('Next')}}"><i class="fa fa-forward"></i></a>
Loading…
Cancel
Save