1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Update Prettier to version 2.0

Please note that these changes were done automatically, using `gulp lint --fix`.

Given that the major version number was increased, there's a fair number of (primarily whitespace) changes; please see https://prettier.io/blog/2020/03/21/2.0.0.html
In order to reduce the size of these changes somewhat, this patch maintains the old "arrowParens" style for now (once mozilla-central updates Prettier we can simply choose the same formatting, assuming it will differ here).
This commit is contained in:
Jonas Jenwald 2020-04-14 12:28:14 +02:00
parent a4dd081d7b
commit 426945b480
145 changed files with 2005 additions and 2009 deletions

View file

@ -855,7 +855,7 @@ const PDFViewerApplication = {
this.pdfDocument
.getData()
.then(function(data) {
.then(function (data) {
const blob = new Blob([data], { type: "application/pdf" });
downloadManager.download(blob, url, filename);
})
@ -950,20 +950,20 @@ const PDFViewerApplication = {
errorMessage.textContent = message;
const closeButton = errorWrapperConfig.closeButton;
closeButton.onclick = function() {
closeButton.onclick = function () {
errorWrapper.setAttribute("hidden", "true");
};
const errorMoreInfo = errorWrapperConfig.errorMoreInfo;
const moreInfoButton = errorWrapperConfig.moreInfoButton;
const lessInfoButton = errorWrapperConfig.lessInfoButton;
moreInfoButton.onclick = function() {
moreInfoButton.onclick = function () {
errorMoreInfo.removeAttribute("hidden");
moreInfoButton.setAttribute("hidden", "true");
lessInfoButton.removeAttribute("hidden");
errorMoreInfo.style.height = errorMoreInfo.scrollHeight + "px";
};
lessInfoButton.onclick = function() {
lessInfoButton.onclick = function () {
errorMoreInfo.setAttribute("hidden", "true");
moreInfoButton.removeAttribute("hidden");
lessInfoButton.setAttribute("hidden", "true");
@ -1036,13 +1036,13 @@ const PDFViewerApplication = {
// Since the `setInitialView` call below depends on this being resolved,
// fetch it early to avoid delaying initial rendering of the PDF document.
const pageLayoutPromise = pdfDocument.getPageLayout().catch(function() {
const pageLayoutPromise = pdfDocument.getPageLayout().catch(function () {
/* Avoid breaking initial rendering; ignoring errors. */
});
const pageModePromise = pdfDocument.getPageMode().catch(function() {
const pageModePromise = pdfDocument.getPageMode().catch(function () {
/* Avoid breaking initial rendering; ignoring errors. */
});
const openActionPromise = pdfDocument.getOpenAction().catch(function() {
const openActionPromise = pdfDocument.getOpenAction().catch(function () {
/* Avoid breaking initial rendering; ignoring errors. */
});
@ -1185,7 +1185,7 @@ const PDFViewerApplication = {
// even if there are any errors thrown above.
this.setInitialView();
})
.then(function() {
.then(function () {
// At this point, rendering of the initial page(s) should always have
// started (and may even have completed).
// To prevent any future issues, e.g. the document being completely
@ -1254,7 +1254,7 @@ const PDFViewerApplication = {
return;
}
if (triggerAutoPrint) {
setTimeout(function() {
setTimeout(function () {
window.print();
});
}
@ -1377,7 +1377,7 @@ const PDFViewerApplication = {
];
if (info.Producer) {
const producer = info.Producer.toLowerCase();
KNOWN_GENERATORS.some(function(generator) {
KNOWN_GENERATORS.some(function (generator) {
if (!producer.includes(generator)) {
return false;
}
@ -1795,7 +1795,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
"http://mozilla.github.io",
"https://mozilla.github.io",
];
validateFileURL = function(file) {
validateFileURL = function (file) {
if (file === undefined) {
return;
}
@ -1843,7 +1843,7 @@ async function loadFakeWorker() {
function loadAndEnablePDFBug(enabledTabs) {
const appConfig = PDFViewerApplication.appConfig;
return loadScript(appConfig.debuggerScriptPath).then(function() {
return loadScript(appConfig.debuggerScriptPath).then(function () {
PDFBug.enable(enabledTabs);
PDFBug.init({ OPS }, appConfig.mainContainer);
});
@ -1883,7 +1883,7 @@ function webViewerInitialized() {
fileInput.value = null;
}
fileInput.addEventListener("change", function(evt) {
fileInput.addEventListener("change", function (evt) {
const files = evt.target.files;
if (!files || files.length === 0) {
return;
@ -1895,12 +1895,12 @@ function webViewerInitialized() {
});
// Enable dragging-and-dropping a new PDF file onto the viewerContainer.
appConfig.mainContainer.addEventListener("dragover", function(evt) {
appConfig.mainContainer.addEventListener("dragover", function (evt) {
evt.preventDefault();
evt.dataTransfer.dropEffect = "move";
});
appConfig.mainContainer.addEventListener("drop", function(evt) {
appConfig.mainContainer.addEventListener("drop", function (evt) {
evt.preventDefault();
const files = evt.dataTransfer.files;
@ -1950,7 +1950,7 @@ function webViewerInitialized() {
appConfig.mainContainer.addEventListener(
"transitionend",
function(evt) {
function (evt) {
if (evt.target === /* mainContainer */ this) {
PDFViewerApplication.eventBus.dispatch("resize", { source: this });
}
@ -1971,14 +1971,14 @@ function webViewerInitialized() {
let webViewerOpenFileViaURL;
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
webViewerOpenFileViaURL = function(file) {
webViewerOpenFileViaURL = function (file) {
if (file && file.lastIndexOf("file:", 0) === 0) {
// file:-scheme. Load the contents in the main thread because QtWebKit
// cannot load file:-URLs in a Web Worker. file:-URLs are usually loaded
// very quickly, so there is no need to set up progress event listeners.
PDFViewerApplication.setTitleUsingUrl(file);
const xhr = new XMLHttpRequest();
xhr.onload = function() {
xhr.onload = function () {
PDFViewerApplication.open(new Uint8Array(xhr.response));
};
xhr.open("GET", file);
@ -1992,12 +1992,12 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
}
};
} else if (PDFJSDev.test("MOZCENTRAL || CHROME")) {
webViewerOpenFileViaURL = function(file) {
webViewerOpenFileViaURL = function (file) {
PDFViewerApplication.setTitleUsingUrl(file);
PDFViewerApplication.initPassiveLoading();
};
} else {
webViewerOpenFileViaURL = function(file) {
webViewerOpenFileViaURL = function (file) {
if (file) {
throw new Error("Not implemented: webViewerOpenFileViaURL");
}
@ -2063,7 +2063,7 @@ function webViewerPageRendered(evt) {
timestamp: evt.timestamp,
});
// It is a good time to report stream and font types.
PDFViewerApplication.pdfDocument.getStats().then(function(stats) {
PDFViewerApplication.pdfDocument.getStats().then(function (stats) {
PDFViewerApplication.externalServices.reportTelemetry({
type: "documentStats",
stats,
@ -2130,7 +2130,7 @@ function webViewerSidebarViewChanged(evt) {
const store = PDFViewerApplication.store;
if (store && PDFViewerApplication.isInitialViewSet) {
// Only update the storage when the document has been loaded *and* rendered.
store.set("sidebarView", evt.view).catch(function() {});
store.set("sidebarView", evt.view).catch(function () {});
}
}
@ -2147,7 +2147,7 @@ function webViewerUpdateViewarea(evt) {
scrollTop: location.top,
rotation: location.rotation,
})
.catch(function() {
.catch(function () {
/* unable to write to storage */
});
}
@ -2169,7 +2169,7 @@ function webViewerScrollModeChanged(evt) {
const store = PDFViewerApplication.store;
if (store && PDFViewerApplication.isInitialViewSet) {
// Only update the storage when the document has been loaded *and* rendered.
store.set("scrollMode", evt.mode).catch(function() {});
store.set("scrollMode", evt.mode).catch(function () {});
}
}
@ -2177,7 +2177,7 @@ function webViewerSpreadModeChanged(evt) {
const store = PDFViewerApplication.store;
if (store && PDFViewerApplication.isInitialViewSet) {
// Only update the storage when the document has been loaded *and* rendered.
store.set("spreadMode", evt.mode).catch(function() {});
store.set("spreadMode", evt.mode).catch(function () {});
}
}
@ -2212,7 +2212,7 @@ function webViewerHashchange(evt) {
let webViewerFileInputChange, webViewerOpenFile;
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
webViewerFileInputChange = function(evt) {
webViewerFileInputChange = function (evt) {
if (
PDFViewerApplication.pdfViewer &&
PDFViewerApplication.pdfViewer.isInPresentationMode
@ -2249,7 +2249,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
appConfig.secondaryToolbar.downloadButton.setAttribute("hidden", "true");
};
webViewerOpenFile = function(evt) {
webViewerOpenFile = function (evt) {
const openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
document.getElementById(openFileInputName).click();
};
@ -2415,7 +2415,7 @@ function setZoomDisabledTimeout() {
if (zoomDisabledTimeout) {
clearTimeout(zoomDisabledTimeout);
}
zoomDisabledTimeout = setTimeout(function() {
zoomDisabledTimeout = setTimeout(function () {
zoomDisabledTimeout = null;
}, WHEEL_ZOOM_DISABLED_TIMEOUT);
}
@ -2549,7 +2549,7 @@ function webViewerKeyDown(evt) {
case 96: // '0' on Numpad of Swedish keyboard
if (!isViewerInPresentationMode) {
// keeping it unhandled (to restore page zoom to 100%)
setTimeout(function() {
setTimeout(function () {
// ... and resetting the scale after browser adjusts its scale
PDFViewerApplication.zoomReset();
});

View file

@ -162,9 +162,9 @@ const defaultOptions = {
cMapUrl: {
/** @type {string} */
value:
(typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")
typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")
? "../external/bcmaps/"
: "../web/cmaps/"),
: "../web/cmaps/",
kind: OptionKind.API,
},
disableAutoFetch: {
@ -232,9 +232,9 @@ const defaultOptions = {
workerSrc: {
/** @type {string} */
value:
(typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")
typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")
? "../src/worker_loader.js"
: "../build/pdf.worker.js"),
: "../build/pdf.worker.js",
kind: OptionKind.WORKER,
},
};
@ -249,7 +249,7 @@ if (
};
defaultOptions.locale = {
/** @type {string} */
value: (typeof navigator !== "undefined" ? navigator.language : "en-US"),
value: typeof navigator !== "undefined" ? navigator.language : "en-US",
kind: OptionKind.VIEWER,
};
defaultOptions.printResolution = {

View file

@ -82,7 +82,7 @@ const DEFAULT_CACHE_SIZE = 10;
function PDFPageViewBuffer(size) {
const data = [];
this.push = function(view) {
this.push = function (view) {
const i = data.indexOf(view);
if (i >= 0) {
data.splice(i, 1);
@ -99,14 +99,14 @@ function PDFPageViewBuffer(size) {
* impact on the final size of the buffer; if pagesToKeep has length larger
* than newSize, some of those pages will be destroyed anyway.
*/
this.resize = function(newSize, pagesToKeep) {
this.resize = function (newSize, pagesToKeep) {
size = newSize;
if (pagesToKeep) {
const pageIdsToKeep = new Set();
for (let i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
pageIdsToKeep.add(pagesToKeep[i].id);
}
moveToEndOfArray(data, function(page) {
moveToEndOfArray(data, function (page) {
return pageIdsToKeep.has(page.id);
});
}
@ -202,7 +202,7 @@ class BaseViewer {
}
// Prevent printing errors when 'disableAutoFetch' is set, by ensuring
// that *all* pages have in fact been completely loaded.
return this._pages.every(function(pageView) {
return this._pages.every(function (pageView) {
return pageView && pageView.pdfPage;
});
}
@ -1042,7 +1042,7 @@ class BaseViewer {
);
return false;
}
return this._getVisiblePages().views.some(function(view) {
return this._getVisiblePages().views.some(function (view) {
return view.id === pageNumber;
});
}
@ -1195,7 +1195,7 @@ class BaseViewer {
* @returns {Array} Array of objects with width/height/rotation fields.
*/
getPagesOverview() {
const pagesOverview = this._pages.map(function(pageView) {
const pagesOverview = this._pages.map(function (pageView) {
const viewport = pageView.pdfPage.getViewport({ scale: 1 });
return {
width: viewport.width,
@ -1207,7 +1207,7 @@ class BaseViewer {
return pagesOverview;
}
const isFirstPagePortrait = isPortraitOrientation(pagesOverview[0]);
return pagesOverview.map(function(size) {
return pagesOverview.map(function (size) {
if (isFirstPagePortrait === isPortraitOrientation(size)) {
return size;
}

View file

@ -72,13 +72,13 @@ const ChromeCom = {
// Assumption: The file being opened is the file that was requested.
// There is no UI to input a different URL, so this assumption will hold
// for now.
setReferer(file, function() {
setReferer(file, function () {
callback(file);
});
return;
}
if (/^file?:/.test(file)) {
getEmbedderOrigin(function(origin) {
getEmbedderOrigin(function (origin) {
// If the origin cannot be determined, let Chrome decide whether to
// allow embedding files. Otherwise, only allow local files to be
// embedded from local files or Chrome extensions.
@ -95,7 +95,7 @@ const ChromeCom = {
);
return;
}
isAllowedFileSchemeAccess(function(isAllowedAccess) {
isAllowedFileSchemeAccess(function (isAllowedAccess) {
if (isAllowedAccess) {
callback(file);
} else {
@ -156,7 +156,7 @@ function requestAccessToLocalFile(fileUrl, overlayManager, callback) {
// for detecting unload of the top-level frame. Should this ever change
// (crbug.com/511670), then the user can just reload the tab.
window.addEventListener("focus", reloadIfRuntimeIsUnavailable);
onCloseOverlay = function() {
onCloseOverlay = function () {
window.removeEventListener("focus", reloadIfRuntimeIsUnavailable);
reloadIfRuntimeIsUnavailable();
overlayManager.close("chromeFileAccessOverlay");
@ -170,7 +170,7 @@ function requestAccessToLocalFile(fileUrl, overlayManager, callback) {
true
);
}
chromeFileAccessOverlayPromise.then(function() {
chromeFileAccessOverlayPromise.then(function () {
const iconPath = chrome.runtime.getManifest().icons[48];
document.getElementById("chrome-pdfjs-logo-bg").style.backgroundImage =
"url(" + chrome.runtime.getURL(iconPath) + ")";
@ -190,7 +190,7 @@ function requestAccessToLocalFile(fileUrl, overlayManager, callback) {
const link = document.getElementById("chrome-link-to-extensions-page");
link.href = "chrome://extensions/?id=" + chrome.runtime.id;
link.onclick = function(e) {
link.onclick = function (e) {
// Direct navigation to chrome:// URLs is blocked by Chrome, so we
// have to ask the background page to open chrome://extensions/?id=...
e.preventDefault();
@ -206,7 +206,7 @@ function requestAccessToLocalFile(fileUrl, overlayManager, callback) {
// why this permission request is shown.
document.getElementById("chrome-url-of-local-file").textContent = fileUrl;
document.getElementById("chrome-file-fallback").onchange = function() {
document.getElementById("chrome-file-fallback").onchange = function () {
const file = this.files[0];
if (file) {
const originalFilename = decodeURIComponent(fileUrl.split("/").pop());
@ -242,7 +242,7 @@ if (window === top) {
// localStorage and restored by extension-router.js.
// Unfortunately, the window and tab index are not restored. And if it was
// the only tab in an incognito window, then the tab is not restored either.
addEventListener("unload", function() {
addEventListener("unload", function () {
// If the runtime is still available, the unload is most likely a normal
// tab closure. Otherwise it is most likely an extension reload.
if (!isRuntimeAvailable()) {
@ -318,11 +318,11 @@ class ChromePreferences extends BasePreferences {
const keysToRemove = Object.keys(this.defaults);
// If the storage is reset, remove the keys so that the values from
// managed storage are applied again.
storageArea.remove(keysToRemove, function() {
storageArea.remove(keysToRemove, function () {
resolve();
});
} else {
storageArea.set(prefObj, function() {
storageArea.set(prefObj, function () {
resolve();
});
}
@ -336,7 +336,7 @@ class ChromePreferences extends BasePreferences {
// Managed storage not supported, e.g. in Opera.
defaultPrefs = this.defaults;
}
storageArea.get(defaultPrefs, function(readPrefs) {
storageArea.get(defaultPrefs, function (readPrefs) {
resolve(readPrefs);
});
};
@ -360,7 +360,7 @@ class ChromePreferences extends BasePreferences {
this.defaults
);
chrome.storage.managed.get(defaultManagedPrefs, function(items) {
chrome.storage.managed.get(defaultManagedPrefs, function (items) {
items = items || defaultManagedPrefs;
// Migration logic for deprecated preferences: If the new preference
// is not defined by an administrator (i.e. the value is the same as
@ -410,7 +410,7 @@ class ChromeExternalServices extends DefaultExternalServices {
ChromeCom.resolvePDFFile(
AppOptions.get("defaultUrl"),
PDFViewerApplication.overlayManager,
function(url, length, originalUrl) {
function (url, length, originalUrl) {
callbacks.onOpenWithURL(url, length, originalUrl);
}
);

View file

@ -126,14 +126,14 @@ var FontInspector = (function FontInspectorClosure() {
var logIt = document.createElement("a");
logIt.href = "";
logIt.textContent = "Log";
logIt.addEventListener("click", function(event) {
logIt.addEventListener("click", function (event) {
event.preventDefault();
console.log(fontObj);
});
const select = document.createElement("input");
select.setAttribute("type", "checkbox");
select.dataset.fontName = fontName;
select.addEventListener("click", function() {
select.addEventListener("click", function () {
selectFont(fontName, select.checked);
});
font.appendChild(select);
@ -174,7 +174,7 @@ var StepperManager = (function StepperManagerClosure() {
var self = this;
stepperControls = document.createElement("div");
stepperChooser = document.createElement("select");
stepperChooser.addEventListener("change", function(event) {
stepperChooser.addEventListener("change", function (event) {
self.selectStepper(this.value);
});
stepperControls.appendChild(stepperChooser);
@ -390,7 +390,7 @@ var Stepper = (function StepperClosure() {
this.table.appendChild(chunk);
},
getNextBreakPoint: function getNextBreakPoint() {
this.breakPoints.sort(function(a, b) {
this.breakPoints.sort(function (a, b) {
return a - b;
});
for (var i = 0; i < this.breakPoints.length; i++) {
@ -405,7 +405,7 @@ var Stepper = (function StepperClosure() {
var self = this;
var dom = document;
self.currentIdx = idx;
var listener = function(e) {
var listener = function (e) {
switch (e.keyCode) {
case 83: // step
dom.removeEventListener("keydown", listener);
@ -486,7 +486,7 @@ var Stats = (function Stats() {
wrapper.appendChild(title);
wrapper.appendChild(statsDiv);
stats.push({ pageNumber, div: wrapper });
stats.sort(function(a, b) {
stats.sort(function (a, b) {
return a.pageNumber - b.pageNumber;
});
clear(this.panel);
@ -523,7 +523,7 @@ window.PDFBug = (function PDFBugClosure() {
}
if (!all) {
// Sort the tools by the order they are enabled.
tools.sort(function(a, b) {
tools.sort(function (a, b) {
var indexA = ids.indexOf(a.id);
indexA = indexA < 0 ? tools.length : indexA;
var indexB = ids.indexOf(b.id);
@ -566,8 +566,8 @@ window.PDFBug = (function PDFBugClosure() {
panelButton.textContent = tool.name;
panelButton.addEventListener(
"click",
(function(selected) {
return function(event) {
(function (selected) {
return function (event) {
event.preventDefault();
self.selectPanel(selected);
};

View file

@ -36,7 +36,7 @@ function composePage(pdfDocument, pageNumber, size, printContainer) {
canvasWrapper.appendChild(canvas);
printContainer.appendChild(canvasWrapper);
canvas.mozPrintCallback = function(obj) {
canvas.mozPrintCallback = function (obj) {
// Printing/rendering the page.
const ctx = obj.context;
@ -47,7 +47,7 @@ function composePage(pdfDocument, pageNumber, size, printContainer) {
pdfDocument
.getPage(pageNumber)
.then(function(pdfPage) {
.then(function (pdfPage) {
const renderContext = {
canvasContext: ctx,
transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
@ -57,11 +57,11 @@ function composePage(pdfDocument, pageNumber, size, printContainer) {
return pdfPage.render(renderContext).promise;
})
.then(
function() {
function () {
// Tell the printEngine that rendering this canvas/page has finished.
obj.done();
},
function(error) {
function (error) {
console.error(error);
// Tell the printEngine that rendering this canvas/page has failed.
// This will make the print process stop.

View file

@ -133,14 +133,14 @@ class DownloadManager {
class FirefoxPreferences extends BasePreferences {
async _writeToStorage(prefObj) {
return new Promise(function(resolve) {
return new Promise(function (resolve) {
FirefoxCom.request("setPreferences", prefObj, resolve);
});
}
async _readFromStorage(prefObj) {
return new Promise(function(resolve) {
FirefoxCom.request("getPreferences", prefObj, function(prefStr) {
return new Promise(function (resolve) {
FirefoxCom.request("getPreferences", prefObj, function (prefStr) {
const readPrefs = JSON.parse(prefStr);
resolve(readPrefs);
});
@ -179,7 +179,7 @@ class MozL10n {
"findentirewordchange",
"findbarclose",
];
const handleEvent = function({ type, detail }) {
const handleEvent = function ({ type, detail }) {
if (!PDFViewerApplication.initialized) {
return;
}
@ -206,7 +206,7 @@ class MozL10n {
(function listenZoomEvents() {
const events = ["zoomin", "zoomout", "zoomreset"];
const handleEvent = function({ type, detail }) {
const handleEvent = function ({ type, detail }) {
if (!PDFViewerApplication.initialized) {
return;
}

View file

@ -180,7 +180,7 @@ GrabToPan.prototype = {
// Get the correct (vendor-prefixed) name of the matches method.
let matchesSelector;
["webkitM", "mozM", "msM", "oM", "m"].some(function(prefix) {
["webkitM", "mozM", "msM", "oM", "m"].some(function (prefix) {
let name = prefix + "atches";
if (name in document.documentElement) {
matchesSelector = name;

View file

@ -84,7 +84,7 @@ class PDFAttachmentViewer {
);
}
let blobUrl;
button.onclick = function() {
button.onclick = function () {
if (!blobUrl) {
blobUrl = createObjectURL(content, "application/pdf");
}
@ -135,7 +135,7 @@ class PDFAttachmentViewer {
return;
}
const names = Object.keys(attachments).sort(function(a, b) {
const names = Object.keys(attachments).sort(function (a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase());
});
attachmentsCount = names.length;

View file

@ -49,7 +49,7 @@ function normalize(text) {
const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
normalizationRegex = new RegExp(`[${replace}]`, "g");
}
return text.replace(normalizationRegex, function(ch) {
return text.replace(normalizationRegex, function (ch) {
return CHARACTERS_TO_NORMALIZE[ch];
});
}
@ -312,7 +312,7 @@ class PDFFindController {
// Sort the array of `{ match: <match>, matchLength: <matchLength> }`
// objects on increasing index first and on the length otherwise.
matchesWithLength.sort(function(a, b) {
matchesWithLength.sort(function (a, b) {
return a.match === b.match
? a.matchLength - b.matchLength
: a.match - b.match;

View file

@ -512,8 +512,8 @@ class PDFPageView {
this.paintTask = paintTask;
const resultPromise = paintTask.promise.then(
function() {
return finishPaintTask(null).then(function() {
function () {
return finishPaintTask(null).then(function () {
if (textLayer) {
const readableStream = pdfPage.streamTextContent({
normalizeWhitespace: true,
@ -523,7 +523,7 @@ class PDFPageView {
}
});
},
function(reason) {
function (reason) {
return finishPaintTask(reason);
}
);
@ -573,7 +573,7 @@ class PDFPageView {
// is complete when `!this.renderingQueue`, to prevent black flickering.
canvas.setAttribute("hidden", "hidden");
let isCanvasHidden = true;
const showCanvas = function() {
const showCanvas = function () {
if (isCanvasHidden) {
canvas.removeAttribute("hidden");
isCanvasHidden = false;
@ -637,7 +637,7 @@ class PDFPageView {
renderInteractiveForms: this.renderInteractiveForms,
};
const renderTask = this.pdfPage.render(renderContext);
renderTask.onContinue = function(cont) {
renderTask.onContinue = function (cont) {
showCanvas();
if (result.onRenderContinue) {
result.onRenderContinue(cont);
@ -647,11 +647,11 @@ class PDFPageView {
};
renderTask.promise.then(
function() {
function () {
showCanvas();
renderCapability.resolve(undefined);
},
function(error) {
function (error) {
showCanvas();
renderCapability.reject(error);
}

View file

@ -43,7 +43,7 @@ function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
return pdfDocument
.getPage(pageNumber)
.then(function(pdfPage) {
.then(function (pdfPage) {
const renderContext = {
canvasContext: ctx,
transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
@ -52,7 +52,7 @@ function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
};
return pdfPage.render(renderContext).promise;
})
.then(function() {
.then(function () {
return {
width,
height,
@ -79,7 +79,7 @@ PDFPrintService.prototype = {
const body = document.querySelector("body");
body.setAttribute("data-pdfjsprinting", true);
const hasEqualPageSizes = this.pagesOverview.every(function(size) {
const hasEqualPageSizes = this.pagesOverview.every(function (size) {
return (
size.width === this.pagesOverview[0].width &&
size.height === this.pagesOverview[0].height
@ -135,7 +135,7 @@ PDFPrintService.prototype = {
this.scratchCanvas.width = this.scratchCanvas.height = 0;
this.scratchCanvas = null;
activeService = null;
ensureOverlay().then(function() {
ensureOverlay().then(function () {
if (overlayManager.active !== "printServiceOverlay") {
return; // overlay was already closed
}
@ -156,7 +156,7 @@ PDFPrintService.prototype = {
renderProgress(index, pageCount, this.l10n);
renderPage(this, this.pdfDocument, index + 1, this.pagesOverview[index])
.then(this.useRenderedPage.bind(this))
.then(function() {
.then(function () {
renderNextPage(resolve, reject);
}, reject);
};
@ -171,7 +171,7 @@ PDFPrintService.prototype = {
const scratchCanvas = this.scratchCanvas;
if ("toBlob" in scratchCanvas && !this.disableCreateObjectURL) {
scratchCanvas.toBlob(function(blob) {
scratchCanvas.toBlob(function (blob) {
img.src = URL.createObjectURL(blob);
});
} else {
@ -182,7 +182,7 @@ PDFPrintService.prototype = {
wrapper.appendChild(img);
this.printContainer.appendChild(wrapper);
return new Promise(function(resolve, reject) {
return new Promise(function (resolve, reject) {
img.onload = resolve;
img.onerror = reject;
});
@ -218,12 +218,12 @@ PDFPrintService.prototype = {
};
const print = window.print;
window.print = function() {
window.print = function () {
if (activeService) {
console.warn("Ignored window.print() because of a pending print job.");
return;
}
ensureOverlay().then(function() {
ensureOverlay().then(function () {
if (activeService) {
overlayManager.open("printServiceOverlay");
}
@ -234,7 +234,7 @@ window.print = function() {
} finally {
if (!activeService) {
console.error("Expected print service to be initialized.");
ensureOverlay().then(function() {
ensureOverlay().then(function () {
if (overlayManager.active === "printServiceOverlay") {
overlayManager.close("printServiceOverlay");
}
@ -244,13 +244,13 @@ window.print = function() {
const activeServiceOnEntry = activeService;
activeService
.renderPages()
.then(function() {
.then(function () {
return activeServiceOnEntry.performPrint();
})
.catch(function() {
.catch(function () {
// Ignore any error messages.
})
.then(function() {
.then(function () {
// aborts acts on the "active" print request, so we need to check
// whether the print request (activeServiceOnEntry) is still active.
// Without the check, an unrelated print request (created after aborting
@ -289,7 +289,7 @@ function renderProgress(index, total, l10n) {
window.addEventListener(
"keydown",
function(event) {
function (event) {
// Intercept Cmd/Ctrl + P in all browsers.
// Also intercept Cmd/Ctrl + Shift + P in Chrome and Opera
if (
@ -316,7 +316,7 @@ window.addEventListener(
if ("onbeforeprint" in window) {
// Do not propagate before/afterprint events when they are not triggered
// from within this polyfill. (FF /IE / Chrome 63+).
const stopPropagationIfNeeded = function(event) {
const stopPropagationIfNeeded = function (event) {
if (event.detail !== "custom" && event.stopImmediatePropagation) {
event.stopImmediatePropagation();
}

View file

@ -128,7 +128,7 @@ class PDFThumbnailView {
this._thumbPageTitle.then(msg => {
anchor.title = msg;
});
anchor.onclick = function() {
anchor.onclick = function () {
linkService.page = id;
return false;
};
@ -350,10 +350,10 @@ class PDFThumbnailView {
renderTask.onContinue = renderContinueCallback;
renderTask.promise.then(
function() {
function () {
finishRenderTask(null);
},
function(error) {
function (error) {
finishRenderTask(error);
}
);

View file

@ -102,7 +102,7 @@ class PDFThumbnailViewer {
if (pageNumber <= first || pageNumber >= last) {
shouldScroll = true;
} else {
visibleThumbs.views.some(function(view) {
visibleThumbs.views.some(function (view) {
if (view.id !== pageNumber) {
return false;
}

View file

@ -21,13 +21,13 @@ function getDefaultPreferences() {
PDFJSDev.json("$ROOT/build/default_preferences.json")
);
} else {
defaultPreferences = new Promise(function(resolve, reject) {
defaultPreferences = new Promise(function (resolve, reject) {
if (typeof SystemJS === "object") {
SystemJS.import("./app_options.js").then(resolve, reject);
} else {
reject(new Error("SystemJS must be used to load AppOptions."));
}
}).then(function({ AppOptions, OptionKind }) {
}).then(function ({ AppOptions, OptionKind }) {
return AppOptions.getAll(OptionKind.PREFERENCE);
});
}

View file

@ -233,7 +233,7 @@ class SecondaryToolbar {
}
_bindCursorToolsListener(buttons) {
this.eventBus._on("cursortoolchanged", function({ tool }) {
this.eventBus._on("cursortoolchanged", function ({ tool }) {
buttons.cursorSelectToolButton.classList.toggle(
"toggled",
tool === CursorTool.SELECT
@ -340,8 +340,9 @@ class SecondaryToolbar {
if (this.containerHeight === this.previousContainerHeight) {
return;
}
this.toolbarButtonContainer.style.maxHeight = `${this.containerHeight -
SCROLLBAR_PADDING}px`;
this.toolbarButtonContainer.style.maxHeight = `${
this.containerHeight - SCROLLBAR_PADDING
}px`;
this.previousContainerHeight = this.containerHeight;
}

View file

@ -111,7 +111,7 @@ class TextLayerBuilder {
this._finishRendering();
this._updateMatches();
},
function(reason) {
function (reason) {
// Cancelled or failed to render text layer; skipping errors.
}
);

View file

@ -137,17 +137,17 @@ class Toolbar {
});
}
// The non-button elements within the toolbar.
pageNumber.addEventListener("click", function() {
pageNumber.addEventListener("click", function () {
this.select();
});
pageNumber.addEventListener("change", function() {
pageNumber.addEventListener("change", function () {
self.eventBus.dispatch("pagenumberchanged", {
source: self,
value: this.value,
});
});
scaleSelect.addEventListener("change", function() {
scaleSelect.addEventListener("change", function () {
if (this.value === "custom") {
return;
}

View file

@ -164,7 +164,7 @@ function scrollIntoView(element, spot, skipOverflowHiddenElements = false) {
* PDF.js friendly one: with scroll debounce and scroll direction.
*/
function watchScroll(viewAreaElement, callback) {
const debounceScroll = function(evt) {
const debounceScroll = function (evt) {
if (rAF) {
return;
}
@ -564,7 +564,7 @@ function getVisibleElements(
last = visible[visible.length - 1];
if (sortByVisibility) {
visible.sort(function(a, b) {
visible.sort(function (a, b) {
const pc = a.percent - b.percent;
if (Math.abs(pc) > 0.001) {
return -pc;
@ -705,7 +705,7 @@ const WaitOnType = {
* @returns {Promise} A promise that is resolved with a {WaitOnType} value.
*/
function waitOnEventOrTimeout({ target, name, delay = 0 }) {
return new Promise(function(resolve, reject) {
return new Promise(function (resolve, reject) {
if (
typeof target !== "object" ||
!(name && typeof name === "string") ||
@ -742,7 +742,7 @@ function waitOnEventOrTimeout({ target, name, delay = 0 }) {
/**
* Promise that is resolved when DOM window becomes visible.
*/
const animationStarted = new Promise(function(resolve) {
const animationStarted = new Promise(function (resolve) {
if (
typeof PDFJSDev !== "undefined" &&
PDFJSDev.test("LIB && TESTING") &&
@ -828,7 +828,7 @@ class EventBus {
let externalListeners;
// Making copy of the listeners array in case if it will be modified
// during dispatch.
eventListeners.slice(0).forEach(function({ listener, external }) {
eventListeners.slice(0).forEach(function ({ listener, external }) {
if (external) {
if (!externalListeners) {
externalListeners = [];
@ -841,7 +841,7 @@ class EventBus {
// Dispatch any "external" listeners *after* the internal ones, to give the
// viewer components time to handle events and update their state first.
if (externalListeners) {
externalListeners.forEach(function(listener) {
externalListeners.forEach(function (listener) {
listener.apply(null, args);
});
externalListeners = null;

View file

@ -193,7 +193,7 @@ function webViewerLoad() {
SystemJS.import("pdfjs-web/app_options.js"),
SystemJS.import("pdfjs-web/genericcom.js"),
SystemJS.import("pdfjs-web/pdf_print_service.js"),
]).then(function([app, appOptions, ...otherModules]) {
]).then(function ([app, appOptions, ...otherModules]) {
window.PDFViewerApplication = app.PDFViewerApplication;
window.PDFViewerApplicationOptions = appOptions.AppOptions;
app.PDFViewerApplication.run(config);