@ -14,65 +14,55 @@
@@ -14,65 +14,55 @@
* /
'use strict' ;
var uiUtilsLib = require ( './ui_utils.js' ) ;
var downloadManagerLib = require ( './download_manager.js' ) ;
var pdfHistoryLib = require ( './pdf_history.js' ) ;
var preferencesLib = require ( './preferences.js' ) ;
var pdfSidebarLib = require ( './pdf_sidebar.js' ) ;
var viewHistoryLib = require ( './view_history.js' ) ;
var pdfThumbnailViewerLib = require ( './pdf_thumbnail_viewer.js' ) ;
var toolbarLib = require ( './toolbar.js' ) ;
var secondaryToolbarLib = require ( './secondary_toolbar.js' ) ;
var passwordPromptLib = require ( './password_prompt.js' ) ;
var pdfPresentationModeLib = require ( './pdf_presentation_mode.js' ) ;
var pdfDocumentPropertiesLib = require ( './pdf_document_properties.js' ) ;
var handToolLib = require ( './hand_tool.js' ) ;
var pdfViewerLib = require ( './pdf_viewer.js' ) ;
var pdfRenderingQueueLib = require ( './pdf_rendering_queue.js' ) ;
var pdfLinkServiceLib = require ( './pdf_link_service.js' ) ;
var pdfOutlineViewerLib = require ( './pdf_outline_viewer.js' ) ;
var overlayManagerLib = require ( './overlay_manager.js' ) ;
var pdfAttachmentViewerLib = require ( './pdf_attachment_viewer.js' ) ;
var pdfFindControllerLib = require ( './pdf_find_controller.js' ) ;
var pdfFindBarLib = require ( './pdf_find_bar.js' ) ;
var domEventsLib = require ( './dom_events.js' ) ;
var pdfjsLib = require ( './pdfjs.js' ) ;
var UNKNOWN _SCALE = uiUtilsLib . UNKNOWN _SCALE ;
var DEFAULT _SCALE _VALUE = uiUtilsLib . DEFAULT _SCALE _VALUE ;
var MIN _SCALE = uiUtilsLib . MIN _SCALE ;
var MAX _SCALE = uiUtilsLib . MAX _SCALE ;
var ProgressBar = uiUtilsLib . ProgressBar ;
var getPDFFileNameFromURL = uiUtilsLib . getPDFFileNameFromURL ;
var noContextMenuHandler = uiUtilsLib . noContextMenuHandler ;
var mozL10n = uiUtilsLib . mozL10n ;
var parseQueryString = uiUtilsLib . parseQueryString ;
var PDFHistory = pdfHistoryLib . PDFHistory ;
var Preferences = preferencesLib . Preferences ;
var SidebarView = pdfSidebarLib . SidebarView ;
var PDFSidebar = pdfSidebarLib . PDFSidebar ;
var ViewHistory = viewHistoryLib . ViewHistory ;
var PDFThumbnailViewer = pdfThumbnailViewerLib . PDFThumbnailViewer ;
var Toolbar = toolbarLib . Toolbar ;
var SecondaryToolbar = secondaryToolbarLib . SecondaryToolbar ;
var PasswordPrompt = passwordPromptLib . PasswordPrompt ;
var PDFPresentationMode = pdfPresentationModeLib . PDFPresentationMode ;
var PDFDocumentProperties = pdfDocumentPropertiesLib . PDFDocumentProperties ;
var HandTool = handToolLib . HandTool ;
var PresentationModeState = pdfViewerLib . PresentationModeState ;
var PDFViewer = pdfViewerLib . PDFViewer ;
var RenderingStates = pdfRenderingQueueLib . RenderingStates ;
var PDFRenderingQueue = pdfRenderingQueueLib . PDFRenderingQueue ;
var PDFLinkService = pdfLinkServiceLib . PDFLinkService ;
var PDFOutlineViewer = pdfOutlineViewerLib . PDFOutlineViewer ;
var OverlayManager = overlayManagerLib . OverlayManager ;
var PDFAttachmentViewer = pdfAttachmentViewerLib . PDFAttachmentViewer ;
var PDFFindController = pdfFindControllerLib . PDFFindController ;
var PDFFindBar = pdfFindBarLib . PDFFindBar ;
var getGlobalEventBus = domEventsLib . getGlobalEventBus ;
var normalizeWheelEventDelta = uiUtilsLib . normalizeWheelEventDelta ;
var animationStarted = uiUtilsLib . animationStarted ;
var localized = uiUtilsLib . localized ;
var RendererType = uiUtilsLib . RendererType ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . PDFPrintServiceFactory = exports . DefaultExternalServices = exports . PDFViewerApplication = undefined ;
var _ui _utils = require ( 'pdfjs-web/ui_utils' ) ;
var _pdfjs = require ( 'pdfjs-web/pdfjs' ) ;
var _pdf _rendering _queue = require ( 'pdfjs-web/pdf_rendering_queue' ) ;
var _pdf _sidebar = require ( 'pdfjs-web/pdf_sidebar' ) ;
var _pdf _viewer = require ( 'pdfjs-web/pdf_viewer' ) ;
var _dom _events = require ( 'pdfjs-web/dom_events' ) ;
var _hand _tool = require ( 'pdfjs-web/hand_tool' ) ;
var _overlay _manager = require ( 'pdfjs-web/overlay_manager' ) ;
var _password _prompt = require ( 'pdfjs-web/password_prompt' ) ;
var _pdf _attachment _viewer = require ( 'pdfjs-web/pdf_attachment_viewer' ) ;
var _pdf _document _properties = require ( 'pdfjs-web/pdf_document_properties' ) ;
var _pdf _find _bar = require ( 'pdfjs-web/pdf_find_bar' ) ;
var _pdf _find _controller = require ( 'pdfjs-web/pdf_find_controller' ) ;
var _pdf _history = require ( 'pdfjs-web/pdf_history' ) ;
var _pdf _link _service = require ( 'pdfjs-web/pdf_link_service' ) ;
var _pdf _outline _viewer = require ( 'pdfjs-web/pdf_outline_viewer' ) ;
var _pdf _presentation _mode = require ( 'pdfjs-web/pdf_presentation_mode' ) ;
var _pdf _thumbnail _viewer = require ( 'pdfjs-web/pdf_thumbnail_viewer' ) ;
var _preferences = require ( 'pdfjs-web/preferences' ) ;
var _secondary _toolbar = require ( 'pdfjs-web/secondary_toolbar' ) ;
var _toolbar = require ( 'pdfjs-web/toolbar' ) ;
var _view _history = require ( 'pdfjs-web/view_history' ) ;
var DEFAULT _SCALE _DELTA = 1.1 ;
var DISABLE _AUTO _FETCH _LOADING _BAR _TIMEOUT = 5000 ;
function configure ( PDFJS ) {
@ -81,13 +71,13 @@ function configure(PDFJS) {
@@ -81,13 +71,13 @@ function configure(PDFJS) {
PDFJS . cMapUrl = '../web/cmaps/' ;
PDFJS . cMapPacked = true ;
}
var DefaultExernalServices = {
var DefaultExt ernalServices = {
updateFindControlState : function ( data ) { } ,
initPassiveLoading : function ( callbacks ) { } ,
fallback : function ( data , callback ) { } ,
reportTelemetry : function ( data ) { } ,
createDownloadManager : function ( ) {
return new downloadManagerLib . DownloadManager ( ) ;
throw new Error ( 'Not implemented: createDownloadManager' ) ;
} ,
supportsIntegratedFind : false ,
supportsDocumentFonts : true ,
@ -124,7 +114,7 @@ var PDFViewerApplication = {
@@ -124,7 +114,7 @@ var PDFViewerApplication = {
pageRotation : 0 ,
isInitialViewSet : false ,
viewerPrefs : {
sidebarViewOnLoad : SidebarView . NONE ,
sidebarViewOnLoad : _pdf _sidebar . SidebarView . NONE ,
pdfBugEnabled : false ,
showPreviousViewOnLoad : true ,
defaultZoomValue : '' ,
@ -137,79 +127,77 @@ var PDFViewerApplication = {
@@ -137,79 +127,77 @@ var PDFViewerApplication = {
isViewerEmbedded : window . parent !== window ,
url : '' ,
baseUrl : '' ,
externalServices : DefaultExernalServices ,
externalServices : DefaultExt ernalServices ,
initialize : function pdfViewInitialize ( appConfig ) {
var self = this ;
var PDFJS = pdfjsLib . PDFJS ;
Preferences . initialize ( ) ;
this . preferences = Preferences ;
configure ( PDFJS ) ;
_preferences . Preferences . initialize ( ) ;
this . preferences = _preferences . Preferences ;
configure ( _pdfjs . PDFJS ) ;
this . appConfig = appConfig ;
return this . _readPreferences ( ) . then ( function ( ) {
return self . _initializeViewerComponents ( ) ;
} ) . then ( function ( ) {
self . bindEvents ( ) ;
self . bindWindowEvents ( ) ;
localized . then ( function ( ) {
_ui _utils . localized . then ( function ( ) {
self . eventBus . dispatch ( 'localized' ) ;
} ) ;
if ( self . isViewerEmbedded && ! PDFJS . isExternalLinkTargetSet ( ) ) {
PDFJS . externalLinkTarget = PDFJS . LinkTarget . TOP ;
if ( self . isViewerEmbedded && ! _pdfjs . PDFJS . isExternalLinkTargetSet ( ) ) {
_pdfjs . PDFJS . externalLinkTarget = _pdfjs . PDFJS . LinkTarget . TOP ;
}
self . initialized = true ;
} ) ;
} ,
_readPreferences : function ( ) {
var self = this ;
var PDFJS = pdfjsLib . PDFJS ;
return Promise . all ( [ Preferences . get ( 'enableWebGL' ) . then ( function resolved ( value ) {
PDFJS . disableWebGL = ! value ;
} ) , Preferences . get ( 'sidebarViewOnLoad' ) . then ( function resolved ( value ) {
return Promise . all ( [ _preferences . Preferences . get ( 'enableWebGL' ) . then ( function resolved ( value ) {
_pdfjs . PDFJS . disableWebGL = ! value ;
} ) , _preferences . Preferences . get ( 'sidebarViewOnLoad' ) . then ( function resolved ( value ) {
self . viewerPrefs [ 'sidebarViewOnLoad' ] = value ;
} ) , Preferences . get ( 'pdfBugEnabled' ) . then ( function resolved ( value ) {
} ) , _preferences . Preferences . get ( 'pdfBugEnabled' ) . then ( function resolved ( value ) {
self . viewerPrefs [ 'pdfBugEnabled' ] = value ;
} ) , Preferences . get ( 'showPreviousViewOnLoad' ) . then ( function resolved ( value ) {
} ) , _preferences . Preferences . get ( 'showPreviousViewOnLoad' ) . then ( function resolved ( value ) {
self . viewerPrefs [ 'showPreviousViewOnLoad' ] = value ;
} ) , Preferences . get ( 'defaultZoomValue' ) . then ( function resolved ( value ) {
} ) , _preferences . Preferences . get ( 'defaultZoomValue' ) . then ( function resolved ( value ) {
self . viewerPrefs [ 'defaultZoomValue' ] = value ;
} ) , Preferences . get ( 'enhanceTextSelection' ) . then ( function resolved ( value ) {
} ) , _preferences . Preferences . get ( 'enhanceTextSelection' ) . then ( function resolved ( value ) {
self . viewerPrefs [ 'enhanceTextSelection' ] = value ;
} ) , Preferences . get ( 'disableTextLayer' ) . then ( function resolved ( value ) {
if ( PDFJS . disableTextLayer === true ) {
} ) , _preferences . Preferences . get ( 'disableTextLayer' ) . then ( function resolved ( value ) {
if ( _pdfjs . PDFJS . disableTextLayer === true ) {
return ;
}
PDFJS . disableTextLayer = value ;
} ) , Preferences . get ( 'disableRange' ) . then ( function resolved ( value ) {
if ( PDFJS . disableRange === true ) {
_pdfjs . PDFJS . disableTextLayer = value ;
} ) , _preferences . Preferences . get ( 'disableRange' ) . then ( function resolved ( value ) {
if ( _pdfjs . PDFJS . disableRange === true ) {
return ;
}
PDFJS . disableRange = value ;
} ) , Preferences . get ( 'disableStream' ) . then ( function resolved ( value ) {
if ( PDFJS . disableStream === true ) {
_pdfjs . PDFJS . disableRange = value ;
} ) , _preferences . Preferences . get ( 'disableStream' ) . then ( function resolved ( value ) {
if ( _pdfjs . 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 ) {
_pdfjs . PDFJS . disableStream = value ;
} ) , _preferences . Preferences . get ( 'disableAutoFetch' ) . then ( function resolved ( value ) {
_pdfjs . PDFJS . disableAutoFetch = value ;
} ) , _preferences . Preferences . get ( 'disableFontFace' ) . then ( function resolved ( value ) {
if ( _pdfjs . 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 ( ) ) {
_pdfjs . PDFJS . disableFontFace = value ;
} ) , _preferences . Preferences . get ( 'useOnlyCssZoom' ) . then ( function resolved ( value ) {
_pdfjs . PDFJS . useOnlyCssZoom = value ;
} ) , _preferences . Preferences . get ( 'externalLinkTarget' ) . then ( function resolved ( value ) {
if ( _pdfjs . PDFJS . isExternalLinkTargetSet ( ) ) {
return ;
}
PDFJS . externalLinkTarget = value ;
} ) , Preferences . get ( 'renderer' ) . then ( function resolved ( value ) {
_pdfjs . PDFJS . externalLinkTarget = value ;
} ) , _preferences . Preferences . get ( 'renderer' ) . then ( function resolved ( value ) {
self . viewerPrefs [ 'renderer' ] = value ;
} ) , Preferences . get ( 'renderInteractiveForms' ) . then ( function resolved ( value ) {
} ) , _preferences . Preferences . get ( 'renderInteractiveForms' ) . then ( function resolved ( value ) {
self . viewerPrefs [ 'renderInteractiveForms' ] = value ;
} ) , Preferences . get ( 'disablePageLabels' ) . then ( function resolved ( value ) {
} ) , _preferences . Preferences . get ( 'disablePageLabels' ) . then ( function resolved ( value ) {
self . viewerPrefs [ 'disablePageLabels' ] = value ;
} ) , Preferences . get ( 'enablePrintAutoRotate' ) . then ( function resolved ( value ) {
} ) , _preferences . Preferences . get ( 'enablePrintAutoRotate' ) . then ( function resolved ( value ) {
self . viewerPrefs [ 'enablePrintAutoRotate' ] = value ;
} ) ] ) . catch ( function ( reason ) { } ) ;
} ,
@ -217,18 +205,18 @@ var PDFViewerApplication = {
@@ -217,18 +205,18 @@ var PDFViewerApplication = {
var self = this ;
var appConfig = this . appConfig ;
return new Promise ( function ( resolve , reject ) {
var eventBus = appConfig . eventBus || getGlobalEventBus ( ) ;
var eventBus = appConfig . eventBus || ( 0 , _dom _events . getGlobalEventBus ) ( ) ;
self . eventBus = eventBus ;
var pdfRenderingQueue = new PDFRenderingQueue ( ) ;
var pdfRenderingQueue = new _pdf _rendering _queue . PDFRenderingQueue ( ) ;
pdfRenderingQueue . onIdle = self . cleanup . bind ( self ) ;
self . pdfRenderingQueue = pdfRenderingQueue ;
var pdfLinkService = new PDFLinkService ( { eventBus : eventBus } ) ;
var pdfLinkService = new _pdf _link _service . PDFLinkService ( { eventBus : eventBus } ) ;
self . pdfLinkService = pdfLinkService ;
var downloadManager = self . externalServices . createDownloadManager ( ) ;
self . downloadManager = downloadManager ;
var container = appConfig . mainContainer ;
var viewer = appConfig . viewerContainer ;
self . pdfViewer = new PDFViewer ( {
self . pdfViewer = new _pdf _viewer . PDFViewer ( {
container : container ,
viewer : viewer ,
eventBus : eventBus ,
@ -243,18 +231,18 @@ var PDFViewerApplication = {
@@ -243,18 +231,18 @@ var PDFViewerApplication = {
pdfRenderingQueue . setViewer ( self . pdfViewer ) ;
pdfLinkService . setViewer ( self . pdfViewer ) ;
var thumbnailContainer = appConfig . sidebar . thumbnailView ;
self . pdfThumbnailViewer = new PDFThumbnailViewer ( {
self . pdfThumbnailViewer = new _pdf _thumbnail _viewer . PDFThumbnailViewer ( {
container : thumbnailContainer ,
renderingQueue : pdfRenderingQueue ,
linkService : pdfLinkService
} ) ;
pdfRenderingQueue . setThumbnailViewer ( self . pdfThumbnailViewer ) ;
self . pdfHistory = new PDFHistory ( {
self . pdfHistory = new _pdf _history . PDFHistory ( {
linkService : pdfLinkService ,
eventBus : eventBus
} ) ;
pdfLinkService . setHistory ( self . pdfHistory ) ;
self . findController = new PDFFindController ( { pdfViewer : self . pdfViewer } ) ;
self . findController = new _pdf _find _controller . PDFFindController ( { pdfViewer : self . pdfViewer } ) ;
self . findController . onUpdateResultsCount = function ( matchCount ) {
if ( self . supportsIntegratedFind ) {
return ;
@ -275,17 +263,17 @@ var PDFViewerApplication = {
@@ -275,17 +263,17 @@ var PDFViewerApplication = {
var findBarConfig = Object . create ( appConfig . findBar ) ;
findBarConfig . findController = self . findController ;
findBarConfig . eventBus = eventBus ;
self . findBar = new PDFFindBar ( findBarConfig ) ;
self . overlayManager = OverlayManager ;
self . handTool = new HandTool ( {
self . findBar = new _pdf _find _bar . PDFFindBar ( findBarConfig ) ;
self . overlayManager = _overlay _manager . OverlayManager ;
self . handTool = new _hand _tool . HandTool ( {
container : container ,
eventBus : eventBus
} ) ;
self . pdfDocumentProperties = new PDFDocumentProperties ( appConfig . documentProperties ) ;
self . toolbar = new Toolbar ( appConfig . toolbar , container , eventBus ) ;
self . secondaryToolbar = new SecondaryToolbar ( appConfig . secondaryToolbar , container , eventBus ) ;
self . pdfDocumentProperties = new _pdf _document _properties . PDFDocumentProperties ( appConfig . documentProperties ) ;
self . toolbar = new _toolbar . Toolbar ( appConfig . toolbar , container , eventBus ) ;
self . secondaryToolbar = new _secondary _toolbar . SecondaryToolbar ( appConfig . secondaryToolbar , container , eventBus ) ;
if ( self . supportsFullscreen ) {
self . pdfPresentationMode = new PDFPresentationMode ( {
self . pdfPresentationMode = new _pdf _presentation _mode . PDFPresentationMode ( {
container : container ,
viewer : viewer ,
pdfViewer : self . pdfViewer ,
@ -293,13 +281,13 @@ var PDFViewerApplication = {
@@ -293,13 +281,13 @@ var PDFViewerApplication = {
contextMenuItems : appConfig . fullscreen
} ) ;
}
self . passwordPrompt = new PasswordPrompt ( appConfig . passwordOverlay ) ;
self . pdfOutlineViewer = new PDFOutlineViewer ( {
self . passwordPrompt = new _password _prompt . PasswordPrompt ( appConfig . passwordOverlay ) ;
self . pdfOutlineViewer = new _pdf _outline _viewer . PDFOutlineViewer ( {
container : appConfig . sidebar . outlineView ,
eventBus : eventBus ,
linkService : pdfLinkService
} ) ;
self . pdfAttachmentViewer = new PDFAttachmentViewer ( {
self . pdfAttachmentViewer = new _pdf _attachment _viewer . PDFAttachmentViewer ( {
container : appConfig . sidebar . attachmentsView ,
eventBus : eventBus ,
downloadManager : downloadManager
@ -309,7 +297,7 @@ var PDFViewerApplication = {
@@ -309,7 +297,7 @@ var PDFViewerApplication = {
sidebarConfig . pdfThumbnailViewer = self . pdfThumbnailViewer ;
sidebarConfig . pdfOutlineViewer = self . pdfOutlineViewer ;
sidebarConfig . eventBus = eventBus ;
self . pdfSidebar = new PDFSidebar ( sidebarConfig ) ;
self . pdfSidebar = new _pdf _sidebar . PDFSidebar ( sidebarConfig ) ;
self . pdfSidebar . onToggled = self . forceRendering . bind ( self ) ;
resolve ( undefined ) ;
} ) ;
@ -322,8 +310,8 @@ var PDFViewerApplication = {
@@ -322,8 +310,8 @@ var PDFViewerApplication = {
do {
newScale = ( newScale * DEFAULT _SCALE _DELTA ) . toFixed ( 2 ) ;
newScale = Math . ceil ( newScale * 10 ) / 10 ;
newScale = Math . min ( MAX _SCALE , newScale ) ;
} while ( -- ticks > 0 && newScale < MAX _SCALE ) ;
newScale = Math . min ( _ui _utils . MAX _SCALE , newScale ) ;
} while ( -- ticks > 0 && newScale < _ui _utils . MAX _SCALE ) ;
this . pdfViewer . currentScaleValue = newScale ;
} ,
zoomOut : function pdfViewZoomOut ( ticks ) {
@ -331,8 +319,8 @@ var PDFViewerApplication = {
@@ -331,8 +319,8 @@ var PDFViewerApplication = {
do {
newScale = ( newScale / DEFAULT _SCALE _DELTA ) . toFixed ( 2 ) ;
newScale = Math . floor ( newScale * 10 ) / 10 ;
newScale = Math . max ( MIN _SCALE , newScale ) ;
} while ( -- ticks > 0 && newScale > MIN _SCALE ) ;
newScale = Math . max ( _ui _utils . MIN _SCALE , newScale ) ;
} while ( -- ticks > 0 && newScale > _ui _utils . MIN _SCALE ) ;
this . pdfViewer . currentScaleValue = newScale ;
} ,
get pagesCount ( ) {
@ -357,10 +345,10 @@ var PDFViewerApplication = {
@@ -357,10 +345,10 @@ var PDFViewerApplication = {
if ( document . fullscreenEnabled === false || document . mozFullScreenEnabled === false || document . webkitFullscreenEnabled === false || document . msFullscreenEnabled === false ) {
support = false ;
}
if ( support && pdfjsLib . PDFJS . disableFullscreen === true ) {
if ( support && _ pdfjs. PDFJS . disableFullscreen === true ) {
support = false ;
}
return pdfjsLib . shadow ( this , 'supportsFullscreen' , support ) ;
return ( 0 , _ pdfjs. shadow ) ( this , 'supportsFullscreen' , support ) ;
} ,
get supportsIntegratedFind ( ) {
return this . externalServices . supportsIntegratedFind ;
@ -372,8 +360,8 @@ var PDFViewerApplication = {
@@ -372,8 +360,8 @@ var PDFViewerApplication = {
return this . externalServices . supportsDocumentColors ;
} ,
get loadingBar ( ) {
var bar = new ProgressBar ( '#loadingBar' , { } ) ;
return pdfjsLib . shadow ( this , 'loadingBar' , bar ) ;
var bar = new _ui _utils . ProgressBar ( '#loadingBar' , { } ) ;
return ( 0 , _ pdfjs. shadow ) ( this , 'loadingBar' , bar ) ;
} ,
get supportedMouseWheelZoomModifierKeys ( ) {
return this . externalServices . supportedMouseWheelZoomModifierKeys ;
@ -384,10 +372,10 @@ var PDFViewerApplication = {
@@ -384,10 +372,10 @@ var PDFViewerApplication = {
setTitleUsingUrl : function pdfViewSetTitleUsingUrl ( url ) {
this . url = url ;
this . baseUrl = url . split ( '#' ) [ 0 ] ;
var title = getPDFFileNameFromURL ( url , '' ) ;
var title = ( 0 , _ui _utils . getPDFFileNameFromURL ) ( url , '' ) ;
if ( ! title ) {
try {
title = decodeURIComponent ( pdfjsLib . getFilenameFromUrl ( url ) ) || url ;
title = decodeURIComponent ( ( 0 , _ pdfjs. getFilenameFromUrl ) ( url ) ) || url ;
} catch ( e ) {
title = url ;
}
@ -434,7 +422,7 @@ var PDFViewerApplication = {
@@ -434,7 +422,7 @@ var PDFViewerApplication = {
}
if ( this . pdfLoadingTask ) {
return this . close ( ) . then ( function ( ) {
Preferences . reload ( ) ;
_preferences . Preferences . reload ( ) ;
return this . open ( file , args ) ;
} . bind ( this ) ) ;
}
@ -462,7 +450,7 @@ var PDFViewerApplication = {
@@ -462,7 +450,7 @@ var PDFViewerApplication = {
}
var self = this ;
self . downloadComplete = false ;
var loadingTask = pdfjsLib . getDocument ( parameters ) ;
var loadingTask = ( 0 , _ pdfjs. getDocument ) ( parameters ) ;
this . pdfLoadingTask = loadingTask ;
loadingTask . onPassword = function passwordNeeded ( updateCallback , reason ) {
self . passwordPrompt . setUpdateCallback ( updateCallback , reason ) ;
@ -476,13 +464,13 @@ var PDFViewerApplication = {
@@ -476,13 +464,13 @@ var PDFViewerApplication = {
self . load ( pdfDocument , scale ) ;
} , function getDocumentError ( exception ) {
var message = exception && exception . message ;
var loadingErrorMessage = mozL10n . get ( 'loading_error' , null , 'An error occurred while loading the PDF.' ) ;
if ( exception instanceof pdfjsLib . InvalidPDFException ) {
loadingErrorMessage = mozL10n . get ( 'invalid_file_error' , null , 'Invalid or corrupted PDF file.' ) ;
} else if ( exception instanceof pdfjsLib . MissingPDFException ) {
loadingErrorMessage = mozL10n . get ( 'missing_file_error' , null , 'Missing PDF file.' ) ;
} else if ( exception instanceof pdfjsLib . UnexpectedResponseException ) {
loadingErrorMessage = mozL10n . get ( 'unexpected_response_error' , null , 'Unexpected server response.' ) ;
var loadingErrorMessage = _ui _utils . mozL10n . get ( 'loading_error' , null , 'An error occurred while loading the PDF.' ) ;
if ( exception instanceof _ pdfjs. InvalidPDFException ) {
loadingErrorMessage = _ui _utils . mozL10n . get ( 'invalid_file_error' , null , 'Invalid or corrupted PDF file.' ) ;
} else if ( exception instanceof _ pdfjs. MissingPDFException ) {
loadingErrorMessage = _ui _utils . mozL10n . get ( 'missing_file_error' , null , 'Missing PDF file.' ) ;
} else if ( exception instanceof _ pdfjs. UnexpectedResponseException ) {
loadingErrorMessage = _ui _utils . mozL10n . get ( 'unexpected_response_error' , null , 'Unexpected server response.' ) ;
}
var moreInfo = { message : message } ;
self . error ( loadingErrorMessage , moreInfo ) ;
@ -494,7 +482,7 @@ var PDFViewerApplication = {
@@ -494,7 +482,7 @@ var PDFViewerApplication = {
downloadManager . downloadUrl ( url , filename ) ;
}
var url = this . baseUrl ;
var filename = getPDFFileNameFromURL ( this . url ) ;
var filename = ( 0 , _ui _utils . getPDFFileNameFromURL ) ( this . url ) ;
var downloadManager = this . downloadManager ;
downloadManager . onerror = function ( err ) {
PDFViewerApplication . error ( 'PDF failed to download.' ) ;
@ -508,26 +496,26 @@ var PDFViewerApplication = {
@@ -508,26 +496,26 @@ var PDFViewerApplication = {
return ;
}
this . pdfDocument . getData ( ) . then ( function getDataSuccess ( data ) {
var blob = pdfjsLib . createBlob ( data , 'application/pdf' ) ;
var blob = ( 0 , _ pdfjs. createBlob ) ( data , 'application/pdf' ) ;
downloadManager . download ( blob , url , filename ) ;
} , downloadByUrl ) . then ( null , downloadByUrl ) ;
} ,
fallback : function pdfViewFallback ( featureId ) { } ,
error : function pdfViewError ( message , moreInfo ) {
var moreInfoText = mozL10n . get ( 'error_version_info' , {
version : pdfjsLib . version || '?' ,
build : pdfjsLib . build || '?'
var moreInfoText = _ui _utils . mozL10n . get ( 'error_version_info' , {
version : _ pdfjs. version || '?' ,
build : _ pdfjs. build || '?'
} , 'PDF.js v{{version}} (build: {{build}})' ) + '\n' ;
if ( moreInfo ) {
moreInfoText += mozL10n . get ( 'error_message' , { message : moreInfo . message } , 'Message: {{message}}' ) ;
moreInfoText += _ui _utils . mozL10n . get ( 'error_message' , { message : moreInfo . message } , 'Message: {{message}}' ) ;
if ( moreInfo . stack ) {
moreInfoText += '\n' + mozL10n . get ( 'error_stack' , { stack : moreInfo . stack } , 'Stack: {{stack}}' ) ;
moreInfoText += '\n' + _ui _utils . mozL10n . get ( 'error_stack' , { stack : moreInfo . stack } , 'Stack: {{stack}}' ) ;
} else {
if ( moreInfo . filename ) {
moreInfoText += '\n' + mozL10n . get ( 'error_file' , { file : moreInfo . filename } , 'File: {{file}}' ) ;
moreInfoText += '\n' + _ui _utils . mozL10n . get ( 'error_file' , { file : moreInfo . filename } , 'File: {{file}}' ) ;
}
if ( moreInfo . lineNumber ) {
moreInfoText += '\n' + mozL10n . get ( 'error_line' , { line : moreInfo . lineNumber } , 'Line: {{line}}' ) ;
moreInfoText += '\n' + _ui _utils . mozL10n . get ( 'error_line' , { line : moreInfo . lineNumber } , 'Line: {{line}}' ) ;
}
}
}
@ -554,9 +542,9 @@ var PDFViewerApplication = {
@@ -554,9 +542,9 @@ var PDFViewerApplication = {
moreInfoButton . removeAttribute ( 'hidden' ) ;
lessInfoButton . setAttribute ( 'hidden' , 'true' ) ;
} ;
moreInfoButton . oncontextmenu = noContextMenuHandler ;
lessInfoButton . oncontextmenu = noContextMenuHandler ;
closeButton . oncontextmenu = noContextMenuHandler ;
moreInfoButton . oncontextmenu = _ui _utils . noContextMenuHandler ;
lessInfoButton . oncontextmenu = _ui _utils . noContextMenuHandler ;
closeButton . oncontextmenu = _ui _utils . noContextMenuHandler ;
moreInfoButton . removeAttribute ( 'hidden' ) ;
lessInfoButton . setAttribute ( 'hidden' , 'true' ) ;
errorMoreInfo . value = moreInfoText ;
@ -565,7 +553,7 @@ var PDFViewerApplication = {
@@ -565,7 +553,7 @@ var PDFViewerApplication = {
var percent = Math . round ( level * 100 ) ;
if ( percent > this . loadingBar . percent || isNaN ( percent ) ) {
this . loadingBar . percent = percent ;
if ( pdfjsLib . PDFJS . disableAutoFetch && percent ) {
if ( _ pdfjs. PDFJS . disableAutoFetch && percent ) {
if ( this . disableAutoFetchLoadingBarTimeout ) {
clearTimeout ( this . disableAutoFetchLoadingBarTimeout ) ;
this . disableAutoFetchLoadingBarTimeout = null ;
@ -580,7 +568,7 @@ var PDFViewerApplication = {
@@ -580,7 +568,7 @@ var PDFViewerApplication = {
} ,
load : function pdfViewLoad ( pdfDocument , scale ) {
var self = this ;
scale = scale || UNKNOWN _SCALE ;
scale = scale || _ui _utils . UNKNOWN _SCALE ;
this . pdfDocument = pdfDocument ;
this . pdfDocumentProperties . setDocumentAndUrl ( pdfDocument , this . url ) ;
var downloadedPromise = pdfDocument . getDownloadInfo ( ) . then ( function ( ) {
@ -590,7 +578,7 @@ var PDFViewerApplication = {
@@ -590,7 +578,7 @@ var PDFViewerApplication = {
this . toolbar . setPagesCount ( pdfDocument . numPages , false ) ;
this . secondaryToolbar . setPagesCount ( pdfDocument . numPages ) ;
var id = this . documentFingerprint = pdfDocument . fingerprint ;
var store = this . store = new ViewHistory ( id ) ;
var store = this . store = new _view _history . ViewHistory ( id ) ;
var baseDocumentUrl ;
baseDocumentUrl = null ;
this . pdfLinkService . setDocument ( pdfDocument , baseDocumentUrl ) ;
@ -608,7 +596,7 @@ var PDFViewerApplication = {
@@ -608,7 +596,7 @@ var PDFViewerApplication = {
self . eventBus . dispatch ( 'documentload' , { source : self } ) ;
} ) ;
self . loadingBar . setWidth ( self . appConfig . viewerContainer ) ;
if ( ! pdfjsLib . PDFJS . disableHistory && ! self . isViewerEmbedded ) {
if ( ! _ pdfjs. PDFJS . disableHistory && ! self . isViewerEmbedded ) {
if ( ! self . viewerPrefs [ 'showPreviousViewOnLoad' ] ) {
self . pdfHistory . clearHistoryState ( ) ;
}
@ -629,11 +617,11 @@ var PDFViewerApplication = {
@@ -629,11 +617,11 @@ var PDFViewerApplication = {
sidebarView = null ;
if ( self . viewerPrefs [ 'showPreviousViewOnLoad' ] && store . get ( 'exists' , false ) ) {
var pageNum = store . get ( 'page' , '1' ) ;
var zoom = self . viewerPrefs [ 'defaultZoomValue' ] || store . get ( 'zoom' , DEFAULT _SCALE _VALUE ) ;
var zoom = self . viewerPrefs [ 'defaultZoomValue' ] || store . get ( 'zoom' , _ui _utils . DEFAULT _SCALE _VALUE ) ;
var left = store . get ( 'scrollLeft' , '0' ) ;
var top = store . get ( 'scrollTop' , '0' ) ;
storedHash = 'page=' + pageNum + '&zoom=' + zoom + ',' + left + ',' + top ;
sidebarView = store . get ( 'sidebarView' , SidebarView . NONE ) ;
sidebarView = store . get ( 'sidebarView' , _pdf _sidebar . SidebarView . NONE ) ;
} else if ( self . viewerPrefs [ 'defaultZoomValue' ] ) {
storedHash = 'page=1&zoom=' + self . viewerPrefs [ 'defaultZoomValue' ] ;
}
@ -688,7 +676,7 @@ var PDFViewerApplication = {
@@ -688,7 +676,7 @@ var PDFViewerApplication = {
pdfDocument . getJavaScript ( ) . then ( function ( javaScript ) {
if ( javaScript . length ) {
console . warn ( 'Warning: JavaScript is not supported' ) ;
self . fallback ( pdfjsLib . UNSUPPORTED _FEATURES . javaScript ) ;
self . fallback ( _ pdfjs. UNSUPPORTED _FEATURES . javaScript ) ;
}
var regex = /\bprint\s*\(/ ;
for ( var i = 0 , ii = javaScript . length ; i < ii ; i ++ ) {
@ -703,7 +691,7 @@ var PDFViewerApplication = {
@@ -703,7 +691,7 @@ var PDFViewerApplication = {
} ) ;
}
} ) ;
Promise . all ( [ onePageRendered , animationStarted ] ) . then ( function ( ) {
Promise . all ( [ onePageRendered , _ui _utils . animationStarted ] ) . then ( function ( ) {
pdfDocument . getOutline ( ) . then ( function ( outline ) {
self . pdfOutlineViewer . render ( { outline : outline } ) ;
} ) ;
@ -716,7 +704,7 @@ var PDFViewerApplication = {
@@ -716,7 +704,7 @@ var PDFViewerApplication = {
metadata = data . metadata ;
self . documentInfo = info ;
self . metadata = metadata ;
console . log ( 'PDF ' + pdfDocument . fingerprint + ' [' + info . PDFFormatVersion + ' ' + ( info . Producer || '-' ) . trim ( ) + ' / ' + ( info . Creator || '-' ) . trim ( ) + ']' + ' (PDF.js: ' + ( pdfjsLib . version || '-' ) + ( ! pdfjsLib . PDFJS . disableWebGL ? ' [WebGL]' : '' ) + ')' ) ;
console . log ( 'PDF ' + pdfDocument . fingerprint + ' [' + info . PDFFormatVersion + ' ' + ( info . Producer || '-' ) . trim ( ) + ' / ' + ( info . Creator || '-' ) . trim ( ) + ']' + ' (PDF.js: ' + ( _ pdfjs. version || '-' ) + ( ! _ pdfjs. PDFJS . disableWebGL ? ' [WebGL]' : '' ) + ')' ) ;
var pdfTitle ;
if ( metadata && metadata . has ( 'dc:title' ) ) {
var title = metadata . get ( 'dc:title' ) ;
@ -732,7 +720,7 @@ var PDFViewerApplication = {
@@ -732,7 +720,7 @@ var PDFViewerApplication = {
}
if ( info . IsAcroFormPresent ) {
console . warn ( 'Warning: AcroForm/XFA is not supported' ) ;
self . fallback ( pdfjsLib . UNSUPPORTED _FEATURES . forms ) ;
self . fallback ( _ pdfjs. UNSUPPORTED _FEATURES . forms ) ;
}
} ) ;
} ,
@ -757,7 +745,7 @@ var PDFViewerApplication = {
@@ -757,7 +745,7 @@ var PDFViewerApplication = {
this . toolbar . setPageNumber ( this . pdfViewer . currentPageNumber , this . pdfViewer . currentPageLabel ) ;
this . secondaryToolbar . setPageNumber ( this . pdfViewer . currentPageNumber ) ;
if ( ! this . pdfViewer . currentScaleValue ) {
this . pdfViewer . currentScaleValue = DEFAULT _SCALE _VALUE ;
this . pdfViewer . currentScaleValue = _ui _utils . DEFAULT _SCALE _VALUE ;
}
} ,
cleanup : function pdfViewCleanup ( ) {
@ -766,7 +754,7 @@ var PDFViewerApplication = {
@@ -766,7 +754,7 @@ var PDFViewerApplication = {
}
this . pdfViewer . cleanup ( ) ;
this . pdfThumbnailViewer . cleanup ( ) ;
if ( this . pdfViewer . renderer !== RendererType . SVG ) {
if ( this . pdfViewer . renderer !== _ui _utils . RendererType . SVG ) {
this . pdfDocument . cleanup ( ) ;
}
} ,
@ -780,12 +768,12 @@ var PDFViewerApplication = {
@@ -780,12 +768,12 @@ var PDFViewerApplication = {
return ;
}
if ( ! this . supportsPrinting ) {
var printMessage = mozL10n . get ( 'printing_not_supported' , null , 'Warning: Printing is not fully supported by this browser.' ) ;
var printMessage = _ui _utils . mozL10n . get ( 'printing_not_supported' , null , 'Warning: Printing is not fully supported by this browser.' ) ;
this . error ( printMessage ) ;
return ;
}
if ( ! this . pdfViewer . pageViewsReady ) {
var notReadyMessage = mozL10n . get ( 'printing_not_ready' , null , 'Warning: The PDF is not fully loaded for printing.' ) ;
var notReadyMessage = _ui _utils . mozL10n . get ( 'printing_not_ready' , null , 'Warning: The PDF is not fully loaded for printing.' ) ;
window . alert ( notReadyMessage ) ;
return ;
}
@ -888,25 +876,27 @@ var PDFViewerApplication = {
@@ -888,25 +876,27 @@ var PDFViewerApplication = {
}
} ;
var validateFileURL ;
var HOSTED _VIEWER _ORIGINS = [ 'null' , 'http://mozilla.github.io' , 'https://mozilla.github.io' ] ;
validateFileURL = function validateFileURL ( file ) {
try {
var viewerOrigin = new URL ( window . location . href ) . origin || 'null' ;
if ( HOSTED _VIEWER _ORIGINS . indexOf ( viewerOrigin ) >= 0 ) {
return ;
}
var fileOrigin = new URL ( file , window . location . href ) . origin ;
if ( fileOrigin !== viewerOrigin ) {
throw new Error ( 'file origin does not match viewer\'s' ) ;
{
var HOSTED _VIEWER _ORIGINS = [ 'null' , 'http://mozilla.github.io' , 'https://mozilla.github.io' ] ;
validateFileURL = function validateFileURL ( file ) {
try {
var viewerOrigin = new URL ( window . location . href ) . origin || 'null' ;
if ( HOSTED _VIEWER _ORIGINS . indexOf ( viewerOrigin ) >= 0 ) {
return ;
}
var fileOrigin = new URL ( file , window . location . href ) . origin ;
if ( fileOrigin !== viewerOrigin ) {
throw new Error ( 'file origin does not match viewer\'s' ) ;
}
} catch ( e ) {
var message = e && e . message ;
var loadingErrorMessage = _ui _utils . mozL10n . get ( 'loading_error' , null , 'An error occurred while loading the PDF.' ) ;
var moreInfo = { message : message } ;
PDFViewerApplication . error ( loadingErrorMessage , moreInfo ) ;
throw e ;
}
} catch ( e ) {
var message = e && e . message ;
var loadingErrorMessage = mozL10n . get ( 'loading_error' , null , 'An error occurred while loading the PDF.' ) ;
var moreInfo = { message : message } ;
PDFViewerApplication . error ( loadingErrorMessage , moreInfo ) ;
throw e ;
}
} ;
} ;
}
function loadAndEnablePDFBug ( enabledTabs ) {
return new Promise ( function ( resolve , reject ) {
var appConfig = PDFViewerApplication . appConfig ;
@ -914,7 +904,10 @@ function loadAndEnablePDFBug(enabledTabs) {
@@ -914,7 +904,10 @@ function loadAndEnablePDFBug(enabledTabs) {
script . src = appConfig . debuggerScriptPath ;
script . onload = function ( ) {
PDFBug . enable ( enabledTabs ) ;
PDFBug . init ( pdfjsLib , appConfig . mainContainer ) ;
PDFBug . init ( {
PDFJS : _pdfjs . PDFJS ,
OPS : _pdfjs . OPS
} , appConfig . mainContainer ) ;
resolve ( ) ;
} ;
script . onerror = function ( ) {
@ -927,7 +920,7 @@ function webViewerInitialized() {
@@ -927,7 +920,7 @@ function webViewerInitialized() {
var appConfig = PDFViewerApplication . appConfig ;
var file ;
var queryString = document . location . search . substring ( 1 ) ;
var params = parseQueryString ( queryString ) ;
var params = ( 0 , _ui _utils . parseQueryString ) ( queryString ) ;
file = 'file' in params ? params . file : appConfig . defaultUrl ;
validateFileURL ( file ) ;
var waitForBeforeOpening = [ ] ;
@ -935,7 +928,7 @@ function webViewerInitialized() {
@@ -935,7 +928,7 @@ function webViewerInitialized() {
fileInput . id = appConfig . openFileInputName ;
fileInput . className = 'fileInput' ;
fileInput . setAttribute ( 'type' , 'file' ) ;
fileInput . oncontextmenu = noContextMenuHandler ;
fileInput . oncontextmenu = _ui _utils . noContextMenuHandler ;
document . body . appendChild ( fileInput ) ;
if ( ! window . File || ! window . FileReader || ! window . FileList || ! window . Blob ) {
appConfig . toolbar . openFile . setAttribute ( 'hidden' , 'true' ) ;
@ -943,47 +936,46 @@ function webViewerInitialized() {
@@ -943,47 +936,46 @@ function webViewerInitialized() {
} else {
fileInput . value = null ;
}
var PDFJS = pdfjsLib . PDFJS ;
if ( PDFViewerApplication . viewerPrefs [ 'pdfBugEnabled' ] ) {
var hash = document . location . hash . substring ( 1 ) ;
var hashParams = parseQueryString ( hash ) ;
var hashParams = ( 0 , _ui _utils . parseQueryString ) ( hash ) ;
if ( 'disableworker' in hashParams ) {
PDFJS . disableWorker = hashParams [ 'disableworker' ] === 'true' ;
_pdfjs . PDFJS . disableWorker = hashParams [ 'disableworker' ] === 'true' ;
}
if ( 'disablerange' in hashParams ) {
PDFJS . disableRange = hashParams [ 'disablerange' ] === 'true' ;
_pdfjs . PDFJS . disableRange = hashParams [ 'disablerange' ] === 'true' ;
}
if ( 'disablestream' in hashParams ) {
PDFJS . disableStream = hashParams [ 'disablestream' ] === 'true' ;
_pdfjs . PDFJS . disableStream = hashParams [ 'disablestream' ] === 'true' ;
}
if ( 'disableautofetch' in hashParams ) {
PDFJS . disableAutoFetch = hashParams [ 'disableautofetch' ] === 'true' ;
_pdfjs . PDFJS . disableAutoFetch = hashParams [ 'disableautofetch' ] === 'true' ;
}
if ( 'disablefontface' in hashParams ) {
PDFJS . disableFontFace = hashParams [ 'disablefontface' ] === 'true' ;
_pdfjs . PDFJS . disableFontFace = hashParams [ 'disablefontface' ] === 'true' ;
}
if ( 'disablehistory' in hashParams ) {
PDFJS . disableHistory = hashParams [ 'disablehistory' ] === 'true' ;
_pdfjs . PDFJS . disableHistory = hashParams [ 'disablehistory' ] === 'true' ;
}
if ( 'webgl' in hashParams ) {
PDFJS . disableWebGL = hashParams [ 'webgl' ] !== 'true' ;
_pdfjs . PDFJS . disableWebGL = hashParams [ 'webgl' ] !== 'true' ;
}
if ( 'useonlycsszoom' in hashParams ) {
PDFJS . useOnlyCssZoom = hashParams [ 'useonlycsszoom' ] === 'true' ;
_pdfjs . PDFJS . useOnlyCssZoom = hashParams [ 'useonlycsszoom' ] === 'true' ;
}
if ( 'verbosity' in hashParams ) {
PDFJS . verbosity = hashParams [ 'verbosity' ] | 0 ;
_pdfjs . PDFJS . verbosity = hashParams [ 'verbosity' ] | 0 ;
}
if ( 'ignorecurrentpositiononzoom' in hashParams ) {
PDFJS . ignoreCurrentPositionOnZoom = hashParams [ 'ignorecurrentpositiononzoom' ] === 'true' ;
_pdfjs . PDFJS . ignoreCurrentPositionOnZoom = hashParams [ 'ignorecurrentpositiononzoom' ] === 'true' ;
}
if ( 'locale' in hashParams ) {
PDFJS . locale = hashParams [ 'locale' ] ;
_pdfjs . PDFJS . locale = hashParams [ 'locale' ] ;
}
if ( 'textlayer' in hashParams ) {
switch ( hashParams [ 'textlayer' ] ) {
case 'off' :
PDFJS . disableTextLayer = true ;
_pdfjs . PDFJS . disableTextLayer = true ;
break ;
case 'visible' :
case 'shadow' :
@ -994,13 +986,13 @@ function webViewerInitialized() {
@@ -994,13 +986,13 @@ function webViewerInitialized() {
}
}
if ( 'pdfbug' in hashParams ) {
PDFJS . pdfBug = true ;
_pdfjs . PDFJS . pdfBug = true ;
var pdfBug = hashParams [ 'pdfbug' ] ;
var enabled = pdfBug . split ( ',' ) ;
waitForBeforeOpening . push ( loadAndEnablePDFBug ( enabled ) ) ;
}
}
mozL10n . setLanguage ( PDFJS . locale ) ;
_ui _utils . mozL10n . setLanguage ( _pdfjs . PDFJS . locale ) ;
if ( ! PDFViewerApplication . supportsPrinting ) {
appConfig . toolbar . print . classList . add ( 'hidden' ) ;
appConfig . secondaryToolbar . printButton . classList . add ( 'hidden' ) ;
@ -1023,30 +1015,32 @@ function webViewerInitialized() {
@@ -1023,30 +1015,32 @@ function webViewerInitialized() {
Promise . all ( waitForBeforeOpening ) . then ( function ( ) {
webViewerOpenFileViaURL ( file ) ;
} ) . catch ( function ( reason ) {
PDFViewerApplication . error ( mozL10n . get ( 'loading_error' , null , 'An error occurred while opening.' ) , reason ) ;
PDFViewerApplication . error ( _ui _utils . mozL10n . get ( 'loading_error' , null , 'An error occurred while opening.' ) , reason ) ;
} ) ;
}
var webViewerOpenFileViaURL ;
webViewerOpenFileViaURL = function webViewerOpenFileViaURL ( file ) {
if ( file && file . lastIndexOf ( 'file:' , 0 ) === 0 ) {
PDFViewerApplication . setTitleUsingUrl ( file ) ;
var xhr = new XMLHttpRequest ( ) ;
xhr . onload = function ( ) {
PDFViewerApplication . open ( new Uint8Array ( xhr . response ) ) ;
} ;
try {
xhr . open ( 'GET' , file ) ;
xhr . responseType = 'arraybuffer' ;
xhr . send ( ) ;
} catch ( e ) {
PDFViewerApplication . error ( mozL10n . get ( 'loading_error' , null , 'An error occurred while loading the PDF.' ) , e ) ;
{
webViewerOpenFileViaURL = function webViewerOpenFileViaURL ( file ) {
if ( file && file . lastIndexOf ( 'file:' , 0 ) === 0 ) {
PDFViewerApplication . setTitleUsingUrl ( file ) ;
var xhr = new XMLHttpRequest ( ) ;
xhr . onload = function ( ) {
PDFViewerApplication . open ( new Uint8Array ( xhr . response ) ) ;
} ;
try {
xhr . open ( 'GET' , file ) ;
xhr . responseType = 'arraybuffer' ;
xhr . send ( ) ;
} catch ( e ) {
PDFViewerApplication . error ( _ui _utils . mozL10n . get ( 'loading_error' , null , 'An error occurred while loading the PDF.' ) , e ) ;
}
return ;
}
return ;
}
if ( file ) {
PDFViewerApplication . open ( file ) ;
}
} ;
if ( file ) {
PDFViewerApplication . open ( file ) ;
}
} ;
}
function webViewerPageRendered ( e ) {
var pageNumber = e . pageNumber ;
var pageIndex = pageNumber - 1 ;
@ -1061,11 +1055,11 @@ function webViewerPageRendered(e) {
@@ -1061,11 +1055,11 @@ function webViewerPageRendered(e) {
var thumbnailView = PDFViewerApplication . pdfThumbnailViewer . getThumbnail ( pageIndex ) ;
thumbnailView . setImage ( pageView ) ;
}
if ( pdfjsLib . PDFJS . pdfBug && Stats . enabled && pageView . stats ) {
if ( _ pdfjs. PDFJS . pdfBug && Stats . enabled && pageView . stats ) {
Stats . add ( pageNumber , pageView . stats ) ;
}
if ( pageView . error ) {
PDFViewerApplication . error ( mozL10n . get ( 'rendering_error' , null , 'An error occurred while rendering the page.' ) , pageView . error ) ;
PDFViewerApplication . error ( _ui _utils . mozL10n . get ( 'rendering_error' , null , 'An error occurred while rendering the page.' ) , pageView . error ) ;
}
}
function webViewerTextLayerRendered ( e ) { }
@ -1074,17 +1068,17 @@ function webViewerPageMode(e) {
@@ -1074,17 +1068,17 @@ function webViewerPageMode(e) {
view ;
switch ( mode ) {
case 'thumbs' :
view = SidebarView . THUMBS ;
view = _pdf _sidebar . SidebarView . THUMBS ;
break ;
case 'bookmarks' :
case 'outline' :
view = SidebarView . OUTLINE ;
view = _pdf _sidebar . SidebarView . OUTLINE ;
break ;
case 'attachments' :
view = SidebarView . ATTACHMENTS ;
view = _pdf _sidebar . SidebarView . ATTACHMENTS ;
break ;
case 'none' :
view = SidebarView . NONE ;
view = _pdf _sidebar . SidebarView . NONE ;
break ;
default :
console . error ( 'Invalid "pagemode" hash parameter: ' + mode ) ;
@ -1108,7 +1102,7 @@ function webViewerNamedAction(e) {
@@ -1108,7 +1102,7 @@ function webViewerNamedAction(e) {
function webViewerPresentationModeChanged ( e ) {
var active = e . active ;
var switchInProgress = e . switchInProgress ;
PDFViewerApplication . pdfViewer . presentationModeState = switchInProgress ? PresentationModeState . CHANGING : active ? PresentationModeState . FULLSCREEN : PresentationModeState . NORMAL ;
PDFViewerApplication . pdfViewer . presentationModeState = switchInProgress ? _pdf _viewer . PresentationModeState . CHANGING : active ? _pdf _viewer . PresentationModeState . FULLSCREEN : _pdf _viewer . PresentationModeState . NORMAL ;
}
function webViewerSidebarViewChanged ( e ) {
PDFViewerApplication . pdfRenderingQueue . isThumbnailViewEnabled = PDFViewerApplication . pdfSidebar . isThumbnailViewVisible ;
@ -1139,7 +1133,7 @@ function webViewerUpdateViewarea(e) {
@@ -1139,7 +1133,7 @@ function webViewerUpdateViewarea(e) {
PDFViewerApplication . appConfig . secondaryToolbar . viewBookmarkButton . href = href ;
PDFViewerApplication . pdfHistory . updateCurrentBookmark ( location . pdfOpenParams , location . pageNumber ) ;
var currentPage = PDFViewerApplication . pdfViewer . getPageView ( PDFViewerApplication . page - 1 ) ;
var loading = currentPage . renderingState !== RenderingStates . FINISHED ;
var loading = currentPage . renderingState !== _pdf _rendering _queue . RenderingStates . FINISHED ;
PDFViewerApplication . toolbar . updateLoadingIndicatorState ( loading ) ;
}
function webViewerResize ( ) {
@ -1147,7 +1141,7 @@ function webViewerResize() {
@@ -1147,7 +1141,7 @@ function webViewerResize() {
if ( currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue === 'page-width' ) {
PDFViewerApplication . pdfViewer . currentScaleValue = currentScaleValue ;
} else if ( ! currentScaleValue ) {
PDFViewerApplication . pdfViewer . currentScaleValue = DEFAULT _SCALE _VALUE ;
PDFViewerApplication . pdfViewer . currentScaleValue = _ui _utils . DEFAULT _SCALE _VALUE ;
}
PDFViewerApplication . pdfViewer . update ( ) ;
}
@ -1165,26 +1159,28 @@ function webViewerHashchange(e) {
@@ -1165,26 +1159,28 @@ function webViewerHashchange(e) {
}
}
var webViewerFileInputChange ;
webViewerFileInputChange = function webViewerFileInputChange ( e ) {
var file = e . fileInput . files [ 0 ] ;
if ( ! pdfjsLib . PDFJS . disableCreateObjectURL && typeof URL !== 'undefined' && URL . createObjectURL ) {
PDFViewerApplication . open ( URL . createObjectURL ( file ) ) ;
} else {
var fileReader = new FileReader ( ) ;
fileReader . onload = function webViewerChangeFileReaderOnload ( evt ) {
var buffer = evt . target . result ;
var uint8Array = new Uint8Array ( buffer ) ;
PDFViewerApplication . open ( uint8Array ) ;
} ;
fileReader . readAsArrayBuffer ( file ) ;
}
PDFViewerApplication . setTitleUsingUrl ( file . name ) ;
var appConfig = PDFViewerApplication . appConfig ;
appConfig . toolbar . viewBookmark . setAttribute ( 'hidden' , 'true' ) ;
appConfig . secondaryToolbar . viewBookmarkButton . setAttribute ( 'hidden' , 'true' ) ;
appConfig . toolbar . download . setAttribute ( 'hidden' , 'true' ) ;
appConfig . secondaryToolbar . downloadButton . setAttribute ( 'hidden' , 'true' ) ;
} ;
{
webViewerFileInputChange = function webViewerFileInputChange ( e ) {
var file = e . fileInput . files [ 0 ] ;
if ( ! _pdfjs . PDFJS . disableCreateObjectURL && typeof URL !== 'undefined' && URL . createObjectURL ) {
PDFViewerApplication . open ( URL . createObjectURL ( file ) ) ;
} else {
var fileReader = new FileReader ( ) ;
fileReader . onload = function webViewerChangeFileReaderOnload ( evt ) {
var buffer = evt . target . result ;
var uint8Array = new Uint8Array ( buffer ) ;
PDFViewerApplication . open ( uint8Array ) ;
} ;
fileReader . readAsArrayBuffer ( file ) ;
}
PDFViewerApplication . setTitleUsingUrl ( file . name ) ;
var appConfig = PDFViewerApplication . appConfig ;
appConfig . toolbar . viewBookmark . setAttribute ( 'hidden' , 'true' ) ;
appConfig . secondaryToolbar . viewBookmarkButton . setAttribute ( 'hidden' , 'true' ) ;
appConfig . toolbar . download . setAttribute ( 'hidden' , 'true' ) ;
appConfig . secondaryToolbar . downloadButton . setAttribute ( 'hidden' , 'true' ) ;
} ;
}
function webViewerPresentationMode ( ) {
PDFViewerApplication . requestPresentationMode ( ) ;
}
@ -1268,7 +1264,7 @@ function webViewerPageChanging(e) {
@@ -1268,7 +1264,7 @@ function webViewerPageChanging(e) {
if ( PDFViewerApplication . pdfSidebar . isThumbnailViewVisible ) {
PDFViewerApplication . pdfThumbnailViewer . scrollThumbnailIntoView ( page ) ;
}
if ( pdfjsLib . PDFJS . pdfBug && Stats . enabled ) {
if ( _ pdfjs. PDFJS . pdfBug && Stats . enabled ) {
var pageView = PDFViewerApplication . pdfViewer . getPageView ( page - 1 ) ;
if ( pageView . stats ) {
Stats . add ( page , pageView . stats ) ;
@ -1292,7 +1288,7 @@ function webViewerWheel(evt) {
@@ -1292,7 +1288,7 @@ function webViewerWheel(evt) {
return ;
}
var previousScale = pdfViewer . currentScale ;
var delta = normalizeWheelEventDelta ( evt ) ;
var delta = ( 0 , _ui _utils . normalizeWheelEventDelta ) ( evt ) ;
var MOUSE _WHEEL _DELTA _PER _PAGE _SCALE = 3.0 ;
var ticks = delta * MOUSE _WHEEL _DELTA _PER _PAGE _SCALE ;
if ( ticks < 0 ) {
@ -1327,7 +1323,7 @@ function webViewerClick(evt) {
@@ -1327,7 +1323,7 @@ function webViewerClick(evt) {
}
}
function webViewerKeyDown ( evt ) {
if ( OverlayManager . active ) {
if ( _overlay _manager . OverlayManager . active ) {
return ;
}
var handled = false ,
@ -1379,7 +1375,7 @@ function webViewerKeyDown(evt) {
@@ -1379,7 +1375,7 @@ function webViewerKeyDown(evt) {
case 96 :
if ( ! isViewerInPresentationMode ) {
setTimeout ( function ( ) {
pdfViewer . currentScaleValue = DEFAULT _SCALE _VALUE ;
pdfViewer . currentScaleValue = _ui _utils . DEFAULT _SCALE _VALUE ;
} ) ;
handled = false ;
}
@ -1548,8 +1544,8 @@ function webViewerKeyDown(evt) {
@@ -1548,8 +1544,8 @@ function webViewerKeyDown(evt) {
evt . preventDefault ( ) ;
}
}
localized . then ( function webViewerLocalized ( ) {
document . getElementsByTagName ( 'html' ) [ 0 ] . dir = mozL10n . getDirection ( ) ;
_ui _utils . localized . then ( function webViewerLocalized ( ) {
document . getElementsByTagName ( 'html' ) [ 0 ] . dir = _ui _utils . mozL10n . getDirection ( ) ;
} ) ;
var PDFPrintServiceFactory = {
instance : {
@ -1560,5 +1556,5 @@ var PDFPrintServiceFactory = {
@@ -1560,5 +1556,5 @@ var PDFPrintServiceFactory = {
}
} ;
exports . PDFViewerApplication = PDFViewerApplication ;
exports . DefaultExernalServices = DefaultExernalServices ;
exports . DefaultExt ernalServices = DefaultExt ernalServices ;
exports . PDFPrintServiceFactory = PDFPrintServiceFactory ;