Revert "Move the Preferences initialization/fetching code to the top of PDFViewerApplication.initialize, to enable using them when initializing the viewer components"

This reverts commit ffb876fdf4b4dbc38273609b9b16b7a341decc02.
This commit is contained in:
Tim van der Meij 2016-09-03 20:27:01 +02:00
parent a2525a8ba3
commit eb2ba3287a

View File

@ -183,69 +183,6 @@ var PDFViewerApplication = {
// called once when the document is loaded
initialize: function pdfViewInitialize(appConfig) {
var self = this;
var PDFJS = pdfjsLib.PDFJS;
Preferences.initialize();
this.preferences = Preferences;
// Fetch the `Preferences` first, so that they can be used below when the
// various viewer components are initialized.
var preferencesPromise = Promise.all([
Preferences.get('enableWebGL').then(function resolved(value) {
PDFJS.disableWebGL = !value;
}),
Preferences.get('sidebarViewOnLoad').then(function resolved(value) {
self.preferenceSidebarViewOnLoad = value;
}),
Preferences.get('pdfBugEnabled').then(function resolved(value) {
self.preferencePdfBugEnabled = value;
}),
Preferences.get('showPreviousViewOnLoad').then(function resolved(value) {
self.preferenceShowPreviousViewOnLoad = value;
}),
Preferences.get('defaultZoomValue').then(function resolved(value) {
self.preferenceDefaultZoomValue = value;
}),
Preferences.get('disableTextLayer').then(function resolved(value) {
if (PDFJS.disableTextLayer === true) {
return;
}
PDFJS.disableTextLayer = value;
}),
Preferences.get('disableRange').then(function resolved(value) {
if (PDFJS.disableRange === true) {
return;
}
PDFJS.disableRange = value;
}),
Preferences.get('disableStream').then(function resolved(value) {
if (PDFJS.disableStream === true) {
return;
}
PDFJS.disableStream = value;
}),
Preferences.get('disableAutoFetch').then(function resolved(value) {
PDFJS.disableAutoFetch = value;
}),
Preferences.get('disableFontFace').then(function resolved(value) {
if (PDFJS.disableFontFace === true) {
return;
}
PDFJS.disableFontFace = value;
}),
Preferences.get('useOnlyCssZoom').then(function resolved(value) {
PDFJS.useOnlyCssZoom = value;
}),
Preferences.get('externalLinkTarget').then(function resolved(value) {
if (PDFJS.isExternalLinkTargetSet()) {
return;
}
PDFJS.externalLinkTarget = value;
}),
// TODO move more preferences and other async stuff here
]).catch(function (reason) { });
var initializedPromise = preferencesPromise.then(function () {
configure(pdfjsLib.PDFJS);
this.appConfig = appConfig;
@ -287,6 +224,9 @@ var PDFViewerApplication = {
});
pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
Preferences.initialize();
this.preferences = Preferences;
this.pdfHistory = new PDFHistory({
linkService: pdfLinkService,
eventBus: this.eventBus
@ -302,8 +242,7 @@ var PDFViewerApplication = {
}
this.findBar.updateResultsCount(matchCount);
}.bind(this);
this.findController.onUpdateState = function (state, previous,
matchCount) {
this.findController.onUpdateState = function (state, previous, matchCount) {
if (this.supportsIntegratedFind) {
this.externalServices.updateFindControlState(
{result: state, findPrevious: previous});
@ -366,7 +305,62 @@ var PDFViewerApplication = {
this.pdfSidebar = new PDFSidebar(sidebarConfig);
this.pdfSidebar.onToggled = this.forceRendering.bind(this);
}.bind(this));
var self = this;
var PDFJS = pdfjsLib.PDFJS;
var initializedPromise = Promise.all([
Preferences.get('enableWebGL').then(function resolved(value) {
PDFJS.disableWebGL = !value;
}),
Preferences.get('sidebarViewOnLoad').then(function resolved(value) {
self.preferenceSidebarViewOnLoad = value;
}),
Preferences.get('pdfBugEnabled').then(function resolved(value) {
self.preferencePdfBugEnabled = value;
}),
Preferences.get('showPreviousViewOnLoad').then(function resolved(value) {
self.preferenceShowPreviousViewOnLoad = value;
}),
Preferences.get('defaultZoomValue').then(function resolved(value) {
self.preferenceDefaultZoomValue = value;
}),
Preferences.get('disableTextLayer').then(function resolved(value) {
if (PDFJS.disableTextLayer === true) {
return;
}
PDFJS.disableTextLayer = value;
}),
Preferences.get('disableRange').then(function resolved(value) {
if (PDFJS.disableRange === true) {
return;
}
PDFJS.disableRange = value;
}),
Preferences.get('disableStream').then(function resolved(value) {
if (PDFJS.disableStream === true) {
return;
}
PDFJS.disableStream = value;
}),
Preferences.get('disableAutoFetch').then(function resolved(value) {
PDFJS.disableAutoFetch = value;
}),
Preferences.get('disableFontFace').then(function resolved(value) {
if (PDFJS.disableFontFace === true) {
return;
}
PDFJS.disableFontFace = value;
}),
Preferences.get('useOnlyCssZoom').then(function resolved(value) {
PDFJS.useOnlyCssZoom = value;
}),
Preferences.get('externalLinkTarget').then(function resolved(value) {
if (PDFJS.isExternalLinkTargetSet()) {
return;
}
PDFJS.externalLinkTarget = value;
}),
// TODO move more preferences and other async stuff here
]).catch(function (reason) { });
return initializedPromise.then(function () {
if (self.isViewerEmbedded && !PDFJS.isExternalLinkTargetSet()) {