From f8a9c78d140e58d785a46c96cc249d7956c2f136 Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Thu, 3 Jul 2014 00:26:57 +0200 Subject: [PATCH] Don't show first page initially if not presenter. --- static/js/directives/pdfviewer.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/static/js/directives/pdfviewer.js b/static/js/directives/pdfviewer.js index d3fcab72..cf1ed855 100644 --- a/static/js/directives/pdfviewer.js +++ b/static/js/directives/pdfviewer.js @@ -127,10 +127,7 @@ define(['require', 'jquery', 'underscore', 'text!partials/pdfviewer.html', 'pdf' // ...and flip the buffers... scope.canvasIndex = 1 - scope.canvasIndex; console.log("Done"); - if (scope.pendingPageNumber !== null) { - scope.showPage(scope.pendingPageNumber); - scope.pendingPageNumber = null; - } + scope.showQueuedPage(); }); }); }); @@ -156,13 +153,25 @@ define(['require', 'jquery', 'underscore', 'text!partials/pdfviewer.html', 'pdf' } }; + $scope.showQueuedPage = function() { + if ($scope.pendingPageNumber !== null) { + $scope.showPage($scope.pendingPageNumber); + $scope.pendingPageNumber = null; + } + }; + $scope.doOpenFile = function(source) { pdf.getDocument(source).then(function(doc) { $scope.$apply(function(scope) { scope.doc = doc; scope.maxPageNumber = doc.numPages; + scope.currentPageNumber = -1; console.log("PDF loaded", doc); - scope.$emit("queuePageRendering", 1); + if ($scope.isPresenter) { + scope.$emit("queuePageRendering", 1); + } else { + scope.showQueuedPage(); + } }); }); }; @@ -301,8 +310,8 @@ define(['require', 'jquery', 'underscore', 'text!partials/pdfviewer.html', 'pdf' //console.log("PdfViewer token request", currenttoken, data, type); session.handleRequest(subscope, xfer, data); }, "xfer"); - $scope.openFile(f); $scope.isPresenter = true; + $scope.openFile(f); }, this)); }, this)); binder.namespace = function() {