Move apiPageLayoutToSpreadMode
and apiPageModeToSidebarView
from web/app.js
and into web/ui_utils.js
These changes will be necessary for the next patch, since we don't want to accidentally pull in the entire default viewer in the standalone viewer components.
This commit is contained in:
parent
583d77a53f
commit
5b9638329c
49
web/app.js
49
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: {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user