@ -209,104 +209,103 @@ var PDFViewerApplication = {
@@ -209,104 +209,103 @@ var PDFViewerApplication = {
_initializeViewerComponents : function _initializeViewerComponents ( ) {
var _this2 = this ;
var self = this ;
var appConfig = this . appConfig ;
return new Promise ( function ( resolve , reject ) {
var eventBus = appConfig . eventBus || ( 0 , _dom _events . getGlobalEventBus ) ( ) ;
_this2 . eventBus = eventBus ;
var pdfRenderingQueue = new _pdf _rendering _queue . PDFRenderingQueue ( ) ;
pdfRenderingQueue . onIdle = self . cleanup . bind ( self ) ;
self . pdfRenderingQueue = pdfRenderingQueue ;
pdfRenderingQueue . onIdle = _this2 . cleanup . bind ( _this2 ) ;
_this2 . pdfRenderingQueue = pdfRenderingQueue ;
var pdfLinkService = new _pdf _link _service . PDFLinkService ( { eventBus : eventBus } ) ;
self . pdfLinkService = pdfLinkService ;
var downloadManager = self . externalServices . createDownloadManager ( ) ;
self . downloadManager = downloadManager ;
_this2 . pdfLinkService = pdfLinkService ;
var downloadManager = _this2 . externalServices . createDownloadManager ( ) ;
_this2 . downloadManager = downloadManager ;
var container = appConfig . mainContainer ;
var viewer = appConfig . viewerContainer ;
self . pdfViewer = new _pdf _viewer . PDFViewer ( {
_this2 . pdfViewer = new _pdf _viewer . PDFViewer ( {
container : container ,
viewer : viewer ,
eventBus : eventBus ,
renderingQueue : pdfRenderingQueue ,
linkService : pdfLinkService ,
downloadManager : downloadManager ,
renderer : self . viewerPrefs [ 'renderer' ] ,
enhanceTextSelection : self . viewerPrefs [ 'enhanceTextSelection' ] ,
renderInteractiveForms : self . viewerPrefs [ 'renderInteractiveForms' ] ,
enablePrintAutoRotate : self . viewerPrefs [ 'enablePrintAutoRotate' ]
renderer : _this2 . viewerPrefs [ 'renderer' ] ,
enhanceTextSelection : _this2 . viewerPrefs [ 'enhanceTextSelection' ] ,
renderInteractiveForms : _this2 . viewerPrefs [ 'renderInteractiveForms' ] ,
enablePrintAutoRotate : _this2 . viewerPrefs [ 'enablePrintAutoRotate' ]
} ) ;
pdfRenderingQueue . setViewer ( self . pdfViewer ) ;
pdfLinkService . setViewer ( self . pdfViewer ) ;
pdfRenderingQueue . setViewer ( _this2 . pdfViewer ) ;
pdfLinkService . setViewer ( _this2 . pdfViewer ) ;
var thumbnailContainer = appConfig . sidebar . thumbnailView ;
self . pdfThumbnailViewer = new _pdf _thumbnail _viewer . PDFThumbnailViewer ( {
_this2 . pdfThumbnailViewer = new _pdf _thumbnail _viewer . PDFThumbnailViewer ( {
container : thumbnailContainer ,
renderingQueue : pdfRenderingQueue ,
linkService : pdfLinkService
} ) ;
pdfRenderingQueue . setThumbnailViewer ( self . pdfThumbnailViewer ) ;
self . pdfHistory = new _pdf _history . PDFHistory ( {
pdfRenderingQueue . setThumbnailViewer ( _this2 . pdfThumbnailViewer ) ;
_this2 . pdfHistory = new _pdf _history . PDFHistory ( {
linkService : pdfLinkService ,
eventBus : eventBus
} ) ;
pdfLinkService . setHistory ( self . pdfHistory ) ;
self . findController = new _pdf _find _controller . PDFFindController ( { pdfViewer : self . pdfViewer } ) ;
self . findController . onUpdateResultsCount = function ( matchCount ) {
if ( self . supportsIntegratedFind ) {
pdfLinkService . setHistory ( _this2 . pdfHistory ) ;
_this2 . findController = new _pdf _find _controller . PDFFindController ( { pdfViewer : _this2 . pdfViewer } ) ;
_this2 . findController . onUpdateResultsCount = function ( matchCount ) {
if ( _this2 . supportsIntegratedFind ) {
return ;
}
self . findBar . updateResultsCount ( matchCount ) ;
_this2 . findBar . updateResultsCount ( matchCount ) ;
} ;
self . findController . onUpdateState = function ( state , previous , matchCount ) {
if ( self . supportsIntegratedFind ) {
self . externalServices . updateFindControlState ( {
_this2 . findController . onUpdateState = function ( state , previous , matchCount ) {
if ( _this2 . supportsIntegratedFind ) {
_this2 . externalServices . updateFindControlState ( {
result : state ,
findPrevious : previous
} ) ;
} else {
self . findBar . updateUIState ( state , previous , matchCount ) ;
_this2 . findBar . updateUIState ( state , previous , matchCount ) ;
}
} ;
self . pdfViewer . setFindController ( self . findController ) ;
_this2 . pdfViewer . setFindController ( _this2 . findController ) ;
var findBarConfig = Object . create ( appConfig . findBar ) ;
findBarConfig . findController = self . findController ;
findBarConfig . findController = _this2 . findController ;
findBarConfig . eventBus = eventBus ;
self . findBar = new _pdf _find _bar . PDFFindBar ( findBarConfig ) ;
self . overlayManager = _overlay _manager . OverlayManager ;
self . handTool = new _hand _tool . HandTool ( {
_this2 . findBar = new _pdf _find _bar . PDFFindBar ( findBarConfig ) ;
_this2 . overlayManager = _overlay _manager . OverlayManager ;
_this2 . handTool = new _hand _tool . HandTool ( {
container : container ,
eventBus : eventBus ,
preferences : _this2 . preferences
} ) ;
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 _pdf _presentation _mode . PDFPresentationMode ( {
_this2 . pdfDocumentProperties = new _pdf _document _properties . PDFDocumentProperties ( appConfig . documentProperties ) ;
_this2 . toolbar = new _toolbar . Toolbar ( appConfig . toolbar , container , eventBus ) ;
_this2 . secondaryToolbar = new _secondary _toolbar . SecondaryToolbar ( appConfig . secondaryToolbar , container , eventBus ) ;
if ( _this2 . supportsFullscreen ) {
_this2 . pdfPresentationMode = new _pdf _presentation _mode . PDFPresentationMode ( {
container : container ,
viewer : viewer ,
pdfViewer : self . pdfViewer ,
pdfViewer : _this2 . pdfViewer ,
eventBus : eventBus ,
contextMenuItems : appConfig . fullscreen
} ) ;
}
self . passwordPrompt = new _password _prompt . PasswordPrompt ( appConfig . passwordOverlay ) ;
self . pdfOutlineViewer = new _pdf _outline _viewer . PDFOutlineViewer ( {
_this2 . passwordPrompt = new _password _prompt . PasswordPrompt ( appConfig . passwordOverlay ) ;
_this2 . pdfOutlineViewer = new _pdf _outline _viewer . PDFOutlineViewer ( {
container : appConfig . sidebar . outlineView ,
eventBus : eventBus ,
linkService : pdfLinkService
} ) ;
self . pdfAttachmentViewer = new _pdf _attachment _viewer . PDFAttachmentViewer ( {
_this2 . pdfAttachmentViewer = new _pdf _attachment _viewer . PDFAttachmentViewer ( {
container : appConfig . sidebar . attachmentsView ,
eventBus : eventBus ,
downloadManager : downloadManager
} ) ;
var sidebarConfig = Object . create ( appConfig . sidebar ) ;
sidebarConfig . pdfViewer = self . pdfViewer ;
sidebarConfig . pdfThumbnailViewer = self . pdfThumbnailViewer ;
sidebarConfig . pdfOutlineViewer = self . pdfOutlineViewer ;
sidebarConfig . pdfViewer = _this2 . pdfViewer ;
sidebarConfig . pdfThumbnailViewer = _this2 . pdfThumbnailViewer ;
sidebarConfig . pdfOutlineViewer = _this2 . pdfOutlineViewer ;
sidebarConfig . eventBus = eventBus ;
self . pdfSidebar = new _pdf _sidebar . PDFSidebar ( sidebarConfig ) ;
self . pdfSidebar . onToggled = self . forceRendering . bind ( self ) ;
_this2 . pdfSidebar = new _pdf _sidebar . PDFSidebar ( sidebarConfig ) ;
_this2 . pdfSidebar . onToggled = _this2 . forceRendering . bind ( _this2 ) ;
resolve ( undefined ) ;
} ) ;
} ,
@ -426,7 +425,7 @@ var PDFViewerApplication = {
@@ -426,7 +425,7 @@ var PDFViewerApplication = {
}
return promise ;
} ,
open : function pdfViewO pen( file , args ) {
open : function o pen( file , args ) {
var _this3 = this ;
if ( arguments . length > 2 || typeof args === 'number' ) {
@ -439,7 +438,7 @@ var PDFViewerApplication = {
@@ -439,7 +438,7 @@ var PDFViewerApplication = {
} ) ;
}
var parameters = Object . create ( null ) ,
scale ;
scale = void 0 ;
if ( typeof file === 'string' ) {
this . setTitleUsingUrl ( file ) ;
parameters . url = file ;
@ -460,21 +459,23 @@ var PDFViewerApplication = {
@@ -460,21 +459,23 @@ var PDFViewerApplication = {
this . pdfDocumentProperties . setFileSize ( args . length ) ;
}
}
var self = this ;
self . downloadComplete = false ;
this . downloadComplete = false ;
var loadingTask = ( 0 , _pdfjs . getDocument ) ( parameters ) ;
this . pdfLoadingTask = loadingTask ;
loadingTask . onPassword = function passwordNeeded ( updateCallback , reason ) {
self . passwordPrompt . setUpdateCallback ( updateCallback , reason ) ;
self . passwordPrompt . open ( ) ;
loadingTask . onPassword = function ( updateCallback , reason ) {
_this3 . passwordPrompt . setUpdateCallback ( updateCallback , reason ) ;
_this3 . passwordPrompt . open ( ) ;
} ;
loadingTask . onProgress = function getDocumentProgress ( progressData ) {
self . progress ( progressData . loaded / progressData . total ) ;
loadingTask . onProgress = function ( _ref ) {
var loaded = _ref . loaded ,
total = _ref . total ;
_this3 . progress ( loaded / total ) ;
} ;
loadingTask . onUnsupportedFeature = this . fallback . bind ( this ) ;
return loadingTask . promise . then ( function getDocumentCallback ( pdfDocument ) {
self . load ( pdfDocument , scale ) ;
} , function getDocumentError ( exception ) {
return loadingTask . promise . then ( function ( pdfDocument ) {
_this3 . load ( pdfDocument , scale ) ;
} , function ( exception ) {
var message = exception && exception . message ;
var loadingErrorMessage = _ui _utils . mozL10n . get ( 'loading_error' , null , 'An error occurred while loading the PDF.' ) ;
if ( exception instanceof _pdfjs . InvalidPDFException ) {
@ -484,11 +485,11 @@ var PDFViewerApplication = {
@@ -484,11 +485,11 @@ var PDFViewerApplication = {
} 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 ) ;
_this3 . error ( loadingErrorMessage , { message : message } ) ;
throw new Error ( loadingErrorMessage ) ;
} ) ;
} ,
download : function pdfViewDownload ( ) {
function downloadByUrl ( ) {
downloadManager . downloadUrl ( url , filename ) ;
@ -580,21 +581,23 @@ var PDFViewerApplication = {
@@ -580,21 +581,23 @@ var PDFViewerApplication = {
}
}
} ,
load : function pdfViewL oad( pdfDocument , scale ) {
load : function l oad( pdfDocument , scale ) {
var _this5 = this ;
var self = this ;
scale = scale || _ui _utils . UNKNOWN _SCALE ;
this . pdfDocument = pdfDocument ;
var downloadedPromise = pdfDocument . getDownloadInfo ( ) . then ( function ( ) {
self . downloadComplete = true ;
self . loadingBar . hide ( ) ;
pdfDocument . getDownloadInfo ( ) . then ( function ( ) {
_this5 . downloadComplete = true ;
_this5 . loadingBar . hide ( ) ;
firstPagePromise . then ( function ( ) {
_this5 . eventBus . dispatch ( 'documentload' , { source : _this5 } ) ;
} ) ;
} ) ;
this . toolbar . setPagesCount ( pdfDocument . numPages , false ) ;
this . secondaryToolbar . setPagesCount ( pdfDocument . numPages ) ;
var id = this . documentFingerprint = pdfDocument . fingerprint ;
var store = this . store = new _view _history . ViewHistory ( id ) ;
var baseDocumentUrl ;
var baseDocumentUrl = void 0 ;
baseDocumentUrl = null ;
this . pdfLinkService . setDocument ( pdfDocument , baseDocumentUrl ) ;
this . pdfDocumentProperties . setDocument ( pdfDocument , this . url ) ;
@ -608,19 +611,16 @@ var PDFViewerApplication = {
@@ -608,19 +611,16 @@ var PDFViewerApplication = {
var pdfThumbnailViewer = this . pdfThumbnailViewer ;
pdfThumbnailViewer . setDocument ( pdfDocument ) ;
firstPagePromise . then ( function ( pdfPage ) {
downloadedPromise . then ( function ( ) {
self . eventBus . dispatch ( 'documentload' , { source : self } ) ;
} ) ;
self . loadingBar . setWidth ( self . appConfig . viewerContainer ) ;
if ( ! _pdfjs . PDFJS . disableHistory && ! self . isViewerEmbedded ) {
if ( ! self . viewerPrefs [ 'showPreviousViewOnLoad' ] ) {
self . pdfHistory . clearHistoryState ( ) ;
_this5 . loadingBar . setWidth ( _this5 . appConfig . viewerContainer ) ;
if ( ! _pdfjs . PDFJS . disableHistory && ! _this5 . isViewerEmbedded ) {
if ( ! _this5 . viewerPrefs [ 'showPreviousViewOnLoad' ] ) {
_this5 . pdfHistory . clearHistoryState ( ) ;
}
self . pdfHistory . initialize ( self . documentFingerprint ) ;
if ( self . pdfHistory . initialDestination ) {
self . initialDestination = self . pdfHistory . initialDestination ;
} else if ( self . pdfHistory . initialBookmark ) {
self . initialBookmark = self . pdfHistory . initialBookmark ;
_this5 . pdfHistory . initialize ( _this5 . documentFingerprint ) ;
if ( _this5 . pdfHistory . initialDestination ) {
_this5 . initialDestination = _this5 . pdfHistory . initialDestination ;
} else if ( _this5 . pdfHistory . initialBookmark ) {
_this5 . initialBookmark = _this5 . pdfHistory . initialBookmark ;
}
}
var initialParams = {
@ -677,12 +677,12 @@ var PDFViewerApplication = {
@@ -677,12 +677,12 @@ var PDFViewerApplication = {
} ) ;
} ) ;
pdfDocument . getPageLabels ( ) . then ( function ( labels ) {
if ( ! labels || self . viewerPrefs [ 'disablePageLabels' ] ) {
if ( ! labels || _this5 . viewerPrefs [ 'disablePageLabels' ] ) {
return ;
}
var i = 0 ,
numLabels = labels . length ;
if ( numLabels !== self . pagesCount ) {
if ( numLabels !== _this5 . pagesCount ) {
console . error ( 'The number of Page Labels does not match ' + 'the number of pages in the document.' ) ;
return ;
}
@ -694,44 +694,46 @@ var PDFViewerApplication = {
@@ -694,44 +694,46 @@ var PDFViewerApplication = {
}
pdfViewer . setPageLabels ( labels ) ;
pdfThumbnailViewer . setPageLabels ( labels ) ;
self . toolbar . setPagesCount ( pdfDocument . numPages , true ) ;
self . toolbar . setPageNumber ( pdfViewer . currentPageNumber , pdfViewer . currentPageLabel ) ;
_this5 . toolbar . setPagesCount ( pdfDocument . numPages , true ) ;
_this5 . toolbar . setPageNumber ( pdfViewer . currentPageNumber , pdfViewer . currentPageLabel ) ;
} ) ;
pagesPromise . then ( function ( ) {
if ( self . supportsPrinting ) {
pdfDocument . getJavaScript ( ) . then ( function ( javaScript ) {
if ( javaScript . length ) {
console . warn ( 'Warning: JavaScript is not supported' ) ;
self . fallback ( _pdfjs . UNSUPPORTED _FEATURES . javaScript ) ;
}
var regex = /\bprint\s*\(/ ;
for ( var i = 0 , ii = javaScript . length ; i < ii ; i ++ ) {
var js = javaScript [ i ] ;
if ( js && regex . test ( js ) ) {
setTimeout ( function ( ) {
window . print ( ) ;
} ) ;
return ;
}
}
} ) ;
if ( ! _this5 . supportsPrinting ) {
return ;
}
pdfDocument . getJavaScript ( ) . then ( function ( javaScript ) {
if ( javaScript . length ) {
console . warn ( 'Warning: JavaScript is not supported' ) ;
_this5 . fallback ( _pdfjs . UNSUPPORTED _FEATURES . javaScript ) ;
}
var regex = /\bprint\s*\(/ ;
for ( var i = 0 , ii = javaScript . length ; i < ii ; i ++ ) {
var js = javaScript [ i ] ;
if ( js && regex . test ( js ) ) {
setTimeout ( function ( ) {
window . print ( ) ;
} ) ;
return ;
}
}
} ) ;
} ) ;
Promise . all ( [ onePageRendered , _ui _utils . animationStarted ] ) . then ( function ( ) {
pdfDocument . getOutline ( ) . then ( function ( outline ) {
self . pdfOutlineViewer . render ( { outline : outline } ) ;
_this5 . pdfOutlineViewer . render ( { outline : outline } ) ;
} ) ;
pdfDocument . getAttachments ( ) . then ( function ( attachments ) {
self . pdfAttachmentViewer . render ( { attachments : attachments } ) ;
_this5 . pdfAttachmentViewer . render ( { attachments : attachments } ) ;
} ) ;
} ) ;
pdfDocument . getMetadata ( ) . then ( function ( data ) {
var info = data . info ,
metadata = data . metadata ;
self . documentInfo = info ;
self . metadata = metadata ;
pdfDocument . getMetadata ( ) . then ( function ( _ref2 ) {
var info = _ref2 . info ,
metadata = _ref2 . metadata ;
_this5 . documentInfo = info ;
_this5 . metadata = metadata ;
console . log ( 'PDF ' + pdfDocument . fingerprint + ' [' + info . PDFFormatVersion + ' ' + ( info . Producer || '-' ) . trim ( ) + ' / ' + ( info . Creator || '-' ) . trim ( ) + ']' + ' (PDF.js: ' + ( _pdfjs . version || '-' ) + ( ! _pdfjs . PDFJS . disableWebGL ? ' [WebGL]' : '' ) + ')' ) ;
var pdfTitle ;
var pdfTitle = void 0 ;
if ( metadata && metadata . has ( 'dc:title' ) ) {
var title = metadata . get ( 'dc:title' ) ;
if ( title !== 'Untitled' ) {
@ -742,11 +744,11 @@ var PDFViewerApplication = {
@@ -742,11 +744,11 @@ var PDFViewerApplication = {
pdfTitle = info [ 'Title' ] ;
}
if ( pdfTitle ) {
self . setTitle ( pdfTitle + ' - ' + document . title ) ;
_this5 . setTitle ( pdfTitle + ' - ' + document . title ) ;
}
if ( info . IsAcroFormPresent ) {
console . warn ( 'Warning: AcroForm/XFA is not supported' ) ;
self . fallback ( _pdfjs . UNSUPPORTED _FEATURES . forms ) ;
_this5 . fallback ( _pdfjs . UNSUPPORTED _FEATURES . forms ) ;
}
} ) ;
} ,