[Pkg-javascript-commits] [pdf.js] 382/414: web/viewer.js: Persist the state of sidebar
David Prévot
taffit at moszumanska.debian.org
Tue Jun 28 17:12:42 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit 6ceda3f29079d9df12c26239e792bcb5cc56da16
Author: Ankit Aggarwal <ankitaggarwal011 at gmail.com>
Date: Wed Apr 13 18:58:53 2016 +0530
web/viewer.js: Persist the state of sidebar
Persist the state of content sidebar while browsing away from viewer and
initializing the same on returning back to the viewer. The state is saved
in persistent store preferences and used upon viewer initialization.
Fixes #6935
---
web/app.js | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/web/app.js b/web/app.js
index 505eeb4..9b54fcd 100644
--- a/web/app.js
+++ b/web/app.js
@@ -963,7 +963,7 @@ var PDFViewerApplication = {
};
store.initializedPromise.then(function resolved() {
- var storedHash = null;
+ var storedHash = null, sidebarView = null;
if (self.preferenceShowPreviousViewOnLoad &&
store.get('exists', false)) {
var pageNum = store.get('page', '1');
@@ -974,10 +974,13 @@ var PDFViewerApplication = {
storedHash = 'page=' + pageNum + '&zoom=' + zoom + ',' +
left + ',' + top;
+
+ sidebarView = store.get('sidebarView', SidebarView.NONE);
} else if (self.preferenceDefaultZoomValue) {
storedHash = 'page=1&zoom=' + self.preferenceDefaultZoomValue;
}
- self.setInitialView(storedHash, scale);
+ self.setInitialView(storedHash,
+ { scale: scale, sidebarView: sidebarView });
initialParams.hash = storedHash;
@@ -988,7 +991,7 @@ var PDFViewerApplication = {
}
}, function rejected(reason) {
console.error(reason);
- self.setInitialView(null, scale);
+ self.setInitialView(null, { scale: scale });
});
// For documents with different page sizes,
@@ -1112,7 +1115,10 @@ var PDFViewerApplication = {
});
},
- setInitialView: function pdfViewSetInitialView(storedHash, scale) {
+ setInitialView: function pdfViewSetInitialView(storedHash, options) {
+ var scale = options && options.scale;
+ var sidebarView = options && options.sidebarView;
+
this.isInitialViewSet = true;
// When opening a new file, when one is already loaded in the viewer,
@@ -1120,7 +1126,8 @@ var PDFViewerApplication = {
document.getElementById('pageNumber').value =
this.pdfViewer.currentPageNumber;
- this.pdfSidebar.setInitialView(this.preferenceSidebarViewOnLoad);
+ this.pdfSidebar.setInitialView(this.preferenceSidebarViewOnLoad ||
+ (sidebarView | 0));
if (this.initialDestination) {
this.pdfLinkService.navigateTo(this.initialDestination);
@@ -1697,6 +1704,9 @@ window.addEventListener('sidebarviewchanged', function (evt) {
// Only update the storage when the document has been loaded *and* rendered.
return;
}
+ store.initializedPromise.then(function() {
+ store.set('sidebarView', evt.detail.view).catch(function() {});
+ });
}, true);
window.addEventListener('updateviewarea', function (evt) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list