2013-01-24 14:03:12 +01:00
var DEFAULT _URL = null , DEFAULT _SCALE = "auto" , DEFAULT _SCALE _DELTA = 1.1 , UNKNOWN _SCALE = 0 , CACHE _SIZE = 20 , CSS _UNITS = 96 / 72 , SCROLLBAR _PADDING = 40 , VERTICAL _PADDING = 5 , MIN _SCALE = 0.25 , MAX _SCALE = 4 , IMAGE _DIR = "./images/" , SETTINGS _MEMORY = 20 , ANNOT _MIN _SIZE = 10 , RenderingStates = { INITIAL : 0 , RUNNING : 1 , PAUSED : 2 , FINISHED : 3 } , FindStates = { FIND _FOUND : 0 , FIND _NOTFOUND : 1 , FIND _WRAPPED : 2 , FIND _PENDING : 3 } ; PDFJS . workerSrc = "pdf.js" ; var mozL10n = document . mozL10n || document . webL10n ;
function getFileName ( a ) { var b = a . indexOf ( "#" ) , c = a . indexOf ( "?" ) , b = Math . min ( 0 < b ? b : a . length , 0 < c ? c : a . length ) ; return a . substring ( a . lastIndexOf ( "/" , b ) + 1 , b ) } function scrollIntoView ( a , b ) { for ( var c = a . offsetParent , d = a . offsetTop ; c . clientHeight == c . scrollHeight ; ) if ( d += c . offsetTop , c = c . offsetParent , ! c ) return ; b && ( d += b . top ) ; c . scrollTop = d }
var Cache = function ( a ) { var b = [ ] ; this . push = function ( c ) { var d = b . indexOf ( c ) ; 0 <= d && b . splice ( d ) ; b . push ( c ) ; b . length > a && b . shift ( ) . destroy ( ) } } , ProgressBar = function ( ) { function a ( a , c ) { this . div = document . querySelector ( a + " .progress" ) ; this . height = c . height || 100 ; this . width = c . width || 100 ; this . units = c . units || "%" ; this . div . style . height = this . height + this . units } a . prototype = { updateBar : function ( ) { if ( this . _indeterminate ) this . div . classList . add ( "indeterminate" ) ; else { var a = this . width * this . _percent / 100 ; 95 < this . _percent ? this . div . classList . add ( "full" ) :
this . div . classList . remove ( "full" ) ; this . div . classList . remove ( "indeterminate" ) ; this . div . style . width = a + this . units } } , get percent ( ) { return this . _percent } , set percent ( a ) { this . _indeterminate = isNaN ( a ) ; this . _percent = Math . min ( Math . max ( a , 0 ) , 100 ) ; this . updateBar ( ) } } ; return a } ( ) , Settings = function ( ) { function a ( a ) { this . fingerprint = a ; this . initializedPromise = new PDFJS . Promise ; a = function ( a ) { this . initialize ( a || "{}" ) ; this . initializedPromise . resolve ( ) } . bind ( this ) ; b && a ( localStorage . getItem ( "database" ) ) } var b ; try { b = "localStorage" in
2013-10-03 14:19:40 +02:00
window && null !== window . localStorage && localStorage } catch ( c ) { b = ! 1 } a . prototype = { initialize : function ( a ) { a = JSON . parse ( a ) ; "files" in a || ( a . files = [ ] ) ; a . files . length >= SETTINGS _MEMORY && a . files . shift ( ) ; for ( var b , c = 0 , e = a . files . length ; c < e ; c ++ ) if ( a . files [ c ] . fingerprint == this . fingerprint ) { b = c ; break } "number" != typeof b && ( b = a . files . push ( { fingerprint : this . fingerprint } ) - 1 ) ; this . file = a . files [ b ] ; this . database = a } , set : function ( a , c ) { if ( this . initializedPromise . isResolved ) { this . file [ a ] = c ; var h = JSON . stringify ( this . database ) ;
b && localStorage . setItem ( "database" , h ) } } , get : function ( a , b ) { return this . initializedPromise . isResolved ? this . file [ a ] || b : b } } ; return a } ( ) , cache = new Cache ( CACHE _SIZE ) , currentPageNumber = 1 , PDFFindController = { startedTextExtraction : ! 1 , extractTextPromises : [ ] , active : ! 1 , pageContents : [ ] , pageMatches : [ ] , selected : { pageIdx : - 1 , matchIdx : - 1 } , offset : { pageIdx : null , matchIdx : null } , resumePageIdx : null , resumeCallback : null , state : null , dirtyMatch : ! 1 , findTimeout : null , initialize : function ( ) { var a = [ "find" , "findagain" , "findhighlightallchange" ,
"findcasesensitivitychange" ] ; this . handleEvent = this . handleEvent . bind ( this ) ; for ( var b = 0 ; b < a . length ; b ++ ) window . addEventListener ( a [ b ] , this . handleEvent ) } , calcFindMatch : function ( a ) { var b = this . pageContents [ a ] , c = this . state . query , d = this . state . caseSensitive , f = c . length ; if ( 0 !== f ) { d || ( b = b . toLowerCase ( ) , c = c . toLowerCase ( ) ) ; for ( var d = [ ] , h = - f ; ; ) { h = b . indexOf ( c , h + f ) ; if ( - 1 === h ) break ; d . push ( h ) } this . pageMatches [ a ] = d ; this . updatePage ( a ) ; this . resumePageIdx === a && ( a = this . resumeCallback , this . resumeCallback = this . resumePageIdx =
null , a ( ) ) } } , extractText : function ( ) { function a ( b ) { PDFView . pages [ b ] . getTextContent ( ) . then ( function ( c ) { c = c . bidiTexts ; for ( var e = "" , g = 0 ; g < c . length ; g ++ ) e += c [ g ] . str ; d . pageContents . push ( e ) ; d . extractTextPromises [ b ] . resolve ( b ) ; b + 1 < PDFView . pages . length && a ( b + 1 ) } ) } if ( ! this . startedTextExtraction ) { this . startedTextExtraction = ! 0 ; this . pageContents = [ ] ; for ( var b = 0 , c = PDFView . pdfDocument . numPages ; b < c ; b ++ ) this . extractTextPromises . push ( new PDFJS . Promise ) ; var d = this ; a ( 0 ) ; return this . extractTextPromise } } , handleEvent : function ( a ) { if ( null ===
2013-01-24 14:03:12 +01:00
this . state || "findagain" !== a . type ) this . dirtyMatch = ! 0 ; this . state = a . detail ; this . updateUIState ( FindStates . FIND _PENDING ) ; this . extractText ( ) ; clearTimeout ( this . findTimeout ) ; "find" === a . type ? this . findTimeout = setTimeout ( this . nextMatch . bind ( this ) , 250 ) : this . nextMatch ( ) } , updatePage : function ( a ) { var b = PDFView . pages [ a ] ; this . selected . pageIdx === a && b . scrollIntoView ( ) ; b . textLayer && b . textLayer . updateMatches ( ) } , nextMatch : function ( ) { var a = this . state . findPrevious , b = PDFView . pages . length ; this . active = ! 0 ; if ( this . dirtyMatch ) { this . dirtyMatch =
! 1 ; this . selected . pageIdx = this . selected . matchIdx = - 1 ; this . offset . pageIdx = a ? b - 1 : 0 ; this . offset . matchIdx = null ; this . hadMatch = ! 1 ; this . resumePageIdx = this . resumeCallback = null ; this . pageMatches = [ ] ; for ( var c = this , d = 0 ; d < b ; d ++ ) this . updatePage ( d ) , this . extractTextPromises [ d ] . onData ( function ( a ) { setTimeout ( function ( ) { c . calcFindMatch ( a ) } ) } ) } if ( "" === this . state . query ) this . updateUIState ( FindStates . FIND _FOUND ) ; else if ( ! this . resumeCallback ) { b = this . offset ; if ( null !== b . matchIdx ) { d = this . pageMatches [ b . pageIdx ] . length ; if ( ! a &&
b . matchIdx + 1 < d || a && 0 < b . matchIdx ) { this . hadMatch = ! 0 ; b . matchIdx = a ? b . matchIdx - 1 : b . matchIdx + 1 ; this . updateMatch ( ! 0 ) ; return } this . advanceOffsetPage ( a ) } this . nextPageMatch ( ) } } , nextPageMatch : function ( ) { null !== this . resumePageIdx && console . error ( "There can only be one pending page." ) ; var a = function ( a ) { var b = this . offset ; a = a . length ; var c = this . state . findPrevious ; if ( a ) this . hadMatch = ! 0 , b . matchIdx = c ? a - 1 : 0 , this . updateMatch ( ! 0 ) ; else { this . advanceOffsetPage ( c ) ; if ( b . wrapped && ( b . matchIdx = null , ! this . hadMatch ) ) { this . updateMatch ( ! 1 ) ;
return } this . nextPageMatch ( ) } } . bind ( this ) , b = this . offset . pageIdx , c = this . pageMatches ; c [ b ] ? a ( c [ b ] ) : ( this . resumeCallback = function ( ) { a ( c [ b ] ) } , this . resumePageIdx = b ) } , advanceOffsetPage : function ( a ) { var b = this . offset , c = this . extractTextPromises . length ; b . pageIdx = a ? b . pageIdx - 1 : b . pageIdx + 1 ; b . matchIdx = null ; if ( b . pageIdx >= c || 0 > b . pageIdx ) b . pageIdx = a ? c - 1 : 0 , b . wrapped = ! 0 } , updateMatch : function ( a ) { var b = FindStates . FIND _NOTFOUND , c = this . offset . wrapped ; this . offset . wrapped = ! 1 ; a && ( a = this . selected . pageIdx , this . selected . pageIdx =
this . offset . pageIdx , this . selected . matchIdx = this . offset . matchIdx , b = c ? FindStates . FIND _WRAPPED : FindStates . FIND _FOUND , - 1 !== a && a !== this . selected . pageIdx && this . updatePage ( a ) ) ; this . updateUIState ( b , this . state . findPrevious ) ; - 1 !== this . selected . pageIdx && this . updatePage ( this . selected . pageIdx , ! 0 ) } , updateUIState : function ( a , b ) { PDFView . supportsIntegratedFind ? FirefoxCom . request ( "updateFindControlState" , { result : a , findPrevious : b } ) : PDFFindBar . updateUIState ( a , b ) } } , PDFFindBar = { opened : ! 1 , initialize : function ( ) { this . bar =
document . getElementById ( "findbar" ) ; this . toggleButton = document . getElementById ( "viewFind" ) ; this . findField = document . getElementById ( "findInput" ) ; this . highlightAll = document . getElementById ( "findHighlightAll" ) ; this . caseSensitive = document . getElementById ( "findMatchCase" ) ; this . findMsg = document . getElementById ( "findMsg" ) ; this . findStatusIcon = document . getElementById ( "findStatusIcon" ) ; var a = this ; this . toggleButton . addEventListener ( "click" , function ( ) { a . toggle ( ) } ) ; this . findField . addEventListener ( "input" , function ( ) { a . dispatchEvent ( "" ) } ) ;
this . bar . addEventListener ( "keydown" , function ( b ) { switch ( b . keyCode ) { case 13 : b . target === a . findField && a . dispatchEvent ( "again" , b . shiftKey ) ; break ; case 27 : a . close ( ) } } ) ; document . getElementById ( "findPrevious" ) . addEventListener ( "click" , function ( ) { a . dispatchEvent ( "again" , ! 0 ) } ) ; document . getElementById ( "findNext" ) . addEventListener ( "click" , function ( ) { a . dispatchEvent ( "again" , ! 1 ) } ) ; this . highlightAll . addEventListener ( "click" , function ( ) { a . dispatchEvent ( "highlightallchange" ) } ) ; this . caseSensitive . addEventListener ( "click" ,
2013-10-03 14:19:40 +02:00
function ( ) { a . dispatchEvent ( "casesensitivitychange" ) } ) } , dispatchEvent : function ( a , b ) { var c = document . createEvent ( "CustomEvent" ) ; c . initCustomEvent ( "find" + a , ! 0 , ! 0 , { query : this . findField . value , caseSensitive : this . caseSensitive . checked , highlightAll : this . highlightAll . checked , findPrevious : b } ) ; return window . dispatchEvent ( c ) } , updateUIState : function ( a , b ) { var c = ! 1 , d = "" , f = "" ; switch ( a ) { case FindStates . FIND _PENDING : f = "pending" ; break ; case FindStates . FIND _NOTFOUND : d = mozL10n . get ( "find_not_found" , null , "Phrase not found" ) ;
c = ! 0 ; break ; case FindStates . FIND _WRAPPED : d = b ? mozL10n . get ( "find_reached_top" , null , "Reached top of document, continued from bottom" ) : mozL10n . get ( "find_reached_bottom" , null , "Reached end of document, continued from top" ) } c ? this . findField . classList . add ( "notFound" ) : this . findField . classList . remove ( "notFound" ) ; this . findField . setAttribute ( "data-status" , f ) ; this . findMsg . textContent = d } , open : function ( ) { this . opened || ( this . opened = ! 0 , this . toggleButton . classList . add ( "toggled" ) , this . bar . classList . remove ( "hidden" ) , this . findField . select ( ) ,
2013-01-24 14:03:12 +01:00
this . findField . focus ( ) ) } , close : function ( ) { this . opened && ( this . opened = ! 1 , this . toggleButton . classList . remove ( "toggled" ) , this . bar . classList . add ( "hidden" ) , PDFFindController . active = ! 1 ) } , toggle : function ( ) { this . opened ? this . close ( ) : this . open ( ) } } , PDFView = { pages : [ ] , thumbnails : [ ] , currentScale : UNKNOWN _SCALE , currentScaleValue : null , initialBookmark : document . location . hash . substring ( 1 ) , startedTextExtraction : ! 1 , pageText : [ ] , container : null , thumbnailContainer : null , initialized : ! 1 , fellback : ! 1 , pdfDocument : null , sidebarOpen : ! 1 ,
pageViewScroll : null , thumbnailViewScroll : null , isFullscreen : ! 1 , previousScale : null , pageRotation : 0 , mouseScrollTimeStamp : 0 , mouseScrollDelta : 0 , lastScroll : 0 , previousPageNumber : 1 , initialize : function ( ) { var a = this , b = this . container = document . getElementById ( "viewerContainer" ) ; this . pageViewScroll = { } ; this . watchScroll ( b , this . pageViewScroll , updateViewarea ) ; var c = this . thumbnailContainer = document . getElementById ( "thumbnailView" ) ; this . thumbnailViewScroll = { } ; this . watchScroll ( c , this . thumbnailViewScroll , this . renderHighestPriority . bind ( this ) ) ;
2013-10-03 14:19:40 +02:00
PDFFindBar . initialize ( ) ; PDFFindController . initialize ( ) ; this . initialized = ! 0 ; b . addEventListener ( "scroll" , function ( ) { a . lastScroll = Date . now ( ) } , ! 1 ) } , watchScroll : function ( a , b , c ) { b . down = ! 0 ; b . lastY = a . scrollTop ; a . addEventListener ( "scroll" , function ( d ) { d = a . scrollTop ; var f = b . lastY ; d > f ? b . down = ! 0 : d < f && ( b . down = ! 1 ) ; b . lastY = d ; c ( ) } , ! 0 ) } , setScale : function ( a , b , c ) { if ( a != this . currentScale ) { for ( var d = this . pages , f = 0 ; f < d . length ; f ++ ) d [ f ] . update ( a * CSS _UNITS ) ; c || this . currentScale == a || this . pages [ this . page - 1 ] . scrollIntoView ( ) ;
this . currentScale = a ; c = document . createEvent ( "UIEvents" ) ; c . initUIEvent ( "scalechange" , ! 1 , ! 1 , window , 0 ) ; c . scale = a ; c . resetAutoSettings = b ; window . dispatchEvent ( c ) } } , parseScale : function ( a , b , c ) { if ( "custom" != a ) { var d = parseFloat ( a ) ; this . currentScaleValue = a ; if ( d ) this . setScale ( d , ! 0 , c ) ; else { var f = this . container , h = this . pages [ this . page - 1 ] ; if ( h ) { var e = ( f . clientWidth - SCROLLBAR _PADDING ) / h . width * h . scale / CSS _UNITS , f = ( f . clientHeight - VERTICAL _PADDING ) / h . height * h . scale / CSS _UNITS ; switch ( a ) { case "page-actual" : d = 1 ; break ; case "page-width" : d =
e ; break ; case "page-height" : d = f ; break ; case "page-fit" : d = Math . min ( e , f ) ; break ; case "auto" : d = Math . min ( 1 , e ) } this . setScale ( d , b , c ) ; selectScaleOption ( a ) } } } } , zoomIn : function ( ) { var a = ( this . currentScale * DEFAULT _SCALE _DELTA ) . toFixed ( 2 ) , a = Math . min ( MAX _SCALE , a ) ; this . parseScale ( a , ! 0 ) } , zoomOut : function ( ) { var a = ( this . currentScale / DEFAULT _SCALE _DELTA ) . toFixed ( 2 ) , a = Math . max ( MIN _SCALE , a ) ; this . parseScale ( a , ! 0 ) } , set page ( a ) { var b = this . pages ; document . getElementById ( "pageNumber" ) ; var c = document . createEvent ( "UIEvents" ) ; c . initUIEvent ( "pagechange" ,
2013-01-24 14:03:12 +01:00
! 1 , ! 1 , window , 0 ) ; 0 < a && a <= b . length ? ( b [ a - 1 ] . updateStats ( ) , this . previousPageNumber = currentPageNumber , currentPageNumber = a , c . pageNumber = a , window . dispatchEvent ( c ) , updateViewarea . inProgress || this . loading && 1 == a || b [ a - 1 ] . scrollIntoView ( ) ) : ( this . previousPageNumber = a , c . pageNumber = this . page , window . dispatchEvent ( c ) ) } , get page ( ) { return currentPageNumber } , get supportsPrinting ( ) { var a = "mozPrintCallback" in document . createElement ( "canvas" ) ; Object . defineProperty ( this , "supportsPrinting" , { value : a , enumerable : ! 0 , configurable : ! 0 ,
writable : ! 1 } ) ; return a } , get supportsFullscreen ( ) { var a = document . documentElement , a = a . requestFullscreen || a . mozRequestFullScreen || a . webkitRequestFullScreen ; window . frameElement && ( a = ! 1 ) ; Object . defineProperty ( this , "supportsFullScreen" , { value : a , enumerable : ! 0 , configurable : ! 0 , writable : ! 1 } ) ; return a } , get supportsIntegratedFind ( ) { Object . defineProperty ( this , "supportsIntegratedFind" , { value : ! 1 , enumerable : ! 0 , configurable : ! 0 , writable : ! 1 } ) ; return ! 1 } , get supportsDocumentFonts ( ) { Object . defineProperty ( this , "supportsDocumentFonts" ,
{ value : ! 0 , enumerable : ! 0 , configurable : ! 0 , writable : ! 1 } ) ; return ! 0 } , get isHorizontalScrollbarEnabled ( ) { var a = document . getElementById ( "viewerContainer" ) ; return a . scrollWidth > a . clientWidth } , initPassiveLoading : function ( ) { PDFView . loadingBar || ( PDFView . loadingBar = new ProgressBar ( "#loadingBar" , { } ) ) ; window . addEventListener ( "message" , function ( a ) { var b = a . data ; if ( "object" === typeof b && "pdfjsLoadAction" in b ) switch ( b . pdfjsLoadAction ) { case "progress" : PDFView . progress ( b . loaded / b . total ) ; break ; case "complete" : if ( ! b . data ) { PDFView . error ( mozL10n . get ( "loading_error" ,
null , "An error occurred while loading the PDF." ) , a ) ; break } PDFView . open ( b . data , 0 ) } } ) ; FirefoxCom . requestSync ( "initPassiveLoading" , null ) } , setTitleUsingUrl : function ( a ) { this . url = a ; try { this . setTitle ( decodeURIComponent ( getFileName ( a ) ) || a ) } catch ( b ) { this . setTitle ( a ) } } , setTitle : function ( a ) { document . title = a } , open : function ( a , b , c ) { var d = { password : c } ; "string" === typeof a ? ( this . setTitleUsingUrl ( a ) , d . url = a ) : a && "byteLength" in a && ( d . data = a ) ; PDFView . loadingBar || ( PDFView . loadingBar = new ProgressBar ( "#loadingBar" , { } ) ) ;
2013-10-03 14:19:40 +02:00
this . pdfDocument = null ; var f = this ; f . loading = ! 0 ; PDFJS . getDocument ( d ) . then ( function ( a ) { f . load ( a , b ) ; f . loading = ! 1 } , function ( d , e ) { if ( e && "PasswordException" === e . name && "needpassword" === e . code ) { var g = mozL10n . get ( "request_password" , null , "PDF is protected by a password:" ) ; if ( ( c = prompt ( g ) ) && 0 < c . length ) return PDFView . open ( a , b , c ) } g = mozL10n . get ( "loading_error" , null , "An error occurred while loading the PDF." ) ; e && "InvalidPDFException" === e . name && ( g = mozL10n . get ( "invalid_file_error" , null , "Invalid or corrupted PDF file." ) ) ;
document . getElementById ( "loading" ) . textContent = mozL10n . get ( "loading_error_indicator" , null , "Error" ) ; f . error ( g , { message : d } ) ; f . loading = ! 1 } , function ( a ) { f . progress ( a . loaded / a . total ) } ) } , download : function ( ) { var a = this . url . split ( "#" ) [ 0 ] ; window . open ( a + "#pdfjs.action=download" , "_parent" ) } , fallback : function ( ) { } , navigateTo : function ( a ) { "string" === typeof a && ( a = this . destinations [ a ] ) ; if ( a instanceof Array ) { var b = a [ 0 ] , b = b instanceof Object ? this . pagesRefMap [ b . num + " " + b . gen + " R" ] : b + 1 ; b > this . pages . length && ( b = this . pages . length ) ;
b && ( this . page = b , this . pages [ b - 1 ] . scrollIntoView ( a ) ) } } , getDestinationHash : function ( a ) { if ( "string" === typeof a ) return PDFView . getAnchorUrl ( "#" + escape ( a ) ) ; if ( a instanceof Array ) { var b = a [ 0 ] ; if ( b = b instanceof Object ? this . pagesRefMap [ b . num + " " + b . gen + " R" ] : b + 1 ) { var b = PDFView . getAnchorUrl ( "#page=" + b ) , c = a [ 1 ] ; "object" === typeof c && "name" in c && "XYZ" == c . name && ( b += "&zoom=" + 100 * ( a [ 4 ] || this . currentScale ) , a [ 2 ] || a [ 3 ] ) && ( b += "," + ( a [ 2 ] || 0 ) + "," + ( a [ 3 ] || 0 ) ) ; return b } } return "" } , getAnchorUrl : function ( a ) { return a } , getOutputScale : function ( ) { var a =
2013-01-24 14:03:12 +01:00
"devicePixelRatio" in window ? window . devicePixelRatio : 1 ; return { sx : a , sy : a , scaled : 1 != a } } , error : function ( a , b ) { var c = mozL10n . get ( "error_version_info" , { version : PDFJS . version || "?" , build : PDFJS . build || "?" } , "PDF.js v{{version}} (build: {{build}})" ) + "\n" ; b && ( c += mozL10n . get ( "error_message" , { message : b . message } , "Message: {{message}}" ) , b . stack ? c += "\n" + mozL10n . get ( "error_stack" , { stack : b . stack } , "Stack: {{stack}}" ) : ( b . filename && ( c += "\n" + mozL10n . get ( "error_file" , { file : b . filename } , "File: {{file}}" ) ) , b . lineNumber && ( c +=
2013-10-03 14:19:40 +02:00
"\n" + mozL10n . get ( "error_line" , { line : b . lineNumber } , "Line: {{line}}" ) ) ) ) ; document . getElementById ( "loadingBox" ) . setAttribute ( "hidden" , "true" ) ; var d = document . getElementById ( "errorWrapper" ) ; d . removeAttribute ( "hidden" ) ; document . getElementById ( "errorMessage" ) . textContent = a ; document . getElementById ( "errorClose" ) . onclick = function ( ) { d . setAttribute ( "hidden" , "true" ) } ; var f = document . getElementById ( "errorMoreInfo" ) , h = document . getElementById ( "errorShowMore" ) , e = document . getElementById ( "errorShowLess" ) ; h . onclick = function ( ) { f . removeAttribute ( "hidden" ) ;
h . setAttribute ( "hidden" , "true" ) ; e . removeAttribute ( "hidden" ) } ; e . onclick = function ( ) { f . setAttribute ( "hidden" , "true" ) ; h . removeAttribute ( "hidden" ) ; e . setAttribute ( "hidden" , "true" ) } ; h . removeAttribute ( "hidden" ) ; e . setAttribute ( "hidden" , "true" ) ; f . value = c ; f . rows = c . split ( "\n" ) . length - 1 } , progress : function ( a ) { a = Math . round ( 100 * a ) ; PDFView . loadingBar . percent = a } , load : function ( a , b ) { function c ( a , b ) { a . onAfterDraw = function ( ) { b . setImage ( a . canvas ) } } this . pdfDocument = a ; document . getElementById ( "errorWrapper" ) . setAttribute ( "hidden" ,
"true" ) ; document . getElementById ( "loadingBox" ) . setAttribute ( "hidden" , "true" ) ; document . getElementById ( "loading" ) . textContent = "" ; var d = document . getElementById ( "thumbnailView" ) ; for ( d . parentNode . scrollTop = 0 ; d . hasChildNodes ( ) ; ) d . removeChild ( d . lastChild ) ; "_loadingInterval" in d && clearInterval ( d . _loadingInterval ) ; for ( var f = document . getElementById ( "viewer" ) ; f . hasChildNodes ( ) ; ) f . removeChild ( f . lastChild ) ; var h = a . numPages , e = a . fingerprint ; document . getElementById ( "numPages" ) . textContent = mozL10n . get ( "page_of" , { pageCount : h } ,
"of {{pageCount}}" ) ; document . getElementById ( "pageNumber" ) . max = h ; PDFView . documentFingerprint = e ; var g = PDFView . store = new Settings ( e ) , e = g . initializedPromise ; this . pageRotation = 0 ; var k = this . pages = [ ] ; this . pageText = [ ] ; this . startedTextExtraction = ! 1 ; for ( var n = { } , l = this . thumbnails = [ ] , m = [ ] , s = 1 ; s <= h ; s ++ ) m . push ( a . getPage ( s ) ) ; var r = this , m = PDFJS . Promise . all ( m ) ; m . then ( function ( a ) { for ( var p = 1 ; p <= h ; p ++ ) { var e = a [ p - 1 ] , g = new PageView ( f , e , p , b , e . stats , r . navigateTo . bind ( r ) ) , m = new ThumbnailView ( d , e , p ) ; c ( g , m ) ; k . push ( g ) ; l . push ( m ) ;
e = e . ref ; n [ e . num + " " + e . gen + " R" ] = p } r . pagesRefMap = n } ) ; s = a . getDestinations ( ) ; s . then ( function ( a ) { r . destinations = a } ) ; PDFJS . Promise . all ( [ m , s , e ] ) . then ( function ( ) { a . getOutline ( ) . then ( function ( a ) { r . outline = new DocumentOutlineView ( a ) } ) ; var c = null ; if ( g . get ( "exists" , ! 1 ) ) var c = g . get ( "page" , "1" ) , d = g . get ( "zoom" , PDFView . currentScale ) , f = g . get ( "scrollLeft" , "0" ) , e = g . get ( "scrollTop" , "0" ) , c = "page=" + c + "&zoom=" + d + "," + f + "," + e ; r . setInitialView ( c , b ) } ) ; a . getMetadata ( ) . then ( function ( b ) { var c = b . info ; b = b . metadata ; r . documentInfo =
c ; r . metadata = b ; console . log ( "PDF " + a . fingerprint + " [" + c . PDFFormatVersion + " " + ( c . Producer || "-" ) + " / " + ( c . Creator || "-" ) + "]" + ( PDFJS . version ? " (PDF.js: " + PDFJS . version + ")" : "" ) ) ; var d ; b && b . has ( "dc:title" ) && ( d = b . get ( "dc:title" ) ) ; ! d && c && c . Title && ( d = c . Title ) ; d && r . setTitle ( d + " - " + document . title ) } ) } , setInitialView : function ( a , b ) { this . currentScale = 0 ; this . currentScaleValue = null ; this . initialBookmark ? ( this . setHash ( this . initialBookmark ) , this . initialBookmark = null ) : a ? this . setHash ( a ) : b && ( this . parseScale ( b , ! 0 ) , this . page =
1 ) ; PDFView . currentScale === UNKNOWN _SCALE && this . parseScale ( DEFAULT _SCALE , ! 0 ) } , renderHighestPriority : function ( ) { var a = this . getVisiblePages ( ) ; ( a = this . getHighestPriority ( a , this . pages , this . pageViewScroll . down ) ) ? this . renderView ( a , "page" ) : this . sidebarOpen && ( a = this . getVisibleThumbs ( ) , ( a = this . getHighestPriority ( a , this . thumbnails , this . thumbnailViewScroll . down ) ) && this . renderView ( a , "thumbnail" ) ) } , getHighestPriority : function ( a , b , c ) { var d = a . views , f = d . length ; if ( 0 === f ) return ! 1 ; for ( var h = 0 ; h < f ; ++ h ) { var e = d [ h ] . view ;
if ( ! this . isViewFinished ( e ) ) return e } a = c ? a . last . id : a . first . id - 2 ; return b [ a ] && ! this . isViewFinished ( b [ a ] ) ? b [ a ] : ! 1 } , isViewFinished : function ( a ) { return a . renderingState === RenderingStates . FINISHED } , renderView : function ( a , b ) { switch ( a . renderingState ) { case RenderingStates . FINISHED : return ! 1 ; case RenderingStates . PAUSED : PDFView . highestPriorityPage = b + a . id ; a . resume ( ) ; break ; case RenderingStates . RUNNING : PDFView . highestPriorityPage = b + a . id ; break ; case RenderingStates . INITIAL : PDFView . highestPriorityPage = b + a . id , a . draw ( this . renderHighestPriority . bind ( this ) ) } return ! 0 } ,
2013-01-24 14:03:12 +01:00
setHash : function ( a ) { if ( a ) if ( 0 <= a . indexOf ( "=" ) ) { var b = PDFView . parseQueryString ( a ) ; if ( "nameddest" in b ) PDFView . navigateTo ( b . nameddest ) ; else if ( "page" in b ) if ( a = b . page | 0 || 1 , "zoom" in b ) { var b = b . zoom . split ( "," ) , c = b [ 0 ] , d = parseFloat ( c ) ; d && ( c = d / 100 ) ; this . pages [ a - 1 ] . scrollIntoView ( [ null , { name : "XYZ" } , b [ 1 ] | 0 , b [ 2 ] | 0 , c ] ) } else this . page = a } else /^\d+$/ . test ( a ) ? this . page = a : PDFView . navigateTo ( unescape ( a ) ) } , switchSidebarView : function ( a ) { var b = document . getElementById ( "thumbnailView" ) , c = document . getElementById ( "outlineView" ) ,
2013-10-03 14:19:40 +02:00
d = document . getElementById ( "viewThumbnail" ) , f = document . getElementById ( "viewOutline" ) ; switch ( a ) { case "thumbs" : a = b . classList . contains ( "hidden" ) ; d . classList . add ( "toggled" ) ; f . classList . remove ( "toggled" ) ; b . classList . remove ( "hidden" ) ; c . classList . add ( "hidden" ) ; PDFView . renderHighestPriority ( ) ; a && scrollIntoView ( document . getElementById ( "thumbnailContainer" + this . page ) ) ; break ; case "outline" : d . classList . remove ( "toggled" ) , f . classList . add ( "toggled" ) , b . classList . add ( "hidden" ) , c . classList . remove ( "hidden" ) , f . getAttribute ( "disabled" ) } } ,
getVisiblePages : function ( ) { return this . getVisibleElements ( this . container , this . pages , ! 0 ) } , getVisibleThumbs : function ( ) { return this . getVisibleElements ( this . thumbnailContainer , this . thumbnails ) } , getVisibleElements : function ( a , b , c ) { for ( var d = 0 , f , h = a . scrollTop , e = 1 , g = b . length ; e <= g ; ++ e ) { f = b [ e - 1 ] ; d = f . el . offsetTop ; if ( d + f . el . clientHeight > h ) break ; d += f . el . clientHeight } var k = [ ] ; if ( this . isFullscreen ) return c = this . pages [ this . page - 1 ] , k . push ( { id : c . id , view : c } ) , { first : c , last : c , views : k } ; a = h + a . clientHeight ; for ( var n , l , m ; e <=
g && d < a ; ++ e ) f = b [ e - 1 ] , m = f . el . clientHeight , d = f . el . offsetTop , n = d + m , l = Math . max ( 0 , h - d ) + Math . max ( 0 , n - a ) , l = Math . floor ( 100 * ( m - l ) / m ) , k . push ( { id : f . id , y : d , view : f , percent : l } ) , d = n ; b = k [ 0 ] ; d = k [ k . length - 1 ] ; c && k . sort ( function ( a , b ) { var c = a . percent - b . percent ; return 0.0010 < Math . abs ( c ) ? - c : a . id - b . id } ) ; return { first : b , last : d , views : k } } , parseQueryString : function ( a ) { a = a . split ( "&" ) ; for ( var b = { } , c = 0 ; c < a . length ; ++ c ) { var d = a [ c ] . split ( "=" ) , f = 1 < d . length ? d [ 1 ] : null ; b [ unescape ( d [ 0 ] ) ] = unescape ( f ) } return b } , beforePrint : function ( ) { if ( this . supportsPrinting ) { document . querySelector ( "body" ) . setAttribute ( "data-mozPrintCallback" ,
2013-01-24 14:03:12 +01:00
! 0 ) ; for ( var a = 0 , b = this . pages . length ; a < b ; ++ a ) this . pages [ a ] . beforePrint ( ) } else a = mozL10n . get ( "printing_not_supported" , null , "Warning: Printing is not fully supported by this browser." ) , this . error ( a ) } , afterPrint : function ( ) { for ( var a = document . getElementById ( "printContainer" ) ; a . hasChildNodes ( ) ; ) a . removeChild ( a . lastChild ) } , fullscreen : function ( ) { if ( document . fullscreenElement || document . mozFullScreen || document . webkitIsFullScreen ) return ! 1 ; var a = document . getElementById ( "viewerContainer" ) ; if ( document . documentElement . requestFullscreen ) a . requestFullscreen ( ) ;
else if ( document . documentElement . mozRequestFullScreen ) a . mozRequestFullScreen ( ) ; else if ( document . documentElement . webkitRequestFullScreen ) a . webkitRequestFullScreen ( Element . ALLOW _KEYBOARD _INPUT ) ; else return ! 1 ; this . isFullscreen = ! 0 ; var b = this . pages [ this . page - 1 ] ; this . previousScale = this . currentScaleValue ; this . parseScale ( "page-fit" , ! 0 ) ; setTimeout ( function ( ) { b . scrollIntoView ( ) } , 0 ) ; this . showPresentationControls ( ) ; return ! 0 } , exitFullscreen : function ( ) { this . isFullscreen = ! 1 ; this . parseScale ( this . previousScale ) ; this . page =
this . page ; this . clearMouseScrollState ( ) ; this . hidePresentationControls ( ) } , showPresentationControls : function ( ) { var a = document . getElementById ( "viewerContainer" ) ; this . presentationControlsTimeout ? clearTimeout ( this . presentationControlsTimeout ) : a . classList . add ( "presentationControls" ) ; this . presentationControlsTimeout = setTimeout ( function ( ) { a . classList . remove ( "presentationControls" ) ; delete PDFView . presentationControlsTimeout } , 3E3 ) } , hidePresentationControls : function ( ) { this . presentationControlsTimeout && ( clearTimeout ( this . presentationControlsTimeout ) ,
delete this . presentationControlsTimeout , document . getElementById ( "viewerContainer" ) . classList . remove ( "presentationControls" ) ) } , rotatePages : function ( a ) { this . pageRotation = ( this . pageRotation + 360 + a ) % 360 ; a = 0 ; for ( var b = this . pages . length ; a < b ; a ++ ) { var c = this . pages [ a ] ; c . update ( c . scale , this . pageRotation ) } a = 0 ; for ( b = this . thumbnails . length ; a < b ; a ++ ) this . thumbnails [ a ] . updateRotation ( this . pageRotation ) ; var d = this . pages [ this . page - 1 ] ; this . parseScale ( this . currentScaleValue , ! 0 ) ; this . renderHighestPriority ( ) ; setTimeout ( function ( ) { d . scrollIntoView ( ) } ,
0 ) } , mouseScroll : function ( a ) { var b = ( new Date ) . getTime ( ) , c = this . mouseScrollTimeStamp ; b > c && 50 > b - c || ( ( 0 < this . mouseScrollDelta && 0 > a || 0 > this . mouseScrollDelta && 0 < a ) && this . clearMouseScrollState ( ) , this . mouseScrollDelta += a , 120 <= Math . abs ( this . mouseScrollDelta ) && ( a = 0 < this . mouseScrollDelta ? - 1 : 1 , this . clearMouseScrollState ( ) , c = this . page , 1 == c && - 1 == a || c == this . pages . length && 1 == a || ( this . page += a , this . mouseScrollTimeStamp = b ) ) ) } , clearMouseScrollState : function ( ) { this . mouseScrollDelta = this . mouseScrollTimeStamp = 0 } } , PageView =
2013-10-03 14:19:40 +02:00
function ( a , b , c , d , f , h ) { function e ( a , b ) { function c ( a , b ) { a . href = PDFView . getDestinationHash ( b ) ; a . onclick = function ( ) { b && PDFView . navigateTo ( b ) ; return ! 1 } } function d ( a , c , f ) { f || ( f = b . convertToViewportRectangle ( c . rect ) , f = PDFJS . Util . normalizeRect ( f ) ) ; a = document . createElement ( a ) ; a . style . left = Math . floor ( f [ 0 ] ) + "px" ; a . style . top = Math . floor ( f [ 1 ] ) + "px" ; a . style . width = Math . ceil ( f [ 2 ] - f [ 0 ] ) + "px" ; a . style . height = Math . ceil ( f [ 3 ] - f [ 1 ] ) + "px" ; return a } function f ( a ) { var c = document . createElement ( "section" ) ; c . className = "annotText" ;
var e = b . convertToViewportRectangle ( a . rect ) , e = PDFJS . Util . normalizeRect ( e ) ; e [ 3 ] - e [ 1 ] < ANNOT _MIN _SIZE && ( e [ 3 ] = e [ 1 ] + ANNOT _MIN _SIZE ) ; e [ 2 ] - e [ 0 ] < ANNOT _MIN _SIZE && ( e [ 2 ] = e [ 0 ] + ( e [ 3 ] - e [ 1 ] ) ) ; var h = d ( "img" , a , e ) , g = a . name ; h . src = IMAGE _DIR + "annotation-" + g . toLowerCase ( ) + ".svg" ; h . alt = mozL10n . get ( "text_annotation_type" , { type : g } , "[{{type}} Annotation]" ) ; var k = document . createElement ( "div" ) ; k . setAttribute ( "hidden" , ! 0 ) ; var g = document . createElement ( "h1" ) , l = document . createElement ( "p" ) ; k . style . left = Math . floor ( e [ 2 ] ) + "px" ; k . style . top =
Math . floor ( e [ 1 ] ) + "px" ; g . textContent = a . title ; if ( a . content || a . title ) { e = document . createElement ( "span" ) ; a = a . content . split ( /(?:\r\n?|\n)/ ) ; for ( var s = 0 , v = a . length ; s < v ; ++ s ) e . appendChild ( document . createTextNode ( a [ s ] ) ) , s < v - 1 && e . appendChild ( document . createElement ( "br" ) ) ; l . appendChild ( e ) ; h . addEventListener ( "mouseover" , function ( ) { k . removeAttribute ( "hidden" ) } , ! 1 ) ; h . addEventListener ( "mouseout" , function ( ) { k . setAttribute ( "hidden" , ! 0 ) } , ! 1 ) } else k . setAttribute ( "hidden" , ! 0 ) ; k . appendChild ( g ) ; k . appendChild ( l ) ; c . appendChild ( h ) ;
c . appendChild ( k ) ; return c } a . getAnnotations ( ) . then ( function ( a ) { for ( var b = 0 ; b < a . length ; b ++ ) { var e = a [ b ] ; switch ( e . type ) { case "Link" : var h = d ( "a" , e ) ; h . href = e . url || "" ; e . url || c ( h , "dest" in e ? e . dest : null ) ; g . appendChild ( h ) ; break ; case "Text" : ( e = f ( e ) ) && g . appendChild ( e ) ; break ; case "Widget" : PDFView . fallback ( ) } } } ) } this . id = c ; this . pdfPage = b ; this . rotation = 0 ; this . scale = d || 1 ; this . viewport = this . pdfPage . getViewport ( this . scale , this . pdfPage . rotate ) ; this . renderingState = RenderingStates . INITIAL ; this . textLayer = this . textContent =
this . resume = null ; c = document . createElement ( "a" ) ; c . name = "" + this . id ; var g = this . el = document . createElement ( "div" ) ; g . id = "pageContainer" + this . id ; g . className = "page" ; g . style . width = Math . floor ( this . viewport . width ) + "px" ; g . style . height = Math . floor ( this . viewport . height ) + "px" ; a . appendChild ( c ) ; a . appendChild ( g ) ; this . destroy = function ( ) { this . update ( ) ; this . pdfPage . destroy ( ) } ; this . update = function ( a , b ) { this . renderingState = RenderingStates . INITIAL ; this . resume = null ; "undefined" !== typeof b && ( this . rotation = b ) ; this . scale = a || this . scale ;
var c = this . pdfPage . getViewport ( this . scale , ( this . rotation + this . pdfPage . rotate ) % 360 ) ; this . viewport = c ; g . style . width = Math . floor ( c . width ) + "px" ; for ( g . style . height = Math . floor ( c . height ) + "px" ; g . hasChildNodes ( ) ; ) g . removeChild ( g . lastChild ) ; g . removeAttribute ( "data-loaded" ) ; delete this . canvas ; this . loadingIconDiv = document . createElement ( "div" ) ; this . loadingIconDiv . className = "loadingIcon" ; g . appendChild ( this . loadingIconDiv ) } ; Object . defineProperty ( this , "width" , { get : function ( ) { return this . viewport . width } , enumerable : ! 0 } ) ;
Object . defineProperty ( this , "height" , { get : function ( ) { return this . viewport . height } , enumerable : ! 0 } ) ; this . getPagePoint = function ( a , b ) { return this . viewport . convertToPdfPoint ( a , b ) } ; this . scrollIntoView = function ( a ) { if ( a ) { var b = 0 , c = 0 , d = 0 , f = 0 , e ; e = 0 ; switch ( a [ 1 ] . name ) { case "XYZ" : b = a [ 2 ] ; c = a [ 3 ] ; e = a [ 4 ] ; break ; case "Fit" : case "FitB" : e = "page-fit" ; break ; case "FitH" : case "FitBH" : c = a [ 2 ] ; e = "page-width" ; break ; case "FitV" : case "FitBV" : b = a [ 2 ] ; e = "page-height" ; break ; case "FitR" : b = a [ 2 ] ; c = a [ 3 ] ; d = a [ 4 ] - b ; f = a [ 5 ] - c ; a = ( this . container . clientWidth -
SCROLLBAR _PADDING ) / d / CSS _UNITS ; e = ( this . container . clientHeight - SCROLLBAR _PADDING ) / f / CSS _UNITS ; e = Math . min ( a , e ) ; break ; default : return } e && e !== PDFView . currentScale ? PDFView . parseScale ( e , ! 0 , ! 0 ) : PDFView . currentScale === UNKNOWN _SCALE && PDFView . parseScale ( DEFAULT _SCALE , ! 0 , ! 0 ) ; var h = [ this . viewport . convertToViewportPoint ( b , c ) , this . viewport . convertToViewportPoint ( b + d , c + f ) ] ; setTimeout ( function ( ) { var a = Math . min ( h [ 0 ] [ 0 ] , h [ 1 ] [ 0 ] ) , b = Math . min ( h [ 0 ] [ 1 ] , h [ 1 ] [ 1 ] ) , c = Math . abs ( h [ 0 ] [ 0 ] - h [ 1 ] [ 0 ] ) , d = Math . abs ( h [ 0 ] [ 1 ] - h [ 1 ] [ 1 ] ) ; scrollIntoView ( g ,
{ left : a , top : b , width : c , height : d } ) } , 0 ) } else scrollIntoView ( g ) } ; this . getTextContent = function ( ) { this . textContent || ( this . textContent = this . pdfPage . getTextContent ( ) ) ; return this . textContent } ; this . draw = function ( a ) { function c ( d ) { p . renderingState = RenderingStates . FINISHED ; p . loadingIconDiv && ( g . removeChild ( p . loadingIconDiv ) , delete p . loadingIconDiv ) ; d && PDFView . error ( mozL10n . get ( "rendering_error" , null , "An error occurred while rendering the page." ) , d ) ; p . stats = b . stats ; p . updateStats ( ) ; if ( p . onAfterDraw ) p . onAfterDraw ( ) ;
cache . push ( p ) ; a ( ) } this . renderingState !== RenderingStates . INITIAL && error ( "Must be in new state before drawing" ) ; this . renderingState = RenderingStates . RUNNING ; var d = document . createElement ( "canvas" ) ; d . id = "page" + this . id ; d . mozOpaque = ! 0 ; g . appendChild ( d ) ; this . canvas = d ; var f = null ; PDFJS . disableTextLayer || ( f = document . createElement ( "div" ) , f . className = "textLayer" , g . appendChild ( f ) ) ; var h = this . textLayer = f ? new TextLayerBuilder ( f , this . id - 1 ) : null , r = this . viewport , q = PDFView . getOutputScale ( ) ; d . width = Math . floor ( r . width ) *
q . sx ; d . height = Math . floor ( r . height ) * q . sy ; q . scaled && ( r = "scale(" + 1 / q . sx + ", " + 1 / q . sy + ")" , CustomStyle . setProp ( "transform" , d , r ) , CustomStyle . setProp ( "transformOrigin" , d , "0% 0%" ) , f && ( CustomStyle . setProp ( "transform" , f , r ) , CustomStyle . setProp ( "transformOrigin" , f , "0% 0%" ) ) ) ; f = d . getContext ( "2d" ) ; f . save ( ) ; f . fillStyle = "rgb(255, 255, 255)" ; f . fillRect ( 0 , 0 , d . width , d . height ) ; f . restore ( ) ; q . scaled && f . scale ( q . sx , q . sy ) ; var p = this ; this . pdfPage . render ( { canvasContext : f , viewport : this . viewport , textLayer : h , continueCallback : function ( a ) { PDFView . highestPriorityPage !==
"page" + p . id ? ( p . renderingState = RenderingStates . PAUSED , p . resume = function ( ) { p . renderingState = RenderingStates . RUNNING ; a ( ) } ) : a ( ) } } ) . then ( function ( ) { c ( null ) } , function ( a ) { c ( a ) } ) ; h && this . getTextContent ( ) . then ( function ( a ) { h . setTextContent ( a ) } ) ; e ( this . pdfPage , this . viewport ) ; g . setAttribute ( "data-loaded" , ! 0 ) } ; this . beforePrint = function ( ) { var a = this . pdfPage , b = a . getViewport ( 1 ) , c = this . canvas = document . createElement ( "canvas" ) ; c . width = 2 * Math . floor ( b . width ) ; c . height = 2 * Math . floor ( b . height ) ; c . style . width = 2 * b . width + "pt" ;
c . style . height = 2 * b . height + "pt" ; CustomStyle . setProp ( "transform" , c , "scale(0.5, 0.5)" ) ; CustomStyle . setProp ( "transformOrigin" , c , "0% 0%" ) ; document . getElementById ( "printContainer" ) . appendChild ( c ) ; var d = this ; c . mozPrintCallback = function ( f ) { var e = f . context ; e . save ( ) ; e . fillStyle = "rgb(255, 255, 255)" ; e . fillRect ( 0 , 0 , c . width , c . height ) ; e . restore ( ) ; e . scale ( 2 , 2 ) ; a . render ( { canvasContext : e , viewport : b } ) . then ( function ( ) { f . done ( ) ; d . pdfPage . destroy ( ) } , function ( a ) { console . error ( a ) ; "abort" in object ? f . abort ( ) : f . done ( ) ; d . pdfPage . destroy ( ) } ) } } ;
this . updateStats = function ( ) { PDFJS . pdfBug && Stats . enabled && Stats . add ( this . id , this . stats ) } } , ThumbnailView = function ( a , b , c ) { function d ( ) { var a = document . createElement ( "canvas" ) ; a . id = "thumbnail" + c ; a . mozOpaque = ! 0 ; a . width = l ; a . height = m ; a . className = "thumbnailImage" ; a . setAttribute ( "aria-label" , mozL10n . get ( "thumb_page_canvas" , { page : c } , "Thumbnail of Page {{page}}" ) ) ; r . setAttribute ( "data-loaded" , ! 0 ) ; q . appendChild ( a ) ; a = a . getContext ( "2d" ) ; a . save ( ) ; a . fillStyle = "rgb(255, 255, 255)" ; a . fillRect ( 0 , 0 , l , m ) ; a . restore ( ) ; return a }
var f = document . createElement ( "a" ) ; f . href = PDFView . getAnchorUrl ( "#page=" + c ) ; f . title = mozL10n . get ( "thumb_page_title" , { page : c } , "Page {{page}}" ) ; f . onclick = function ( ) { PDFView . page = c ; return ! 1 } ; var h = 0 , e = ( h + b . rotate ) % 360 , g = b . getViewport ( 1 , e ) , k = this . width = g . width , n = this . height = g . height ; this . id = c ; var l = 98 , m = l / this . width * this . height , s = this . scaleX = l / k ; this . scaleY = m / n ; var r = this . el = document . createElement ( "div" ) ; r . id = "thumbnailContainer" + c ; r . className = "thumbnail" ; 1 === c && r . classList . add ( "selected" ) ; var q = document . createElement ( "div" ) ;
q . className = "thumbnailSelectionRing" ; q . style . width = l + "px" ; q . style . height = m + "px" ; r . appendChild ( q ) ; f . appendChild ( r ) ; a . appendChild ( f ) ; this . hasImage = ! 1 ; this . renderingState = RenderingStates . INITIAL ; this . updateRotation = function ( a ) { h = a ; e = ( h + b . rotate ) % 360 ; g = b . getViewport ( 1 , e ) ; k = this . width = g . width ; n = this . height = g . height ; m = l / this . width * this . height ; s = this . scaleX = l / k ; this . scaleY = m / n ; r . removeAttribute ( "data-loaded" ) ; q . textContent = "" ; q . style . width = l + "px" ; q . style . height = m + "px" ; this . hasImage = ! 1 ; this . renderingState =
RenderingStates . INITIAL ; this . resume = null } ; this . drawingRequired = function ( ) { return ! this . hasImage } ; this . draw = function ( a ) { this . renderingState !== RenderingStates . INITIAL && error ( "Must be in new state before drawing" ) ; this . renderingState = RenderingStates . RUNNING ; if ( this . hasImage ) a ( ) ; else { var c = this , f = d ( ) , h = b . getViewport ( s , e ) ; b . render ( { canvasContext : f , viewport : h , continueCallback : function ( a ) { PDFView . highestPriorityPage !== "thumbnail" + c . id ? ( c . renderingState = RenderingStates . PAUSED , c . resume = function ( ) { c . renderingState =
RenderingStates . RUNNING ; a ( ) } ) : a ( ) } } ) . then ( function ( ) { c . renderingState = RenderingStates . FINISHED ; a ( ) } , function ( b ) { c . renderingState = RenderingStates . FINISHED ; a ( ) } ) ; this . hasImage = ! 0 } } ; this . setImage = function ( a ) { if ( ! this . hasImage && a ) { this . renderingState = RenderingStates . FINISHED ; var b = d ( ) ; b . drawImage ( a , 0 , 0 , a . width , a . height , 0 , 0 , b . canvas . width , b . canvas . height ) ; this . hasImage = ! 0 } } } , DocumentOutlineView = function ( a ) { function b ( a , b ) { a . href = PDFView . getDestinationHash ( b . dest ) ; a . onclick = function ( a ) { PDFView . navigateTo ( b . dest ) ;
return ! 1 } } for ( var c = document . getElementById ( "outlineView" ) ; c . firstChild ; ) c . removeChild ( c . firstChild ) ; if ( a ) for ( c = [ { parent : c , items : a } ] ; 0 < c . length ; ) { a = c . shift ( ) ; var d , f = a . items . length ; for ( d = 0 ; d < f ; d ++ ) { var h = a . items [ d ] , e = document . createElement ( "div" ) ; e . className = "outlineItem" ; var g = document . createElement ( "a" ) ; b ( g , h ) ; g . textContent = h . title ; e . appendChild ( g ) ; 0 < h . items . length && ( g = document . createElement ( "div" ) , g . className = "outlineItems" , e . appendChild ( g ) , c . push ( { parent : g , items : h . items } ) ) ; a . parent . appendChild ( e ) } } else a =
document . createElement ( "div" ) , a . classList . add ( "noOutline" ) , a . textContent = mozL10n . get ( "no_outline" , null , "No Outline Available" ) , c . appendChild ( a ) } , CustomStyle = function ( ) { function a ( ) { } var b = [ "ms" , "Moz" , "Webkit" , "O" ] , c = { } ; a . getProp = function ( a , f ) { if ( 1 == arguments . length && "string" == typeof c [ a ] ) return c [ a ] ; f = f || document . documentElement ; var h = f . style , e , g ; if ( "string" == typeof h [ a ] ) return c [ a ] = a ; g = a . charAt ( 0 ) . toUpperCase ( ) + a . slice ( 1 ) ; for ( var k = 0 , n = b . length ; k < n ; k ++ ) if ( e = b [ k ] + g , "string" == typeof h [ e ] ) return c [ a ] =
e ; return c [ a ] = "undefined" } ; a . setProp = function ( a , b , c ) { a = this . getProp ( a ) ; "undefined" != a && ( b . style [ a ] = c ) } ; return a } ( ) , TextLayerBuilder = function ( a , b ) { var c = document . createDocumentFragment ( ) ; this . textLayerDiv = a ; this . divContentDone = this . layoutDone = ! 1 ; this . pageIdx = b ; this . matches = [ ] ; this . beginLayout = function ( ) { this . textDivs = [ ] ; this . textLayerQueue = [ ] ; this . renderingDone = ! 1 } ; this . endLayout = function ( ) { this . layoutDone = ! 0 ; this . insertDivContent ( ) } ; this . renderLayer = function ( ) { var a = this . textDivs , b = this . textLayerDiv ,
h = document . createElement ( "canvas" ) . getContext ( "2d" ) ; if ( ! ( 1E5 < a . length ) ) { for ( var e = 0 , g = a . length ; e < g ; e ++ ) { var k = a [ e ] ; c . appendChild ( k ) ; h . font = k . style . fontSize + " " + k . style . fontFamily ; var n = h . measureText ( k . textContent ) . width ; 0 < n && ( CustomStyle . setProp ( "transform" , k , "scale(" + k . dataset . canvasWidth / n + ", 1)" ) , CustomStyle . setProp ( "transformOrigin" , k , "0% 0%" ) , b . appendChild ( k ) ) } this . renderingDone = ! 0 ; this . updateMatches ( ) ; b . appendChild ( c ) } } ; this . setupRenderLayoutTimer = function ( ) { var a = this ; 200 < Date . now ( ) - PDFView . lastScroll ?
this . renderLayer ( ) : ( this . renderTimer && clearTimeout ( this . renderTimer ) , this . renderTimer = setTimeout ( function ( ) { a . setupRenderLayoutTimer ( ) } , 200 ) ) } ; this . appendText = function ( a ) { var b = document . createElement ( "div" ) , c = a . fontSize * a . vScale ; b . dataset . canvasWidth = a . canvasWidth * a . hScale ; b . dataset . fontName = a . fontName ; b . style . fontSize = c + "px" ; b . style . fontFamily = a . fontFamily ; b . style . left = a . x + "px" ; b . style . top = a . y - c + "px" ; this . textDivs . push ( b ) } ; this . insertDivContent = function ( ) { if ( this . layoutDone && ! this . divContentDone &&
this . textContent ) { this . divContentDone = ! 0 ; for ( var a = this . textDivs , b = this . textContent . bidiTexts , c = 0 ; c < b . length ; c ++ ) { var e = b [ c ] , g = a [ c ] ; g . textContent = e . str ; g . dir = e . ltr ? "ltr" : "rtl" } this . setupRenderLayoutTimer ( ) } } ; this . setTextContent = function ( a ) { this . textContent = a ; this . insertDivContent ( ) } ; this . convertMatches = function ( a ) { for ( var b = 0 , c = 0 , e = this . textContent . bidiTexts , g = e . length - 1 , k = PDFFindController . state . query . length , n = [ ] , l = 0 ; l < a . length ; l ++ ) { for ( var m = a [ l ] ; b !== g && m >= c + e [ b ] . str . length ; ) c += e [ b ] . str . length ,
b ++ ; b == e . length && console . error ( "Could not find matching mapping" ) ; for ( var s = { begin : { divIdx : b , offset : m - c } } , m = m + k ; b !== g && m > c + e [ b ] . str . length ; ) c += e [ b ] . str . length , b ++ ; s . end = { divIdx : b , offset : m - c } ; n . push ( s ) } return n } ; this . renderMatches = function ( a ) { function b ( a , c ) { var d = a . divIdx , f = g [ d ] ; f . textContent = "" ; var h = e [ d ] . str . substring ( 0 , a . offset ) , h = document . createTextNode ( h ) ; if ( c ) { var d = n && d === l , k = document . createElement ( "span" ) ; k . className = c + ( d ? " selected" : "" ) ; k . appendChild ( h ) ; f . appendChild ( k ) } else f . appendChild ( h ) }
function c ( a , b , d ) { var f = a . divIdx , h = g [ f ] ; a = e [ f ] . str . substring ( a . offset , b . offset ) ; a = document . createTextNode ( a ) ; d ? ( b = document . createElement ( "span" ) , b . className = d , b . appendChild ( a ) , h . appendChild ( b ) ) : h . appendChild ( a ) } if ( 0 !== a . length ) { var e = this . textContent . bidiTexts , g = this . textDivs , k = null , n = this . pageIdx === PDFFindController . selected . pageIdx , l = PDFFindController . selected . matchIdx , m = { divIdx : - 1 , offset : void 0 } , s = l , r = s + 1 ; if ( PDFFindController . state . highlightAll ) s = 0 , r = a . length ; else if ( ! n ) return ; for ( ; s < r ; s ++ ) { var q =
a [ s ] , p = q . begin , q = q . end , u = n && s === l , t = u ? " selected" : "" ; u && scrollIntoView ( g [ p . divIdx ] , { top : - 50 } ) ; k && p . divIdx === k . divIdx ? c ( k , p ) : ( null !== k && c ( k , m ) , b ( p ) ) ; if ( p . divIdx === q . divIdx ) c ( p , q , "highlight" + t ) ; else { c ( p , m , "highlight begin" + t ) ; for ( k = p . divIdx + 1 ; k < q . divIdx ; k ++ ) g [ k ] . className = "highlight middle" + t ; b ( q , "highlight end" + t ) } k = q } k && c ( k , m ) } } ; this . updateMatches = function ( ) { if ( this . renderingDone ) { for ( var a = this . matches , b = this . textDivs , c = this . textContent . bidiTexts , e = - 1 , g = 0 ; g < a . length ; g ++ ) { for ( var k = a [ g ] , e = Math . max ( e ,
k . begin . divIdx ) ; e <= k . end . divIdx ; e ++ ) { var n = b [ e ] ; n . textContent = c [ e ] . str ; n . className = "" } e = k . end . divIdx + 1 } PDFFindController . active && ( this . matches = this . convertMatches ( PDFFindController . pageMatches [ this . pageIdx ] || [ ] ) , this . renderMatches ( this . matches ) ) } } } ;
document . addEventListener ( "DOMContentLoaded" , function ( a ) { PDFView . initialize ( ) ; a = PDFView . parseQueryString ( document . location . search . substring ( 1 ) ) . file || DEFAULT _URL ; window . File && window . FileReader && window . FileList && window . Blob && ( document . getElementById ( "fileInput" ) . value = null ) ; var b = document . location . hash . substring ( 1 ) , b = PDFView . parseQueryString ( b ) ; "disableWorker" in b && ( PDFJS . disableWorker = "true" === b . disableWorker ) ; var c = navigator . language ; "locale" in b && ( c = b . locale ) ; mozL10n . setLanguage ( c ) ; if ( "textLayer" in
2013-01-24 14:03:12 +01:00
b ) switch ( b . textLayer ) { case "off" : PDFJS . disableTextLayer = ! 0 ; break ; case "visible" : case "shadow" : case "hover" : document . getElementById ( "viewer" ) . classList . add ( "textLayer-" + b . textLayer ) } "pdfBug" in b && ( PDFJS . pdfBug = ! 0 , b = b . pdfBug . split ( "," ) , PDFBug . enable ( b ) , PDFBug . init ( ) ) ; PDFView . supportsPrinting || document . getElementById ( "print" ) . classList . add ( "hidden" ) ; PDFView . supportsFullscreen || document . getElementById ( "fullscreen" ) . classList . add ( "hidden" ) ; PDFView . supportsIntegratedFind && document . querySelector ( "#viewFind" ) . classList . add ( "hidden" ) ;
2013-10-03 14:19:40 +02:00
PDFJS . LogManager . addLogger ( { warn : function ( ) { PDFView . fallback ( ) } } ) ; var d = document . getElementById ( "mainContainer" ) , f = document . getElementById ( "outerContainer" ) ; d . addEventListener ( "transitionend" , function ( a ) { a . target == d && ( a = document . createEvent ( "UIEvents" ) , a . initUIEvent ( "resize" , ! 1 , ! 1 , window , 0 ) , window . dispatchEvent ( a ) , f . classList . remove ( "sidebarMoving" ) ) } , ! 0 ) ; document . getElementById ( "sidebarToggle" ) . addEventListener ( "click" , function ( ) { this . classList . toggle ( "toggled" ) ; f . classList . add ( "sidebarMoving" ) ;
f . classList . toggle ( "sidebarOpen" ) ; PDFView . sidebarOpen = f . classList . contains ( "sidebarOpen" ) ; PDFView . renderHighestPriority ( ) } ) ; document . getElementById ( "viewThumbnail" ) . addEventListener ( "click" , function ( ) { PDFView . switchSidebarView ( "thumbs" ) } ) ; document . getElementById ( "viewOutline" ) . addEventListener ( "click" , function ( ) { PDFView . switchSidebarView ( "outline" ) } ) ; document . getElementById ( "previous" ) . addEventListener ( "click" , function ( ) { PDFView . page -- } ) ; document . getElementById ( "next" ) . addEventListener ( "click" , function ( ) { PDFView . page ++ } ) ;
2013-01-24 14:03:12 +01:00
document . querySelector ( ".zoomIn" ) . addEventListener ( "click" , function ( ) { PDFView . zoomIn ( ) } ) ; document . querySelector ( ".zoomOut" ) . addEventListener ( "click" , function ( ) { PDFView . zoomOut ( ) } ) ; document . getElementById ( "fullscreen" ) . addEventListener ( "click" , function ( ) { PDFView . fullscreen ( ) } ) ; document . getElementById ( "print" ) . addEventListener ( "click" , function ( ) { window . print ( ) } ) ; document . getElementById ( "pageNumber" ) . addEventListener ( "change" , function ( ) { PDFView . page = this . value } ) ; document . getElementById ( "scaleSelect" ) . addEventListener ( "change" ,
function ( ) { PDFView . parseScale ( this . value ) } ) ; document . getElementById ( "first_page" ) . addEventListener ( "click" , function ( ) { PDFView . page = 1 } ) ; document . getElementById ( "last_page" ) . addEventListener ( "click" , function ( ) { PDFView . page = PDFView . pdfDocument . numPages } ) ; document . getElementById ( "page_rotate_ccw" ) . addEventListener ( "click" , function ( ) { PDFView . rotatePages ( - 90 ) } ) ; document . getElementById ( "page_rotate_cw" ) . addEventListener ( "click" , function ( ) { PDFView . rotatePages ( 90 ) } ) ; PDFView . open ( a , 0 ) } , ! 0 ) ;
2013-10-03 14:19:40 +02:00
function updateViewarea ( ) { if ( PDFView . initialized ) { var a = PDFView . getVisiblePages ( ) , b = a . views ; if ( 0 !== b . length ) { PDFView . renderHighestPriority ( ) ; for ( var c = PDFView . page , a = a . first , d = 0 , f = b . length , h = ! 1 ; d < f ; ++ d ) { var e = b [ d ] ; if ( 100 > e . percent ) break ; if ( e . id === PDFView . page ) { h = ! 0 ; break } } h || ( c = b [ 0 ] . id ) ; PDFView . isFullscreen || ( updateViewarea . inProgress = ! 0 , PDFView . page = c , updateViewarea . inProgress = ! 1 ) ; var b = PDFView . currentScale , c = PDFView . currentScaleValue , g = c == b ? 100 * b : c , k = a . id , b = "#page=" + k + ( "&zoom=" + g ) , n = PDFView . pages [ k -
1 ] . getPagePoint ( PDFView . container . scrollLeft , PDFView . container . scrollTop - a . y ) , b = b + ( "," + Math . round ( n [ 0 ] ) + "," + Math . round ( n [ 1 ] ) ) , l = PDFView . store ; l . initializedPromise . then ( function ( ) { l . set ( "exists" , ! 0 ) ; l . set ( "page" , k ) ; l . set ( "zoom" , g ) ; l . set ( "scrollLeft" , Math . round ( n [ 0 ] ) ) ; l . set ( "scrollTop" , Math . round ( n [ 1 ] ) ) } ) ; PDFView . getAnchorUrl ( b ) } } }
window . addEventListener ( "resize" , function ( a ) { PDFView . initialized && ( document . getElementById ( "pageWidthOption" ) . selected || document . getElementById ( "pageFitOption" ) . selected || document . getElementById ( "pageAutoOption" ) . selected ) && PDFView . parseScale ( document . getElementById ( "scaleSelect" ) . value ) ; updateViewarea ( ) } ) ; window . addEventListener ( "hashchange" , function ( a ) { PDFView . setHash ( document . location . hash . substring ( 1 ) ) } ) ;
window . addEventListener ( "change" , function ( a ) { var b = a . target . files ; b && 0 != b . length && ( a = new FileReader , a . onload = function ( a ) { a = new Uint8Array ( a . target . result ) ; PDFView . open ( a , 0 ) } , b = b [ 0 ] , a . readAsArrayBuffer ( b ) , PDFView . setTitleUsingUrl ( b . name ) ) } , ! 0 ) ; function selectScaleOption ( a ) { for ( var b = document . getElementById ( "scaleSelect" ) . options , c = ! 1 , d = 0 ; d < b . length ; d ++ ) { var f = b [ d ] ; f . value != a ? f . selected = ! 1 : c = f . selected = ! 0 } return c }
window . addEventListener ( "localized" , function ( a ) { document . getElementsByTagName ( "html" ) [ 0 ] . dir = mozL10n . getDirection ( ) } , ! 0 ) ;
window . addEventListener ( "scalechange" , function ( a ) { var b = document . getElementById ( "customScaleOption" ) ; b . selected = ! 1 ; ! a . resetAutoSettings && ( document . getElementById ( "pageWidthOption" ) . selected || document . getElementById ( "pageFitOption" ) . selected || document . getElementById ( "pageAutoOption" ) . selected ) || selectScaleOption ( "" + a . scale ) || ( b . textContent = Math . round ( 1E4 * a . scale ) / 100 + "%" , b . selected = ! 0 ) ; updateViewarea ( ) } , ! 0 ) ;
window . addEventListener ( "pagechange" , function ( a ) { a = a . pageNumber ; if ( PDFView . previousPageNumber !== a ) { document . getElementById ( "pageNumber" ) . value = a ; var b = document . querySelector ( ".thumbnail.selected" ) ; b && b . classList . remove ( "selected" ) ; b = document . getElementById ( "thumbnailContainer" + a ) ; b . classList . add ( "selected" ) ; var c = PDFView . getVisibleThumbs ( ) , d = c . views . length ; if ( 0 < d ) { var f = c . first . id , c = 1 < d ? c . last . id : f ; ( a <= f || a >= c ) && scrollIntoView ( b ) } } document . getElementById ( "previous" ) . disabled = 1 >= a ; document . getElementById ( "next" ) . disabled =
a >= PDFView . pages . length } , ! 0 ) ; window . addEventListener ( "DOMMouseScroll" , function ( a ) { if ( a . ctrlKey ) { a . preventDefault ( ) ; var b = a . detail ; a = 0 < b ? "zoomOut" : "zoomIn" ; for ( var c = 0 , b = Math . abs ( b ) ; c < b ; c ++ ) PDFView [ a ] ( ) } else PDFView . isFullscreen && PDFView . mouseScroll ( - 40 * a . detail ) } , ! 1 ) ; window . addEventListener ( "mousemove" , function ( a ) { PDFView . isFullscreen && PDFView . showPresentationControls ( ) } , ! 1 ) ; window . addEventListener ( "mousedown" , function ( a ) { PDFView . isFullscreen && 0 === a . button && ( a . preventDefault ( ) , PDFView . page ++ ) } , ! 1 ) ;
2013-01-24 14:03:12 +01:00
window . addEventListener ( "keydown" , function ( a ) { var b = ! 1 , c = ( a . ctrlKey ? 1 : 0 ) | ( a . altKey ? 2 : 0 ) | ( a . shiftKey ? 4 : 0 ) | ( a . metaKey ? 8 : 0 ) ; if ( 1 == c || 8 == c ) switch ( a . keyCode ) { case 70 : PDFView . supportsIntegratedFind || ( PDFFindBar . toggle ( ) , b = ! 0 ) ; break ; case 61 : case 107 : case 187 : case 171 : PDFView . zoomIn ( ) ; b = ! 0 ; break ; case 173 : case 109 : case 189 : PDFView . zoomOut ( ) ; b = ! 0 ; break ; case 48 : case 96 : PDFView . parseScale ( DEFAULT _SCALE , ! 0 ) , b = ! 0 } if ( 1 == c || 8 == c || 5 == c || 12 == c ) switch ( a . keyCode ) { case 71 : PDFView . supportsIntegratedFind || ( PDFFindBar . dispatchEvent ( "again" ,
2013-10-03 14:19:40 +02:00
5 == c || 12 == c ) , b = ! 0 ) } if ( b ) a . preventDefault ( ) ; else { var d = document . activeElement ; if ( ! d || "INPUT" != d . tagName && "SELECT" != d . tagName ) { for ( var f = document . getElementById ( "toolbar" ) ; d ; ) { if ( d === f && ! PDFView . isFullscreen ) return ; d = d . parentNode } if ( 0 == c ) switch ( a . keyCode ) { case 38 : case 33 : case 8 : if ( ! PDFView . isFullscreen && "page-fit" !== PDFView . currentScaleValue ) break ; case 37 : if ( PDFView . isHorizontalScrollbarEnabled ) break ; case 75 : case 80 : PDFView . page -- ; b = ! 0 ; break ; case 40 : case 34 : case 32 : if ( ! PDFView . isFullscreen && "page-fit" !==
PDFView . currentScaleValue ) break ; case 39 : if ( PDFView . isHorizontalScrollbarEnabled ) break ; case 74 : case 78 : PDFView . page ++ ; b = ! 0 ; break ; case 36 : PDFView . isFullscreen && ( PDFView . page = 1 , b = ! 0 ) ; break ; case 35 : PDFView . isFullscreen && ( PDFView . page = PDFView . pdfDocument . numPages , b = ! 0 ) ; break ; case 82 : PDFView . rotatePages ( 90 ) } if ( 4 == c ) switch ( a . keyCode ) { case 82 : PDFView . rotatePages ( - 90 ) } b && ( a . preventDefault ( ) , PDFView . clearMouseScrollState ( ) ) } } } ) ; window . addEventListener ( "beforeprint" , function ( a ) { PDFView . beforePrint ( ) } ) ;
window . addEventListener ( "afterprint" , function ( a ) { PDFView . afterPrint ( ) } ) ; ( function ( ) { function a ( a ) { document . fullscreenElement || document . mozFullScreen || document . webkitIsFullScreen || PDFView . exitFullscreen ( ) } window . addEventListener ( "fullscreenchange" , a , ! 1 ) ; window . addEventListener ( "mozfullscreenchange" , a , ! 1 ) ; window . addEventListener ( "webkitfullscreenchange" , a , ! 1 ) } ) ( ) ;