@ -720,47 +720,54 @@ exports.SimpleLinkService = exports.PDFLinkService = undefined;
var _typeof = typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ? function ( obj ) { return typeof obj ; } : function ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ;
var _typeof = typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ? function ( obj ) { return typeof obj ; } : function ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ;
var _createClass = function ( ) { function defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ( ) ;
var _dom _events = _ _w _pdfjs _require _ _ ( 2 ) ;
var _dom _events = _ _w _pdfjs _require _ _ ( 2 ) ;
var _ui _utils = _ _w _pdfjs _require _ _ ( 1 ) ;
var _ui _utils = _ _w _pdfjs _require _ _ ( 1 ) ;
var PDFLinkService = function PDFLinkServiceClosure ( ) {
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
function PDFLinkService ( options ) {
options = options || { } ;
var PDFLinkService = function ( ) {
this . eventBus = options . eventBus || ( 0 , _dom _events . getGlobalEventBus ) ( ) ;
function PDFLinkService ( ) {
var _ref = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ,
eventBus = _ref . eventBus ;
_classCallCheck ( this , PDFLinkService ) ;
this . eventBus = eventBus || ( 0 , _dom _events . getGlobalEventBus ) ( ) ;
this . baseUrl = null ;
this . baseUrl = null ;
this . pdfDocument = null ;
this . pdfDocument = null ;
this . pdfViewer = null ;
this . pdfViewer = null ;
this . pdfHistory = null ;
this . pdfHistory = null ;
this . _pagesRefCache = null ;
this . _pagesRefCache = null ;
}
}
PDFLinkService . prototype = {
setDocument : function PDFLinkService _setDocument ( pdfDocument , baseUrl ) {
_createClass ( PDFLinkService , [ {
key : 'setDocument' ,
value : function setDocument ( pdfDocument , baseUrl ) {
this . baseUrl = baseUrl ;
this . baseUrl = baseUrl ;
this . pdfDocument = pdfDocument ;
this . pdfDocument = pdfDocument ;
this . _pagesRefCache = Object . create ( null ) ;
this . _pagesRefCache = Object . create ( null ) ;
} ,
}
setViewer : function PDFLinkService _setViewer ( pdfViewer ) {
} , {
key : 'setViewer' ,
value : function setViewer ( pdfViewer ) {
this . pdfViewer = pdfViewer ;
this . pdfViewer = pdfViewer ;
} ,
}
setHistory : function PDFLinkService _setHistory ( pdfHistory ) {
} , {
key : 'setHistory' ,
value : function setHistory ( pdfHistory ) {
this . pdfHistory = pdfHistory ;
this . pdfHistory = pdfHistory ;
} ,
}
get pagesCount ( ) {
} , {
return this . pdfDocument ? this . pdfDocument . numPages : 0 ;
key : 'navigateTo' ,
} ,
value : function navigateTo ( dest ) {
get page ( ) {
return this . pdfViewer . currentPageNumber ;
} ,
set page ( value ) {
this . pdfViewer . currentPageNumber = value ;
} ,
navigateTo : function navigateTo ( dest ) {
var _this = this ;
var _this = this ;
var goToDestination = function goToDestination ( _ref ) {
var goToDestination = function goToDestination ( _ref2 ) {
var namedDest = _ref . namedDest ,
var namedDest = _ref2 . namedDest ,
explicitDest = _ref . explicitDest ;
explicitDest = _ref2 . explicitDest ;
var destRef = explicitDest [ 0 ] ,
var destRef = explicitDest [ 0 ] ,
pageNumber = void 0 ;
pageNumber = void 0 ;
@ -821,8 +828,10 @@ var PDFLinkService = function PDFLinkServiceClosure() {
}
}
goToDestination ( data ) ;
goToDestination ( data ) ;
} ) ;
} ) ;
} ,
}
getDestinationHash : function getDestinationHash ( dest ) {
} , {
key : 'getDestinationHash' ,
value : function getDestinationHash ( dest ) {
if ( typeof dest === 'string' ) {
if ( typeof dest === 'string' ) {
return this . getAnchorUrl ( '#' + escape ( dest ) ) ;
return this . getAnchorUrl ( '#' + escape ( dest ) ) ;
}
}
@ -831,13 +840,17 @@ var PDFLinkService = function PDFLinkServiceClosure() {
return this . getAnchorUrl ( '#' + escape ( str ) ) ;
return this . getAnchorUrl ( '#' + escape ( str ) ) ;
}
}
return this . getAnchorUrl ( '' ) ;
return this . getAnchorUrl ( '' ) ;
} ,
}
} , {
getAnchorUrl : function PDFLinkService _getAnchorUrl ( anchor ) {
key : 'getAnchorUrl' ,
value : function getAnchorUrl ( anchor ) {
return ( this . baseUrl || '' ) + anchor ;
return ( this . baseUrl || '' ) + anchor ;
} ,
}
setHash : function PDFLinkService _setHash ( hash ) {
} , {
var pageNumber , dest ;
key : 'setHash' ,
value : function setHash ( hash ) {
var pageNumber = void 0 ,
dest = void 0 ;
if ( hash . indexOf ( '=' ) >= 0 ) {
if ( hash . indexOf ( '=' ) >= 0 ) {
var params = ( 0 , _ui _utils . parseQueryString ) ( hash ) ;
var params = ( 0 , _ui _utils . parseQueryString ) ( hash ) ;
if ( 'search' in params ) {
if ( 'search' in params ) {
@ -870,12 +883,12 @@ var PDFLinkService = function PDFLinkServiceClosure() {
dest = [ null , { name : zoomArg } , zoomArgs . length > 1 ? zoomArgs [ 1 ] | 0 : null ] ;
dest = [ null , { name : zoomArg } , zoomArgs . length > 1 ? zoomArgs [ 1 ] | 0 : null ] ;
} else if ( zoomArg === 'FitR' ) {
} else if ( zoomArg === 'FitR' ) {
if ( zoomArgs . length !== 5 ) {
if ( zoomArgs . length !== 5 ) {
console . error ( 'PDFLinkService_setHash: ' + 'Not enough parameters for \'FitR\' .' ) ;
console . error ( 'PDFLinkService.setHash: Not enough parameters for "FitR" .' ) ;
} else {
} else {
dest = [ null , { name : zoomArg } , zoomArgs [ 1 ] | 0 , zoomArgs [ 2 ] | 0 , zoomArgs [ 3 ] | 0 , zoomArgs [ 4 ] | 0 ] ;
dest = [ null , { name : zoomArg } , zoomArgs [ 1 ] | 0 , zoomArgs [ 2 ] | 0 , zoomArgs [ 3 ] | 0 , zoomArgs [ 4 ] | 0 ] ;
}
}
} else {
} else {
console . error ( 'PDFLinkService_setHash: \' ' + zoomArg + '\' is not a valid zoom value.' ) ;
console . error ( 'PDFLinkService.setHash: " ' + zoomArg + '" is not ' + ' a valid zoom value.' ) ;
}
}
}
}
}
}
@ -896,7 +909,7 @@ var PDFLinkService = function PDFLinkServiceClosure() {
}
}
} else {
} else {
if ( /^\d+$/ . test ( hash ) && hash <= this . pagesCount ) {
if ( /^\d+$/ . test ( hash ) && hash <= this . pagesCount ) {
console . warn ( 'PDFLinkService_setHash: specifying a page number ' + 'directly after the hash symbol (#) is deprecated, ' + 'please use the "#page=' + hash + '" form instead.' ) ;
console . warn ( 'PDFLinkService_setHash: specifying a page number ' + 'directly after the hash symbol (#) is deprecated, ' + ( 'please use the "#page=' + hash + '" form instead.' ) ) ;
this . page = hash | 0 ;
this . page = hash | 0 ;
}
}
dest = unescape ( hash ) ;
dest = unescape ( hash ) ;
@ -913,10 +926,12 @@ var PDFLinkService = function PDFLinkServiceClosure() {
this . navigateTo ( dest ) ;
this . navigateTo ( dest ) ;
return ;
return ;
}
}
console . error ( 'PDFLinkService_setHash: \' ' + unescape ( hash ) + '\' is not a valid destination.' ) ;
console . error ( 'PDFLinkService.setHash: " ' + unescape ( hash ) + '" is not ' + ' a valid destination.' ) ;
}
}
} ,
}
executeNamedAction : function PDFLinkService _executeNamedAction ( action ) {
} , {
key : 'executeNamedAction' ,
value : function executeNamedAction ( action ) {
switch ( action ) {
switch ( action ) {
case 'GoBack' :
case 'GoBack' :
if ( this . pdfHistory ) {
if ( this . pdfHistory ) {
@ -951,27 +966,51 @@ var PDFLinkService = function PDFLinkServiceClosure() {
source : this ,
source : this ,
action : action
action : action
} ) ;
} ) ;
} ,
}
onFileAttachmentAnnotation : function onFileAttachmentAnnotation ( ) {
} , {
var params = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
key : 'onFileAttachmentAnnotation' ,
value : function onFileAttachmentAnnotation ( _ref3 ) {
var id = _ref3 . id ,
filename = _ref3 . filename ,
content = _ref3 . content ;
this . eventBus . dispatch ( 'fileattachmentannotation' , {
this . eventBus . dispatch ( 'fileattachmentannotation' , {
source : this ,
source : this ,
id : params . id ,
id : id ,
filename : params . filename ,
filename : filename ,
content : params . content
content : content
} ) ;
} ) ;
} ,
}
} , {
cachePageRef : function PDFLinkService _cachePageRef ( pageNum , pageRef ) {
key : 'cachePageRef' ,
value : function cachePageRef ( pageNum , pageRef ) {
var refStr = pageRef . num + ' ' + pageRef . gen + ' R' ;
var refStr = pageRef . num + ' ' + pageRef . gen + ' R' ;
this . _pagesRefCache [ refStr ] = pageNum ;
this . _pagesRefCache [ refStr ] = pageNum ;
} ,
}
_cachedPageNumber : function PDFLinkService _cachedPageNumber ( pageRef ) {
} , {
key : '_cachedPageNumber' ,
value : function _cachedPageNumber ( pageRef ) {
var refStr = pageRef . num + ' ' + pageRef . gen + ' R' ;
var refStr = pageRef . num + ' ' + pageRef . gen + ' R' ;
return this . _pagesRefCache && this . _pagesRefCache [ refStr ] || null ;
return this . _pagesRefCache && this . _pagesRefCache [ refStr ] || null ;
}
}
} ;
} , {
key : 'pagesCount' ,
get : function get ( ) {
return this . pdfDocument ? this . pdfDocument . numPages : 0 ;
}
} , {
key : 'page' ,
get : function get ( ) {
return this . pdfViewer . currentPageNumber ;
} ,
set : function set ( value ) {
this . pdfViewer . currentPageNumber = value ;
}
} ] ) ;
return PDFLinkService ;
} ( ) ;
function isValidExplicitDestination ( dest ) {
function isValidExplicitDestination ( dest ) {
if ( ! ( dest instanceof Array ) ) {
if ( ! ( dest instanceof Array ) ) {
return false ;
return false ;
@ -1023,29 +1062,52 @@ var PDFLinkService = function PDFLinkServiceClosure() {
}
}
return true ;
return true ;
}
}
return PDFLinkService ;
} ( ) ;
var SimpleLinkService = function ( ) {
var SimpleLinkService = function SimpleLinkServiceClosure ( ) {
function SimpleLinkService ( ) {
function SimpleLinkService ( ) { }
_classCallCheck ( this , SimpleLinkService ) ;
SimpleLinkService . prototype = {
}
get page ( ) {
return 0 ;
_createClass ( SimpleLinkService , [ {
} ,
key : 'navigateTo' ,
set page ( value ) { } ,
value : function navigateTo ( dest ) { }
navigateTo : function navigateTo ( dest ) { } ,
} , {
getDestinationHash : function getDestinationHash ( dest ) {
key : 'getDestinationHash' ,
value : function getDestinationHash ( dest ) {
return '#' ;
return '#' ;
} ,
}
getAnchorUrl : function getAnchorUrl ( hash ) {
} , {
key : 'getAnchorUrl' ,
value : function getAnchorUrl ( hash ) {
return '#' ;
return '#' ;
}
} , {
key : 'setHash' ,
value : function setHash ( hash ) { }
} , {
key : 'executeNamedAction' ,
value : function executeNamedAction ( action ) { }
} , {
key : 'onFileAttachmentAnnotation' ,
value : function onFileAttachmentAnnotation ( _ref4 ) {
var id = _ref4 . id ,
filename = _ref4 . filename ,
content = _ref4 . content ;
}
} , {
key : 'cachePageRef' ,
value : function cachePageRef ( pageNum , pageRef ) { }
} , {
key : 'page' ,
get : function get ( ) {
return 0 ;
} ,
} ,
setHash : function setHash ( hash ) { } ,
set : function set ( value ) { }
executeNamedAction : function executeNamedAction ( action ) { } ,
} ] ) ;
onFileAttachmentAnnotation : function onFileAttachmentAnnotation ( params ) { } ,
cachePageRef : function cachePageRef ( pageNum , pageRef ) { }
} ;
return SimpleLinkService ;
return SimpleLinkService ;
} ( ) ;
} ( ) ;
exports . PDFLinkService = PDFLinkService ;
exports . PDFLinkService = PDFLinkService ;
exports . SimpleLinkService = SimpleLinkService ;
exports . SimpleLinkService = SimpleLinkService ;