164 lines
79 KiB
JavaScript
164 lines
79 KiB
JavaScript
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,MAX_AUTO_SCALE=1.25,MIN_SCALE=0.25,MAX_SCALE=4,VIEW_HISTORY_MEMORY=20,SCALE_SELECT_CONTAINER_PADDING=8,SCALE_SELECT_PADDING=22,THUMBNAIL_SCROLL_MARGIN=-19,USE_ONLY_CSS_ZOOM=!1,CLEANUP_TIMEOUT=3E4,IGNORE_CURRENT_POSITION_ON_ZOOM=!1,RenderingStates={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},FindStates={FIND_FOUND:0,FIND_NOTFOUND:1,FIND_WRAPPED:2,FIND_PENDING:3};
|
|
PDFJS.imageResourcesPath="./images/";PDFJS.workerSrc="pdf.worker.min.js";
|
|
var mozL10n=document.mozL10n||document.webL10n,CustomStyle=function(){function a(){}var b=["ms","Moz","Webkit","O"],c={};a.getProp=function(a,e){if(1==arguments.length&&"string"==typeof c[a])return c[a];e=e||document.documentElement;var g=e.style,h,f;if("string"==typeof g[a])return c[a]=a;f=a.charAt(0).toUpperCase()+a.slice(1);for(var k=0,s=b.length;k<s;k++)if(h=b[k]+f,"string"==typeof g[h])return c[a]=h;return c[a]="undefined"};a.setProp=function(a,b,c){a=this.getProp(a);"undefined"!=a&&(b.style[a]=
|
|
c)};return a}();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 getOutputScale(a){a=(window.devicePixelRatio||1)/(a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio||a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||a.backingStorePixelRatio||1);return{sx:a,sy:a,scaled:1!=a}}
|
|
function scrollIntoView(a,b){var c=a.offsetParent,d=a.offsetTop+a.clientTop,e=a.offsetLeft+a.clientLeft;if(c){for(;c.clientHeight===c.scrollHeight;)if(c.dataset._scaleY&&(d/=c.dataset._scaleY,e/=c.dataset._scaleX),d+=c.offsetTop,e+=c.offsetLeft,c=c.offsetParent,!c)return;b&&(void 0!==b.top&&(d+=b.top),void 0!==b.left&&(e+=b.left,c.scrollLeft=e));c.scrollTop=d}else console.error("offsetParent is not set -- cannot scroll")}function noContextMenuHandler(a){a.preventDefault()}
|
|
function getPDFFileNameFromURL(a){var b=/[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;a=/^(?:([^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(a);if(a=b.exec(a[1])||b.exec(a[2])||b.exec(a[3]))if(a=a[0],-1!=a.indexOf("%"))try{a=b.exec(decodeURIComponent(a))[0]}catch(c){}return a||"document.pdf"}
|
|
var ProgressBar=function(){function a(a,c){this.div=document.querySelector(a+" .progress");this.bar=this.div.parentNode;this.height=c.height||100;this.width=c.width||100;this.units=c.units||"%";this.div.style.height=this.height+this.units;this.percent=0}a.prototype={updateBar:function(){this._indeterminate?(this.div.classList.add("indeterminate"),this.div.style.width=this.width+this.units):(this.div.classList.remove("indeterminate"),this.div.style.width=this.width*this._percent/100+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()},setWidth:function(a){a&&(a=a.parentNode.offsetWidth-a.offsetWidth,0<a&&this.bar.setAttribute("style","width: calc(100% - "+a+"px);"))},hide:function(){this.bar.classList.add("hidden");this.bar.removeAttribute("style")}};return a}(),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()}},isLocalStorageEnabled=function(){try{return"localStorage"in
|
|
window&&null!==window.localStorage&&localStorage}catch(a){return!1}}(),EXPORTED_SYMBOLS=["DEFAULT_PREFERENCES"],DEFAULT_PREFERENCES={showPreviousViewOnLoad:!0,defaultZoomValue:"",ifAvailableShowOutlineOnLoad:!1},Preferences=function(){function a(){this.prefs={};this.isInitializedPromiseResolved=!1;this.initializedPromise=this.readFromStorage().then(function(a){this.isInitializedPromiseResolved=!0;a&&(this.prefs=a)}.bind(this))}a.prototype={writeToStorage:function(a){},readFromStorage:function(){return Promise.resolve()},
|
|
reset:function(){this.isInitializedPromiseResolved&&(this.prefs={},this.writeToStorage(this.prefs))},set:function(a,c){if(this.isInitializedPromiseResolved)if(void 0===DEFAULT_PREFERENCES[a])console.error("Preferences_set: '"+a+"' is undefined.");else if(void 0===c)console.error("Preferences_set: no value is specified.");else{var d=typeof c,e=typeof DEFAULT_PREFERENCES[a];if(d!==e)if("number"===d&&"string"===e)c=c.toString();else{console.error("Preferences_set: '"+c+"' is a \""+d+'", expected a "'+
|
|
e+'".');return}this.prefs[a]=c;this.writeToStorage(this.prefs)}},get:function(a){var c=DEFAULT_PREFERENCES[a];if(void 0===c)console.error("Preferences_get: '"+a+"' is undefined.");else return this.isInitializedPromiseResolved&&(a=this.prefs[a],void 0!==a)?a:c}};return a}();Preferences.prototype.writeToStorage=function(a){isLocalStorageEnabled&&localStorage.setItem("preferences",JSON.stringify(a))};
|
|
Preferences.prototype.readFromStorage=function(){return new Promise(function(a){if(isLocalStorageEnabled){var b=JSON.parse(localStorage.getItem("preferences"));a(b)}})};
|
|
(function(){function a(a){var b=document.createEvent("CustomEvent");b.initCustomEvent(a,!1,!1,"custom");window.dispatchEvent(b)}function b(){if(e)if(d(),++g<e.length){var a=e[g];"function"===typeof a.mozPrintCallback?a.mozPrintCallback({context:a.getContext("2d"),abort:c,done:b}):b()}else d(),h.call(window),setTimeout(c,20)}function c(){e&&(e=null,d(),a("afterprint"))}function d(){var a=document.getElementById("mozPrintCallback-shim");if(e){var b=Math.round(100*g/e.length),d=a.querySelector("progress"),
|
|
h=a.querySelector(".relative-progress");d.value=b;h.textContent=b+"%";a.removeAttribute("hidden");a.onclick=c}else a.setAttribute("hidden","")}if(!("mozPrintCallback"in document.createElement("canvas"))){HTMLCanvasElement.prototype.mozPrintCallback=void 0;var e,g,h=window.print;window.print=function(){if(e)console.warn("Ignored window.print() because of a pending print job.");else try{a("beforeprint")}finally{e=document.querySelectorAll("canvas"),g=-1,b()}};var f=!!document.attachEvent;window.addEventListener("keydown",
|
|
function(a){80===a.keyCode&&(a.ctrlKey||a.metaKey)?(window.print(),f||(a.preventDefault(),a.stopImmediatePropagation?a.stopImmediatePropagation():a.stopPropagation())):27===a.keyCode&&e&&c()},!0);f&&document.attachEvent("onkeydown",function(a){a=a||window.event;if(80===a.keyCode&&a.ctrlKey)return a.keyCode=0,!1});if("onbeforeprint"in window){var k=function(a){"custom"!==a.detail&&a.stopImmediatePropagation&&a.stopImmediatePropagation()};window.addEventListener("beforeprint",k,!1);window.addEventListener("afterprint",
|
|
k,!1)}}})();
|
|
var DownloadManager=function(){function a(a,b){var e=document.createElement("a");e.click?(e.href=a,e.target="_parent","download"in e&&(e.download=b),(document.body||document.documentElement).appendChild(e),e.click(),e.parentNode.removeChild(e)):(window.top===window&&a.split("#")[0]===window.location.href.split("#")[0]&&(e=-1===a.indexOf("?")?"?":"&",a=a.replace(/#|$/,e+"$&")),window.open(a,"_parent"))}function b(){}b.prototype={downloadUrl:function(b,d){PDFJS.isValidUrl(b,!0)&&a(b+"#pdfjs.action=download",d)},
|
|
download:function(b,d,e){URL?navigator.msSaveBlob?navigator.msSaveBlob(b,e)||this.downloadUrl(d,e):(b=URL.createObjectURL(b),a(b,e)):this.downloadUrl(d,e)}};return b}(),cache=new Cache(CACHE_SIZE),currentPageNumber=1,ViewHistory=function(){function a(a){this.fingerprint=a;var c;this.isInitializedPromiseResolved=!1;this.initializedPromise=new Promise(function(a){c=a});a=function(a){this.isInitializedPromiseResolved=!0;this.initialize(a||"{}");c()}.bind(this);isLocalStorageEnabled&&a(localStorage.getItem("database"))}
|
|
a.prototype={initialize:function(a){a=JSON.parse(a);"files"in a||(a.files=[]);a.files.length>=VIEW_HISTORY_MEMORY&&a.files.shift();for(var c,d=0,e=a.files.length;d<e;d++)if(a.files[d].fingerprint===this.fingerprint){c=d;break}"number"!==typeof c&&(c=a.files.push({fingerprint:this.fingerprint})-1);this.file=a.files[c];this.database=a},set:function(a,c){if(this.isInitializedPromiseResolved){this.file[a]=c;var d=JSON.stringify(this.database);isLocalStorageEnabled&&localStorage.setItem("database",d)}},
|
|
get:function(a,c){return this.isInitializedPromiseResolved?this.file[a]||c:c}};return a}(),PDFFindBar={opened:!1,bar:null,toggleButton:null,findField:null,highlightAll:null,caseSensitive:null,findMsg:null,findStatusIcon:null,findPreviousButton:null,findNextButton:null,initialize:function(a){if("undefined"===typeof PDFFindController||null===PDFFindController)throw"PDFFindBar cannot be initialized without a PDFFindController instance.";this.bar=a.bar;this.toggleButton=a.toggleButton;this.findField=
|
|
a.findField;this.highlightAll=a.highlightAllCheckbox;this.caseSensitive=a.caseSensitiveCheckbox;this.findMsg=a.findMsg;this.findStatusIcon=a.findStatusIcon;this.findPreviousButton=a.findPreviousButton;this.findNextButton=a.findNextButton;var b=this;this.toggleButton.addEventListener("click",function(){b.toggle()});this.findField.addEventListener("input",function(){b.dispatchEvent("")});this.bar.addEventListener("keydown",function(a){switch(a.keyCode){case 13:a.target===b.findField&&b.dispatchEvent("again",
|
|
a.shiftKey);break;case 27:b.close()}});this.findPreviousButton.addEventListener("click",function(){b.dispatchEvent("again",!0)});this.findNextButton.addEventListener("click",function(){b.dispatchEvent("again",!1)});this.highlightAll.addEventListener("click",function(){b.dispatchEvent("highlightallchange")});this.caseSensitive.addEventListener("click",function(){b.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="",e="";switch(a){case FindStates.FIND_PENDING:e="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",e);this.findMsg.textContent=d},open:function(){this.opened||(this.opened=!0,this.toggleButton.classList.add("toggled"),this.bar.classList.remove("hidden"));this.findField.select();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()}},PDFFindController={startedTextExtraction:!1,extractTextPromises:[],pendingFindMatches:{},active:!1,pageContents:[],pageMatches:[],selected:{pageIdx:-1,matchIdx:-1},offset:{pageIdx:null,matchIdx:null},resumePageIdx:null,resumeCallback:null,state:null,dirtyMatch:!1,findTimeout:null,pdfPageSource:null,integratedFind:!1,initialize:function(a){if("undefined"===typeof PDFFindBar||null===PDFFindBar)throw"PDFFindController cannot be initialized without a PDFFindController instance";
|
|
this.pdfPageSource=a.pdfPageSource;this.integratedFind=a.integratedFind;a=["find","findagain","findhighlightallchange","findcasesensitivitychange"];this.firstPagePromise=new Promise(function(a){this.resolveFirstPage=a}.bind(this));this.handleEvent=this.handleEvent.bind(this);for(var b=0;b<a.length;b++)window.addEventListener(a[b],this.handleEvent)},reset:function(){this.startedTextExtraction=!1;this.extractTextPromises=[];this.active=!1},calcFindMatch:function(a){var b=this.pageContents[a],c=this.state.query,
|
|
d=this.state.caseSensitive,e=c.length;if(0!==e){d||(b=b.toLowerCase(),c=c.toLowerCase());for(var d=[],g=-e;;){g=b.indexOf(c,g+e);if(-1===g)break;d.push(g)}this.pageMatches[a]=d;this.updatePage(a);this.resumePageIdx===a&&(a=this.resumeCallback,this.resumeCallback=this.resumePageIdx=null,a())}},extractText:function(){function a(c){e.pdfPageSource.pages[c].getTextContent().then(function(d){d=d.bidiTexts;for(var f="",k=0;k<d.length;k++)f+=d[k].str;e.pageContents.push(f);b[c](c);c+1<e.pdfPageSource.pages.length&&
|
|
a(c+1)})}if(!this.startedTextExtraction){this.startedTextExtraction=!0;this.pageContents=[];for(var b=[],c=0,d=this.pdfPageSource.pdfDocument.numPages;c<d;c++)this.extractTextPromises.push(new Promise(function(a){b.push(a)}));var e=this;a(0)}},handleEvent:function(a){if(null===this.state||"findagain"!==a.type)this.dirtyMatch=!0;this.state=a.detail;this.updateUIState(FindStates.FIND_PENDING);this.firstPagePromise.then(function(){this.extractText();clearTimeout(this.findTimeout);"find"===a.type?this.findTimeout=
|
|
setTimeout(this.nextMatch.bind(this),250):this.nextMatch()}.bind(this))},updatePage:function(a){var b=this.pdfPageSource.pages[a];this.selected.pageIdx===a&&b.scrollIntoView();b.textLayer&&b.textLayer.updateMatches()},nextMatch:function(){var a=this.state.findPrevious,b=this.pdfPageSource.page-1,c=this.pdfPageSource.pages.length;this.active=!0;if(this.dirtyMatch){this.dirtyMatch=!1;this.selected.pageIdx=this.selected.matchIdx=-1;this.offset.pageIdx=b;this.offset.matchIdx=null;this.hadMatch=!1;this.resumePageIdx=
|
|
this.resumeCallback=null;this.pageMatches=[];for(var d=this,b=0;b<c;b++)this.updatePage(b),b in this.pendingFindMatches||(this.pendingFindMatches[b]=!0,this.extractTextPromises[b].then(function(a){delete d.pendingFindMatches[a];d.calcFindMatch(a)}))}if(""===this.state.query)this.updateUIState(FindStates.FIND_FOUND);else if(!this.resumeCallback){c=this.offset;if(null!==c.matchIdx){b=this.pageMatches[c.pageIdx].length;if(!a&&c.matchIdx+1<b||a&&0<c.matchIdx){this.hadMatch=!0;c.matchIdx=a?c.matchIdx-
|
|
1:c.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){this.integratedFind?FirefoxCom.request("updateFindControlState",{result:a,findPrevious:b}):PDFFindBar.updateUIState(a,b)}},PDFHistory={initialized:!1,initialDestination:null,initialize:function(a){function b(){var a=c._getPreviousParams(null,!0);a&&(c._pushToHistory(a,
|
|
!1,!c.current.dest&&c.current.hash!==c.previousHash),c._updatePreviousBookmark());window.removeEventListener("beforeunload",b,!1)}if(!PDFJS.disableHistory&&!PDFView.isViewerEmbedded){this.initialized=!0;this.reInitialized=!1;this.historyUnlocked=this.allowHashChange=!0;this.previousHash=window.location.hash.substring(1);this.currentBookmark="";this.currentPage=0;this.updatePreviousBookmark=!1;this.previousBookmark="";this.previousPage=0;this.nextHashParam="";this.fingerprint=a;this.currentUid=this.uid=
|
|
0;this.current={};a=window.history.state;this._isStateObjectDefined(a)?(a.target.dest?this.initialDestination=a.target.dest:PDFView.initialBookmark=a.target.hash,this.currentUid=a.uid,this.uid=a.uid+1,this.current=a.target):(a&&a.fingerprint&&this.fingerprint!==a.fingerprint&&(this.reInitialized=!0),this._pushOrReplaceState({fingerprint:this.fingerprint},!0));var c=this;window.addEventListener("popstate",function(a){a.preventDefault();a.stopPropagation();c.historyUnlocked&&(a.state?c._goTo(a.state):
|
|
(c.previousHash=window.location.hash.substring(1),0===c.uid&&(a=c.previousHash&&c.currentBookmark&&c.previousHash!==c.currentBookmark?{hash:c.currentBookmark,page:c.currentPage}:{page:1},c.historyUnlocked=!1,c.allowHashChange=!1,window.history.back(),c._pushToHistory(a,!1,!0),window.history.forward(),c.historyUnlocked=!0),c._pushToHistory({hash:c.previousHash},!1,!0),c._updatePreviousBookmark()))},!1);window.addEventListener("beforeunload",b,!1);window.addEventListener("pageshow",function(a){window.addEventListener("beforeunload",
|
|
b,!1)},!1)}},_isStateObjectDefined:function(a){return a&&0<=a.uid&&a.fingerprint&&this.fingerprint===a.fingerprint&&a.target&&a.target.hash?!0:!1},_pushOrReplaceState:function(a,b){b?window.history.replaceState(a,"",document.URL):window.history.pushState(a,"",document.URL)},get isHashChangeUnlocked(){if(!this.initialized)return!0;var a=this.allowHashChange;this.allowHashChange=!0;return a},_updatePreviousBookmark:function(){this.updatePreviousBookmark&&this.currentBookmark&&this.currentPage&&(this.previousBookmark=
|
|
this.currentBookmark,this.previousPage=this.currentPage,this.updatePreviousBookmark=!1)},updateCurrentBookmark:function(a,b){this.initialized&&(this.currentBookmark=a.substring(1),this.currentPage=b|0,this._updatePreviousBookmark())},updateNextHashParam:function(a){this.initialized&&(this.nextHashParam=a)},push:function(a,b){if(this.initialized&&this.historyUnlocked)if(a.dest&&!a.hash&&(a.hash=this.current.hash&&this.current.dest&&this.current.dest===a.dest?this.current.hash:PDFView.getDestinationHash(a.dest).split("#")[1]),
|
|
a.page&&(a.page|=0),b){var c=window.history.state.target;c||(this._pushToHistory(a,!1),this.previousHash=window.location.hash.substring(1));this.updatePreviousBookmark=this.nextHashParam?!1:!0;c&&this._updatePreviousBookmark()}else{if(this.nextHashParam){if(this.nextHashParam===a.hash){this.nextHashParam=null;this.updatePreviousBookmark=!0;return}this.nextHashParam=null}a.hash?this.current.hash?this.current.hash!==a.hash?this._pushToHistory(a,!0):(!this.current.page&&a.page&&this._pushToHistory(a,
|
|
!1,!0),this.updatePreviousBookmark=!0):this._pushToHistory(a,!0):this.current.page&&a.page&&this.current.page!==a.page&&this._pushToHistory(a,!0)}},_getPreviousParams:function(a,b){if(!this.currentBookmark||!this.currentPage)return null;this.updatePreviousBookmark&&(this.updatePreviousBookmark=!1);if(0<this.uid&&(!this.previousBookmark||!this.previousPage))return null;if(!this.current.dest&&!a||b){if(this.previousBookmark===this.currentBookmark)return null}else if(this.current.page||a){if(this.previousPage===
|
|
this.currentPage)return null}else return null;var c={hash:this.currentBookmark,page:this.currentPage};PresentationMode.active&&(c.hash=null);return c},_stateObj:function(a){return{fingerprint:this.fingerprint,uid:this.uid,target:a}},_pushToHistory:function(a,b,c){this.initialized&&(!a.hash&&a.page&&(a.hash="page="+a.page),b&&!c&&(b=this._getPreviousParams())&&this._pushToHistory(b,!1,!this.current.dest&&this.current.hash!==this.previousHash),this._pushOrReplaceState(this._stateObj(a),c||0===this.uid),
|
|
this.currentUid=this.uid++,this.current=a,this.updatePreviousBookmark=!0)},_goTo:function(a){if(this.initialized&&this.historyUnlocked&&this._isStateObjectDefined(a)){if(!this.reInitialized&&a.uid<this.currentUid){var b=this._getPreviousParams(!0);if(b){this._pushToHistory(this.current,!1);this._pushToHistory(b,!1);this.currentUid=a.uid;window.history.back();return}}this.historyUnlocked=!1;a.target.dest?PDFView.navigateTo(a.target.dest):PDFView.setHash(a.target.hash);this.currentUid=a.uid;a.uid>this.uid&&
|
|
(this.uid=a.uid);this.current=a.target;this.updatePreviousBookmark=!0;a=window.location.hash.substring(1);this.previousHash!==a&&(this.allowHashChange=!1);this.previousHash=a;this.historyUnlocked=!0}},back:function(){this.go(-1)},forward:function(){this.go(1)},go:function(a){if(this.initialized&&this.historyUnlocked){var b=window.history.state;-1===a&&b&&0<b.uid?window.history.back():1===a&&b&&b.uid<this.uid-1&&window.history.forward()}}},SecondaryToolbar={opened:!1,previousContainerHeight:null,newContainerHeight:null,
|
|
initialize:function(a){this.toolbar=a.toolbar;this.presentationMode=a.presentationMode;this.buttonContainer=this.toolbar.firstElementChild;this.toggleButton=a.toggleButton;this.presentationModeButton=a.presentationModeButton;this.openFile=a.openFile;this.print=a.print;this.download=a.download;this.firstPage=a.firstPage;this.lastPage=a.lastPage;this.pageRotateCw=a.pageRotateCw;this.pageRotateCcw=a.pageRotateCcw;a=[{element:this.toggleButton,handler:this.toggle},{element:this.presentationModeButton,
|
|
handler:this.presentationModeClick},{element:this.print,handler:this.printClick},{element:this.firstPage,handler:this.firstPageClick},{element:this.lastPage,handler:this.lastPageClick},{element:this.pageRotateCw,handler:this.pageRotateCwClick},{element:this.pageRotateCcw,handler:this.pageRotateCcwClick}];for(var b in a){var c=a[b].element;c&&c.addEventListener("click",a[b].handler.bind(this))}},presentationModeClick:function(a){this.presentationMode.request();this.close()},openFileClick:function(a){document.getElementById("fileInput").click();
|
|
this.close(a.target)},printClick:function(a){window.print();this.close(a.target)},downloadClick:function(a){PDFView.download();this.close(a.target)},firstPageClick:function(a){PDFView.page=1},lastPageClick:function(a){PDFView.page=PDFView.pdfDocument.numPages},pageRotateCwClick:function(a){PDFView.rotatePages(90)},pageRotateCcwClick:function(a){PDFView.rotatePages(-90)},setMaxHeight:function(a){a&&this.buttonContainer&&(this.newContainerHeight=a.clientHeight,this.previousContainerHeight!==this.newContainerHeight&&
|
|
(this.buttonContainer.setAttribute("style","max-height: "+(this.newContainerHeight-SCROLLBAR_PADDING)+"px;"),this.previousContainerHeight=this.newContainerHeight))},open:function(){this.opened||(this.opened=!0,this.toggleButton.classList.add("toggled"),this.toolbar.classList.remove("hidden"))},close:function(a){!this.opened||a&&!this.toolbar.contains(a)||(this.opened=!1,this.toolbar.classList.add("hidden"),this.toggleButton.classList.remove("toggled"))},toggle:function(){this.opened?this.close():
|
|
this.open()}},PasswordPrompt={visible:!1,updatePassword:null,reason:null,overlayContainer:null,passwordField:null,passwordText:null,passwordSubmit:null,passwordCancel:null,initialize:function(a){this.overlayContainer=a.overlayContainer;this.passwordField=a.passwordField;this.passwordText=a.passwordText;this.passwordSubmit=a.passwordSubmit;this.passwordCancel=a.passwordCancel;this.passwordSubmit.addEventListener("click",this.verifyPassword.bind(this));this.passwordCancel.addEventListener("click",this.hide.bind(this));
|
|
this.passwordField.addEventListener("keydown",function(a){13===a.keyCode&&this.verifyPassword()}.bind(this));this.overlayContainer.addEventListener("keydown",function(a){27===a.keyCode&&this.hide()}.bind(this))},show:function(){if(!this.visible){this.visible=!0;this.overlayContainer.classList.remove("hidden");this.passwordField.focus();var a=mozL10n.get("password_label",null,"Enter the password to open this PDF file.");this.reason===PDFJS.PasswordResponses.INCORRECT_PASSWORD&&(a=mozL10n.get("password_invalid",
|
|
null,"Invalid password. Please try again."));this.passwordText.textContent=a}},hide:function(){this.visible&&(this.visible=!1,this.passwordField.value="",this.overlayContainer.classList.add("hidden"))},verifyPassword:function(){var a=this.passwordField.value;if(a&&0<a.length)return this.hide(),this.updatePassword(a)}},DELAY_BEFORE_HIDING_CONTROLS=3E3,SELECTOR="presentationControls",DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS=1E3,PresentationMode={active:!1,args:null,contextMenuOpen:!1,prevCoords:{x:null,
|
|
y:null},initialize:function(a){this.container=a.container;this.secondaryToolbar=a.secondaryToolbar;this.viewer=this.container.firstElementChild;this.firstPage=a.firstPage;this.lastPage=a.lastPage;this.pageRotateCw=a.pageRotateCw;this.pageRotateCcw=a.pageRotateCcw;this.firstPage.addEventListener("click",function(){this.contextMenuOpen=!1;this.secondaryToolbar.firstPageClick()}.bind(this));this.lastPage.addEventListener("click",function(){this.contextMenuOpen=!1;this.secondaryToolbar.lastPageClick()}.bind(this));
|
|
this.pageRotateCw.addEventListener("click",function(){this.contextMenuOpen=!1;this.secondaryToolbar.pageRotateCwClick()}.bind(this));this.pageRotateCcw.addEventListener("click",function(){this.contextMenuOpen=!1;this.secondaryToolbar.pageRotateCcwClick()}.bind(this))},get isFullscreen(){return document.fullscreenElement||document.mozFullScreen||document.webkitIsFullScreen||document.msFullscreenElement},_setSwitchInProgress:function(){this.switchInProgress&&clearTimeout(this.switchInProgress);this.switchInProgress=
|
|
setTimeout(function(){delete this.switchInProgress}.bind(this),DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);PDFView.currentPosition=null},_resetSwitchInProgress:function(){this.switchInProgress&&(clearTimeout(this.switchInProgress),delete this.switchInProgress)},request:function(){if(!PDFView.supportsFullscreen||this.isFullscreen||!this.viewer.hasChildNodes())return!1;this._setSwitchInProgress();if(this.container.requestFullscreen)this.container.requestFullscreen();else if(this.container.mozRequestFullScreen)this.container.mozRequestFullScreen();
|
|
else if(this.container.webkitRequestFullScreen)this.container.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);else if(this.container.msRequestFullscreen)this.container.msRequestFullscreen();else return!1;this.args={page:PDFView.page,previousScale:PDFView.currentScaleValue};return!0},enter:function(){this.active=!0;this._resetSwitchInProgress();setTimeout(function(){PDFView.page=this.args.page;PDFView.setScale("page-fit",!0)}.bind(this),0);window.addEventListener("mousemove",this.mouseMove,!1);
|
|
window.addEventListener("mousedown",this.mouseDown,!1);window.addEventListener("contextmenu",this.contextMenu,!1);this.showControls();HandTool.enterPresentationMode();this.contextMenuOpen=!1;this.container.setAttribute("contextmenu","viewerContextMenu")},exit:function(){var a=PDFView.page;setTimeout(function(){PDFView.setScale(this.args.previousScale);PDFView.page=a;this.active=!1;this.args=null}.bind(this),0);window.removeEventListener("mousemove",this.mouseMove,!1);window.removeEventListener("mousedown",
|
|
this.mouseDown,!1);window.removeEventListener("contextmenu",this.contextMenu,!1);this.hideControls();PDFView.clearMouseScrollState();HandTool.exitPresentationMode();this.container.removeAttribute("contextmenu");this.contextMenuOpen=!1;scrollIntoView(document.getElementById("thumbnailContainer"+a))},showControls:function(){this.controlsTimeout?clearTimeout(this.controlsTimeout):this.container.classList.add(SELECTOR);this.controlsTimeout=setTimeout(function(){this.container.classList.remove(SELECTOR);
|
|
delete this.controlsTimeout}.bind(this),DELAY_BEFORE_HIDING_CONTROLS)},hideControls:function(){this.controlsTimeout&&(this.container.classList.remove(SELECTOR),clearTimeout(this.controlsTimeout),delete this.controlsTimeout)},mouseMove:function(a){a={x:a.clientX,y:a.clientY};var b=PresentationMode.prevCoords;PresentationMode.prevCoords=a;a.x===b.x&&a.y===b.y||PresentationMode.showControls()},mouseDown:function(a){var b=PresentationMode;b.contextMenuOpen?(b.contextMenuOpen=!1,a.preventDefault()):0!==
|
|
a.button||a.target.href&&a.target.classList.contains("internalLink")||(a.preventDefault(),PDFView.page+=a.shiftKey?-1:1)},contextMenu:function(a){PresentationMode.contextMenuOpen=!0}};(function(){function a(a){PresentationMode.isFullscreen?PresentationMode.enter():PresentationMode.exit()}window.addEventListener("fullscreenchange",a,!1);window.addEventListener("mozfullscreenchange",a,!1);window.addEventListener("webkitfullscreenchange",a,!1);window.addEventListener("MSFullscreenChange",a,!1)})();"use strict";
|
|
var GrabToPan=function(){function a(a){this.element=a.element;this.document=a.element.ownerDocument;"function"===typeof a.ignoreTarget&&(this.ignoreTarget=a.ignoreTarget);this.onActiveChanged=a.onActiveChanged;this.activate=this.activate.bind(this);this.deactivate=this.deactivate.bind(this);this.toggle=this.toggle.bind(this);this._onmousedown=this._onmousedown.bind(this);this._onmousemove=this._onmousemove.bind(this);this._endPan=this._endPan.bind(this)}a.prototype={CSS_CLASS_GRAB:"grab-to-pan-grab",
|
|
CSS_CLASS_GRABBING:"grab-to-pan-grabbing",activate:function(){if(!this.active&&(this.active=!0,this.element.addEventListener("mousedown",this._onmousedown,!0),this.element.classList.add(this.CSS_CLASS_GRAB),this.onActiveChanged))this.onActiveChanged(!0)},deactivate:function(){if(this.active&&(this.active=!1,this.element.removeEventListener("mousedown",this._onmousedown,!0),this._endPan(),this.element.classList.remove(this.CSS_CLASS_GRAB),this.onActiveChanged))this.onActiveChanged(!1)},toggle:function(){this.active?
|
|
this.deactivate():this.activate()},ignoreTarget:function(a){return a[b]("a[href], a[href] *, input, textarea, button, button *, select, option")},_onmousedown:function(a){if(0===a.button&&!this.ignoreTarget(a.target)){if(a.originalTarget)try{a.originalTarget.tagName}catch(b){return}this.scrollLeftStart=this.element.scrollLeft;this.scrollTopStart=this.element.scrollTop;this.clientXStart=a.clientX;this.clientYStart=a.clientY;this.document.addEventListener("mousemove",this._onmousemove,!0);this.document.addEventListener("mouseup",
|
|
this._endPan,!0);this.element.addEventListener("scroll",this._endPan,!0);a.preventDefault();a.stopPropagation();this.element.classList.remove(this.CSS_CLASS_GRAB);this.document.documentElement.classList.add(this.CSS_CLASS_GRABBING)}},_onmousemove:function(a){this.element.removeEventListener("scroll",this._endPan,!0);var b;b="buttons"in a&&c?!(a.buttons|1):e||g?0===a.which:void 0;b?this.document.removeEventListener("mousemove",this._onmousemove,!0):(b=a.clientX-this.clientXStart,this.element.scrollTop=
|
|
this.scrollTopStart-(a.clientY-this.clientYStart),this.element.scrollLeft=this.scrollLeftStart-b)},_endPan:function(){this.element.removeEventListener("scroll",this._endPan,!0);this.document.removeEventListener("mousemove",this._onmousemove,!0);this.document.removeEventListener("mouseup",this._endPan,!0);this.document.documentElement.classList.remove(this.CSS_CLASS_GRABBING);this.element.classList.add(this.CSS_CLASS_GRAB)}};var b;["webkitM","mozM","msM","oM","m"].some(function(a){a+="atches";a in
|
|
document.documentElement&&(b=a);a+="Selector";a in document.documentElement&&(b=a);return b});var c=!document.documentMode||9<document.documentMode,d=window.chrome,e=d&&(d.webstore||d.app),g=/Apple/.test(navigator.vendor)&&/Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);return a}(),HandTool={initialize:function(a){var b=a.toggleHandTool;this.handTool=new GrabToPan({element:a.container,onActiveChanged:function(a){b&&(a?(b.title=mozL10n.get("hand_tool_disable.title",null,"Disable hand tool"),
|
|
b.firstElementChild.textContent=mozL10n.get("hand_tool_disable_label",null,"Disable hand tool")):(b.title=mozL10n.get("hand_tool_enable.title",null,"Enable hand tool"),b.firstElementChild.textContent=mozL10n.get("hand_tool_enable_label",null,"Enable hand tool")))}});b&&b.addEventListener("click",this.handTool.toggle,!1)},toggle:function(){this.handTool.toggle()},enterPresentationMode:function(){this.handTool.active&&(this.wasActive=!0,this.handTool.deactivate())},exitPresentationMode:function(){this.wasActive&&
|
|
(this.wasActive=null,this.handTool.activate())}},PDFView={pages:[],thumbnails:[],currentScale:UNKNOWN_SCALE,currentScaleValue:null,initialBookmark:document.location.hash.substring(1),container:null,thumbnailContainer:null,initialized:!1,fellback:!1,pdfDocument:null,sidebarOpen:!1,pageViewScroll:null,thumbnailViewScroll:null,pageRotation:0,mouseScrollTimeStamp:0,mouseScrollDelta:0,lastScroll:0,previousPageNumber:1,isViewerEmbedded:window.parent!==window,idleTimeout:null,currentPosition:null,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));PDFFindBar.initialize({bar:document.getElementById("findbar"),toggleButton:document.getElementById("viewFind"),findField:document.getElementById("findInput"),highlightAllCheckbox:document.getElementById("findHighlightAll"),
|
|
caseSensitiveCheckbox:document.getElementById("findMatchCase"),findMsg:document.getElementById("findMsg"),findStatusIcon:document.getElementById("findStatusIcon"),findPreviousButton:document.getElementById("findPrevious"),findNextButton:document.getElementById("findNext")});PDFFindController.initialize({pdfPageSource:this,integratedFind:this.supportsIntegratedFind});HandTool.initialize({container:b,toggleHandTool:document.getElementById("toggleHandTool")});SecondaryToolbar.initialize({toolbar:document.getElementById("secondaryToolbar"),
|
|
presentationMode:PresentationMode,toggleButton:document.getElementById("secondaryToolbarToggle"),presentationModeButton:document.getElementById("secondaryPresentationMode"),openFile:document.getElementById("secondaryOpenFile"),print:document.getElementById("secondaryPrint"),download:document.getElementById("secondaryDownload"),firstPage:document.getElementById("firstPage"),lastPage:document.getElementById("lastPage"),pageRotateCw:document.getElementById("pageRotateCw"),pageRotateCcw:document.getElementById("pageRotateCcw")});
|
|
PasswordPrompt.initialize({overlayContainer:document.getElementById("overlayContainer"),passwordField:document.getElementById("password"),passwordText:document.getElementById("passwordText"),passwordSubmit:document.getElementById("passwordSubmit"),passwordCancel:document.getElementById("passwordCancel")});PresentationMode.initialize({container:b,secondaryToolbar:SecondaryToolbar,firstPage:document.getElementById("contextFirstPage"),lastPage:document.getElementById("contextLastPage"),pageRotateCw:document.getElementById("contextPageRotateCw"),
|
|
pageRotateCcw:document.getElementById("contextPageRotateCcw")});this.initialized=!0;b.addEventListener("scroll",function(){a.lastScroll=Date.now()},!1)},getPage:function(a){return this.pdfDocument.getPage(a)},watchScroll:function(a,b,c){b.down=!0;b.lastY=a.scrollTop;a.addEventListener("scroll",function(d){d=a.scrollTop;var e=b.lastY;d>e?b.down=!0:d<e&&(b.down=!1);b.lastY=d;c()},!0)},_setScaleUpdatePages:function(a,b,c,d){this.currentScaleValue=b;if(a!==this.currentScale){b=0;for(var e=this.pages.length;b<
|
|
e;b++)this.pages[b].update(a);this.currentScale=a;if(!d){d=this.page;var g;this.currentPosition&&!IGNORE_CURRENT_POSITION_ON_ZOOM&&(d=this.currentPosition.page,g=[null,{name:"XYZ"},this.currentPosition.left,this.currentPosition.top,null]);this.pages[d-1].scrollIntoView(g)}g=document.createEvent("UIEvents");g.initUIEvent("scalechange",!1,!1,window,0);g.scale=a;g.resetAutoSettings=c;window.dispatchEvent(g)}},setScale:function(a,b,c){if("custom"!==a){var d=parseFloat(a);if(0<d)this._setScaleUpdatePages(d,
|
|
a,!0,c);else{var e=this.pages[this.page-1];if(e){d=(this.container.clientWidth-SCROLLBAR_PADDING)/e.width*e.scale;e=(this.container.clientHeight-VERTICAL_PADDING)/e.height*e.scale;switch(a){case "page-actual":d=1;break;case "page-width":break;case "page-height":d=e;break;case "page-fit":d=Math.min(d,e);break;case "auto":d=Math.min(MAX_AUTO_SCALE,d);break;default:console.error("pdfViewSetScale: '"+a+"' is an unknown zoom value.");return}this._setScaleUpdatePages(d,a,b,c);selectScaleOption(a)}}}},zoomIn:function(a){var b=
|
|
this.currentScale;do b=(b*DEFAULT_SCALE_DELTA).toFixed(2),b=Math.ceil(10*b)/10,b=Math.min(MAX_SCALE,b);while(--a&&b<MAX_SCALE);this.setScale(b,!0)},zoomOut:function(a){var b=this.currentScale;do b=(b/DEFAULT_SCALE_DELTA).toFixed(2),b=Math.floor(10*b)/10,b=Math.max(MIN_SCALE,b);while(--a&&b>MIN_SCALE);this.setScale(b,!0)},set page(a){var b=this.pages,c=document.createEvent("UIEvents");c.initUIEvent("pagechange",!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||a.msRequestFullscreen;!1===document.fullscreenEnabled||!1===document.mozFullScreenEnabled||!1===document.webkitFullscreenEnabled||!1===document.msFullscreenEnabled?a=!1:this.isViewerEmbedded&&(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 supportsDocumentColors(){Object.defineProperty(this,"supportsDocumentColors",{value:!0,enumerable:!0,configurable:!0,writable:!1});return!0},get loadingBar(){var a=new ProgressBar("#loadingBar",{});Object.defineProperty(this,"loadingBar",{value:a,enumerable:!0,configurable:!0,writable:!1});return a},get isHorizontalScrollbarEnabled(){return PresentationMode.active?
|
|
!1:this.container.scrollWidth>this.container.clientWidth},initPassiveLoading:function(){var a={rangeListeners:[],progressListeners:[],addRangeListener:function(a){this.rangeListeners.push(a)},addProgressListener:function(a){this.progressListeners.push(a)},onDataRange:function(a,c){for(var d=this.rangeListeners,e=0,g=d.length;e<g;++e)d[e](a,c)},onDataProgress:function(a){for(var c=this.progressListeners,d=0,e=c.length;d<e;++d)c[d](a)},requestDataRange:function(a,c){FirefoxCom.request("requestDataRange",
|
|
{begin:a,end:c})}};window.addEventListener("message",function(b){var c=b.data;if("object"===typeof c&&"pdfjsLoadAction"in c)switch(c.pdfjsLoadAction){case "supportsRangedLoading":PDFView.open(c.pdfUrl,0,void 0,a,{length:c.length,initialData:c.data});break;case "range":a.onDataRange(c.begin,c.chunk);break;case "rangeProgress":a.onDataProgress(c.loaded);break;case "progress":PDFView.progress(c.loaded/c.total);break;case "complete":if(!c.data){PDFView.error(mozL10n.get("loading_error",null,"An error occurred while loading the PDF."),
|
|
b);break}PDFView.open(c.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,d,e){c={password:c};"string"===typeof a?(this.setTitleUsingUrl(a),c.url=a):a&&"byteLength"in a&&(c.data=a);if(e)for(var g in e)c[g]=e[g];this.pdfDocument=null;var h=this;h.loading=!0;PDFJS.getDocument(c,d,function(a,b){PasswordPrompt.updatePassword=
|
|
a;PasswordPrompt.reason=b;PasswordPrompt.show()},function(a){h.progress(a.loaded/a.total)}).then(function(a){h.load(a,b);h.loading=!1},function(a,b){var c=mozL10n.get("loading_error",null,"An error occurred while loading the PDF.");b&&"InvalidPDFException"===b.name&&(c=mozL10n.get("invalid_file_error",null,"Invalid or corrupted PDF file."));b&&"MissingPDFException"===b.name&&(c=mozL10n.get("missing_file_error",null,"Missing PDF file."));h.error(c,{message:a});h.loading=!1})},download:function(){function a(){d.downloadUrl(b,
|
|
c)}var b=this.url.split("#")[0],c=getPDFFileNameFromURL(b),d=new DownloadManager;d.onerror=function(a){PDFView.error("PDF failed to download.")};this.pdfDocument?this.pdfDocument.getData().then(function(a){a=PDFJS.createBlob(a,"application/pdf");d.download(a,b,c)},a).then(null,a):a()},fallback:function(a){},navigateTo:function(a){var b="",c=this,d=function(e){c.pendingRefStr=null;var g=e instanceof Object?c.pagesRefMap[e.num+" "+e.gen+" R"]:e+1;g?(g>c.pages.length&&(g=c.pages.length),c.pages[g-1].scrollIntoView(a),
|
|
PDFHistory.push({dest:a,hash:b,page:g})):c.pdfDocument.getPageIndex(e).then(function(a){c.pagesRefMap[e.num+" "+e.gen+" R"]=a+1;d(e)})};this.destinationsPromise.then(function(){"string"===typeof a&&(b=a,a=c.destinations[a]);a instanceof Array&&d(a[0])})},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];
|
|
if("object"===typeof c&&"name"in c&&"XYZ"==c.name){var c=a[4]||this.currentScaleValue,d=parseFloat(c);d&&(c=100*d);b+="&zoom="+c;if(a[2]||a[3])b+=","+(a[2]||0)+","+(a[3]||0)}return b}}return""},getAnchorUrl:function(a){return 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+="\n"+mozL10n.get("error_line",{line:b.lineNumber},"Line: {{line}}"))));var d=document.getElementById("errorWrapper");d.removeAttribute("hidden");document.getElementById("errorMessage").textContent=a;var e=document.getElementById("errorClose");e.onclick=function(){d.setAttribute("hidden","true")};var g=document.getElementById("errorMoreInfo"),h=document.getElementById("errorShowMore"),
|
|
f=document.getElementById("errorShowLess");h.onclick=function(){g.removeAttribute("hidden");h.setAttribute("hidden","true");f.removeAttribute("hidden");g.style.height=g.scrollHeight+"px"};f.onclick=function(){g.setAttribute("hidden","true");h.removeAttribute("hidden");f.setAttribute("hidden","true")};h.oncontextmenu=noContextMenuHandler;f.oncontextmenu=noContextMenuHandler;e.oncontextmenu=noContextMenuHandler;h.removeAttribute("hidden");f.setAttribute("hidden","true");g.value=c},progress:function(a){a=
|
|
Math.round(100*a);a>PDFView.loadingBar.percent&&(PDFView.loadingBar.percent=a)},load:function(a,b){function c(a,b){a.onAfterDraw=function(){e||(e=!0,g());b.setImage(a.canvas)}}var d=this,e=!1,g=null,h=new Promise(function(a){g=a});PDFFindController.reset();this.pdfDocument=a;document.getElementById("errorWrapper").setAttribute("hidden","true");a.dataLoaded().then(function(){PDFView.loadingBar.hide();document.getElementById("outerContainer").classList.remove("loadingInProgress")});var f=document.getElementById("thumbnailView");
|
|
for(f.parentNode.scrollTop=0;f.hasChildNodes();)f.removeChild(f.lastChild);"_loadingInterval"in f&&clearInterval(f._loadingInterval);for(var k=document.getElementById("viewer");k.hasChildNodes();)k.removeChild(k.lastChild);var s=a.numPages,n=a.fingerprint;document.getElementById("numPages").textContent=mozL10n.get("page_of",{pageCount:s},"of {{pageCount}}");document.getElementById("pageNumber").max=s;var q=PDFView.prefs=new Preferences;PDFView.documentFingerprint=n;var t=PDFView.store=new ViewHistory(n);
|
|
this.pageRotation=0;var u=this.pages=[],p=this.pagesRefMap={},l=this.thumbnails=[],r;this.pagesPromise=n=new Promise(function(a){r=a});var m=a.getPage(1);m.then(function(e){e=e.getViewport((b||1)*CSS_UNITS);for(var g=1;g<=s;++g){var n=e.clone(),q=new PageView(k,g,b,d.navigateTo.bind(d),n),n=new ThumbnailView(f,g,n);c(q,n);u.push(q);l.push(n)}h.then(function(){if(PDFJS.disableAutoFetch)r();else for(var b=s,c=1;c<=s;++c)a.getPage(c).then(function(a,c){var d=u[a-1];d.pdfPage||d.setPdfPage(c);p[c.ref.num+
|
|
" "+c.ref.gen+" R"]=a;b--;b||r()}.bind(null,c))});e=document.createEvent("CustomEvent");e.initCustomEvent("documentload",!0,!0,{});window.dispatchEvent(e);PDFView.loadingBar.setWidth(k);PDFFindController.resolveFirstPage()});Promise.all([m,q.initializedPromise,t.initializedPromise]).then(function(){var a=q.get("showPreviousViewOnLoad"),c=q.get("defaultZoomValue"),e=null;if(a&&t.get("exists",!1))var a=t.get("page","1"),c=c||t.get("zoom",PDFView.currentScale),e=t.get("scrollLeft","0"),h=t.get("scrollTop",
|
|
"0"),e="page="+a+"&zoom="+c+","+e+","+h;else c&&(e="page=1&zoom="+c);PDFHistory.initialize(d.documentFingerprint);d.setInitialView(e,b);d.isViewerEmbedded||d.container.focus()});n.then(function(){PDFView.supportsPrinting&&a.getJavaScript().then(function(a){a.length&&(console.warn("Warning: JavaScript is not supported"),PDFView.fallback(PDFJS.UNSUPPORTED_FEATURES.javaScript));for(var b=/\bprint\s*\(/g,c=0,d=a.length;c<d;c++){var e=a[c];if(e&&b.test(e)){setTimeout(function(){window.print()});break}}})});
|
|
m=this.destinationsPromise=a.getDestinations();m.then(function(a){d.destinations=a});Promise.all([n,m,PDFView.animationStartedPromise]).then(function(){a.getOutline().then(function(a){d.outline=new DocumentOutlineView(a);document.getElementById("viewOutline").disabled=!a;a&&q.get("ifAvailableShowOutlineOnLoad")&&(d.sidebarOpen||document.getElementById("sidebarToggle").click(),d.switchSidebarView("outline"))})});a.getMetadata().then(function(b){var c=b.info;b=b.metadata;d.documentInfo=c;d.metadata=
|
|
b;console.log("PDF "+a.fingerprint+" ["+c.PDFFormatVersion+" "+(c.Producer||"-")+" / "+(c.Creator||"-")+"]"+(PDFJS.version?" (PDF.js: "+PDFJS.version+")":""));var e;b&&b.has("dc:title")&&(e=b.get("dc:title"));!e&&c&&c.Title&&(e=c.Title);e&&d.setTitle(e+" - "+document.title);c.IsAcroFormPresent&&(console.warn("Warning: AcroForm/XFA is not supported"),PDFView.fallback(PDFJS.UNSUPPORTED_FEATURES.forms))})},setInitialView:function(a,b){this.currentScale=0;this.currentScaleValue=null;document.getElementById("pageNumber").value=
|
|
currentPageNumber=1;this.currentPosition=null;PDFHistory.initialDestination?(this.navigateTo(PDFHistory.initialDestination),PDFHistory.initialDestination=null):this.initialBookmark?(this.setHash(this.initialBookmark),PDFHistory.push({hash:this.initialBookmark},!!this.initialBookmark),this.initialBookmark=null):a?this.setHash(a):b&&(this.setScale(b,!0),this.page=1);PDFView.currentScale===UNKNOWN_SCALE&&this.setScale(DEFAULT_SCALE,!0)},renderHighestPriority:function(){PDFView.idleTimeout&&(clearTimeout(PDFView.idleTimeout),
|
|
PDFView.idleTimeout=null);var a=this.getVisiblePages();if(a=this.getHighestPriority(a,this.pages,this.pageViewScroll.down))this.renderView(a,"page");else{if(this.sidebarOpen&&(a=this.getVisibleThumbs(),a=this.getHighestPriority(a,this.thumbnails,this.thumbnailViewScroll.down))){this.renderView(a,"thumbnail");return}PDFView.idleTimeout=setTimeout(function(){PDFView.cleanup()},CLEANUP_TIMEOUT)}},cleanup:function(){for(var a=0,b=this.pages.length;a<b;a++)this.pages[a]&&this.pages[a].renderingState!==
|
|
RenderingStates.FINISHED&&this.pages[a].reset();this.pdfDocument.cleanup()},getHighestPriority:function(a,b,c){var d=a.views,e=d.length;if(0===e)return!1;for(var g=0;g<e;++g){var h=d[g].view;if(!this.isViewFinished(h))return h}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},setHash:function(a){if(a)if(0<=a.indexOf("="))if(a=PDFView.parseQueryString(a),"nameddest"in a)PDFHistory.updateNextHashParam(a.nameddest),PDFView.navigateTo(a.nameddest);else{var b,c;"page"in a&&(b=a.page|0||1);if("zoom"in a){c=a.zoom.split(",");var d=c[0],e=parseFloat(d);e&&(d=e/100);
|
|
c=[null,{name:"XYZ"},1<c.length?c[1]|0:null,2<c.length?c[2]|0:null,d]}c?this.pages[(b||this.page)-1].scrollIntoView(c):b&&(this.page=b);"pagemode"in a&&(b=document.getElementById("sidebarToggle"),"thumbs"===a.pagemode||"bookmarks"===a.pagemode?(this.sidebarOpen||b.click(),this.switchSidebarView("thumbs"===a.pagemode?"thumbs":"outline")):"none"===a.pagemode&&this.sidebarOpen&&b.click())}else/^\d+$/.test(a)?this.page=a:(PDFHistory.updateNextHashParam(unescape(a)),PDFView.navigateTo(unescape(a)))},switchSidebarView:function(a){var b=
|
|
document.getElementById("thumbnailView"),c=document.getElementById("outlineView"),d=document.getElementById("viewThumbnail"),e=document.getElementById("viewOutline");switch(a){case "thumbs":a=b.classList.contains("hidden");d.classList.add("toggled");e.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"),e.classList.add("toggled"),
|
|
b.classList.add("hidden"),c.classList.remove("hidden"),e.getAttribute("disabled")}},getVisiblePages:function(){return this.getVisibleElements(this.container,this.pages,!PresentationMode.active)},getVisibleThumbs:function(){return this.getVisibleElements(this.thumbnailContainer,this.thumbnails)},getVisibleElements:function(a,b,c){var d=a.scrollTop,e=d+a.clientHeight,g=a.scrollLeft,h=g+a.clientWidth;a=[];for(var f,k,s,n,q,t=0,u=b.length;t<u;++t)if(f=b[t],k=f.el.offsetTop+f.el.clientTop,s=f.el.clientHeight,
|
|
!(k+s<d)){if(k>e)break;q=f.el.offsetLeft+f.el.clientLeft;n=f.el.clientWidth;q+n<g||q>h||(n=Math.max(0,d-k)+Math.max(0,k+s-e),s=100*(s-n)/s|0,a.push({id:f.id,x:q,y:k,view:f,percent:s}))}b=a[0];d=a[a.length-1];c&&a.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:a}},parseQueryString:function(a){a=a.split("&");for(var b={},c=0;c<a.length;++c){var d=a[c].split("="),e=1<d.length?d[1]:null;b[decodeURIComponent(d[0])]=decodeURIComponent(e)}return b},
|
|
beforePrint:function(){if(this.supportsPrinting){var a=!1;if(this.pages.length)for(var b=0,c=this.pages.length;b<c;++b){if(!this.pages[b].pdfPage){a=!0;break}}else a=!0;if(a)a=mozL10n.get("printing_not_ready",null,"Warning: The PDF is not fully loaded for printing."),window.alert(a);else for(document.querySelector("body").setAttribute("data-mozPrintCallback",!0),b=0,c=this.pages.length;b<c;++b)this.pages[b].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)},rotatePages:function(a){var b=this.pages[this.page-1];this.pageRotation=(this.pageRotation+360+a)%360;a=0;for(var c=this.pages.length;a<c;a++){var d=this.pages[a];d.update(d.scale,this.pageRotation)}a=0;for(c=this.thumbnails.length;a<c;a++)this.thumbnails[a].update(this.pageRotation);this.setScale(this.currentScaleValue,!0,!0);this.renderHighestPriority();b&&b.scrollIntoView()},
|
|
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=
|
|
function(a,b,c,d,e){function g(a,b,c){function d(a,b){a.href=PDFView.getDestinationHash(b);a.onclick=function(){b&&PDFView.navigateTo(b);return!1};b&&(a.className="internalLink")}function e(a,b){a.href=PDFView.getAnchorUrl("");a.onclick=function(){switch(b){case "GoToPage":document.getElementById("pageNumber").focus();break;case "GoBack":PDFHistory.back();break;case "GoForward":PDFHistory.forward();break;case "Find":PDFView.supportsIntegratedFind||PDFFindBar.toggle();break;case "NextPage":PDFView.page++;
|
|
break;case "PrevPage":PDFView.page--;break;case "LastPage":PDFView.page=PDFView.pages.length;break;case "FirstPage":PDFView.page=1}return!1};a.className="internalLink"}b.getAnnotations().then(function(h){f.annotationLayer&&(a.removeChild(f.annotationLayer),f.annotationLayer=null);c=c.clone({dontFlip:!0});for(var g=0;g<h.length;g++){var l=h[g];if((l=PDFJS.Annotation.fromData(l))&&l.hasHtml()){var r=l.getHtmlElement(b.commonObjs);mozL10n.translate(r);var l=l.getData(),m=l.rect,v=b.view,m=PDFJS.Util.normalizeRect([m[0],
|
|
v[3]-m[1]+v[1],m[2],v[3]-m[3]+v[1]]);r.style.left=m[0]+"px";r.style.top=m[1]+"px";r.style.position="absolute";v="matrix("+c.transform.join(",")+")";CustomStyle.setProp("transform",r,v);CustomStyle.setProp("transformOrigin",r,-m[0]+"px "+-m[1]+"px");"Link"!==l.subtype||l.url||(l.action?e(r,l.action):d(r,"dest"in l?l.dest:null));f.annotationLayer||(l=document.createElement("div"),l.className="annotationLayer",a.appendChild(l),f.annotationLayer=l);f.annotationLayer.appendChild(r)}}})}this.id=b;this.rotation=
|
|
0;this.scale=c||1;this.viewport=e;this.pdfPageRotate=e.rotation;this.renderingState=RenderingStates.INITIAL;this.annotationLayer=this.zoomLayer=this.textLayer=this.resume=null;b=document.createElement("a");b.name=""+this.id;var h=this.el=document.createElement("div");h.id="pageContainer"+this.id;h.className="page";h.style.width=Math.floor(this.viewport.width)+"px";h.style.height=Math.floor(this.viewport.height)+"px";a.appendChild(b);a.appendChild(h);this.setPdfPage=function(a){this.pdfPage=a;this.pdfPageRotate=
|
|
a.rotate;this.viewport=a.getViewport(this.scale*CSS_UNITS,(this.rotation+this.pdfPageRotate)%360);this.stats=a.stats;this.reset()};this.destroy=function(){this.zoomLayer=null;this.reset();this.pdfPage&&this.pdfPage.destroy()};this.reset=function(){this.renderTask&&this.renderTask.cancel();this.resume=null;this.renderingState=RenderingStates.INITIAL;h.style.width=Math.floor(this.viewport.width)+"px";h.style.height=Math.floor(this.viewport.height)+"px";for(var a=h.childNodes,b=h.childNodes.length-1;0<=
|
|
b;b--){var c=a[b];this.zoomLayer&&this.zoomLayer===c||h.removeChild(c)}h.removeAttribute("data-loaded");this.annotationLayer=null;delete this.canvas;this.loadingIconDiv=document.createElement("div");this.loadingIconDiv.className="loadingIcon";h.appendChild(this.loadingIconDiv)};this.update=function(a,b){this.scale=a||this.scale;"undefined"!==typeof b&&(this.rotation=b);this.viewport=this.viewport.clone({scale:this.scale*CSS_UNITS,rotation:(this.rotation+this.pdfPageRotate)%360});USE_ONLY_CSS_ZOOM&&
|
|
this.canvas?this.cssTransform(this.canvas):(this.canvas&&!this.zoomLayer&&(this.zoomLayer=this.canvas.parentNode,this.zoomLayer.style.position="absolute"),this.zoomLayer&&this.cssTransform(this.zoomLayer.firstChild),this.reset())};this.cssTransform=function(a){var b=this.viewport.width,c=this.viewport.height;a.style.width=a.parentNode.style.width=h.style.width=Math.floor(b)+"px";a.style.height=a.parentNode.style.height=h.style.height=Math.floor(c)+"px";var d=this.viewport.rotation-a._viewport.rotation,
|
|
e=Math.abs(d),f=1,p=1;if(90===e||270===e)f=c/b,p=b/c;CustomStyle.setProp("transform",a,"rotate("+d+"deg) scale("+f+","+p+")");if(this.textLayer){c=Math.abs(this.viewport.rotation-this.textLayer.viewport.rotation);d=b/a.width;if(90===c||270===c)d=b/a.height;a=this.textLayer.textLayerDiv;var l,r;switch(c){case 0:l=r=0;break;case 90:l=0;r="-"+a.style.height;break;case 180:l="-"+a.style.width;r="-"+a.style.height;break;case 270:l="-"+a.style.width;r=0;break;default:console.error("Bad rotation value.")}CustomStyle.setProp("transform",
|
|
a,"rotate("+c+"deg) scale("+d+", "+d+") translate("+l+", "+r+")");CustomStyle.setProp("transformOrigin",a,"0% 0%")}USE_ONLY_CSS_ZOOM&&this.annotationLayer&&g(h,this.pdfPage,this.viewport)};Object.defineProperty(this,"width",{get:function(){return this.viewport.width},enumerable:!0});Object.defineProperty(this,"height",{get:function(){return this.viewport.height},enumerable:!0});var f=this;this.getPagePoint=function(a,b){return this.viewport.convertToPdfPoint(a,b)};this.scrollIntoView=function(a){PresentationMode.active&&
|
|
(a=null,PDFView.setScale(PDFView.currentScaleValue,!0,!0));if(a){var b=0,c=0,d=0,e=0,g,f;f=!!(this.rotation%180);g=(f?this.height:this.width)/this.scale/CSS_UNITS;f=(f?this.width:this.height)/this.scale/CSS_UNITS;var l=0;switch(a[1].name){case "XYZ":b=a[2];c=a[3];l=a[4];b=null!==b?b:0;c=null!==c?c:f;break;case "Fit":case "FitB":l="page-fit";break;case "FitH":case "FitBH":c=a[2];l="page-width";break;case "FitV":case "FitBV":b=a[2];d=g;e=f;l="page-height";break;case "FitR":b=a[2];c=a[3];d=a[4]-b;e=
|
|
a[5]-c;g=(PDFView.container.clientWidth-SCROLLBAR_PADDING)/d/CSS_UNITS;f=(PDFView.container.clientHeight-SCROLLBAR_PADDING)/e/CSS_UNITS;l=Math.min(Math.abs(g),Math.abs(f));break;default:return}l&&l!==PDFView.currentScale?PDFView.setScale(l,!0,!0):PDFView.currentScale===UNKNOWN_SCALE&&PDFView.setScale(DEFAULT_SCALE,!0,!0);"page-fit"!==l||a[4]?(b=[this.viewport.convertToViewportPoint(b,c),this.viewport.convertToViewportPoint(b+d,c+e)],a=Math.min(b[0][0],b[1][0]),b=Math.min(b[0][1],b[1][1]),scrollIntoView(h,
|
|
{left:a,top:b})):scrollIntoView(h)}else scrollIntoView(h)};this.getTextContent=function(){return PDFView.getPage(this.id).then(function(a){return a.getTextContent()})};this.draw=function(a){function b(d){v===m.renderTask&&(m.renderTask=null);if("cancelled"!==d){m.renderingState=RenderingStates.FINISHED;m.loadingIconDiv&&(h.removeChild(m.loadingIconDiv),delete m.loadingIconDiv);m.zoomLayer&&(h.removeChild(m.zoomLayer),m.zoomLayer=null);d&&PDFView.error(mozL10n.get("rendering_error",null,"An error occurred while rendering the page."),
|
|
d);m.stats=c.stats;m.updateStats();if(m.onAfterDraw)m.onAfterDraw();cache.push(m);d=document.createEvent("CustomEvent");d.initCustomEvent("pagerender",!0,!0,{pageNumber:c.pageNumber});h.dispatchEvent(d);a()}}var c=this.pdfPage;if(!this.pagePdfPromise)if(c){this.renderingState!==RenderingStates.INITIAL&&console.error("Must be in new state before drawing");this.renderingState=RenderingStates.RUNNING;var d=this.viewport,e=document.createElement("div");e.style.width=h.style.width;e.style.height=h.style.height;
|
|
e.classList.add("canvasWrapper");var f=document.createElement("canvas");f.id="page"+this.id;e.appendChild(f);h.appendChild(e);this.canvas=f;var e=f.getContext("2d"),p=getOutputScale(e);if(USE_ONLY_CSS_ZOOM){var l=d.clone({scale:CSS_UNITS});p.sx*=l.width/d.width;p.sy*=l.height/d.height;p.scaled=!0}f.width=Math.floor(d.width)*p.sx|0;f.height=Math.floor(d.height)*p.sy|0;f.style.width=Math.floor(d.width)+"px";f.style.height=Math.floor(d.height)+"px";f._viewport=d;d=null;PDFJS.disableTextLayer||(d=document.createElement("div"),
|
|
d.className="textLayer",d.style.width=f.width+"px",d.style.height=f.height+"px",h.appendChild(d));var r=this.textLayer=d?new TextLayerBuilder({textLayerDiv:d,pageIndex:this.id-1,lastScrollSource:PDFView,viewport:this.viewport,isViewerInPresentationMode:PresentationMode.active}):null;e._scaleX=p.sx;e._scaleY=p.sy;p.scaled&&e.scale(p.sx,p.sy);p.scaled&&d&&(CustomStyle.setProp("transform",d,"scale("+1/p.sx+", "+1/p.sy+")"),CustomStyle.setProp("transformOrigin",d,"0% 0%"),d.dataset._scaleX=p.sx,d.dataset._scaleY=
|
|
p.sy);var m=this,v=this.renderTask=this.pdfPage.render({canvasContext:e,viewport:this.viewport,textLayer:r,continueCallback:function(a){PDFView.highestPriorityPage!=="page"+m.id?(m.renderingState=RenderingStates.PAUSED,m.resume=function(){m.renderingState=RenderingStates.RUNNING;a()}):a()}});this.renderTask.promise.then(function(){b(null)},function(a){b(a)});r&&this.getTextContent().then(function(a){r.setTextContent(a)});g(h,c,this.viewport);h.setAttribute("data-loaded",!0)}else f=PDFView.getPage(this.id),
|
|
f.then(function(b){delete this.pagePdfPromise;this.setPdfPage(b);this.draw(a)}.bind(this)),this.pagePdfPromise=f};this.beforePrint=function(){var a=this.pdfPage,b=a.getViewport(1),c=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%");var d=document.getElementById("printContainer"),e=document.createElement("div");
|
|
e.style.width=b.width+"pt";e.style.height=b.height+"pt";e.appendChild(c);d.appendChild(e);var h=this;c.mozPrintCallback=function(d){var e=d.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}).promise.then(function(){d.done();h.pdfPage.destroy()},function(a){console.error(a);"abort"in d?d.abort():d.done();h.pdfPage.destroy()})}};this.updateStats=function(){this.stats&&PDFJS.pdfBug&&Stats.enabled&&Stats.add(this.id,
|
|
this.stats)}},ThumbnailView=function(a,b,c){var d=document.createElement("a");d.href=PDFView.getAnchorUrl("#page="+b);d.title=mozL10n.get("thumb_page_title",{page:b},"Page {{page}}");d.onclick=function(){PDFView.page=b;return!1};this.pdfPage=void 0;this.viewport=c;this.pdfPageRotate=c.rotation;this.rotation=0;this.pageWidth=this.viewport.width;this.pageHeight=this.viewport.height;this.pageRatio=this.pageWidth/this.pageHeight;this.id=b;this.canvasWidth=98;this.canvasHeight=this.canvasWidth/this.pageWidth*
|
|
this.pageHeight;this.scale=this.canvasWidth/this.pageWidth;var e=this.el=document.createElement("div");e.id="thumbnailContainer"+b;e.className="thumbnail";1===b&&e.classList.add("selected");var g=document.createElement("div");g.className="thumbnailSelectionRing";g.style.width=this.canvasWidth+"px";g.style.height=this.canvasHeight+"px";e.appendChild(g);d.appendChild(e);a.appendChild(d);this.hasImage=!1;this.renderingState=RenderingStates.INITIAL;this.setPdfPage=function(a){this.pdfPage=a;this.pdfPageRotate=
|
|
a.rotate;this.viewport=a.getViewport(1,(this.rotation+this.pdfPageRotate)%360);this.update()};this.update=function(a){void 0!==a&&(this.rotation=a);this.viewport=this.viewport.clone({scale:1,rotation:(this.rotation+this.pdfPageRotate)%360});this.pageWidth=this.viewport.width;this.pageHeight=this.viewport.height;this.pageRatio=this.pageWidth/this.pageHeight;this.canvasHeight=this.canvasWidth/this.pageWidth*this.pageHeight;this.scale=this.canvasWidth/this.pageWidth;e.removeAttribute("data-loaded");
|
|
g.textContent="";g.style.width=this.canvasWidth+"px";g.style.height=this.canvasHeight+"px";this.hasImage=!1;this.renderingState=RenderingStates.INITIAL;this.resume=null};this.getPageDrawContext=function(){var a=document.createElement("canvas");a.id="thumbnail"+b;a.width=this.canvasWidth;a.height=this.canvasHeight;a.className="thumbnailImage";a.setAttribute("aria-label",mozL10n.get("thumb_page_canvas",{page:b},"Thumbnail of Page {{page}}"));e.setAttribute("data-loaded",!0);g.appendChild(a);a=a.getContext("2d");
|
|
a.save();a.fillStyle="rgb(255, 255, 255)";a.fillRect(0,0,this.canvasWidth,this.canvasHeight);a.restore();return a};this.drawingRequired=function(){return!this.hasImage};this.draw=function(a){if(this.pdfPage)if(this.renderingState!==RenderingStates.INITIAL&&console.error("Must be in new state before drawing"),this.renderingState=RenderingStates.RUNNING,this.hasImage)a();else{var b=this,c=this.getPageDrawContext(),d=this.viewport.clone({scale:this.scale});this.pdfPage.render({canvasContext:c,viewport:d,
|
|
continueCallback:function(a){PDFView.highestPriorityPage!=="thumbnail"+b.id?(b.renderingState=RenderingStates.PAUSED,b.resume=function(){b.renderingState=RenderingStates.RUNNING;a()}):a()}}).promise.then(function(){b.renderingState=RenderingStates.FINISHED;a()},function(c){b.renderingState=RenderingStates.FINISHED;a()});this.hasImage=!0}else PDFView.getPage(this.id).then(function(b){this.setPdfPage(b);this.draw(a)}.bind(this))};this.setImage=function(a){if(!this.pdfPage)PDFView.getPage(this.id).then(function(b){this.setPdfPage(b);
|
|
this.setImage(a)}.bind(this));else if(!this.hasImage&&a){this.renderingState=RenderingStates.FINISHED;var b=this.getPageDrawContext();b.drawImage(a,0,0,a.width,a.height,0,0,b.canvas.width,b.canvas.height);this.hasImage=!0}}},FIND_SCROLL_OFFSET_TOP=-50,FIND_SCROLL_OFFSET_LEFT=-400,TextLayerBuilder=function(a){var b=document.createDocumentFragment();this.textLayerDiv=a.textLayerDiv;this.divContentDone=this.layoutDone=!1;this.pageIdx=a.pageIndex;this.matches=[];this.lastScrollSource=a.lastScrollSource;
|
|
this.viewport=a.viewport;this.isViewerInPresentationMode=a.isViewerInPresentationMode;"undefined"===typeof PDFFindController&&(window.PDFFindController=null);"undefined"===typeof this.lastScrollSource&&(this.lastScrollSource=null);this.beginLayout=function(){this.textDivs=[];this.renderingDone=!1};this.endLayout=function(){this.layoutDone=!0;this.insertDivContent()};this.renderLayer=function(){var a=this.textDivs,d=this.textLayerDiv,e=document.createElement("canvas").getContext("2d");if(!(1E5<a.length)){for(var g=
|
|
0,h=a.length;g<h;g++){var f=a[g];if(!("isWhitespace"in f.dataset)){e.font=f.style.fontSize+" "+f.style.fontFamily;var k=e.measureText(f.textContent).width;0<k&&(b.appendChild(f),k="scale("+f.dataset.canvasWidth/k+", 1)",k="rotate("+f.dataset.angle+"deg) "+k,CustomStyle.setProp("transform",f,k),CustomStyle.setProp("transformOrigin",f,"0% 0%"))}}d.appendChild(b);this.renderingDone=!0;this.updateMatches()}};this.setupRenderLayoutTimer=function(){var a=this,b=null===this.lastScrollSource?0:this.lastScrollSource.lastScroll;
|
|
200<Date.now()-b?this.renderLayer():(this.renderTimer&&clearTimeout(this.renderTimer),this.renderTimer=setTimeout(function(){a.setupRenderLayoutTimer()},200))};this.appendText=function(a){var b=document.createElement("div"),e=a.fontSize*Math.abs(a.vScale);b.dataset.canvasWidth=a.canvasWidth*Math.abs(a.hScale);b.dataset.fontName=a.fontName;b.dataset.angle=180/Math.PI*a.angle;b.style.fontSize=e+"px";b.style.fontFamily=a.fontFamily;e=a.ascent?a.ascent*e:a.descent?(1+a.descent)*e:e;b.style.left=a.x+e*
|
|
Math.sin(a.angle)+"px";b.style.top=a.y-e*Math.cos(a.angle)+"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,e=0;e<b.length;e++){var g=b[e],h=a[e];/\S/.test(g.str)?(h.textContent=g.str,h.dir=g.dir):h.dataset.isWhitespace=!0}this.setupRenderLayoutTimer()}};this.setTextContent=function(a){this.textContent=a;this.insertDivContent()};this.convertMatches=function(a){for(var b=
|
|
0,e=0,g=this.textContent.bidiTexts,h=g.length-1,f=null===PDFFindController?0:PDFFindController.state.query.length,k=[],s=0;s<a.length;s++){for(var n=a[s];b!==h&&n>=e+g[b].str.length;)e+=g[b].str.length,b++;b==g.length&&console.error("Could not find matching mapping");for(var q={begin:{divIdx:b,offset:n-e}},n=n+f;b!==h&&n>e+g[b].str.length;)e+=g[b].str.length,b++;q.end={divIdx:b,offset:n-e};k.push(q)}return k};this.renderMatches=function(a){function b(a,c){var d=a.divIdx,e=h[d];e.textContent="";var f=
|
|
g[d].str.substring(0,a.offset),f=document.createTextNode(f);if(c){var d=k&&d===s,l=document.createElement("span");l.className=c+(d?" selected":"");l.appendChild(f);e.appendChild(l)}else e.appendChild(f)}function e(a,b,c){var d=a.divIdx,e=h[d];a=g[d].str.substring(a.offset,b.offset);a=document.createTextNode(a);c?(b=document.createElement("span"),b.className=c,b.appendChild(a),e.appendChild(b)):e.appendChild(a)}if(0!==a.length){var g=this.textContent.bidiTexts,h=this.textDivs,f=null,k=null===PDFFindController?
|
|
!1:this.pageIdx===PDFFindController.selected.pageIdx,s=null===PDFFindController?-1:PDFFindController.selected.matchIdx,n={divIdx:-1,offset:void 0},q=s,t=q+1;if(null===PDFFindController?0:PDFFindController.state.highlightAll)q=0,t=a.length;else if(!k)return;for(;q<t;q++){var u=a[q],p=u.begin,u=u.end,l=k&&q===s,r=l?" selected":"";l&&!this.isViewerInPresentationMode&&scrollIntoView(h[p.divIdx],{top:FIND_SCROLL_OFFSET_TOP,left:FIND_SCROLL_OFFSET_LEFT});f&&p.divIdx===f.divIdx?e(f,p):(null!==f&&e(f,n),
|
|
b(p));if(p.divIdx===u.divIdx)e(p,u,"highlight"+r);else{e(p,n,"highlight begin"+r);for(f=p.divIdx+1;f<u.divIdx;f++)h[f].className="highlight middle"+r;b(u,"highlight end"+r)}f=u}f&&e(f,n)}};this.updateMatches=function(){if(this.renderingDone){for(var a=this.matches,b=this.textDivs,e=this.textContent.bidiTexts,g=-1,h=0;h<a.length;h++){for(var f=a[h],g=Math.max(g,f.begin.divIdx);g<=f.end.divIdx;g++){var k=b[g];k.textContent=e[g].str;k.className=""}g=f.end.divIdx+1}null!==PDFFindController&&PDFFindController.active&&
|
|
(this.matches=this.convertMatches(null===PDFFindController?[]:PDFFindController.pageMatches[this.pageIdx]||[]),this.renderMatches(this.matches))}}},DocumentOutlineView=function(a){function b(a,b){a.href=PDFView.getDestinationHash(b.dest);a.onclick=function(a){PDFView.navigateTo(b.dest);return!1}}var c=document.getElementById("outlineView");for(document.getElementById("viewOutline");c.firstChild;)c.removeChild(c.firstChild);if(a)for(a=[{parent:c,items:a}];0<a.length;){var c=a.shift(),d,e=c.items.length;
|
|
for(d=0;d<e;d++){var g=c.items[d],h=document.createElement("div");h.className="outlineItem";var f=document.createElement("a");b(f,g);f.textContent=g.title;h.appendChild(f);0<g.items.length&&(f=document.createElement("div"),f.className="outlineItems",h.appendChild(f),a.push({parent:f,items:g.items}));c.parent.appendChild(h)}}else c.classList.contains("hidden")||PDFView.switchSidebarView("thumbs")};
|
|
document.addEventListener("DOMContentLoaded",function(a){PDFView.initialize();a=PDFView.parseQueryString(document.location.search.substring(1)).file||DEFAULT_URL;var b=document.createElement("input");b.id="fileInput";b.className="fileInput";b.setAttribute("type","file");b.oncontextmenu=noContextMenuHandler;document.body.appendChild(b);window.File&&window.FileReader&&window.FileList&&window.Blob&&(document.getElementById("fileInput").value=null);b=document.location.hash.substring(1);b=PDFView.parseQueryString(b);
|
|
"disableWorker"in b&&(PDFJS.disableWorker="true"===b.disableWorker);"disableRange"in b&&(PDFJS.disableRange="true"===b.disableRange);"disableAutoFetch"in b&&(PDFJS.disableAutoFetch="true"===b.disableAutoFetch);"disableFontFace"in b&&(PDFJS.disableFontFace="true"===b.disableFontFace);"disableHistory"in b&&(PDFJS.disableHistory="true"===b.disableHistory);"useOnlyCssZoom"in b&&(USE_ONLY_CSS_ZOOM="true"===b.useOnlyCssZoom);"verbosity"in b&&(PDFJS.verbosity=b.verbosity|0);"ignoreCurrentPositionOnZoom"in
|
|
b&&(IGNORE_CURRENT_POSITION_ON_ZOOM="true"===b.ignoreCurrentPositionOnZoom);var c=navigator.language;"locale"in b&&(c=b.locale);mozL10n.setLanguage(c);if("textLayer"in 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"),
|
|
document.getElementById("secondaryPrint").classList.add("hidden"));PDFView.supportsFullscreen||(document.getElementById("presentationMode").classList.add("hidden"),document.getElementById("secondaryPresentationMode").classList.add("hidden"));PDFView.supportsIntegratedFind&&document.getElementById("viewFind").classList.add("hidden");PDFJS.UnsupportedManager.listen(PDFView.fallback.bind(PDFView));document.getElementById("scaleSelect").oncontextmenu=noContextMenuHandler;var d=document.getElementById("mainContainer"),
|
|
e=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),e.classList.remove("sidebarMoving"))},!0);document.getElementById("sidebarToggle").addEventListener("click",function(){this.classList.toggle("toggled");e.classList.add("sidebarMoving");e.classList.toggle("sidebarOpen");PDFView.sidebarOpen=e.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++});document.getElementById("zoomIn").addEventListener("click",function(){PDFView.zoomIn()});document.getElementById("zoomOut").addEventListener("click",
|
|
function(){PDFView.zoomOut()});document.getElementById("pageNumber").addEventListener("click",function(){this.select()});document.getElementById("pageNumber").addEventListener("change",function(){PDFView.page=this.value|0;this.value!==(this.value|0).toString()&&(this.value=PDFView.page)});document.getElementById("scaleSelect").addEventListener("change",function(){PDFView.setScale(this.value)});document.getElementById("presentationMode").addEventListener("click",SecondaryToolbar.presentationModeClick.bind(SecondaryToolbar));
|
|
document.getElementById("print").addEventListener("click",SecondaryToolbar.printClick.bind(SecondaryToolbar));PDFView.open(a,0)},!0);
|
|
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,e=b.length,g=!1;d<e;++d){var h=b[d];if(100>h.percent)break;if(h.id===PDFView.page){g=!0;break}}g||(c=b[0].id);updateViewarea.inProgress=!0;PDFView.page=c;updateViewarea.inProgress=!1;var b=PDFView.currentScale,c=PDFView.currentScaleValue,f=parseFloat(c)===b?Math.round(1E4*b)/100:c,k=a.id,b="#page="+k+("&zoom="+f),c=PDFView.container,
|
|
a=PDFView.pages[k-1].getPagePoint(c.scrollLeft-a.x,c.scrollTop-a.y),s=Math.round(a[0]),n=Math.round(a[1]),b=b+(","+s+","+n);PDFView.currentPosition=PresentationMode.active||PresentationMode.switchInProgress?null:{page:k,left:s,top:n};var q=PDFView.store;q.initializedPromise.then(function(){q.set("exists",!0);q.set("page",k);q.set("zoom",f);q.set("scrollLeft",s);q.set("scrollTop",n)});a=PDFView.getAnchorUrl(b);document.getElementById("viewBookmark").href=a;document.getElementById("secondaryViewBookmark").href=
|
|
a;PDFHistory.updateCurrentBookmark(b,k)}}}window.addEventListener("resize",function(a){PDFView.initialized&&(document.getElementById("pageWidthOption").selected||document.getElementById("pageFitOption").selected||document.getElementById("pageAutoOption").selected)&&PDFView.setScale(document.getElementById("scaleSelect").value);updateViewarea();SecondaryToolbar.setMaxHeight(PDFView.container)});window.addEventListener("hashchange",function(a){PDFHistory.isHashChangeUnlocked&&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),document.getElementById("viewBookmark").setAttribute("hidden","true"),document.getElementById("secondaryViewBookmark").setAttribute("hidden","true"),document.getElementById("download").setAttribute("hidden","true"),document.getElementById("secondaryDownload").setAttribute("hidden",
|
|
"true"))},!0);function selectScaleOption(a){for(var b=document.getElementById("scaleSelect").options,c=!1,d=0;d<b.length;d++){var e=b[d];e.value!=a?e.selected=!1:c=e.selected=!0}return c}
|
|
window.addEventListener("localized",function(a){document.getElementsByTagName("html")[0].dir=mozL10n.getDirection();PDFView.animationStartedPromise.then(function(){var a=document.getElementById("scaleSelectContainer");if(0<a.clientWidth){var c=document.getElementById("scaleSelect");c.setAttribute("style","min-width: inherit;");var d=c.clientWidth+SCALE_SELECT_CONTAINER_PADDING;c.setAttribute("style","min-width: "+(d+SCALE_SELECT_PADDING)+"px;");a.setAttribute("style","min-width: "+d+"px; max-width: "+
|
|
d+"px;")}SecondaryToolbar.setMaxHeight(PDFView.container)})},!0);
|
|
window.addEventListener("scalechange",function(a){document.getElementById("zoomOut").disabled=a.scale===MIN_SCALE;document.getElementById("zoomIn").disabled=a.scale===MAX_SCALE;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 e=c.first.id,c=1<d?c.last.id:e;(a<=e||a>=c)&&scrollIntoView(b,{top:THUMBNAIL_SCROLL_MARGIN})}}document.getElementById("previous").disabled=1>=
|
|
a;document.getElementById("next").disabled=a>=PDFView.pages.length},!0);window.addEventListener("DOMMouseScroll",function(a){a.ctrlKey?(a.preventDefault(),a=a.detail,PDFView[0<a?"zoomOut":"zoomIn"](Math.abs(a))):PresentationMode.active&&PDFView.mouseScroll(-40*a.detail)},!1);window.addEventListener("click",function(a){PresentationMode.active?0===a.button&&a.preventDefault():SecondaryToolbar.opened&&PDFView.container.contains(a.target)&&SecondaryToolbar.close()},!1);
|
|
window.addEventListener("keydown",function(a){if(!PasswordPrompt.visible){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||5===c||12===c)switch(a.keyCode){case 70:PDFView.supportsIntegratedFind||(PDFFindBar.open(),b=!0);break;case 71:PDFView.supportsIntegratedFind||(PDFFindBar.dispatchEvent("again",5===c||12===c),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:setTimeout(function(){PDFView.setScale(DEFAULT_SCALE,
|
|
!0)}),b=!1}if(3===c||10===c)switch(a.keyCode){case 80:SecondaryToolbar.presentationModeClick();b=!0;break;case 71:document.getElementById("pageNumber").select(),b=!0}if(b)a.preventDefault();else{var d=document.activeElement||document.querySelector(":focus");if(!d||"INPUT"!==d.tagName.toUpperCase()&&"TEXTAREA"!==d.tagName.toUpperCase()&&"SELECT"!==d.tagName.toUpperCase()||27===a.keyCode){for(var e=document.getElementById("toolbar");d;){if(d===e&&!PresentationMode.active)return;d=d.parentNode}if(0===
|
|
c)switch(a.keyCode){case 38:case 33:case 8:if(!PresentationMode.active&&"page-fit"!==PDFView.currentScaleValue)break;case 37:if(PDFView.isHorizontalScrollbarEnabled)break;case 75:case 80:PDFView.page--;b=!0;break;case 27:SecondaryToolbar.opened&&(SecondaryToolbar.close(),b=!0);!PDFView.supportsIntegratedFind&&PDFFindBar.opened&&(PDFFindBar.close(),b=!0);break;case 40:case 34:case 32:if(!PresentationMode.active&&"page-fit"!==PDFView.currentScaleValue)break;case 39:if(PDFView.isHorizontalScrollbarEnabled)break;
|
|
case 74:case 78:PDFView.page++;b=!0;break;case 36:PresentationMode.active&&(PDFView.page=1,b=!0);break;case 35:PresentationMode.active&&(PDFView.page=PDFView.pdfDocument.numPages,b=!0);break;case 72:PresentationMode.active||HandTool.toggle();break;case 82:PDFView.rotatePages(90)}if(4===c)switch(a.keyCode){case 32:if(!PresentationMode.active&&"page-fit"!==PDFView.currentScaleValue)break;PDFView.page--;b=!0;break;case 82:PDFView.rotatePages(-90)}if(2===c)switch(a.keyCode){case 37:PresentationMode.active&&
|
|
(PDFHistory.back(),b=!0);break;case 39:PresentationMode.active&&(PDFHistory.forward(),b=!0)}b&&(a.preventDefault(),PDFView.clearMouseScrollState())}}}});window.addEventListener("beforeprint",function(a){PDFView.beforePrint()});window.addEventListener("afterprint",function(a){PDFView.afterPrint()});
|
|
(function(){var a=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){a()};PDFView.animationStartedPromise=new Promise(function(b){a(function(){b()})})})();
|