diff --git a/web/app.js b/web/app.js index 8cefd7e56..ff1722148 100644 --- a/web/app.js +++ b/web/app.js @@ -16,6 +16,8 @@ import { animationStarted, + apiPageLayoutToSpreadMode, + apiPageModeToSidebarView, AutoPrintRegExp, DEFAULT_SCALE_VALUE, EventBus, @@ -3350,53 +3352,6 @@ function beforeUnload(evt) { return false; } -/** - * Converts API PageLayout values to the format used by `PDFViewer`. - * NOTE: This is supported to the extent that the viewer implements the - * necessary Scroll/Spread modes (since SinglePage, TwoPageLeft, - * and TwoPageRight all suggests using non-continuous scrolling). - * @param {string} mode - The API PageLayout value. - * @returns {number} A value from {SpreadMode}. - */ -function apiPageLayoutToSpreadMode(layout) { - switch (layout) { - case "SinglePage": - case "OneColumn": - return SpreadMode.NONE; - case "TwoColumnLeft": - case "TwoPageLeft": - return SpreadMode.ODD; - case "TwoColumnRight": - case "TwoPageRight": - return SpreadMode.EVEN; - } - return SpreadMode.NONE; // Default value. -} - -/** - * Converts API PageMode values to the format used by `PDFSidebar`. - * NOTE: There's also a "FullScreen" parameter which is not possible to support, - * since the Fullscreen API used in browsers requires that entering - * fullscreen mode only occurs as a result of a user-initiated event. - * @param {string} mode - The API PageMode value. - * @returns {number} A value from {SidebarView}. - */ -function apiPageModeToSidebarView(mode) { - switch (mode) { - case "UseNone": - return SidebarView.NONE; - case "UseThumbs": - return SidebarView.THUMBS; - case "UseOutlines": - return SidebarView.OUTLINE; - case "UseAttachments": - return SidebarView.ATTACHMENTS; - case "UseOC": - return SidebarView.LAYERS; - } - return SidebarView.NONE; // Default value. -} - /* Abstract factory for the print service. */ const PDFPrintServiceFactory = { instance: { diff --git a/web/ui_utils.js b/web/ui_utils.js index addfb90f9..c90bfd428 100644 --- a/web/ui_utils.js +++ b/web/ui_utils.js @@ -1001,8 +1001,57 @@ function getActiveOrFocusedElement() { return curActiveOrFocused; } +/** + * Converts API PageLayout values to the format used by `BaseViewer`. + * NOTE: This is supported to the extent that the viewer implements the + * necessary Scroll/Spread modes (since SinglePage, TwoPageLeft, + * and TwoPageRight all suggests using non-continuous scrolling). + * @param {string} mode - The API PageLayout value. + * @returns {number} A value from {SpreadMode}. + */ +function apiPageLayoutToSpreadMode(layout) { + switch (layout) { + case "SinglePage": + case "OneColumn": + return SpreadMode.NONE; + case "TwoColumnLeft": + case "TwoPageLeft": + return SpreadMode.ODD; + case "TwoColumnRight": + case "TwoPageRight": + return SpreadMode.EVEN; + } + return SpreadMode.NONE; // Default value. +} + +/** + * Converts API PageMode values to the format used by `PDFSidebar`. + * NOTE: There's also a "FullScreen" parameter which is not possible to support, + * since the Fullscreen API used in browsers requires that entering + * fullscreen mode only occurs as a result of a user-initiated event. + * @param {string} mode - The API PageMode value. + * @returns {number} A value from {SidebarView}. + */ +function apiPageModeToSidebarView(mode) { + switch (mode) { + case "UseNone": + return SidebarView.NONE; + case "UseThumbs": + return SidebarView.THUMBS; + case "UseOutlines": + return SidebarView.OUTLINE; + case "UseAttachments": + return SidebarView.ATTACHMENTS; + case "UseOC": + return SidebarView.LAYERS; + } + return SidebarView.NONE; // Default value. +} + export { animationStarted, + apiPageLayoutToSpreadMode, + apiPageModeToSidebarView, approximateFraction, AutoPrintRegExp, backtrackBeforeAllVisibleElements, // only exported for testing