1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-21 23:58:07 +02:00

Add preferences for default scroll/spread modes

This commit adds `scrollModeOnLoad` and `spreadModeOnLoad` preferences
that control the default viewer state when opening a new document for
the first time.

This commit also contains a minor refactoring of some of the option UI
rendering code in extensions/chromium/options/options.js, as I couldn't
bear creating two more functions nearly identical to the four that
already existed.
This commit is contained in:
Ryan Hendrickson 2018-05-14 23:10:33 -04:00
parent c24bc29757
commit d7c051e807
5 changed files with 87 additions and 79 deletions

View file

@ -242,6 +242,12 @@ let PDFViewerApplication = {
preferences.get('enablePrintAutoRotate').then(function resolved(value) {
AppOptions.set('enablePrintAutoRotate', value);
}),
preferences.get('scrollModeOnLoad').then(function resolved(value) {
AppOptions.set('scrollModeOnLoad', value);
}),
preferences.get('spreadModeOnLoad').then(function resolved(value) {
AppOptions.set('spreadModeOnLoad', value);
}),
]).catch(function(reason) { });
},
@ -1040,8 +1046,8 @@ let PDFViewerApplication = {
('zoom=' + AppOptions.get('defaultZoomValue')) : null;
let rotation = null;
let sidebarView = AppOptions.get('sidebarViewOnLoad');
let scrollMode = null;
let spreadMode = null;
let scrollMode = AppOptions.get('scrollModeOnLoad');
let spreadMode = AppOptions.get('spreadModeOnLoad');
if (values.exists && AppOptions.get('showPreviousViewOnLoad')) {
hash = 'page=' + values.page +
@ -1248,6 +1254,10 @@ let PDFViewerApplication = {
this.pdfViewer.pagesRotation = angle;
}
};
// Putting these before isInitialViewSet = true prevents these values from
// being stored in the document history (and overriding any future changes
// made to the corresponding global preferences), just this once.
if (Number.isInteger(scrollMode)) {
this.pdfViewer.setScrollMode(scrollMode);
}

View file

@ -16,5 +16,7 @@
"renderInteractiveForms": false,
"enablePrintAutoRotate": false,
"disablePageMode": false,
"disablePageLabels": false
"disablePageLabels": false,
"scrollModeOnLoad": 0,
"spreadModeOnLoad": 0
}