| 1 |
/** |
| 2 |
* @licstart The following is the entire license notice for the |
| 3 |
* Javascript code in this page |
| 4 |
* |
| 5 |
* Copyright 2018 Mozilla Foundation |
| 6 |
* |
| 7 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 |
* you may not use this file except in compliance with the License. |
| 9 |
* You may obtain a copy of the License at |
| 10 |
* |
| 11 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 12 |
* |
| 13 |
* Unless required by applicable law or agreed to in writing, software |
| 14 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 15 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 |
* See the License for the specific language governing permissions and |
| 17 |
* limitations under the License. |
| 18 |
* |
| 19 |
* @licend The above is the entire license notice for the |
| 20 |
* Javascript code in this page |
| 21 |
*/ |
| 22 |
|
| 23 |
/******/ (function(modules) { // webpackBootstrap |
| 24 |
/******/ // The module cache |
| 25 |
/******/ var installedModules = {}; |
| 26 |
/******/ |
| 27 |
/******/ // The require function |
| 28 |
/******/ function __webpack_require__(moduleId) { |
| 29 |
/******/ |
| 30 |
/******/ // Check if module is in cache |
| 31 |
/******/ if(installedModules[moduleId]) { |
| 32 |
/******/ return installedModules[moduleId].exports; |
| 33 |
/******/ } |
| 34 |
/******/ // Create a new module (and put it into the cache) |
| 35 |
/******/ var module = installedModules[moduleId] = { |
| 36 |
/******/ i: moduleId, |
| 37 |
/******/ l: false, |
| 38 |
/******/ exports: {} |
| 39 |
/******/ }; |
| 40 |
/******/ |
| 41 |
/******/ // Execute the module function |
| 42 |
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
| 43 |
/******/ |
| 44 |
/******/ // Flag the module as loaded |
| 45 |
/******/ module.l = true; |
| 46 |
/******/ |
| 47 |
/******/ // Return the exports of the module |
| 48 |
/******/ return module.exports; |
| 49 |
/******/ } |
| 50 |
/******/ |
| 51 |
/******/ |
| 52 |
/******/ // expose the modules object (__webpack_modules__) |
| 53 |
/******/ __webpack_require__.m = modules; |
| 54 |
/******/ |
| 55 |
/******/ // expose the module cache |
| 56 |
/******/ __webpack_require__.c = installedModules; |
| 57 |
/******/ |
| 58 |
/******/ // define getter function for harmony exports |
| 59 |
/******/ __webpack_require__.d = function(exports, name, getter) { |
| 60 |
/******/ if(!__webpack_require__.o(exports, name)) { |
| 61 |
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); |
| 62 |
/******/ } |
| 63 |
/******/ }; |
| 64 |
/******/ |
| 65 |
/******/ // define __esModule on exports |
| 66 |
/******/ __webpack_require__.r = function(exports) { |
| 67 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
| 68 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
| 69 |
/******/ } |
| 70 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
| 71 |
/******/ }; |
| 72 |
/******/ |
| 73 |
/******/ // create a fake namespace object |
| 74 |
/******/ // mode & 1: value is a module id, require it |
| 75 |
/******/ // mode & 2: merge all properties of value into the ns |
| 76 |
/******/ // mode & 4: return value when already ns object |
| 77 |
/******/ // mode & 8|1: behave like require |
| 78 |
/******/ __webpack_require__.t = function(value, mode) { |
| 79 |
/******/ if(mode & 1) value = __webpack_require__(value); |
| 80 |
/******/ if(mode & 8) return value; |
| 81 |
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; |
| 82 |
/******/ var ns = Object.create(null); |
| 83 |
/******/ __webpack_require__.r(ns); |
| 84 |
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); |
| 85 |
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); |
| 86 |
/******/ return ns; |
| 87 |
/******/ }; |
| 88 |
/******/ |
| 89 |
/******/ // getDefaultExport function for compatibility with non-harmony modules |
| 90 |
/******/ __webpack_require__.n = function(module) { |
| 91 |
/******/ var getter = module && module.__esModule ? |
| 92 |
/******/ function getDefault() { return module['default']; } : |
| 93 |
/******/ function getModuleExports() { return module; }; |
| 94 |
/******/ __webpack_require__.d(getter, 'a', getter); |
| 95 |
/******/ return getter; |
| 96 |
/******/ }; |
| 97 |
/******/ |
| 98 |
/******/ // Object.prototype.hasOwnProperty.call |
| 99 |
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; |
| 100 |
/******/ |
| 101 |
/******/ // __webpack_public_path__ |
| 102 |
/******/ __webpack_require__.p = ""; |
| 103 |
/******/ |
| 104 |
/******/ |
| 105 |
/******/ // Load entry module and return exports |
| 106 |
/******/ return __webpack_require__(__webpack_require__.s = 0); |
| 107 |
/******/ }) |
| 108 |
/************************************************************************/ |
| 109 |
/******/ ([ |
| 110 |
/* 0 */ |
| 111 |
/***/ (function(module, exports, __webpack_require__) { |
| 112 |
|
| 113 |
"use strict"; |
| 114 |
|
| 115 |
|
| 116 |
; |
| 117 |
var pdfjsWebApp = void 0, |
| 118 |
pdfjsWebAppOptions = void 0; |
| 119 |
{ |
| 120 |
pdfjsWebApp = __webpack_require__(1); |
| 121 |
pdfjsWebAppOptions = __webpack_require__(12); |
| 122 |
} |
| 123 |
; |
| 124 |
{ |
| 125 |
__webpack_require__(38); |
| 126 |
} |
| 127 |
; |
| 128 |
{ |
| 129 |
__webpack_require__(43); |
| 130 |
} |
| 131 |
function getViewerConfiguration() { |
| 132 |
return { |
| 133 |
appContainer: document.body, |
| 134 |
mainContainer: document.getElementById('viewerContainer'), |
| 135 |
viewerContainer: document.getElementById('viewer'), |
| 136 |
eventBus: null, |
| 137 |
toolbar: { |
| 138 |
container: document.getElementById('toolbarViewer'), |
| 139 |
numPages: document.getElementById('numPages'), |
| 140 |
pageNumber: document.getElementById('pageNumber'), |
| 141 |
scaleSelectContainer: document.getElementById('scaleSelectContainer'), |
| 142 |
scaleSelect: document.getElementById('scaleSelect'), |
| 143 |
customScaleOption: document.getElementById('customScaleOption'), |
| 144 |
previous: document.getElementById('previous'), |
| 145 |
next: document.getElementById('next'), |
| 146 |
zoomIn: document.getElementById('zoomIn'), |
| 147 |
zoomOut: document.getElementById('zoomOut'), |
| 148 |
viewFind: document.getElementById('viewFind'), |
| 149 |
openFile: document.getElementById('openFile'), |
| 150 |
print: document.getElementById('print'), |
| 151 |
presentationModeButton: document.getElementById('presentationMode'), |
| 152 |
download: document.getElementById('download'), |
| 153 |
viewBookmark: document.getElementById('viewBookmark') |
| 154 |
}, |
| 155 |
secondaryToolbar: { |
| 156 |
toolbar: document.getElementById('secondaryToolbar'), |
| 157 |
toggleButton: document.getElementById('secondaryToolbarToggle'), |
| 158 |
toolbarButtonContainer: document.getElementById('secondaryToolbarButtonContainer'), |
| 159 |
presentationModeButton: document.getElementById('secondaryPresentationMode'), |
| 160 |
openFileButton: document.getElementById('secondaryOpenFile'), |
| 161 |
printButton: document.getElementById('secondaryPrint'), |
| 162 |
downloadButton: document.getElementById('secondaryDownload'), |
| 163 |
viewBookmarkButton: document.getElementById('secondaryViewBookmark'), |
| 164 |
firstPageButton: document.getElementById('firstPage'), |
| 165 |
lastPageButton: document.getElementById('lastPage'), |
| 166 |
pageRotateCwButton: document.getElementById('pageRotateCw'), |
| 167 |
pageRotateCcwButton: document.getElementById('pageRotateCcw'), |
| 168 |
cursorSelectToolButton: document.getElementById('cursorSelectTool'), |
| 169 |
cursorHandToolButton: document.getElementById('cursorHandTool'), |
| 170 |
scrollVerticalButton: document.getElementById('scrollVertical'), |
| 171 |
scrollHorizontalButton: document.getElementById('scrollHorizontal'), |
| 172 |
scrollWrappedButton: document.getElementById('scrollWrapped'), |
| 173 |
spreadNoneButton: document.getElementById('spreadNone'), |
| 174 |
spreadOddButton: document.getElementById('spreadOdd'), |
| 175 |
spreadEvenButton: document.getElementById('spreadEven'), |
| 176 |
documentPropertiesButton: document.getElementById('documentProperties') |
| 177 |
}, |
| 178 |
fullscreen: { |
| 179 |
contextFirstPage: document.getElementById('contextFirstPage'), |
| 180 |
contextLastPage: document.getElementById('contextLastPage'), |
| 181 |
contextPageRotateCw: document.getElementById('contextPageRotateCw'), |
| 182 |
contextPageRotateCcw: document.getElementById('contextPageRotateCcw') |
| 183 |
}, |
| 184 |
sidebar: { |
| 185 |
outerContainer: document.getElementById('outerContainer'), |
| 186 |
viewerContainer: document.getElementById('viewerContainer'), |
| 187 |
toggleButton: document.getElementById('sidebarToggle'), |
| 188 |
thumbnailButton: document.getElementById('viewThumbnail'), |
| 189 |
outlineButton: document.getElementById('viewOutline'), |
| 190 |
attachmentsButton: document.getElementById('viewAttachments'), |
| 191 |
thumbnailView: document.getElementById('thumbnailView'), |
| 192 |
outlineView: document.getElementById('outlineView'), |
| 193 |
attachmentsView: document.getElementById('attachmentsView') |
| 194 |
}, |
| 195 |
sidebarResizer: { |
| 196 |
outerContainer: document.getElementById('outerContainer'), |
| 197 |
resizer: document.getElementById('sidebarResizer') |
| 198 |
}, |
| 199 |
findBar: { |
| 200 |
bar: document.getElementById('findbar'), |
| 201 |
toggleButton: document.getElementById('viewFind'), |
| 202 |
findField: document.getElementById('findInput'), |
| 203 |
highlightAllCheckbox: document.getElementById('findHighlightAll'), |
| 204 |
caseSensitiveCheckbox: document.getElementById('findMatchCase'), |
| 205 |
entireWordCheckbox: document.getElementById('findEntireWord'), |
| 206 |
findMsg: document.getElementById('findMsg'), |
| 207 |
findResultsCount: document.getElementById('findResultsCount'), |
| 208 |
findPreviousButton: document.getElementById('findPrevious'), |
| 209 |
findNextButton: document.getElementById('findNext') |
| 210 |
}, |
| 211 |
passwordOverlay: { |
| 212 |
overlayName: 'passwordOverlay', |
| 213 |
container: document.getElementById('passwordOverlay'), |
| 214 |
label: document.getElementById('passwordText'), |
| 215 |
input: document.getElementById('password'), |
| 216 |
submitButton: document.getElementById('passwordSubmit'), |
| 217 |
cancelButton: document.getElementById('passwordCancel') |
| 218 |
}, |
| 219 |
documentProperties: { |
| 220 |
overlayName: 'documentPropertiesOverlay', |
| 221 |
container: document.getElementById('documentPropertiesOverlay'), |
| 222 |
closeButton: document.getElementById('documentPropertiesClose'), |
| 223 |
fields: { |
| 224 |
'fileName': document.getElementById('fileNameField'), |
| 225 |
'fileSize': document.getElementById('fileSizeField'), |
| 226 |
'title': document.getElementById('titleField'), |
| 227 |
'author': document.getElementById('authorField'), |
| 228 |
'subject': document.getElementById('subjectField'), |
| 229 |
'keywords': document.getElementById('keywordsField'), |
| 230 |
'creationDate': document.getElementById('creationDateField'), |
| 231 |
'modificationDate': document.getElementById('modificationDateField'), |
| 232 |
'creator': document.getElementById('creatorField'), |
| 233 |
'producer': document.getElementById('producerField'), |
| 234 |
'version': document.getElementById('versionField'), |
| 235 |
'pageCount': document.getElementById('pageCountField'), |
| 236 |
'pageSize': document.getElementById('pageSizeField'), |
| 237 |
'linearized': document.getElementById('linearizedField') |
| 238 |
} |
| 239 |
}, |
| 240 |
errorWrapper: { |
| 241 |
container: document.getElementById('errorWrapper'), |
| 242 |
errorMessage: document.getElementById('errorMessage'), |
| 243 |
closeButton: document.getElementById('errorClose'), |
| 244 |
errorMoreInfo: document.getElementById('errorMoreInfo'), |
| 245 |
moreInfoButton: document.getElementById('errorShowMore'), |
| 246 |
lessInfoButton: document.getElementById('errorShowLess') |
| 247 |
}, |
| 248 |
printContainer: document.getElementById('printContainer'), |
| 249 |
openFileInputName: 'fileInput', |
| 250 |
debuggerScriptPath: './debugger.js' |
| 251 |
}; |
| 252 |
} |
| 253 |
function webViewerLoad() { |
| 254 |
var config = getViewerConfiguration(); |
| 255 |
window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication; |
| 256 |
window.PDFViewerApplicationOptions = pdfjsWebAppOptions.AppOptions; |
| 257 |
pdfjsWebApp.PDFViewerApplication.run(config); |
| 258 |
} |
| 259 |
if (document.readyState === 'interactive' || document.readyState === 'complete') { |
| 260 |
webViewerLoad(); |
| 261 |
} else { |
| 262 |
document.addEventListener('DOMContentLoaded', webViewerLoad, true); |
| 263 |
} |
| 264 |
|
| 265 |
/***/ }), |
| 266 |
/* 1 */ |
| 267 |
/***/ (function(module, exports, __webpack_require__) { |
| 268 |
|
| 269 |
"use strict"; |
| 270 |
|
| 271 |
|
| 272 |
Object.defineProperty(exports, "__esModule", { |
| 273 |
value: true |
| 274 |
}); |
| 275 |
exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = undefined; |
| 276 |
|
| 277 |
var _regenerator = __webpack_require__(2); |
| 278 |
|
| 279 |
var _regenerator2 = _interopRequireDefault(_regenerator); |
| 280 |
|
| 281 |
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); |
| 282 |
|
| 283 |
var _ui_utils = __webpack_require__(6); |
| 284 |
|
| 285 |
var _pdfjsLib = __webpack_require__(7); |
| 286 |
|
| 287 |
var _pdf_cursor_tools = __webpack_require__(8); |
| 288 |
|
| 289 |
var _pdf_rendering_queue = __webpack_require__(10); |
| 290 |
|
| 291 |
var _pdf_sidebar = __webpack_require__(11); |
| 292 |
|
| 293 |
var _app_options = __webpack_require__(12); |
| 294 |
|
| 295 |
var _dom_events = __webpack_require__(14); |
| 296 |
|
| 297 |
var _overlay_manager = __webpack_require__(15); |
| 298 |
|
| 299 |
var _password_prompt = __webpack_require__(16); |
| 300 |
|
| 301 |
var _pdf_attachment_viewer = __webpack_require__(17); |
| 302 |
|
| 303 |
var _pdf_document_properties = __webpack_require__(18); |
| 304 |
|
| 305 |
var _pdf_find_bar = __webpack_require__(19); |
| 306 |
|
| 307 |
var _pdf_find_controller = __webpack_require__(20); |
| 308 |
|
| 309 |
var _pdf_history = __webpack_require__(22); |
| 310 |
|
| 311 |
var _pdf_link_service = __webpack_require__(23); |
| 312 |
|
| 313 |
var _pdf_outline_viewer = __webpack_require__(24); |
| 314 |
|
| 315 |
var _pdf_presentation_mode = __webpack_require__(25); |
| 316 |
|
| 317 |
var _pdf_sidebar_resizer = __webpack_require__(26); |
| 318 |
|
| 319 |
var _pdf_thumbnail_viewer = __webpack_require__(27); |
| 320 |
|
| 321 |
var _pdf_viewer = __webpack_require__(29); |
| 322 |
|
| 323 |
var _secondary_toolbar = __webpack_require__(34); |
| 324 |
|
| 325 |
var _toolbar = __webpack_require__(36); |
| 326 |
|
| 327 |
var _view_history = __webpack_require__(37); |
| 328 |
|
| 329 |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
| 330 |
|
| 331 |
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } |
| 332 |
|
| 333 |
var DEFAULT_SCALE_DELTA = 1.1; |
| 334 |
var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000; |
| 335 |
var FORCE_PAGES_LOADED_TIMEOUT = 10000; |
| 336 |
var DefaultExternalServices = { |
| 337 |
updateFindControlState: function updateFindControlState(data) {}, |
| 338 |
updateFindMatchesCount: function updateFindMatchesCount(data) {}, |
| 339 |
initPassiveLoading: function initPassiveLoading(callbacks) {}, |
| 340 |
fallback: function fallback(data, callback) {}, |
| 341 |
reportTelemetry: function reportTelemetry(data) {}, |
| 342 |
createDownloadManager: function createDownloadManager(options) { |
| 343 |
throw new Error('Not implemented: createDownloadManager'); |
| 344 |
}, |
| 345 |
createPreferences: function createPreferences() { |
| 346 |
throw new Error('Not implemented: createPreferences'); |
| 347 |
}, |
| 348 |
createL10n: function createL10n(options) { |
| 349 |
throw new Error('Not implemented: createL10n'); |
| 350 |
}, |
| 351 |
|
| 352 |
supportsIntegratedFind: false, |
| 353 |
supportsDocumentFonts: true, |
| 354 |
supportsDocumentColors: true, |
| 355 |
supportedMouseWheelZoomModifierKeys: { |
| 356 |
ctrlKey: true, |
| 357 |
metaKey: true |
| 358 |
} |
| 359 |
}; |
| 360 |
var PDFViewerApplication = { |
| 361 |
initialBookmark: document.location.hash.substring(1), |
| 362 |
initialized: false, |
| 363 |
fellback: false, |
| 364 |
appConfig: null, |
| 365 |
pdfDocument: null, |
| 366 |
pdfLoadingTask: null, |
| 367 |
printService: null, |
| 368 |
pdfViewer: null, |
| 369 |
pdfThumbnailViewer: null, |
| 370 |
pdfRenderingQueue: null, |
| 371 |
pdfPresentationMode: null, |
| 372 |
pdfDocumentProperties: null, |
| 373 |
pdfLinkService: null, |
| 374 |
pdfHistory: null, |
| 375 |
pdfSidebar: null, |
| 376 |
pdfSidebarResizer: null, |
| 377 |
pdfOutlineViewer: null, |
| 378 |
pdfAttachmentViewer: null, |
| 379 |
pdfCursorTools: null, |
| 380 |
store: null, |
| 381 |
downloadManager: null, |
| 382 |
overlayManager: null, |
| 383 |
preferences: null, |
| 384 |
toolbar: null, |
| 385 |
secondaryToolbar: null, |
| 386 |
eventBus: null, |
| 387 |
l10n: null, |
| 388 |
isInitialViewSet: false, |
| 389 |
downloadComplete: false, |
| 390 |
isViewerEmbedded: window.parent !== window, |
| 391 |
url: '', |
| 392 |
baseUrl: '', |
| 393 |
externalServices: DefaultExternalServices, |
| 394 |
_boundEvents: {}, |
| 395 |
contentDispositionFilename: null, |
| 396 |
initialize: function () { |
| 397 |
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(appConfig) { |
| 398 |
var _this = this; |
| 399 |
|
| 400 |
var appContainer; |
| 401 |
return _regenerator2.default.wrap(function _callee$(_context) { |
| 402 |
while (1) { |
| 403 |
switch (_context.prev = _context.next) { |
| 404 |
case 0: |
| 405 |
this.preferences = this.externalServices.createPreferences(); |
| 406 |
this.appConfig = appConfig; |
| 407 |
_context.next = 4; |
| 408 |
return this._readPreferences(); |
| 409 |
|
| 410 |
case 4: |
| 411 |
_context.next = 6; |
| 412 |
return this._parseHashParameters(); |
| 413 |
|
| 414 |
case 6: |
| 415 |
_context.next = 8; |
| 416 |
return this._initializeL10n(); |
| 417 |
|
| 418 |
case 8: |
| 419 |
if (this.isViewerEmbedded && _app_options.AppOptions.get('externalLinkTarget') === _pdfjsLib.LinkTarget.NONE) { |
| 420 |
_app_options.AppOptions.set('externalLinkTarget', _pdfjsLib.LinkTarget.TOP); |
| 421 |
} |
| 422 |
_context.next = 11; |
| 423 |
return this._initializeViewerComponents(); |
| 424 |
|
| 425 |
case 11: |
| 426 |
this.bindEvents(); |
| 427 |
this.bindWindowEvents(); |
| 428 |
appContainer = appConfig.appContainer || document.documentElement; |
| 429 |
|
| 430 |
this.l10n.translate(appContainer).then(function () { |
| 431 |
_this.eventBus.dispatch('localized', { source: _this }); |
| 432 |
}); |
| 433 |
this.initialized = true; |
| 434 |
|
| 435 |
case 16: |
| 436 |
case 'end': |
| 437 |
return _context.stop(); |
| 438 |
} |
| 439 |
} |
| 440 |
}, _callee, this); |
| 441 |
})); |
| 442 |
|
| 443 |
function initialize(_x) { |
| 444 |
return _ref.apply(this, arguments); |
| 445 |
} |
| 446 |
|
| 447 |
return initialize; |
| 448 |
}(), |
| 449 |
_readPreferences: function () { |
| 450 |
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() { |
| 451 |
var OVERRIDES, prefs, name; |
| 452 |
return _regenerator2.default.wrap(function _callee2$(_context2) { |
| 453 |
while (1) { |
| 454 |
switch (_context2.prev = _context2.next) { |
| 455 |
case 0: |
| 456 |
OVERRIDES = { |
| 457 |
disableFontFace: true, |
| 458 |
disableRange: true, |
| 459 |
disableStream: true, |
| 460 |
textLayerMode: _ui_utils.TextLayerMode.DISABLE |
| 461 |
}; |
| 462 |
_context2.prev = 1; |
| 463 |
_context2.next = 4; |
| 464 |
return this.preferences.getAll(); |
| 465 |
|
| 466 |
case 4: |
| 467 |
prefs = _context2.sent; |
| 468 |
_context2.t0 = _regenerator2.default.keys(prefs); |
| 469 |
|
| 470 |
case 6: |
| 471 |
if ((_context2.t1 = _context2.t0()).done) { |
| 472 |
_context2.next = 13; |
| 473 |
break; |
| 474 |
} |
| 475 |
|
| 476 |
name = _context2.t1.value; |
| 477 |
|
| 478 |
if (!(name in OVERRIDES && _app_options.AppOptions.get(name) === OVERRIDES[name])) { |
| 479 |
_context2.next = 10; |
| 480 |
break; |
| 481 |
} |
| 482 |
|
| 483 |
return _context2.abrupt('continue', 6); |
| 484 |
|
| 485 |
case 10: |
| 486 |
_app_options.AppOptions.set(name, prefs[name]); |
| 487 |
_context2.next = 6; |
| 488 |
break; |
| 489 |
|
| 490 |
case 13: |
| 491 |
_context2.next = 17; |
| 492 |
break; |
| 493 |
|
| 494 |
case 15: |
| 495 |
_context2.prev = 15; |
| 496 |
_context2.t2 = _context2['catch'](1); |
| 497 |
|
| 498 |
case 17: |
| 499 |
case 'end': |
| 500 |
return _context2.stop(); |
| 501 |
} |
| 502 |
} |
| 503 |
}, _callee2, this, [[1, 15]]); |
| 504 |
})); |
| 505 |
|
| 506 |
function _readPreferences() { |
| 507 |
return _ref2.apply(this, arguments); |
| 508 |
} |
| 509 |
|
| 510 |
return _readPreferences; |
| 511 |
}(), |
| 512 |
_parseHashParameters: function () { |
| 513 |
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3() { |
| 514 |
var waitOn, hash, hashParams, viewer, enabled; |
| 515 |
return _regenerator2.default.wrap(function _callee3$(_context3) { |
| 516 |
while (1) { |
| 517 |
switch (_context3.prev = _context3.next) { |
| 518 |
case 0: |
| 519 |
if (_app_options.AppOptions.get('pdfBugEnabled')) { |
| 520 |
_context3.next = 2; |
| 521 |
break; |
| 522 |
} |
| 523 |
|
| 524 |
return _context3.abrupt('return'); |
| 525 |
|
| 526 |
case 2: |
| 527 |
waitOn = []; |
| 528 |
hash = document.location.hash.substring(1); |
| 529 |
hashParams = (0, _ui_utils.parseQueryString)(hash); |
| 530 |
|
| 531 |
if ('disableworker' in hashParams && hashParams['disableworker'] === 'true') { |
| 532 |
waitOn.push(loadFakeWorker()); |
| 533 |
} |
| 534 |
if ('disablerange' in hashParams) { |
| 535 |
_app_options.AppOptions.set('disableRange', hashParams['disablerange'] === 'true'); |
| 536 |
} |
| 537 |
if ('disablestream' in hashParams) { |
| 538 |
_app_options.AppOptions.set('disableStream', hashParams['disablestream'] === 'true'); |
| 539 |
} |
| 540 |
if ('disableautofetch' in hashParams) { |
| 541 |
_app_options.AppOptions.set('disableAutoFetch', hashParams['disableautofetch'] === 'true'); |
| 542 |
} |
| 543 |
if ('disablefontface' in hashParams) { |
| 544 |
_app_options.AppOptions.set('disableFontFace', hashParams['disablefontface'] === 'true'); |
| 545 |
} |
| 546 |
if ('disablehistory' in hashParams) { |
| 547 |
_app_options.AppOptions.set('disableHistory', hashParams['disablehistory'] === 'true'); |
| 548 |
} |
| 549 |
if ('webgl' in hashParams) { |
| 550 |
_app_options.AppOptions.set('enableWebGL', hashParams['webgl'] === 'true'); |
| 551 |
} |
| 552 |
if ('useonlycsszoom' in hashParams) { |
| 553 |
_app_options.AppOptions.set('useOnlyCssZoom', hashParams['useonlycsszoom'] === 'true'); |
| 554 |
} |
| 555 |
if ('verbosity' in hashParams) { |
| 556 |
_app_options.AppOptions.set('verbosity', hashParams['verbosity'] | 0); |
| 557 |
} |
| 558 |
|
| 559 |
if (!('textlayer' in hashParams)) { |
| 560 |
_context3.next = 23; |
| 561 |
break; |
| 562 |
} |
| 563 |
|
| 564 |
_context3.t0 = hashParams['textlayer']; |
| 565 |
_context3.next = _context3.t0 === 'off' ? 18 : _context3.t0 === 'visible' ? 20 : _context3.t0 === 'shadow' ? 20 : _context3.t0 === 'hover' ? 20 : 23; |
| 566 |
break; |
| 567 |
|
| 568 |
case 18: |
| 569 |
_app_options.AppOptions.set('textLayerMode', _ui_utils.TextLayerMode.DISABLE); |
| 570 |
return _context3.abrupt('break', 23); |
| 571 |
|
| 572 |
case 20: |
| 573 |
viewer = this.appConfig.viewerContainer; |
| 574 |
|
| 575 |
viewer.classList.add('textLayer-' + hashParams['textlayer']); |
| 576 |
return _context3.abrupt('break', 23); |
| 577 |
|
| 578 |
case 23: |
| 579 |
if ('pdfbug' in hashParams) { |
| 580 |
_app_options.AppOptions.set('pdfBug', true); |
| 581 |
enabled = hashParams['pdfbug'].split(','); |
| 582 |
|
| 583 |
waitOn.push(loadAndEnablePDFBug(enabled)); |
| 584 |
} |
| 585 |
if ('locale' in hashParams) { |
| 586 |
_app_options.AppOptions.set('locale', hashParams['locale']); |
| 587 |
} |
| 588 |
return _context3.abrupt('return', Promise.all(waitOn).catch(function (reason) { |
| 589 |
console.error('_parseHashParameters: "' + reason.message + '".'); |
| 590 |
})); |
| 591 |
|
| 592 |
case 26: |
| 593 |
case 'end': |
| 594 |
return _context3.stop(); |
| 595 |
} |
| 596 |
} |
| 597 |
}, _callee3, this); |
| 598 |
})); |
| 599 |
|
| 600 |
function _parseHashParameters() { |
| 601 |
return _ref3.apply(this, arguments); |
| 602 |
} |
| 603 |
|
| 604 |
return _parseHashParameters; |
| 605 |
}(), |
| 606 |
_initializeL10n: function () { |
| 607 |
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4() { |
| 608 |
var dir; |
| 609 |
return _regenerator2.default.wrap(function _callee4$(_context4) { |
| 610 |
while (1) { |
| 611 |
switch (_context4.prev = _context4.next) { |
| 612 |
case 0: |
| 613 |
this.l10n = this.externalServices.createL10n({ locale: _app_options.AppOptions.get('locale') }); |
| 614 |
_context4.next = 3; |
| 615 |
return this.l10n.getDirection(); |
| 616 |
|
| 617 |
case 3: |
| 618 |
dir = _context4.sent; |
| 619 |
|
| 620 |
document.getElementsByTagName('html')[0].dir = dir; |
| 621 |
|
| 622 |
case 5: |
| 623 |
case 'end': |
| 624 |
return _context4.stop(); |
| 625 |
} |
| 626 |
} |
| 627 |
}, _callee4, this); |
| 628 |
})); |
| 629 |
|
| 630 |
function _initializeL10n() { |
| 631 |
return _ref4.apply(this, arguments); |
| 632 |
} |
| 633 |
|
| 634 |
return _initializeL10n; |
| 635 |
}(), |
| 636 |
_initializeViewerComponents: function () { |
| 637 |
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee5() { |
| 638 |
var appConfig, dispatchToDOM, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer, thumbnailContainer, sidebarConfig; |
| 639 |
return _regenerator2.default.wrap(function _callee5$(_context5) { |
| 640 |
while (1) { |
| 641 |
switch (_context5.prev = _context5.next) { |
| 642 |
case 0: |
| 643 |
appConfig = this.appConfig; |
| 644 |
|
| 645 |
this.overlayManager = new _overlay_manager.OverlayManager(); |
| 646 |
dispatchToDOM = _app_options.AppOptions.get('eventBusDispatchToDOM'); |
| 647 |
eventBus = appConfig.eventBus || (0, _dom_events.getGlobalEventBus)(dispatchToDOM); |
| 648 |
|
| 649 |
this.eventBus = eventBus; |
| 650 |
pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue(); |
| 651 |
|
| 652 |
pdfRenderingQueue.onIdle = this.cleanup.bind(this); |
| 653 |
this.pdfRenderingQueue = pdfRenderingQueue; |
| 654 |
pdfLinkService = new _pdf_link_service.PDFLinkService({ |
| 655 |
eventBus: eventBus, |
| 656 |
externalLinkTarget: _app_options.AppOptions.get('externalLinkTarget'), |
| 657 |
externalLinkRel: _app_options.AppOptions.get('externalLinkRel') |
| 658 |
}); |
| 659 |
|
| 660 |
this.pdfLinkService = pdfLinkService; |
| 661 |
downloadManager = this.externalServices.createDownloadManager({ disableCreateObjectURL: _app_options.AppOptions.get('disableCreateObjectURL') }); |
| 662 |
|
| 663 |
this.downloadManager = downloadManager; |
| 664 |
findController = new _pdf_find_controller.PDFFindController({ |
| 665 |
linkService: pdfLinkService, |
| 666 |
eventBus: eventBus |
| 667 |
}); |
| 668 |
|
| 669 |
this.findController = findController; |
| 670 |
container = appConfig.mainContainer; |
| 671 |
viewer = appConfig.viewerContainer; |
| 672 |
|
| 673 |
this.pdfViewer = new _pdf_viewer.PDFViewer({ |
| 674 |
container: container, |
| 675 |
viewer: viewer, |
| 676 |
eventBus: eventBus, |
| 677 |
renderingQueue: pdfRenderingQueue, |
| 678 |
linkService: pdfLinkService, |
| 679 |
downloadManager: downloadManager, |
| 680 |
findController: findController, |
| 681 |
renderer: _app_options.AppOptions.get('renderer'), |
| 682 |
enableWebGL: _app_options.AppOptions.get('enableWebGL'), |
| 683 |
l10n: this.l10n, |
| 684 |
textLayerMode: _app_options.AppOptions.get('textLayerMode'), |
| 685 |
imageResourcesPath: _app_options.AppOptions.get('imageResourcesPath'), |
| 686 |
renderInteractiveForms: _app_options.AppOptions.get('renderInteractiveForms'), |
| 687 |
enablePrintAutoRotate: _app_options.AppOptions.get('enablePrintAutoRotate'), |
| 688 |
useOnlyCssZoom: _app_options.AppOptions.get('useOnlyCssZoom'), |
| 689 |
maxCanvasPixels: _app_options.AppOptions.get('maxCanvasPixels') |
| 690 |
}); |
| 691 |
pdfRenderingQueue.setViewer(this.pdfViewer); |
| 692 |
pdfLinkService.setViewer(this.pdfViewer); |
| 693 |
thumbnailContainer = appConfig.sidebar.thumbnailView; |
| 694 |
|
| 695 |
this.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({ |
| 696 |
container: thumbnailContainer, |
| 697 |
renderingQueue: pdfRenderingQueue, |
| 698 |
linkService: pdfLinkService, |
| 699 |
l10n: this.l10n |
| 700 |
}); |
| 701 |
pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer); |
| 702 |
this.pdfHistory = new _pdf_history.PDFHistory({ |
| 703 |
linkService: pdfLinkService, |
| 704 |
eventBus: eventBus |
| 705 |
}); |
| 706 |
pdfLinkService.setHistory(this.pdfHistory); |
| 707 |
this.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, this.l10n); |
| 708 |
this.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, this.l10n); |
| 709 |
this.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({ |
| 710 |
container: container, |
| 711 |
eventBus: eventBus, |
| 712 |
cursorToolOnLoad: _app_options.AppOptions.get('cursorToolOnLoad') |
| 713 |
}); |
| 714 |
this.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, this.l10n); |
| 715 |
this.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus); |
| 716 |
if (this.supportsFullscreen) { |
| 717 |
this.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({ |
| 718 |
container: container, |
| 719 |
viewer: viewer, |
| 720 |
pdfViewer: this.pdfViewer, |
| 721 |
eventBus: eventBus, |
| 722 |
contextMenuItems: appConfig.fullscreen |
| 723 |
}); |
| 724 |
} |
| 725 |
this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.l10n); |
| 726 |
this.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({ |
| 727 |
container: appConfig.sidebar.outlineView, |
| 728 |
eventBus: eventBus, |
| 729 |
linkService: pdfLinkService |
| 730 |
}); |
| 731 |
this.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({ |
| 732 |
container: appConfig.sidebar.attachmentsView, |
| 733 |
eventBus: eventBus, |
| 734 |
downloadManager: downloadManager |
| 735 |
}); |
| 736 |
sidebarConfig = Object.create(appConfig.sidebar); |
| 737 |
|
| 738 |
sidebarConfig.pdfViewer = this.pdfViewer; |
| 739 |
sidebarConfig.pdfThumbnailViewer = this.pdfThumbnailViewer; |
| 740 |
this.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig, eventBus, this.l10n); |
| 741 |
this.pdfSidebar.onToggled = this.forceRendering.bind(this); |
| 742 |
this.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, this.l10n); |
| 743 |
|
| 744 |
case 39: |
| 745 |
case 'end': |
| 746 |
return _context5.stop(); |
| 747 |
} |
| 748 |
} |
| 749 |
}, _callee5, this); |
| 750 |
})); |
| 751 |
|
| 752 |
function _initializeViewerComponents() { |
| 753 |
return _ref5.apply(this, arguments); |
| 754 |
} |
| 755 |
|
| 756 |
return _initializeViewerComponents; |
| 757 |
}(), |
| 758 |
run: function run(config) { |
| 759 |
this.initialize(config).then(webViewerInitialized); |
| 760 |
}, |
| 761 |
zoomIn: function zoomIn(ticks) { |
| 762 |
var newScale = this.pdfViewer.currentScale; |
| 763 |
do { |
| 764 |
newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2); |
| 765 |
newScale = Math.ceil(newScale * 10) / 10; |
| 766 |
newScale = Math.min(_ui_utils.MAX_SCALE, newScale); |
| 767 |
} while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE); |
| 768 |
this.pdfViewer.currentScaleValue = newScale; |
| 769 |
}, |
| 770 |
zoomOut: function zoomOut(ticks) { |
| 771 |
var newScale = this.pdfViewer.currentScale; |
| 772 |
do { |
| 773 |
newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2); |
| 774 |
newScale = Math.floor(newScale * 10) / 10; |
| 775 |
newScale = Math.max(_ui_utils.MIN_SCALE, newScale); |
| 776 |
} while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE); |
| 777 |
this.pdfViewer.currentScaleValue = newScale; |
| 778 |
}, |
| 779 |
|
| 780 |
get pagesCount() { |
| 781 |
return this.pdfDocument ? this.pdfDocument.numPages : 0; |
| 782 |
}, |
| 783 |
set page(val) { |
| 784 |
this.pdfViewer.currentPageNumber = val; |
| 785 |
}, |
| 786 |
get page() { |
| 787 |
return this.pdfViewer.currentPageNumber; |
| 788 |
}, |
| 789 |
get printing() { |
| 790 |
return !!this.printService; |
| 791 |
}, |
| 792 |
get supportsPrinting() { |
| 793 |
return PDFPrintServiceFactory.instance.supportsPrinting; |
| 794 |
}, |
| 795 |
get supportsFullscreen() { |
| 796 |
var support = void 0; |
| 797 |
var doc = document.documentElement; |
| 798 |
support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen); |
| 799 |
if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) { |
| 800 |
support = false; |
| 801 |
} |
| 802 |
return (0, _pdfjsLib.shadow)(this, 'supportsFullscreen', support); |
| 803 |
}, |
| 804 |
get supportsIntegratedFind() { |
| 805 |
return this.externalServices.supportsIntegratedFind; |
| 806 |
}, |
| 807 |
get supportsDocumentFonts() { |
| 808 |
return this.externalServices.supportsDocumentFonts; |
| 809 |
}, |
| 810 |
get supportsDocumentColors() { |
| 811 |
return this.externalServices.supportsDocumentColors; |
| 812 |
}, |
| 813 |
get loadingBar() { |
| 814 |
var bar = new _ui_utils.ProgressBar('#loadingBar'); |
| 815 |
return (0, _pdfjsLib.shadow)(this, 'loadingBar', bar); |
| 816 |
}, |
| 817 |
get supportedMouseWheelZoomModifierKeys() { |
| 818 |
return this.externalServices.supportedMouseWheelZoomModifierKeys; |
| 819 |
}, |
| 820 |
initPassiveLoading: function initPassiveLoading() { |
| 821 |
throw new Error('Not implemented: initPassiveLoading'); |
| 822 |
}, |
| 823 |
setTitleUsingUrl: function setTitleUsingUrl() { |
| 824 |
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; |
| 825 |
|
| 826 |
this.url = url; |
| 827 |
this.baseUrl = url.split('#')[0]; |
| 828 |
var title = (0, _ui_utils.getPDFFileNameFromURL)(url, ''); |
| 829 |
if (!title) { |
| 830 |
try { |
| 831 |
title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url; |
| 832 |
} catch (ex) { |
| 833 |
title = url; |
| 834 |
} |
| 835 |
} |
| 836 |
this.setTitle(title); |
| 837 |
}, |
| 838 |
setTitle: function setTitle(title) { |
| 839 |
if (this.isViewerEmbedded) { |
| 840 |
return; |
| 841 |
} |
| 842 |
document.title = title; |
| 843 |
}, |
| 844 |
close: function () { |
| 845 |
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee6() { |
| 846 |
var errorWrapper, promise; |
| 847 |
return _regenerator2.default.wrap(function _callee6$(_context6) { |
| 848 |
while (1) { |
| 849 |
switch (_context6.prev = _context6.next) { |
| 850 |
case 0: |
| 851 |
errorWrapper = this.appConfig.errorWrapper.container; |
| 852 |
|
| 853 |
errorWrapper.setAttribute('hidden', 'true'); |
| 854 |
|
| 855 |
if (this.pdfLoadingTask) { |
| 856 |
_context6.next = 4; |
| 857 |
break; |
| 858 |
} |
| 859 |
|
| 860 |
return _context6.abrupt('return'); |
| 861 |
|
| 862 |
case 4: |
| 863 |
promise = this.pdfLoadingTask.destroy(); |
| 864 |
|
| 865 |
this.pdfLoadingTask = null; |
| 866 |
if (this.pdfDocument) { |
| 867 |
this.pdfDocument = null; |
| 868 |
this.pdfThumbnailViewer.setDocument(null); |
| 869 |
this.pdfViewer.setDocument(null); |
| 870 |
this.pdfLinkService.setDocument(null); |
| 871 |
this.pdfDocumentProperties.setDocument(null); |
| 872 |
} |
| 873 |
this.store = null; |
| 874 |
this.isInitialViewSet = false; |
| 875 |
this.downloadComplete = false; |
| 876 |
this.url = ''; |
| 877 |
this.baseUrl = ''; |
| 878 |
this.contentDispositionFilename = null; |
| 879 |
this.pdfSidebar.reset(); |
| 880 |
this.pdfOutlineViewer.reset(); |
| 881 |
this.pdfAttachmentViewer.reset(); |
| 882 |
this.findBar.reset(); |
| 883 |
this.toolbar.reset(); |
| 884 |
this.secondaryToolbar.reset(); |
| 885 |
if (typeof PDFBug !== 'undefined') { |
| 886 |
PDFBug.cleanup(); |
| 887 |
} |
| 888 |
return _context6.abrupt('return', promise); |
| 889 |
|
| 890 |
case 21: |
| 891 |
case 'end': |
| 892 |
return _context6.stop(); |
| 893 |
} |
| 894 |
} |
| 895 |
}, _callee6, this); |
| 896 |
})); |
| 897 |
|
| 898 |
function close() { |
| 899 |
return _ref6.apply(this, arguments); |
| 900 |
} |
| 901 |
|
| 902 |
return close; |
| 903 |
}(), |
| 904 |
open: function () { |
| 905 |
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee7(file, args) { |
| 906 |
var _this2 = this; |
| 907 |
|
| 908 |
var workerParameters, key, parameters, apiParameters, _key, prop, loadingTask; |
| 909 |
|
| 910 |
return _regenerator2.default.wrap(function _callee7$(_context7) { |
| 911 |
while (1) { |
| 912 |
switch (_context7.prev = _context7.next) { |
| 913 |
case 0: |
| 914 |
if (!this.pdfLoadingTask) { |
| 915 |
_context7.next = 3; |
| 916 |
break; |
| 917 |
} |
| 918 |
|
| 919 |
_context7.next = 3; |
| 920 |
return this.close(); |
| 921 |
|
| 922 |
case 3: |
| 923 |
workerParameters = _app_options.AppOptions.getAll('worker'); |
| 924 |
|
| 925 |
for (key in workerParameters) { |
| 926 |
_pdfjsLib.GlobalWorkerOptions[key] = workerParameters[key]; |
| 927 |
} |
| 928 |
parameters = Object.create(null); |
| 929 |
|
| 930 |
if (typeof file === 'string') { |
| 931 |
this.setTitleUsingUrl(file); |
| 932 |
parameters.url = file; |
| 933 |
} else if (file && 'byteLength' in file) { |
| 934 |
parameters.data = file; |
| 935 |
} else if (file.url && file.originalUrl) { |
| 936 |
this.setTitleUsingUrl(file.originalUrl); |
| 937 |
parameters.url = file.url; |
| 938 |
} |
| 939 |
apiParameters = _app_options.AppOptions.getAll('api'); |
| 940 |
|
| 941 |
for (_key in apiParameters) { |
| 942 |
parameters[_key] = apiParameters[_key]; |
| 943 |
} |
| 944 |
if (args) { |
| 945 |
for (prop in args) { |
| 946 |
if (prop === 'length') { |
| 947 |
this.pdfDocumentProperties.setFileSize(args[prop]); |
| 948 |
} |
| 949 |
parameters[prop] = args[prop]; |
| 950 |
} |
| 951 |
} |
| 952 |
loadingTask = (0, _pdfjsLib.getDocument)(parameters); |
| 953 |
|
| 954 |
this.pdfLoadingTask = loadingTask; |
| 955 |
loadingTask.onPassword = function (updateCallback, reason) { |
| 956 |
_this2.passwordPrompt.setUpdateCallback(updateCallback, reason); |
| 957 |
_this2.passwordPrompt.open(); |
| 958 |
}; |
| 959 |
loadingTask.onProgress = function (_ref8) { |
| 960 |
var loaded = _ref8.loaded, |
| 961 |
total = _ref8.total; |
| 962 |
|
| 963 |
_this2.progress(loaded / total); |
| 964 |
}; |
| 965 |
loadingTask.onUnsupportedFeature = this.fallback.bind(this); |
| 966 |
return _context7.abrupt('return', loadingTask.promise.then(function (pdfDocument) { |
| 967 |
_this2.load(pdfDocument); |
| 968 |
}, function (exception) { |
| 969 |
if (loadingTask !== _this2.pdfLoadingTask) { |
| 970 |
return; |
| 971 |
} |
| 972 |
var message = exception && exception.message; |
| 973 |
var loadingErrorMessage = void 0; |
| 974 |
if (exception instanceof _pdfjsLib.InvalidPDFException) { |
| 975 |
loadingErrorMessage = _this2.l10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.'); |
| 976 |
} else if (exception instanceof _pdfjsLib.MissingPDFException) { |
| 977 |
loadingErrorMessage = _this2.l10n.get('missing_file_error', null, 'Missing PDF file.'); |
| 978 |
} else if (exception instanceof _pdfjsLib.UnexpectedResponseException) { |
| 979 |
loadingErrorMessage = _this2.l10n.get('unexpected_response_error', null, 'Unexpected server response.'); |
| 980 |
} else { |
| 981 |
loadingErrorMessage = _this2.l10n.get('loading_error', null, 'An error occurred while loading the PDF.'); |
| 982 |
} |
| 983 |
return loadingErrorMessage.then(function (msg) { |
| 984 |
_this2.error(msg, { message: message }); |
| 985 |
throw new Error(msg); |
| 986 |
}); |
| 987 |
})); |
| 988 |
|
| 989 |
case 16: |
| 990 |
case 'end': |
| 991 |
return _context7.stop(); |
| 992 |
} |
| 993 |
} |
| 994 |
}, _callee7, this); |
| 995 |
})); |
| 996 |
|
| 997 |
function open(_x3, _x4) { |
| 998 |
return _ref7.apply(this, arguments); |
| 999 |
} |
| 1000 |
|
| 1001 |
return open; |
| 1002 |
}(), |
| 1003 |
download: function download() { |
| 1004 |
var _this3 = this; |
| 1005 |
|
| 1006 |
function downloadByUrl() { |
| 1007 |
downloadManager.downloadUrl(url, filename); |
| 1008 |
} |
| 1009 |
var url = this.baseUrl; |
| 1010 |
var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url); |
| 1011 |
var downloadManager = this.downloadManager; |
| 1012 |
downloadManager.onerror = function (err) { |
| 1013 |
_this3.error('PDF failed to download: ' + err); |
| 1014 |
}; |
| 1015 |
if (!this.pdfDocument || !this.downloadComplete) { |
| 1016 |
downloadByUrl(); |
| 1017 |
return; |
| 1018 |
} |
| 1019 |
this.pdfDocument.getData().then(function (data) { |
| 1020 |
var blob = new Blob([data], { type: 'application/pdf' }); |
| 1021 |
downloadManager.download(blob, url, filename); |
| 1022 |
}).catch(downloadByUrl); |
| 1023 |
}, |
| 1024 |
fallback: function fallback(featureId) {}, |
| 1025 |
error: function error(message, moreInfo) { |
| 1026 |
var moreInfoText = [this.l10n.get('error_version_info', { |
| 1027 |
version: _pdfjsLib.version || '?', |
| 1028 |
build: _pdfjsLib.build || '?' |
| 1029 |
}, 'PDF.js v{{version}} (build: {{build}})')]; |
| 1030 |
if (moreInfo) { |
| 1031 |
moreInfoText.push(this.l10n.get('error_message', { message: moreInfo.message }, 'Message: {{message}}')); |
| 1032 |
if (moreInfo.stack) { |
| 1033 |
moreInfoText.push(this.l10n.get('error_stack', { stack: moreInfo.stack }, 'Stack: {{stack}}')); |
| 1034 |
} else { |
| 1035 |
if (moreInfo.filename) { |
| 1036 |
moreInfoText.push(this.l10n.get('error_file', { file: moreInfo.filename }, 'File: {{file}}')); |
| 1037 |
} |
| 1038 |
if (moreInfo.lineNumber) { |
| 1039 |
moreInfoText.push(this.l10n.get('error_line', { line: moreInfo.lineNumber }, 'Line: {{line}}')); |
| 1040 |
} |
| 1041 |
} |
| 1042 |
} |
| 1043 |
var errorWrapperConfig = this.appConfig.errorWrapper; |
| 1044 |
var errorWrapper = errorWrapperConfig.container; |
| 1045 |
errorWrapper.removeAttribute('hidden'); |
| 1046 |
var errorMessage = errorWrapperConfig.errorMessage; |
| 1047 |
errorMessage.textContent = message; |
| 1048 |
var closeButton = errorWrapperConfig.closeButton; |
| 1049 |
closeButton.onclick = function () { |
| 1050 |
errorWrapper.setAttribute('hidden', 'true'); |
| 1051 |
}; |
| 1052 |
var errorMoreInfo = errorWrapperConfig.errorMoreInfo; |
| 1053 |
var moreInfoButton = errorWrapperConfig.moreInfoButton; |
| 1054 |
var lessInfoButton = errorWrapperConfig.lessInfoButton; |
| 1055 |
moreInfoButton.onclick = function () { |
| 1056 |
errorMoreInfo.removeAttribute('hidden'); |
| 1057 |
moreInfoButton.setAttribute('hidden', 'true'); |
| 1058 |
lessInfoButton.removeAttribute('hidden'); |
| 1059 |
errorMoreInfo.style.height = errorMoreInfo.scrollHeight + 'px'; |
| 1060 |
}; |
| 1061 |
lessInfoButton.onclick = function () { |
| 1062 |
errorMoreInfo.setAttribute('hidden', 'true'); |
| 1063 |
moreInfoButton.removeAttribute('hidden'); |
| 1064 |
lessInfoButton.setAttribute('hidden', 'true'); |
| 1065 |
}; |
| 1066 |
moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler; |
| 1067 |
lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler; |
| 1068 |
closeButton.oncontextmenu = _ui_utils.noContextMenuHandler; |
| 1069 |
moreInfoButton.removeAttribute('hidden'); |
| 1070 |
lessInfoButton.setAttribute('hidden', 'true'); |
| 1071 |
Promise.all(moreInfoText).then(function (parts) { |
| 1072 |
errorMoreInfo.value = parts.join('\n'); |
| 1073 |
}); |
| 1074 |
}, |
| 1075 |
progress: function progress(level) { |
| 1076 |
var _this4 = this; |
| 1077 |
|
| 1078 |
if (this.downloadComplete) { |
| 1079 |
return; |
| 1080 |
} |
| 1081 |
var percent = Math.round(level * 100); |
| 1082 |
if (percent > this.loadingBar.percent || isNaN(percent)) { |
| 1083 |
this.loadingBar.percent = percent; |
| 1084 |
var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams['disableAutoFetch'] : _app_options.AppOptions.get('disableAutoFetch'); |
| 1085 |
if (disableAutoFetch && percent) { |
| 1086 |
if (this.disableAutoFetchLoadingBarTimeout) { |
| 1087 |
clearTimeout(this.disableAutoFetchLoadingBarTimeout); |
| 1088 |
this.disableAutoFetchLoadingBarTimeout = null; |
| 1089 |
} |
| 1090 |
this.loadingBar.show(); |
| 1091 |
this.disableAutoFetchLoadingBarTimeout = setTimeout(function () { |
| 1092 |
_this4.loadingBar.hide(); |
| 1093 |
_this4.disableAutoFetchLoadingBarTimeout = null; |
| 1094 |
}, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT); |
| 1095 |
} |
| 1096 |
} |
| 1097 |
}, |
| 1098 |
load: function load(pdfDocument) { |
| 1099 |
var _this5 = this; |
| 1100 |
|
| 1101 |
this.pdfDocument = pdfDocument; |
| 1102 |
pdfDocument.getDownloadInfo().then(function () { |
| 1103 |
_this5.downloadComplete = true; |
| 1104 |
_this5.loadingBar.hide(); |
| 1105 |
firstPagePromise.then(function () { |
| 1106 |
_this5.eventBus.dispatch('documentloaded', { source: _this5 }); |
| 1107 |
_this5.eventBus.dispatch('documentload', { source: _this5 }); |
| 1108 |
}); |
| 1109 |
}); |
| 1110 |
var pageModePromise = pdfDocument.getPageMode().catch(function () {}); |
| 1111 |
this.toolbar.setPagesCount(pdfDocument.numPages, false); |
| 1112 |
this.secondaryToolbar.setPagesCount(pdfDocument.numPages); |
| 1113 |
var store = this.store = new _view_history.ViewHistory(pdfDocument.fingerprint); |
| 1114 |
var baseDocumentUrl = void 0; |
| 1115 |
baseDocumentUrl = null; |
| 1116 |
this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl); |
| 1117 |
this.pdfDocumentProperties.setDocument(pdfDocument, this.url); |
| 1118 |
var pdfViewer = this.pdfViewer; |
| 1119 |
pdfViewer.setDocument(pdfDocument); |
| 1120 |
var firstPagePromise = pdfViewer.firstPagePromise; |
| 1121 |
var pagesPromise = pdfViewer.pagesPromise; |
| 1122 |
var onePageRendered = pdfViewer.onePageRendered; |
| 1123 |
var pdfThumbnailViewer = this.pdfThumbnailViewer; |
| 1124 |
pdfThumbnailViewer.setDocument(pdfDocument); |
| 1125 |
firstPagePromise.then(function (pdfPage) { |
| 1126 |
_this5.loadingBar.setWidth(_this5.appConfig.viewerContainer); |
| 1127 |
if (!_app_options.AppOptions.get('disableHistory') && !_this5.isViewerEmbedded) { |
| 1128 |
var resetHistory = !_app_options.AppOptions.get('showPreviousViewOnLoad'); |
| 1129 |
_this5.pdfHistory.initialize(pdfDocument.fingerprint, resetHistory); |
| 1130 |
if (_this5.pdfHistory.initialBookmark) { |
| 1131 |
_this5.initialBookmark = _this5.pdfHistory.initialBookmark; |
| 1132 |
_this5.initialRotation = _this5.pdfHistory.initialRotation; |
| 1133 |
} |
| 1134 |
} |
| 1135 |
var storePromise = store.getMultiple({ |
| 1136 |
page: null, |
| 1137 |
zoom: _ui_utils.DEFAULT_SCALE_VALUE, |
| 1138 |
scrollLeft: '0', |
| 1139 |
scrollTop: '0', |
| 1140 |
rotation: null, |
| 1141 |
sidebarView: _pdf_sidebar.SidebarView.NONE, |
| 1142 |
scrollMode: null, |
| 1143 |
spreadMode: null |
| 1144 |
}).catch(function () {}); |
| 1145 |
Promise.all([storePromise, pageModePromise]).then(function () { |
| 1146 |
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee8(_ref9) { |
| 1147 |
var _ref11 = _slicedToArray(_ref9, 2), |
| 1148 |
_ref11$ = _ref11[0], |
| 1149 |
values = _ref11$ === undefined ? {} : _ref11$, |
| 1150 |
pageMode = _ref11[1]; |
| 1151 |
|
| 1152 |
var initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode; |
| 1153 |
return _regenerator2.default.wrap(function _callee8$(_context8) { |
| 1154 |
while (1) { |
| 1155 |
switch (_context8.prev = _context8.next) { |
| 1156 |
case 0: |
| 1157 |
initialBookmark = _this5.initialBookmark; |
| 1158 |
zoom = _app_options.AppOptions.get('defaultZoomValue'); |
| 1159 |
hash = zoom ? 'zoom=' + zoom : null; |
| 1160 |
rotation = null; |
| 1161 |
sidebarView = _app_options.AppOptions.get('sidebarViewOnLoad'); |
| 1162 |
scrollMode = _app_options.AppOptions.get('scrollModeOnLoad'); |
| 1163 |
spreadMode = _app_options.AppOptions.get('spreadModeOnLoad'); |
| 1164 |
|
| 1165 |
if (values.page && _app_options.AppOptions.get('showPreviousViewOnLoad')) { |
| 1166 |
hash = 'page=' + values.page + '&zoom=' + (zoom || values.zoom) + ',' + values.scrollLeft + ',' + values.scrollTop; |
| 1167 |
rotation = parseInt(values.rotation, 10); |
| 1168 |
sidebarView = sidebarView || values.sidebarView | 0; |
| 1169 |
scrollMode = scrollMode || values.scrollMode | 0; |
| 1170 |
spreadMode = spreadMode || values.spreadMode | 0; |
| 1171 |
} |
| 1172 |
if (pageMode && !_app_options.AppOptions.get('disablePageMode')) { |
| 1173 |
sidebarView = sidebarView || apiPageModeToSidebarView(pageMode); |
| 1174 |
} |
| 1175 |
_this5.setInitialView(hash, { |
| 1176 |
rotation: rotation, |
| 1177 |
sidebarView: sidebarView, |
| 1178 |
scrollMode: scrollMode, |
| 1179 |
spreadMode: spreadMode |
| 1180 |
}); |
| 1181 |
_this5.eventBus.dispatch('documentinit', { source: _this5 }); |
| 1182 |
if (!_this5.isViewerEmbedded) { |
| 1183 |
pdfViewer.focus(); |
| 1184 |
} |
| 1185 |
_context8.next = 14; |
| 1186 |
return Promise.race([pagesPromise, new Promise(function (resolve) { |
| 1187 |
setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT); |
| 1188 |
})]); |
| 1189 |
|
| 1190 |
case 14: |
| 1191 |
if (!(!initialBookmark && !hash)) { |
| 1192 |
_context8.next = 16; |
| 1193 |
break; |
| 1194 |
} |
| 1195 |
|
| 1196 |
return _context8.abrupt('return'); |
| 1197 |
|
| 1198 |
case 16: |
| 1199 |
if (!pdfViewer.hasEqualPageSizes) { |
| 1200 |
_context8.next = 18; |
| 1201 |
break; |
| 1202 |
} |
| 1203 |
|
| 1204 |
return _context8.abrupt('return'); |
| 1205 |
|
| 1206 |
case 18: |
| 1207 |
_this5.initialBookmark = initialBookmark; |
| 1208 |
pdfViewer.currentScaleValue = pdfViewer.currentScaleValue; |
| 1209 |
_this5.setInitialView(hash); |
| 1210 |
|
| 1211 |
case 21: |
| 1212 |
case 'end': |
| 1213 |
return _context8.stop(); |
| 1214 |
} |
| 1215 |
} |
| 1216 |
}, _callee8, _this5); |
| 1217 |
})); |
| 1218 |
|
| 1219 |
return function (_x5) { |
| 1220 |
return _ref10.apply(this, arguments); |
| 1221 |
}; |
| 1222 |
}()).then(function () { |
| 1223 |
pdfViewer.update(); |
| 1224 |
}); |
| 1225 |
}); |
| 1226 |
pdfDocument.getPageLabels().then(function (labels) { |
| 1227 |
if (!labels || _app_options.AppOptions.get('disablePageLabels')) { |
| 1228 |
return; |
| 1229 |
} |
| 1230 |
var i = 0, |
| 1231 |
numLabels = labels.length; |
| 1232 |
if (numLabels !== _this5.pagesCount) { |
| 1233 |
console.error('The number of Page Labels does not match ' + 'the number of pages in the document.'); |
| 1234 |
return; |
| 1235 |
} |
| 1236 |
while (i < numLabels && labels[i] === (i + 1).toString()) { |
| 1237 |
i++; |
| 1238 |
} |
| 1239 |
if (i === numLabels) { |
| 1240 |
return; |
| 1241 |
} |
| 1242 |
pdfViewer.setPageLabels(labels); |
| 1243 |
pdfThumbnailViewer.setPageLabels(labels); |
| 1244 |
_this5.toolbar.setPagesCount(pdfDocument.numPages, true); |
| 1245 |
_this5.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel); |
| 1246 |
}); |
| 1247 |
pagesPromise.then(function () { |
| 1248 |
if (!_this5.supportsPrinting) { |
| 1249 |
return; |
| 1250 |
} |
| 1251 |
pdfDocument.getJavaScript().then(function (javaScript) { |
| 1252 |
if (!javaScript) { |
| 1253 |
return; |
| 1254 |
} |
| 1255 |
javaScript.some(function (js) { |
| 1256 |
if (!js) { |
| 1257 |
return false; |
| 1258 |
} |
| 1259 |
console.warn('Warning: JavaScript is not supported'); |
| 1260 |
_this5.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript); |
| 1261 |
return true; |
| 1262 |
}); |
| 1263 |
var regex = /\bprint\s*\(/; |
| 1264 |
for (var i = 0, ii = javaScript.length; i < ii; i++) { |
| 1265 |
var js = javaScript[i]; |
| 1266 |
if (js && regex.test(js)) { |
| 1267 |
setTimeout(function () { |
| 1268 |
window.print(); |
| 1269 |
}); |
| 1270 |
return; |
| 1271 |
} |
| 1272 |
} |
| 1273 |
}); |
| 1274 |
}); |
| 1275 |
Promise.all([onePageRendered, _ui_utils.animationStarted]).then(function () { |
| 1276 |
pdfDocument.getOutline().then(function (outline) { |
| 1277 |
_this5.pdfOutlineViewer.render({ outline: outline }); |
| 1278 |
}); |
| 1279 |
pdfDocument.getAttachments().then(function (attachments) { |
| 1280 |
_this5.pdfAttachmentViewer.render({ attachments: attachments }); |
| 1281 |
}); |
| 1282 |
}); |
| 1283 |
pdfDocument.getMetadata().then(function (_ref12) { |
| 1284 |
var info = _ref12.info, |
| 1285 |
metadata = _ref12.metadata, |
| 1286 |
contentDispositionFilename = _ref12.contentDispositionFilename; |
| 1287 |
|
| 1288 |
_this5.documentInfo = info; |
| 1289 |
_this5.metadata = metadata; |
| 1290 |
_this5.contentDispositionFilename = contentDispositionFilename; |
| 1291 |
console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdfjsLib.version || '-') + (_app_options.AppOptions.get('enableWebGL') ? ' [WebGL]' : '') + ')'); |
| 1292 |
var pdfTitle = void 0; |
| 1293 |
if (metadata && metadata.has('dc:title')) { |
| 1294 |
var title = metadata.get('dc:title'); |
| 1295 |
if (title !== 'Untitled') { |
| 1296 |
pdfTitle = title; |
| 1297 |
} |
| 1298 |
} |
| 1299 |
if (!pdfTitle && info && info['Title']) { |
| 1300 |
pdfTitle = info['Title']; |
| 1301 |
} |
| 1302 |
if (pdfTitle) { |
| 1303 |
_this5.setTitle(pdfTitle + ' - ' + (contentDispositionFilename || document.title)); |
| 1304 |
} else if (contentDispositionFilename) { |
| 1305 |
_this5.setTitle(contentDispositionFilename); |
| 1306 |
} |
| 1307 |
if (info.IsAcroFormPresent) { |
| 1308 |
console.warn('Warning: AcroForm/XFA is not supported'); |
| 1309 |
_this5.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms); |
| 1310 |
} |
| 1311 |
}); |
| 1312 |
}, |
| 1313 |
setInitialView: function setInitialView(storedHash) { |
| 1314 |
var _this6 = this; |
| 1315 |
|
| 1316 |
var _ref13 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, |
| 1317 |
rotation = _ref13.rotation, |
| 1318 |
sidebarView = _ref13.sidebarView, |
| 1319 |
scrollMode = _ref13.scrollMode, |
| 1320 |
spreadMode = _ref13.spreadMode; |
| 1321 |
|
| 1322 |
var setRotation = function setRotation(angle) { |
| 1323 |
if ((0, _ui_utils.isValidRotation)(angle)) { |
| 1324 |
_this6.pdfViewer.pagesRotation = angle; |
| 1325 |
} |
| 1326 |
}; |
| 1327 |
var setViewerModes = function setViewerModes(scroll, spread) { |
| 1328 |
if (Number.isInteger(scroll)) { |
| 1329 |
_this6.pdfViewer.scrollMode = scroll; |
| 1330 |
} |
| 1331 |
if (Number.isInteger(spread)) { |
| 1332 |
_this6.pdfViewer.spreadMode = spread; |
| 1333 |
} |
| 1334 |
}; |
| 1335 |
setViewerModes(scrollMode, spreadMode); |
| 1336 |
this.isInitialViewSet = true; |
| 1337 |
this.pdfSidebar.setInitialView(sidebarView); |
| 1338 |
if (this.initialBookmark) { |
| 1339 |
setRotation(this.initialRotation); |
| 1340 |
delete this.initialRotation; |
| 1341 |
this.pdfLinkService.setHash(this.initialBookmark); |
| 1342 |
this.initialBookmark = null; |
| 1343 |
} else if (storedHash) { |
| 1344 |
setRotation(rotation); |
| 1345 |
this.pdfLinkService.setHash(storedHash); |
| 1346 |
} |
| 1347 |
this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel); |
| 1348 |
this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber); |
| 1349 |
if (!this.pdfViewer.currentScaleValue) { |
| 1350 |
this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE; |
| 1351 |
} |
| 1352 |
}, |
| 1353 |
cleanup: function cleanup() { |
| 1354 |
if (!this.pdfDocument) { |
| 1355 |
return; |
| 1356 |
} |
| 1357 |
this.pdfViewer.cleanup(); |
| 1358 |
this.pdfThumbnailViewer.cleanup(); |
| 1359 |
if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) { |
| 1360 |
this.pdfDocument.cleanup(); |
| 1361 |
} |
| 1362 |
}, |
| 1363 |
forceRendering: function forceRendering() { |
| 1364 |
this.pdfRenderingQueue.printing = this.printing; |
| 1365 |
this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible; |
| 1366 |
this.pdfRenderingQueue.renderHighestPriority(); |
| 1367 |
}, |
| 1368 |
beforePrint: function beforePrint() { |
| 1369 |
var _this7 = this; |
| 1370 |
|
| 1371 |
if (this.printService) { |
| 1372 |
return; |
| 1373 |
} |
| 1374 |
if (!this.supportsPrinting) { |
| 1375 |
this.l10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by ' + 'this browser.').then(function (printMessage) { |
| 1376 |
_this7.error(printMessage); |
| 1377 |
}); |
| 1378 |
return; |
| 1379 |
} |
| 1380 |
if (!this.pdfViewer.pageViewsReady) { |
| 1381 |
this.l10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.').then(function (notReadyMessage) { |
| 1382 |
window.alert(notReadyMessage); |
| 1383 |
}); |
| 1384 |
return; |
| 1385 |
} |
| 1386 |
var pagesOverview = this.pdfViewer.getPagesOverview(); |
| 1387 |
var printContainer = this.appConfig.printContainer; |
| 1388 |
var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, this.l10n); |
| 1389 |
this.printService = printService; |
| 1390 |
this.forceRendering(); |
| 1391 |
printService.layout(); |
| 1392 |
}, |
| 1393 |
|
| 1394 |
afterPrint: function pdfViewSetupAfterPrint() { |
| 1395 |
if (this.printService) { |
| 1396 |
this.printService.destroy(); |
| 1397 |
this.printService = null; |
| 1398 |
} |
| 1399 |
this.forceRendering(); |
| 1400 |
}, |
| 1401 |
rotatePages: function rotatePages(delta) { |
| 1402 |
if (!this.pdfDocument) { |
| 1403 |
return; |
| 1404 |
} |
| 1405 |
var newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360; |
| 1406 |
this.pdfViewer.pagesRotation = newRotation; |
| 1407 |
}, |
| 1408 |
requestPresentationMode: function requestPresentationMode() { |
| 1409 |
if (!this.pdfPresentationMode) { |
| 1410 |
return; |
| 1411 |
} |
| 1412 |
this.pdfPresentationMode.request(); |
| 1413 |
}, |
| 1414 |
bindEvents: function bindEvents() { |
| 1415 |
var eventBus = this.eventBus, |
| 1416 |
_boundEvents = this._boundEvents; |
| 1417 |
|
| 1418 |
_boundEvents.beforePrint = this.beforePrint.bind(this); |
| 1419 |
_boundEvents.afterPrint = this.afterPrint.bind(this); |
| 1420 |
eventBus.on('resize', webViewerResize); |
| 1421 |
eventBus.on('hashchange', webViewerHashchange); |
| 1422 |
eventBus.on('beforeprint', _boundEvents.beforePrint); |
| 1423 |
eventBus.on('afterprint', _boundEvents.afterPrint); |
| 1424 |
eventBus.on('pagerendered', webViewerPageRendered); |
| 1425 |
eventBus.on('textlayerrendered', webViewerTextLayerRendered); |
| 1426 |
eventBus.on('updateviewarea', webViewerUpdateViewarea); |
| 1427 |
eventBus.on('pagechanging', webViewerPageChanging); |
| 1428 |
eventBus.on('scalechanging', webViewerScaleChanging); |
| 1429 |
eventBus.on('rotationchanging', webViewerRotationChanging); |
| 1430 |
eventBus.on('sidebarviewchanged', webViewerSidebarViewChanged); |
| 1431 |
eventBus.on('pagemode', webViewerPageMode); |
| 1432 |
eventBus.on('namedaction', webViewerNamedAction); |
| 1433 |
eventBus.on('presentationmodechanged', webViewerPresentationModeChanged); |
| 1434 |
eventBus.on('presentationmode', webViewerPresentationMode); |
| 1435 |
eventBus.on('openfile', webViewerOpenFile); |
| 1436 |
eventBus.on('print', webViewerPrint); |
| 1437 |
eventBus.on('download', webViewerDownload); |
| 1438 |
eventBus.on('firstpage', webViewerFirstPage); |
| 1439 |
eventBus.on('lastpage', webViewerLastPage); |
| 1440 |
eventBus.on('nextpage', webViewerNextPage); |
| 1441 |
eventBus.on('previouspage', webViewerPreviousPage); |
| 1442 |
eventBus.on('zoomin', webViewerZoomIn); |
| 1443 |
eventBus.on('zoomout', webViewerZoomOut); |
| 1444 |
eventBus.on('pagenumberchanged', webViewerPageNumberChanged); |
| 1445 |
eventBus.on('scalechanged', webViewerScaleChanged); |
| 1446 |
eventBus.on('rotatecw', webViewerRotateCw); |
| 1447 |
eventBus.on('rotateccw', webViewerRotateCcw); |
| 1448 |
eventBus.on('switchscrollmode', webViewerSwitchScrollMode); |
| 1449 |
eventBus.on('scrollmodechanged', webViewerScrollModeChanged); |
| 1450 |
eventBus.on('switchspreadmode', webViewerSwitchSpreadMode); |
| 1451 |
eventBus.on('spreadmodechanged', webViewerSpreadModeChanged); |
| 1452 |
eventBus.on('documentproperties', webViewerDocumentProperties); |
| 1453 |
eventBus.on('find', webViewerFind); |
| 1454 |
eventBus.on('findfromurlhash', webViewerFindFromUrlHash); |
| 1455 |
eventBus.on('updatefindmatchescount', webViewerUpdateFindMatchesCount); |
| 1456 |
eventBus.on('updatefindcontrolstate', webViewerUpdateFindControlState); |
| 1457 |
eventBus.on('fileinputchange', webViewerFileInputChange); |
| 1458 |
}, |
| 1459 |
bindWindowEvents: function bindWindowEvents() { |
| 1460 |
var eventBus = this.eventBus, |
| 1461 |
_boundEvents = this._boundEvents; |
| 1462 |
|
| 1463 |
_boundEvents.windowResize = function () { |
| 1464 |
eventBus.dispatch('resize', { source: window }); |
| 1465 |
}; |
| 1466 |
_boundEvents.windowHashChange = function () { |
| 1467 |
eventBus.dispatch('hashchange', { |
| 1468 |
source: window, |
| 1469 |
hash: document.location.hash.substring(1) |
| 1470 |
}); |
| 1471 |
}; |
| 1472 |
_boundEvents.windowBeforePrint = function () { |
| 1473 |
eventBus.dispatch('beforeprint', { source: window }); |
| 1474 |
}; |
| 1475 |
_boundEvents.windowAfterPrint = function () { |
| 1476 |
eventBus.dispatch('afterprint', { source: window }); |
| 1477 |
}; |
| 1478 |
window.addEventListener('wheel', webViewerWheel); |
| 1479 |
window.addEventListener('click', webViewerClick); |
| 1480 |
window.addEventListener('keydown', webViewerKeyDown); |
| 1481 |
window.addEventListener('resize', _boundEvents.windowResize); |
| 1482 |
window.addEventListener('hashchange', _boundEvents.windowHashChange); |
| 1483 |
window.addEventListener('beforeprint', _boundEvents.windowBeforePrint); |
| 1484 |
window.addEventListener('afterprint', _boundEvents.windowAfterPrint); |
| 1485 |
}, |
| 1486 |
unbindEvents: function unbindEvents() { |
| 1487 |
var eventBus = this.eventBus, |
| 1488 |
_boundEvents = this._boundEvents; |
| 1489 |
|
| 1490 |
eventBus.off('resize', webViewerResize); |
| 1491 |
eventBus.off('hashchange', webViewerHashchange); |
| 1492 |
eventBus.off('beforeprint', _boundEvents.beforePrint); |
| 1493 |
eventBus.off('afterprint', _boundEvents.afterPrint); |
| 1494 |
eventBus.off('pagerendered', webViewerPageRendered); |
| 1495 |
eventBus.off('textlayerrendered', webViewerTextLayerRendered); |
| 1496 |
eventBus.off('updateviewarea', webViewerUpdateViewarea); |
| 1497 |
eventBus.off('pagechanging', webViewerPageChanging); |
| 1498 |
eventBus.off('scalechanging', webViewerScaleChanging); |
| 1499 |
eventBus.off('rotationchanging', webViewerRotationChanging); |
| 1500 |
eventBus.off('sidebarviewchanged', webViewerSidebarViewChanged); |
| 1501 |
eventBus.off('pagemode', webViewerPageMode); |
| 1502 |
eventBus.off('namedaction', webViewerNamedAction); |
| 1503 |
eventBus.off('presentationmodechanged', webViewerPresentationModeChanged); |
| 1504 |
eventBus.off('presentationmode', webViewerPresentationMode); |
| 1505 |
eventBus.off('openfile', webViewerOpenFile); |
| 1506 |
eventBus.off('print', webViewerPrint); |
| 1507 |
eventBus.off('download', webViewerDownload); |
| 1508 |
eventBus.off('firstpage', webViewerFirstPage); |
| 1509 |
eventBus.off('lastpage', webViewerLastPage); |
| 1510 |
eventBus.off('nextpage', webViewerNextPage); |
| 1511 |
eventBus.off('previouspage', webViewerPreviousPage); |
| 1512 |
eventBus.off('zoomin', webViewerZoomIn); |
| 1513 |
eventBus.off('zoomout', webViewerZoomOut); |
| 1514 |
eventBus.off('pagenumberchanged', webViewerPageNumberChanged); |
| 1515 |
eventBus.off('scalechanged', webViewerScaleChanged); |
| 1516 |
eventBus.off('rotatecw', webViewerRotateCw); |
| 1517 |
eventBus.off('rotateccw', webViewerRotateCcw); |
| 1518 |
eventBus.off('switchscrollmode', webViewerSwitchScrollMode); |
| 1519 |
eventBus.off('scrollmodechanged', webViewerScrollModeChanged); |
| 1520 |
eventBus.off('switchspreadmode', webViewerSwitchSpreadMode); |
| 1521 |
eventBus.off('spreadmodechanged', webViewerSpreadModeChanged); |
| 1522 |
eventBus.off('documentproperties', webViewerDocumentProperties); |
| 1523 |
eventBus.off('find', webViewerFind); |
| 1524 |
eventBus.off('findfromurlhash', webViewerFindFromUrlHash); |
| 1525 |
eventBus.off('updatefindmatchescount', webViewerUpdateFindMatchesCount); |
| 1526 |
eventBus.off('updatefindcontrolstate', webViewerUpdateFindControlState); |
| 1527 |
eventBus.off('fileinputchange', webViewerFileInputChange); |
| 1528 |
_boundEvents.beforePrint = null; |
| 1529 |
_boundEvents.afterPrint = null; |
| 1530 |
}, |
| 1531 |
unbindWindowEvents: function unbindWindowEvents() { |
| 1532 |
var _boundEvents = this._boundEvents; |
| 1533 |
|
| 1534 |
window.removeEventListener('wheel', webViewerWheel); |
| 1535 |
window.removeEventListener('click', webViewerClick); |
| 1536 |
window.removeEventListener('keydown', webViewerKeyDown); |
| 1537 |
window.removeEventListener('resize', _boundEvents.windowResize); |
| 1538 |
window.removeEventListener('hashchange', _boundEvents.windowHashChange); |
| 1539 |
window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint); |
| 1540 |
window.removeEventListener('afterprint', _boundEvents.windowAfterPrint); |
| 1541 |
_boundEvents.windowResize = null; |
| 1542 |
_boundEvents.windowHashChange = null; |
| 1543 |
_boundEvents.windowBeforePrint = null; |
| 1544 |
_boundEvents.windowAfterPrint = null; |
| 1545 |
} |
| 1546 |
}; |
| 1547 |
var validateFileURL = void 0; |
| 1548 |
{ |
| 1549 |
var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io']; |
| 1550 |
validateFileURL = function validateFileURL(file) { |
| 1551 |
if (file === undefined) { |
| 1552 |
return; |
| 1553 |
} |
| 1554 |
try { |
| 1555 |
var viewerOrigin = new _pdfjsLib.URL(window.location.href).origin || 'null'; |
| 1556 |
if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) { |
| 1557 |
return; |
| 1558 |
} |
| 1559 |
|
| 1560 |
var _ref14 = new _pdfjsLib.URL(file, window.location.href), |
| 1561 |
origin = _ref14.origin, |
| 1562 |
protocol = _ref14.protocol; |
| 1563 |
|
| 1564 |
if (origin !== viewerOrigin && protocol !== 'blob:') { |
| 1565 |
throw new Error('file origin does not match viewer\'s'); |
| 1566 |
} |
| 1567 |
} catch (ex) { |
| 1568 |
var message = ex && ex.message; |
| 1569 |
PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (loadingErrorMessage) { |
| 1570 |
PDFViewerApplication.error(loadingErrorMessage, { message: message }); |
| 1571 |
}); |
| 1572 |
throw ex; |
| 1573 |
} |
| 1574 |
}; |
| 1575 |
} |
| 1576 |
function loadFakeWorker() { |
| 1577 |
if (!_pdfjsLib.GlobalWorkerOptions.workerSrc) { |
| 1578 |
_pdfjsLib.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get('workerSrc'); |
| 1579 |
} |
| 1580 |
return (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.getWorkerSrc()); |
| 1581 |
} |
| 1582 |
function loadAndEnablePDFBug(enabledTabs) { |
| 1583 |
var appConfig = PDFViewerApplication.appConfig; |
| 1584 |
return (0, _pdfjsLib.loadScript)(appConfig.debuggerScriptPath).then(function () { |
| 1585 |
PDFBug.enable(enabledTabs); |
| 1586 |
PDFBug.init({ |
| 1587 |
OPS: _pdfjsLib.OPS, |
| 1588 |
createObjectURL: _pdfjsLib.createObjectURL |
| 1589 |
}, appConfig.mainContainer); |
| 1590 |
}); |
| 1591 |
} |
| 1592 |
function webViewerInitialized() { |
| 1593 |
var appConfig = PDFViewerApplication.appConfig; |
| 1594 |
var file = void 0; |
| 1595 |
var queryString = document.location.search.substring(1); |
| 1596 |
var params = (0, _ui_utils.parseQueryString)(queryString); |
| 1597 |
file = 'file' in params ? params.file : _app_options.AppOptions.get('defaultUrl'); |
| 1598 |
validateFileURL(file); |
| 1599 |
var fileInput = document.createElement('input'); |
| 1600 |
fileInput.id = appConfig.openFileInputName; |
| 1601 |
fileInput.className = 'fileInput'; |
| 1602 |
fileInput.setAttribute('type', 'file'); |
| 1603 |
fileInput.oncontextmenu = _ui_utils.noContextMenuHandler; |
| 1604 |
document.body.appendChild(fileInput); |
| 1605 |
if (!window.File || !window.FileReader || !window.FileList || !window.Blob) { |
| 1606 |
appConfig.toolbar.openFile.setAttribute('hidden', 'true'); |
| 1607 |
appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true'); |
| 1608 |
} else { |
| 1609 |
fileInput.value = null; |
| 1610 |
} |
| 1611 |
fileInput.addEventListener('change', function (evt) { |
| 1612 |
var files = evt.target.files; |
| 1613 |
if (!files || files.length === 0) { |
| 1614 |
return; |
| 1615 |
} |
| 1616 |
PDFViewerApplication.eventBus.dispatch('fileinputchange', { |
| 1617 |
source: this, |
| 1618 |
fileInput: evt.target |
| 1619 |
}); |
| 1620 |
}); |
| 1621 |
appConfig.mainContainer.addEventListener('dragover', function (evt) { |
| 1622 |
evt.preventDefault(); |
| 1623 |
evt.dataTransfer.dropEffect = 'move'; |
| 1624 |
}); |
| 1625 |
appConfig.mainContainer.addEventListener('drop', function (evt) { |
| 1626 |
evt.preventDefault(); |
| 1627 |
var files = evt.dataTransfer.files; |
| 1628 |
if (!files || files.length === 0) { |
| 1629 |
return; |
| 1630 |
} |
| 1631 |
PDFViewerApplication.eventBus.dispatch('fileinputchange', { |
| 1632 |
source: this, |
| 1633 |
fileInput: evt.dataTransfer |
| 1634 |
}); |
| 1635 |
}); |
| 1636 |
if (!PDFViewerApplication.supportsPrinting) { |
| 1637 |
appConfig.toolbar.print.classList.add('hidden'); |
| 1638 |
appConfig.secondaryToolbar.printButton.classList.add('hidden'); |
| 1639 |
} |
| 1640 |
if (!PDFViewerApplication.supportsFullscreen) { |
| 1641 |
appConfig.toolbar.presentationModeButton.classList.add('hidden'); |
| 1642 |
appConfig.secondaryToolbar.presentationModeButton.classList.add('hidden'); |
| 1643 |
} |
| 1644 |
if (PDFViewerApplication.supportsIntegratedFind) { |
| 1645 |
appConfig.toolbar.viewFind.classList.add('hidden'); |
| 1646 |
} |
| 1647 |
appConfig.mainContainer.addEventListener('transitionend', function (evt) { |
| 1648 |
if (evt.target === this) { |
| 1649 |
PDFViewerApplication.eventBus.dispatch('resize', { source: this }); |
| 1650 |
} |
| 1651 |
}, true); |
| 1652 |
appConfig.sidebar.toggleButton.addEventListener('click', function () { |
| 1653 |
PDFViewerApplication.pdfSidebar.toggle(); |
| 1654 |
}); |
| 1655 |
try { |
| 1656 |
webViewerOpenFileViaURL(file); |
| 1657 |
} catch (reason) { |
| 1658 |
PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (msg) { |
| 1659 |
PDFViewerApplication.error(msg, reason); |
| 1660 |
}); |
| 1661 |
} |
| 1662 |
} |
| 1663 |
var webViewerOpenFileViaURL = void 0; |
| 1664 |
{ |
| 1665 |
webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) { |
| 1666 |
if (file && file.lastIndexOf('file:', 0) === 0) { |
| 1667 |
PDFViewerApplication.setTitleUsingUrl(file); |
| 1668 |
var xhr = new XMLHttpRequest(); |
| 1669 |
xhr.onload = function () { |
| 1670 |
PDFViewerApplication.open(new Uint8Array(xhr.response)); |
| 1671 |
}; |
| 1672 |
try { |
| 1673 |
xhr.open('GET', file); |
| 1674 |
xhr.responseType = 'arraybuffer'; |
| 1675 |
xhr.send(); |
| 1676 |
} catch (ex) { |
| 1677 |
throw ex; |
| 1678 |
} |
| 1679 |
return; |
| 1680 |
} |
| 1681 |
if (file) { |
| 1682 |
PDFViewerApplication.open(file); |
| 1683 |
} |
| 1684 |
}; |
| 1685 |
} |
| 1686 |
function webViewerPageRendered(evt) { |
| 1687 |
var pageNumber = evt.pageNumber; |
| 1688 |
var pageIndex = pageNumber - 1; |
| 1689 |
var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex); |
| 1690 |
if (pageNumber === PDFViewerApplication.page) { |
| 1691 |
PDFViewerApplication.toolbar.updateLoadingIndicatorState(false); |
| 1692 |
} |
| 1693 |
if (!pageView) { |
| 1694 |
return; |
| 1695 |
} |
| 1696 |
if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) { |
| 1697 |
var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex); |
| 1698 |
thumbnailView.setImage(pageView); |
| 1699 |
} |
| 1700 |
if (typeof Stats !== 'undefined' && Stats.enabled && pageView.stats) { |
| 1701 |
Stats.add(pageNumber, pageView.stats); |
| 1702 |
} |
| 1703 |
if (pageView.error) { |
| 1704 |
PDFViewerApplication.l10n.get('rendering_error', null, 'An error occurred while rendering the page.').then(function (msg) { |
| 1705 |
PDFViewerApplication.error(msg, pageView.error); |
| 1706 |
}); |
| 1707 |
} |
| 1708 |
} |
| 1709 |
function webViewerTextLayerRendered(evt) {} |
| 1710 |
function webViewerPageMode(evt) { |
| 1711 |
var mode = evt.mode, |
| 1712 |
view = void 0; |
| 1713 |
switch (mode) { |
| 1714 |
case 'thumbs': |
| 1715 |
view = _pdf_sidebar.SidebarView.THUMBS; |
| 1716 |
break; |
| 1717 |
case 'bookmarks': |
| 1718 |
case 'outline': |
| 1719 |
view = _pdf_sidebar.SidebarView.OUTLINE; |
| 1720 |
break; |
| 1721 |
case 'attachments': |
| 1722 |
view = _pdf_sidebar.SidebarView.ATTACHMENTS; |
| 1723 |
break; |
| 1724 |
case 'none': |
| 1725 |
view = _pdf_sidebar.SidebarView.NONE; |
| 1726 |
break; |
| 1727 |
default: |
| 1728 |
console.error('Invalid "pagemode" hash parameter: ' + mode); |
| 1729 |
return; |
| 1730 |
} |
| 1731 |
PDFViewerApplication.pdfSidebar.switchView(view, true); |
| 1732 |
} |
| 1733 |
function webViewerNamedAction(evt) { |
| 1734 |
var action = evt.action; |
| 1735 |
switch (action) { |
| 1736 |
case 'GoToPage': |
| 1737 |
PDFViewerApplication.appConfig.toolbar.pageNumber.select(); |
| 1738 |
break; |
| 1739 |
case 'Find': |
| 1740 |
if (!PDFViewerApplication.supportsIntegratedFind) { |
| 1741 |
PDFViewerApplication.findBar.toggle(); |
| 1742 |
} |
| 1743 |
break; |
| 1744 |
} |
| 1745 |
} |
| 1746 |
function webViewerPresentationModeChanged(evt) { |
| 1747 |
var active = evt.active, |
| 1748 |
switchInProgress = evt.switchInProgress; |
| 1749 |
|
| 1750 |
PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? _ui_utils.PresentationModeState.CHANGING : active ? _ui_utils.PresentationModeState.FULLSCREEN : _ui_utils.PresentationModeState.NORMAL; |
| 1751 |
} |
| 1752 |
function webViewerSidebarViewChanged(evt) { |
| 1753 |
PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible; |
| 1754 |
var store = PDFViewerApplication.store; |
| 1755 |
if (store && PDFViewerApplication.isInitialViewSet) { |
| 1756 |
store.set('sidebarView', evt.view).catch(function () {}); |
| 1757 |
} |
| 1758 |
} |
| 1759 |
function webViewerUpdateViewarea(evt) { |
| 1760 |
var location = evt.location, |
| 1761 |
store = PDFViewerApplication.store; |
| 1762 |
if (store && PDFViewerApplication.isInitialViewSet) { |
| 1763 |
store.setMultiple({ |
| 1764 |
'page': location.pageNumber, |
| 1765 |
'zoom': location.scale, |
| 1766 |
'scrollLeft': location.left, |
| 1767 |
'scrollTop': location.top, |
| 1768 |
'rotation': location.rotation |
| 1769 |
}).catch(function () {}); |
| 1770 |
} |
| 1771 |
var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams); |
| 1772 |
PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href; |
| 1773 |
PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href; |
| 1774 |
var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1); |
| 1775 |
var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED; |
| 1776 |
PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading); |
| 1777 |
} |
| 1778 |
function webViewerScrollModeChanged(evt) { |
| 1779 |
var store = PDFViewerApplication.store; |
| 1780 |
if (store && PDFViewerApplication.isInitialViewSet) { |
| 1781 |
store.set('scrollMode', evt.mode).catch(function () {}); |
| 1782 |
} |
| 1783 |
} |
| 1784 |
function webViewerSpreadModeChanged(evt) { |
| 1785 |
var store = PDFViewerApplication.store; |
| 1786 |
if (store && PDFViewerApplication.isInitialViewSet) { |
| 1787 |
store.set('spreadMode', evt.mode).catch(function () {}); |
| 1788 |
} |
| 1789 |
} |
| 1790 |
function webViewerResize() { |
| 1791 |
var pdfDocument = PDFViewerApplication.pdfDocument, |
| 1792 |
pdfViewer = PDFViewerApplication.pdfViewer; |
| 1793 |
|
| 1794 |
if (!pdfDocument) { |
| 1795 |
return; |
| 1796 |
} |
| 1797 |
var currentScaleValue = pdfViewer.currentScaleValue; |
| 1798 |
if (currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue === 'page-width') { |
| 1799 |
pdfViewer.currentScaleValue = currentScaleValue; |
| 1800 |
} |
| 1801 |
pdfViewer.update(); |
| 1802 |
} |
| 1803 |
function webViewerHashchange(evt) { |
| 1804 |
var hash = evt.hash; |
| 1805 |
if (!hash) { |
| 1806 |
return; |
| 1807 |
} |
| 1808 |
if (!PDFViewerApplication.isInitialViewSet) { |
| 1809 |
PDFViewerApplication.initialBookmark = hash; |
| 1810 |
} else if (!PDFViewerApplication.pdfHistory.popStateInProgress) { |
| 1811 |
PDFViewerApplication.pdfLinkService.setHash(hash); |
| 1812 |
} |
| 1813 |
} |
| 1814 |
var webViewerFileInputChange = void 0; |
| 1815 |
{ |
| 1816 |
webViewerFileInputChange = function webViewerFileInputChange(evt) { |
| 1817 |
if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) { |
| 1818 |
return; |
| 1819 |
} |
| 1820 |
var file = evt.fileInput.files[0]; |
| 1821 |
if (_pdfjsLib.URL.createObjectURL && !_app_options.AppOptions.get('disableCreateObjectURL')) { |
| 1822 |
var _url = _pdfjsLib.URL.createObjectURL(file); |
| 1823 |
if (file.name) { |
| 1824 |
_url = { |
| 1825 |
url: _url, |
| 1826 |
originalUrl: file.name |
| 1827 |
}; |
| 1828 |
} |
| 1829 |
PDFViewerApplication.open(_url); |
| 1830 |
} else { |
| 1831 |
PDFViewerApplication.setTitleUsingUrl(file.name); |
| 1832 |
var fileReader = new FileReader(); |
| 1833 |
fileReader.onload = function webViewerChangeFileReaderOnload(evt) { |
| 1834 |
var buffer = evt.target.result; |
| 1835 |
PDFViewerApplication.open(new Uint8Array(buffer)); |
| 1836 |
}; |
| 1837 |
fileReader.readAsArrayBuffer(file); |
| 1838 |
} |
| 1839 |
var appConfig = PDFViewerApplication.appConfig; |
| 1840 |
appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true'); |
| 1841 |
appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', 'true'); |
| 1842 |
appConfig.toolbar.download.setAttribute('hidden', 'true'); |
| 1843 |
appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true'); |
| 1844 |
}; |
| 1845 |
} |
| 1846 |
function webViewerPresentationMode() { |
| 1847 |
PDFViewerApplication.requestPresentationMode(); |
| 1848 |
} |
| 1849 |
function webViewerOpenFile() { |
| 1850 |
var openFileInputName = PDFViewerApplication.appConfig.openFileInputName; |
| 1851 |
document.getElementById(openFileInputName).click(); |
| 1852 |
} |
| 1853 |
function webViewerPrint() { |
| 1854 |
window.print(); |
| 1855 |
} |
| 1856 |
function webViewerDownload() { |
| 1857 |
PDFViewerApplication.download(); |
| 1858 |
} |
| 1859 |
function webViewerFirstPage() { |
| 1860 |
if (PDFViewerApplication.pdfDocument) { |
| 1861 |
PDFViewerApplication.page = 1; |
| 1862 |
} |
| 1863 |
} |
| 1864 |
function webViewerLastPage() { |
| 1865 |
if (PDFViewerApplication.pdfDocument) { |
| 1866 |
PDFViewerApplication.page = PDFViewerApplication.pagesCount; |
| 1867 |
} |
| 1868 |
} |
| 1869 |
function webViewerNextPage() { |
| 1870 |
PDFViewerApplication.page++; |
| 1871 |
} |
| 1872 |
function webViewerPreviousPage() { |
| 1873 |
PDFViewerApplication.page--; |
| 1874 |
} |
| 1875 |
function webViewerZoomIn() { |
| 1876 |
PDFViewerApplication.zoomIn(); |
| 1877 |
} |
| 1878 |
function webViewerZoomOut() { |
| 1879 |
PDFViewerApplication.zoomOut(); |
| 1880 |
} |
| 1881 |
function webViewerPageNumberChanged(evt) { |
| 1882 |
var pdfViewer = PDFViewerApplication.pdfViewer; |
| 1883 |
pdfViewer.currentPageLabel = evt.value; |
| 1884 |
if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) { |
| 1885 |
PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel); |
| 1886 |
} |
| 1887 |
} |
| 1888 |
function webViewerScaleChanged(evt) { |
| 1889 |
PDFViewerApplication.pdfViewer.currentScaleValue = evt.value; |
| 1890 |
} |
| 1891 |
function webViewerRotateCw() { |
| 1892 |
PDFViewerApplication.rotatePages(90); |
| 1893 |
} |
| 1894 |
function webViewerRotateCcw() { |
| 1895 |
PDFViewerApplication.rotatePages(-90); |
| 1896 |
} |
| 1897 |
function webViewerSwitchScrollMode(evt) { |
| 1898 |
PDFViewerApplication.pdfViewer.scrollMode = evt.mode; |
| 1899 |
} |
| 1900 |
function webViewerSwitchSpreadMode(evt) { |
| 1901 |
PDFViewerApplication.pdfViewer.spreadMode = evt.mode; |
| 1902 |
} |
| 1903 |
function webViewerDocumentProperties() { |
| 1904 |
PDFViewerApplication.pdfDocumentProperties.open(); |
| 1905 |
} |
| 1906 |
function webViewerFind(evt) { |
| 1907 |
PDFViewerApplication.findController.executeCommand('find' + evt.type, { |
| 1908 |
query: evt.query, |
| 1909 |
phraseSearch: evt.phraseSearch, |
| 1910 |
caseSensitive: evt.caseSensitive, |
| 1911 |
entireWord: evt.entireWord, |
| 1912 |
highlightAll: evt.highlightAll, |
| 1913 |
findPrevious: evt.findPrevious |
| 1914 |
}); |
| 1915 |
} |
| 1916 |
function webViewerFindFromUrlHash(evt) { |
| 1917 |
PDFViewerApplication.findController.executeCommand('find', { |
| 1918 |
query: evt.query, |
| 1919 |
phraseSearch: evt.phraseSearch, |
| 1920 |
caseSensitive: false, |
| 1921 |
entireWord: false, |
| 1922 |
highlightAll: true, |
| 1923 |
findPrevious: false |
| 1924 |
}); |
| 1925 |
} |
| 1926 |
function webViewerUpdateFindMatchesCount(_ref15) { |
| 1927 |
var matchesCount = _ref15.matchesCount; |
| 1928 |
|
| 1929 |
if (PDFViewerApplication.supportsIntegratedFind) { |
| 1930 |
PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount); |
| 1931 |
} else { |
| 1932 |
PDFViewerApplication.findBar.updateResultsCount(matchesCount); |
| 1933 |
} |
| 1934 |
} |
| 1935 |
function webViewerUpdateFindControlState(_ref16) { |
| 1936 |
var state = _ref16.state, |
| 1937 |
previous = _ref16.previous, |
| 1938 |
matchesCount = _ref16.matchesCount; |
| 1939 |
|
| 1940 |
if (PDFViewerApplication.supportsIntegratedFind) { |
| 1941 |
PDFViewerApplication.externalServices.updateFindControlState({ |
| 1942 |
result: state, |
| 1943 |
findPrevious: previous, |
| 1944 |
matchesCount: matchesCount |
| 1945 |
}); |
| 1946 |
} else { |
| 1947 |
PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount); |
| 1948 |
} |
| 1949 |
} |
| 1950 |
function webViewerScaleChanging(evt) { |
| 1951 |
PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale); |
| 1952 |
PDFViewerApplication.pdfViewer.update(); |
| 1953 |
} |
| 1954 |
function webViewerRotationChanging(evt) { |
| 1955 |
PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation; |
| 1956 |
PDFViewerApplication.forceRendering(); |
| 1957 |
PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber; |
| 1958 |
} |
| 1959 |
function webViewerPageChanging(evt) { |
| 1960 |
var page = evt.pageNumber; |
| 1961 |
PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null); |
| 1962 |
PDFViewerApplication.secondaryToolbar.setPageNumber(page); |
| 1963 |
if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) { |
| 1964 |
PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page); |
| 1965 |
} |
| 1966 |
if (typeof Stats !== 'undefined' && Stats.enabled) { |
| 1967 |
var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1); |
| 1968 |
if (pageView && pageView.stats) { |
| 1969 |
Stats.add(page, pageView.stats); |
| 1970 |
} |
| 1971 |
} |
| 1972 |
} |
| 1973 |
var zoomDisabled = false, |
| 1974 |
zoomDisabledTimeout = void 0; |
| 1975 |
function webViewerWheel(evt) { |
| 1976 |
var pdfViewer = PDFViewerApplication.pdfViewer; |
| 1977 |
if (pdfViewer.isInPresentationMode) { |
| 1978 |
return; |
| 1979 |
} |
| 1980 |
if (evt.ctrlKey || evt.metaKey) { |
| 1981 |
var support = PDFViewerApplication.supportedMouseWheelZoomModifierKeys; |
| 1982 |
if (evt.ctrlKey && !support.ctrlKey || evt.metaKey && !support.metaKey) { |
| 1983 |
return; |
| 1984 |
} |
| 1985 |
evt.preventDefault(); |
| 1986 |
if (zoomDisabled) { |
| 1987 |
return; |
| 1988 |
} |
| 1989 |
var previousScale = pdfViewer.currentScale; |
| 1990 |
var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt); |
| 1991 |
var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0; |
| 1992 |
var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE; |
| 1993 |
if (ticks < 0) { |
| 1994 |
PDFViewerApplication.zoomOut(-ticks); |
| 1995 |
} else { |
| 1996 |
PDFViewerApplication.zoomIn(ticks); |
| 1997 |
} |
| 1998 |
var currentScale = pdfViewer.currentScale; |
| 1999 |
if (previousScale !== currentScale) { |
| 2000 |
var scaleCorrectionFactor = currentScale / previousScale - 1; |
| 2001 |
var rect = pdfViewer.container.getBoundingClientRect(); |
| 2002 |
var dx = evt.clientX - rect.left; |
| 2003 |
var dy = evt.clientY - rect.top; |
| 2004 |
pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor; |
| 2005 |
pdfViewer.container.scrollTop += dy * scaleCorrectionFactor; |
| 2006 |
} |
| 2007 |
} else { |
| 2008 |
zoomDisabled = true; |
| 2009 |
clearTimeout(zoomDisabledTimeout); |
| 2010 |
zoomDisabledTimeout = setTimeout(function () { |
| 2011 |
zoomDisabled = false; |
| 2012 |
}, 1000); |
| 2013 |
} |
| 2014 |
} |
| 2015 |
function webViewerClick(evt) { |
| 2016 |
if (!PDFViewerApplication.secondaryToolbar.isOpen) { |
| 2017 |
return; |
| 2018 |
} |
| 2019 |
var appConfig = PDFViewerApplication.appConfig; |
| 2020 |
if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) { |
| 2021 |
PDFViewerApplication.secondaryToolbar.close(); |
| 2022 |
} |
| 2023 |
} |
| 2024 |
function webViewerKeyDown(evt) { |
| 2025 |
if (PDFViewerApplication.overlayManager.active) { |
| 2026 |
return; |
| 2027 |
} |
| 2028 |
var handled = false, |
| 2029 |
ensureViewerFocused = false; |
| 2030 |
var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0); |
| 2031 |
var pdfViewer = PDFViewerApplication.pdfViewer; |
| 2032 |
var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode; |
| 2033 |
if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) { |
| 2034 |
switch (evt.keyCode) { |
| 2035 |
case 70: |
| 2036 |
if (!PDFViewerApplication.supportsIntegratedFind) { |
| 2037 |
PDFViewerApplication.findBar.open(); |
| 2038 |
handled = true; |
| 2039 |
} |
| 2040 |
break; |
| 2041 |
case 71: |
| 2042 |
if (!PDFViewerApplication.supportsIntegratedFind) { |
| 2043 |
var findState = PDFViewerApplication.findController.state; |
| 2044 |
if (findState) { |
| 2045 |
PDFViewerApplication.findController.executeCommand('findagain', { |
| 2046 |
query: findState.query, |
| 2047 |
phraseSearch: findState.phraseSearch, |
| 2048 |
caseSensitive: findState.caseSensitive, |
| 2049 |
entireWord: findState.entireWord, |
| 2050 |
highlightAll: findState.highlightAll, |
| 2051 |
findPrevious: cmd === 5 || cmd === 12 |
| 2052 |
}); |
| 2053 |
} |
| 2054 |
handled = true; |
| 2055 |
} |
| 2056 |
break; |
| 2057 |
case 61: |
| 2058 |
case 107: |
| 2059 |
case 187: |
| 2060 |
case 171: |
| 2061 |
if (!isViewerInPresentationMode) { |
| 2062 |
PDFViewerApplication.zoomIn(); |
| 2063 |
} |
| 2064 |
handled = true; |
| 2065 |
break; |
| 2066 |
case 173: |
| 2067 |
case 109: |
| 2068 |
case 189: |
| 2069 |
if (!isViewerInPresentationMode) { |
| 2070 |
PDFViewerApplication.zoomOut(); |
| 2071 |
} |
| 2072 |
handled = true; |
| 2073 |
break; |
| 2074 |
case 48: |
| 2075 |
case 96: |
| 2076 |
if (!isViewerInPresentationMode) { |
| 2077 |
setTimeout(function () { |
| 2078 |
pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE; |
| 2079 |
}); |
| 2080 |
handled = false; |
| 2081 |
} |
| 2082 |
break; |
| 2083 |
case 38: |
| 2084 |
if (isViewerInPresentationMode || PDFViewerApplication.page > 1) { |
| 2085 |
PDFViewerApplication.page = 1; |
| 2086 |
handled = true; |
| 2087 |
ensureViewerFocused = true; |
| 2088 |
} |
| 2089 |
break; |
| 2090 |
case 40: |
| 2091 |
if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) { |
| 2092 |
PDFViewerApplication.page = PDFViewerApplication.pagesCount; |
| 2093 |
handled = true; |
| 2094 |
ensureViewerFocused = true; |
| 2095 |
} |
| 2096 |
break; |
| 2097 |
} |
| 2098 |
} |
| 2099 |
if (cmd === 1 || cmd === 8) { |
| 2100 |
switch (evt.keyCode) { |
| 2101 |
case 83: |
| 2102 |
PDFViewerApplication.download(); |
| 2103 |
handled = true; |
| 2104 |
break; |
| 2105 |
} |
| 2106 |
} |
| 2107 |
if (cmd === 3 || cmd === 10) { |
| 2108 |
switch (evt.keyCode) { |
| 2109 |
case 80: |
| 2110 |
PDFViewerApplication.requestPresentationMode(); |
| 2111 |
handled = true; |
| 2112 |
break; |
| 2113 |
case 71: |
| 2114 |
PDFViewerApplication.appConfig.toolbar.pageNumber.select(); |
| 2115 |
handled = true; |
| 2116 |
break; |
| 2117 |
} |
| 2118 |
} |
| 2119 |
if (handled) { |
| 2120 |
if (ensureViewerFocused && !isViewerInPresentationMode) { |
| 2121 |
pdfViewer.focus(); |
| 2122 |
} |
| 2123 |
evt.preventDefault(); |
| 2124 |
return; |
| 2125 |
} |
| 2126 |
var curElement = document.activeElement || document.querySelector(':focus'); |
| 2127 |
var curElementTagName = curElement && curElement.tagName.toUpperCase(); |
| 2128 |
if (curElementTagName === 'INPUT' || curElementTagName === 'TEXTAREA' || curElementTagName === 'SELECT') { |
| 2129 |
if (evt.keyCode !== 27) { |
| 2130 |
return; |
| 2131 |
} |
| 2132 |
} |
| 2133 |
if (cmd === 0) { |
| 2134 |
var turnPage = 0, |
| 2135 |
turnOnlyIfPageFit = false; |
| 2136 |
switch (evt.keyCode) { |
| 2137 |
case 38: |
| 2138 |
case 33: |
| 2139 |
if (pdfViewer.isVerticalScrollbarEnabled) { |
| 2140 |
turnOnlyIfPageFit = true; |
| 2141 |
} |
| 2142 |
turnPage = -1; |
| 2143 |
break; |
| 2144 |
case 8: |
| 2145 |
if (!isViewerInPresentationMode) { |
| 2146 |
turnOnlyIfPageFit = true; |
| 2147 |
} |
| 2148 |
turnPage = -1; |
| 2149 |
break; |
| 2150 |
case 37: |
| 2151 |
if (pdfViewer.isHorizontalScrollbarEnabled) { |
| 2152 |
turnOnlyIfPageFit = true; |
| 2153 |
} |
| 2154 |
case 75: |
| 2155 |
case 80: |
| 2156 |
turnPage = -1; |
| 2157 |
break; |
| 2158 |
case 27: |
| 2159 |
if (PDFViewerApplication.secondaryToolbar.isOpen) { |
| 2160 |
PDFViewerApplication.secondaryToolbar.close(); |
| 2161 |
handled = true; |
| 2162 |
} |
| 2163 |
if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) { |
| 2164 |
PDFViewerApplication.findBar.close(); |
| 2165 |
handled = true; |
| 2166 |
} |
| 2167 |
break; |
| 2168 |
case 40: |
| 2169 |
case 34: |
| 2170 |
if (pdfViewer.isVerticalScrollbarEnabled) { |
| 2171 |
turnOnlyIfPageFit = true; |
| 2172 |
} |
| 2173 |
turnPage = 1; |
| 2174 |
break; |
| 2175 |
case 13: |
| 2176 |
case 32: |
| 2177 |
if (!isViewerInPresentationMode) { |
| 2178 |
turnOnlyIfPageFit = true; |
| 2179 |
} |
| 2180 |
turnPage = 1; |
| 2181 |
break; |
| 2182 |
case 39: |
| 2183 |
if (pdfViewer.isHorizontalScrollbarEnabled) { |
| 2184 |
turnOnlyIfPageFit = true; |
| 2185 |
} |
| 2186 |
case 74: |
| 2187 |
case 78: |
| 2188 |
turnPage = 1; |
| 2189 |
break; |
| 2190 |
case 36: |
| 2191 |
if (isViewerInPresentationMode || PDFViewerApplication.page > 1) { |
| 2192 |
PDFViewerApplication.page = 1; |
| 2193 |
handled = true; |
| 2194 |
ensureViewerFocused = true; |
| 2195 |
} |
| 2196 |
break; |
| 2197 |
case 35: |
| 2198 |
if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) { |
| 2199 |
PDFViewerApplication.page = PDFViewerApplication.pagesCount; |
| 2200 |
handled = true; |
| 2201 |
ensureViewerFocused = true; |
| 2202 |
} |
| 2203 |
break; |
| 2204 |
case 83: |
| 2205 |
PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT); |
| 2206 |
break; |
| 2207 |
case 72: |
| 2208 |
PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND); |
| 2209 |
break; |
| 2210 |
case 82: |
| 2211 |
PDFViewerApplication.rotatePages(90); |
| 2212 |
break; |
| 2213 |
} |
| 2214 |
if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === 'page-fit')) { |
| 2215 |
if (turnPage > 0) { |
| 2216 |
if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) { |
| 2217 |
PDFViewerApplication.page++; |
| 2218 |
} |
| 2219 |
} else { |
| 2220 |
if (PDFViewerApplication.page > 1) { |
| 2221 |
PDFViewerApplication.page--; |
| 2222 |
} |
| 2223 |
} |
| 2224 |
handled = true; |
| 2225 |
} |
| 2226 |
} |
| 2227 |
if (cmd === 4) { |
| 2228 |
switch (evt.keyCode) { |
| 2229 |
case 13: |
| 2230 |
case 32: |
| 2231 |
if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') { |
| 2232 |
break; |
| 2233 |
} |
| 2234 |
if (PDFViewerApplication.page > 1) { |
| 2235 |
PDFViewerApplication.page--; |
| 2236 |
} |
| 2237 |
handled = true; |
| 2238 |
break; |
| 2239 |
case 82: |
| 2240 |
PDFViewerApplication.rotatePages(-90); |
| 2241 |
break; |
| 2242 |
} |
| 2243 |
} |
| 2244 |
if (!handled && !isViewerInPresentationMode) { |
| 2245 |
if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== 'BUTTON') { |
| 2246 |
ensureViewerFocused = true; |
| 2247 |
} |
| 2248 |
} |
| 2249 |
if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) { |
| 2250 |
pdfViewer.focus(); |
| 2251 |
} |
| 2252 |
if (handled) { |
| 2253 |
evt.preventDefault(); |
| 2254 |
} |
| 2255 |
} |
| 2256 |
function apiPageModeToSidebarView(mode) { |
| 2257 |
switch (mode) { |
| 2258 |
case 'UseNone': |
| 2259 |
return _pdf_sidebar.SidebarView.NONE; |
| 2260 |
case 'UseThumbs': |
| 2261 |
return _pdf_sidebar.SidebarView.THUMBS; |
| 2262 |
case 'UseOutlines': |
| 2263 |
return _pdf_sidebar.SidebarView.OUTLINE; |
| 2264 |
case 'UseAttachments': |
| 2265 |
return _pdf_sidebar.SidebarView.ATTACHMENTS; |
| 2266 |
case 'UseOC': |
| 2267 |
} |
| 2268 |
return _pdf_sidebar.SidebarView.NONE; |
| 2269 |
} |
| 2270 |
var PDFPrintServiceFactory = { |
| 2271 |
instance: { |
| 2272 |
supportsPrinting: false, |
| 2273 |
createPrintService: function createPrintService() { |
| 2274 |
throw new Error('Not implemented: createPrintService'); |
| 2275 |
} |
| 2276 |
} |
| 2277 |
}; |
| 2278 |
exports.PDFViewerApplication = PDFViewerApplication; |
| 2279 |
exports.DefaultExternalServices = DefaultExternalServices; |
| 2280 |
exports.PDFPrintServiceFactory = PDFPrintServiceFactory; |
| 2281 |
|
| 2282 |
/***/ }), |
| 2283 |
/* 2 */ |
| 2284 |
/***/ (function(module, exports, __webpack_require__) { |
| 2285 |
|
| 2286 |
"use strict"; |
| 2287 |
|
| 2288 |
|
| 2289 |
module.exports = __webpack_require__(3); |
| 2290 |
|
| 2291 |
/***/ }), |
| 2292 |
/* 3 */ |
| 2293 |
/***/ (function(module, exports, __webpack_require__) { |
| 2294 |
|
| 2295 |
"use strict"; |
| 2296 |
|
| 2297 |
|
| 2298 |
var g = function () { |
| 2299 |
return this; |
| 2300 |
}() || Function("return this")(); |
| 2301 |
var hadRuntime = g.regeneratorRuntime && Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0; |
| 2302 |
var oldRuntime = hadRuntime && g.regeneratorRuntime; |
| 2303 |
g.regeneratorRuntime = undefined; |
| 2304 |
module.exports = __webpack_require__(4); |
| 2305 |
if (hadRuntime) { |
| 2306 |
g.regeneratorRuntime = oldRuntime; |
| 2307 |
} else { |
| 2308 |
try { |
| 2309 |
delete g.regeneratorRuntime; |
| 2310 |
} catch (e) { |
| 2311 |
g.regeneratorRuntime = undefined; |
| 2312 |
} |
| 2313 |
} |
| 2314 |
|
| 2315 |
/***/ }), |
| 2316 |
/* 4 */ |
| 2317 |
/***/ (function(module, exports, __webpack_require__) { |
| 2318 |
|
| 2319 |
"use strict"; |
| 2320 |
/* WEBPACK VAR INJECTION */(function(module) { |
| 2321 |
|
| 2322 |
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; |
| 2323 |
|
| 2324 |
!function (global) { |
| 2325 |
"use strict"; |
| 2326 |
|
| 2327 |
var Op = Object.prototype; |
| 2328 |
var hasOwn = Op.hasOwnProperty; |
| 2329 |
var undefined; |
| 2330 |
var $Symbol = typeof Symbol === "function" ? Symbol : {}; |
| 2331 |
var iteratorSymbol = $Symbol.iterator || "@@iterator"; |
| 2332 |
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; |
| 2333 |
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; |
| 2334 |
var inModule = ( false ? undefined : _typeof(module)) === "object"; |
| 2335 |
var runtime = global.regeneratorRuntime; |
| 2336 |
if (runtime) { |
| 2337 |
if (inModule) { |
| 2338 |
module.exports = runtime; |
| 2339 |
} |
| 2340 |
return; |
| 2341 |
} |
| 2342 |
runtime = global.regeneratorRuntime = inModule ? module.exports : {}; |
| 2343 |
function wrap(innerFn, outerFn, self, tryLocsList) { |
| 2344 |
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; |
| 2345 |
var generator = Object.create(protoGenerator.prototype); |
| 2346 |
var context = new Context(tryLocsList || []); |
| 2347 |
generator._invoke = makeInvokeMethod(innerFn, self, context); |
| 2348 |
return generator; |
| 2349 |
} |
| 2350 |
runtime.wrap = wrap; |
| 2351 |
function tryCatch(fn, obj, arg) { |
| 2352 |
try { |
| 2353 |
return { |
| 2354 |
type: "normal", |
| 2355 |
arg: fn.call(obj, arg) |
| 2356 |
}; |
| 2357 |
} catch (err) { |
| 2358 |
return { |
| 2359 |
type: "throw", |
| 2360 |
arg: err |
| 2361 |
}; |
| 2362 |
} |
| 2363 |
} |
| 2364 |
var GenStateSuspendedStart = "suspendedStart"; |
| 2365 |
var GenStateSuspendedYield = "suspendedYield"; |
| 2366 |
var GenStateExecuting = "executing"; |
| 2367 |
var GenStateCompleted = "completed"; |
| 2368 |
var ContinueSentinel = {}; |
| 2369 |
function Generator() {} |
| 2370 |
function GeneratorFunction() {} |
| 2371 |
function GeneratorFunctionPrototype() {} |
| 2372 |
var IteratorPrototype = {}; |
| 2373 |
IteratorPrototype[iteratorSymbol] = function () { |
| 2374 |
return this; |
| 2375 |
}; |
| 2376 |
var getProto = Object.getPrototypeOf; |
| 2377 |
var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); |
| 2378 |
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { |
| 2379 |
IteratorPrototype = NativeIteratorPrototype; |
| 2380 |
} |
| 2381 |
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); |
| 2382 |
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; |
| 2383 |
GeneratorFunctionPrototype.constructor = GeneratorFunction; |
| 2384 |
GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction"; |
| 2385 |
function defineIteratorMethods(prototype) { |
| 2386 |
["next", "throw", "return"].forEach(function (method) { |
| 2387 |
prototype[method] = function (arg) { |
| 2388 |
return this._invoke(method, arg); |
| 2389 |
}; |
| 2390 |
}); |
| 2391 |
} |
| 2392 |
runtime.isGeneratorFunction = function (genFun) { |
| 2393 |
var ctor = typeof genFun === "function" && genFun.constructor; |
| 2394 |
return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false; |
| 2395 |
}; |
| 2396 |
runtime.mark = function (genFun) { |
| 2397 |
if (Object.setPrototypeOf) { |
| 2398 |
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); |
| 2399 |
} else { |
| 2400 |
genFun.__proto__ = GeneratorFunctionPrototype; |
| 2401 |
if (!(toStringTagSymbol in genFun)) { |
| 2402 |
genFun[toStringTagSymbol] = "GeneratorFunction"; |
| 2403 |
} |
| 2404 |
} |
| 2405 |
genFun.prototype = Object.create(Gp); |
| 2406 |
return genFun; |
| 2407 |
}; |
| 2408 |
runtime.awrap = function (arg) { |
| 2409 |
return { __await: arg }; |
| 2410 |
}; |
| 2411 |
function AsyncIterator(generator) { |
| 2412 |
function invoke(method, arg, resolve, reject) { |
| 2413 |
var record = tryCatch(generator[method], generator, arg); |
| 2414 |
if (record.type === "throw") { |
| 2415 |
reject(record.arg); |
| 2416 |
} else { |
| 2417 |
var result = record.arg; |
| 2418 |
var value = result.value; |
| 2419 |
if (value && (typeof value === "undefined" ? "undefined" : _typeof(value)) === "object" && hasOwn.call(value, "__await")) { |
| 2420 |
return Promise.resolve(value.__await).then(function (value) { |
| 2421 |
invoke("next", value, resolve, reject); |
| 2422 |
}, function (err) { |
| 2423 |
invoke("throw", err, resolve, reject); |
| 2424 |
}); |
| 2425 |
} |
| 2426 |
return Promise.resolve(value).then(function (unwrapped) { |
| 2427 |
result.value = unwrapped; |
| 2428 |
resolve(result); |
| 2429 |
}, reject); |
| 2430 |
} |
| 2431 |
} |
| 2432 |
var previousPromise; |
| 2433 |
function enqueue(method, arg) { |
| 2434 |
function callInvokeWithMethodAndArg() { |
| 2435 |
return new Promise(function (resolve, reject) { |
| 2436 |
invoke(method, arg, resolve, reject); |
| 2437 |
}); |
| 2438 |
} |
| 2439 |
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); |
| 2440 |
} |
| 2441 |
this._invoke = enqueue; |
| 2442 |
} |
| 2443 |
defineIteratorMethods(AsyncIterator.prototype); |
| 2444 |
AsyncIterator.prototype[asyncIteratorSymbol] = function () { |
| 2445 |
return this; |
| 2446 |
}; |
| 2447 |
runtime.AsyncIterator = AsyncIterator; |
| 2448 |
runtime.async = function (innerFn, outerFn, self, tryLocsList) { |
| 2449 |
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList)); |
| 2450 |
return runtime.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { |
| 2451 |
return result.done ? result.value : iter.next(); |
| 2452 |
}); |
| 2453 |
}; |
| 2454 |
function makeInvokeMethod(innerFn, self, context) { |
| 2455 |
var state = GenStateSuspendedStart; |
| 2456 |
return function invoke(method, arg) { |
| 2457 |
if (state === GenStateExecuting) { |
| 2458 |
throw new Error("Generator is already running"); |
| 2459 |
} |
| 2460 |
if (state === GenStateCompleted) { |
| 2461 |
if (method === "throw") { |
| 2462 |
throw arg; |
| 2463 |
} |
| 2464 |
return doneResult(); |
| 2465 |
} |
| 2466 |
context.method = method; |
| 2467 |
context.arg = arg; |
| 2468 |
while (true) { |
| 2469 |
var delegate = context.delegate; |
| 2470 |
if (delegate) { |
| 2471 |
var delegateResult = maybeInvokeDelegate(delegate, context); |
| 2472 |
if (delegateResult) { |
| 2473 |
if (delegateResult === ContinueSentinel) continue; |
| 2474 |
return delegateResult; |
| 2475 |
} |
| 2476 |
} |
| 2477 |
if (context.method === "next") { |
| 2478 |
context.sent = context._sent = context.arg; |
| 2479 |
} else if (context.method === "throw") { |
| 2480 |
if (state === GenStateSuspendedStart) { |
| 2481 |
state = GenStateCompleted; |
| 2482 |
throw context.arg; |
| 2483 |
} |
| 2484 |
context.dispatchException(context.arg); |
| 2485 |
} else if (context.method === "return") { |
| 2486 |
context.abrupt("return", context.arg); |
| 2487 |
} |
| 2488 |
state = GenStateExecuting; |
| 2489 |
var record = tryCatch(innerFn, self, context); |
| 2490 |
if (record.type === "normal") { |
| 2491 |
state = context.done ? GenStateCompleted : GenStateSuspendedYield; |
| 2492 |
if (record.arg === ContinueSentinel) { |
| 2493 |
continue; |
| 2494 |
} |
| 2495 |
return { |
| 2496 |
value: record.arg, |
| 2497 |
done: context.done |
| 2498 |
}; |
| 2499 |
} else if (record.type === "throw") { |
| 2500 |
state = GenStateCompleted; |
| 2501 |
context.method = "throw"; |
| 2502 |
context.arg = record.arg; |
| 2503 |
} |
| 2504 |
} |
| 2505 |
}; |
| 2506 |
} |
| 2507 |
function maybeInvokeDelegate(delegate, context) { |
| 2508 |
var method = delegate.iterator[context.method]; |
| 2509 |
if (method === undefined) { |
| 2510 |
context.delegate = null; |
| 2511 |
if (context.method === "throw") { |
| 2512 |
if (delegate.iterator.return) { |
| 2513 |
context.method = "return"; |
| 2514 |
context.arg = undefined; |
| 2515 |
maybeInvokeDelegate(delegate, context); |
| 2516 |
if (context.method === "throw") { |
| 2517 |
return ContinueSentinel; |
| 2518 |
} |
| 2519 |
} |
| 2520 |
context.method = "throw"; |
| 2521 |
context.arg = new TypeError("The iterator does not provide a 'throw' method"); |
| 2522 |
} |
| 2523 |
return ContinueSentinel; |
| 2524 |
} |
| 2525 |
var record = tryCatch(method, delegate.iterator, context.arg); |
| 2526 |
if (record.type === "throw") { |
| 2527 |
context.method = "throw"; |
| 2528 |
context.arg = record.arg; |
| 2529 |
context.delegate = null; |
| 2530 |
return ContinueSentinel; |
| 2531 |
} |
| 2532 |
var info = record.arg; |
| 2533 |
if (!info) { |
| 2534 |
context.method = "throw"; |
| 2535 |
context.arg = new TypeError("iterator result is not an object"); |
| 2536 |
context.delegate = null; |
| 2537 |
return ContinueSentinel; |
| 2538 |
} |
| 2539 |
if (info.done) { |
| 2540 |
context[delegate.resultName] = info.value; |
| 2541 |
context.next = delegate.nextLoc; |
| 2542 |
if (context.method !== "return") { |
| 2543 |
context.method = "next"; |
| 2544 |
context.arg = undefined; |
| 2545 |
} |
| 2546 |
} else { |
| 2547 |
return info; |
| 2548 |
} |
| 2549 |
context.delegate = null; |
| 2550 |
return ContinueSentinel; |
| 2551 |
} |
| 2552 |
defineIteratorMethods(Gp); |
| 2553 |
Gp[toStringTagSymbol] = "Generator"; |
| 2554 |
Gp[iteratorSymbol] = function () { |
| 2555 |
return this; |
| 2556 |
}; |
| 2557 |
Gp.toString = function () { |
| 2558 |
return "[object Generator]"; |
| 2559 |
}; |
| 2560 |
function pushTryEntry(locs) { |
| 2561 |
var entry = { tryLoc: locs[0] }; |
| 2562 |
if (1 in locs) { |
| 2563 |
entry.catchLoc = locs[1]; |
| 2564 |
} |
| 2565 |
if (2 in locs) { |
| 2566 |
entry.finallyLoc = locs[2]; |
| 2567 |
entry.afterLoc = locs[3]; |
| 2568 |
} |
| 2569 |
this.tryEntries.push(entry); |
| 2570 |
} |
| 2571 |
function resetTryEntry(entry) { |
| 2572 |
var record = entry.completion || {}; |
| 2573 |
record.type = "normal"; |
| 2574 |
delete record.arg; |
| 2575 |
entry.completion = record; |
| 2576 |
} |
| 2577 |
function Context(tryLocsList) { |
| 2578 |
this.tryEntries = [{ tryLoc: "root" }]; |
| 2579 |
tryLocsList.forEach(pushTryEntry, this); |
| 2580 |
this.reset(true); |
| 2581 |
} |
| 2582 |
runtime.keys = function (object) { |
| 2583 |
var keys = []; |
| 2584 |
for (var key in object) { |
| 2585 |
keys.push(key); |
| 2586 |
} |
| 2587 |
keys.reverse(); |
| 2588 |
return function next() { |
| 2589 |
while (keys.length) { |
| 2590 |
var key = keys.pop(); |
| 2591 |
if (key in object) { |
| 2592 |
next.value = key; |
| 2593 |
next.done = false; |
| 2594 |
return next; |
| 2595 |
} |
| 2596 |
} |
| 2597 |
next.done = true; |
| 2598 |
return next; |
| 2599 |
}; |
| 2600 |
}; |
| 2601 |
function values(iterable) { |
| 2602 |
if (iterable) { |
| 2603 |
var iteratorMethod = iterable[iteratorSymbol]; |
| 2604 |
if (iteratorMethod) { |
| 2605 |
return iteratorMethod.call(iterable); |
| 2606 |
} |
| 2607 |
if (typeof iterable.next === "function") { |
| 2608 |
return iterable; |
| 2609 |
} |
| 2610 |
if (!isNaN(iterable.length)) { |
| 2611 |
var i = -1, |
| 2612 |
next = function next() { |
| 2613 |
while (++i < iterable.length) { |
| 2614 |
if (hasOwn.call(iterable, i)) { |
| 2615 |
next.value = iterable[i]; |
| 2616 |
next.done = false; |
| 2617 |
return next; |
| 2618 |
} |
| 2619 |
} |
| 2620 |
next.value = undefined; |
| 2621 |
next.done = true; |
| 2622 |
return next; |
| 2623 |
}; |
| 2624 |
return next.next = next; |
| 2625 |
} |
| 2626 |
} |
| 2627 |
return { next: doneResult }; |
| 2628 |
} |
| 2629 |
runtime.values = values; |
| 2630 |
function doneResult() { |
| 2631 |
return { |
| 2632 |
value: undefined, |
| 2633 |
done: true |
| 2634 |
}; |
| 2635 |
} |
| 2636 |
Context.prototype = { |
| 2637 |
constructor: Context, |
| 2638 |
reset: function reset(skipTempReset) { |
| 2639 |
this.prev = 0; |
| 2640 |
this.next = 0; |
| 2641 |
this.sent = this._sent = undefined; |
| 2642 |
this.done = false; |
| 2643 |
this.delegate = null; |
| 2644 |
this.method = "next"; |
| 2645 |
this.arg = undefined; |
| 2646 |
this.tryEntries.forEach(resetTryEntry); |
| 2647 |
if (!skipTempReset) { |
| 2648 |
for (var name in this) { |
| 2649 |
if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) { |
| 2650 |
this[name] = undefined; |
| 2651 |
} |
| 2652 |
} |
| 2653 |
} |
| 2654 |
}, |
| 2655 |
stop: function stop() { |
| 2656 |
this.done = true; |
| 2657 |
var rootEntry = this.tryEntries[0]; |
| 2658 |
var rootRecord = rootEntry.completion; |
| 2659 |
if (rootRecord.type === "throw") { |
| 2660 |
throw rootRecord.arg; |
| 2661 |
} |
| 2662 |
return this.rval; |
| 2663 |
}, |
| 2664 |
dispatchException: function dispatchException(exception) { |
| 2665 |
if (this.done) { |
| 2666 |
throw exception; |
| 2667 |
} |
| 2668 |
var context = this; |
| 2669 |
function handle(loc, caught) { |
| 2670 |
record.type = "throw"; |
| 2671 |
record.arg = exception; |
| 2672 |
context.next = loc; |
| 2673 |
if (caught) { |
| 2674 |
context.method = "next"; |
| 2675 |
context.arg = undefined; |
| 2676 |
} |
| 2677 |
return !!caught; |
| 2678 |
} |
| 2679 |
for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
| 2680 |
var entry = this.tryEntries[i]; |
| 2681 |
var record = entry.completion; |
| 2682 |
if (entry.tryLoc === "root") { |
| 2683 |
return handle("end"); |
| 2684 |
} |
| 2685 |
if (entry.tryLoc <= this.prev) { |
| 2686 |
var hasCatch = hasOwn.call(entry, "catchLoc"); |
| 2687 |
var hasFinally = hasOwn.call(entry, "finallyLoc"); |
| 2688 |
if (hasCatch && hasFinally) { |
| 2689 |
if (this.prev < entry.catchLoc) { |
| 2690 |
return handle(entry.catchLoc, true); |
| 2691 |
} else if (this.prev < entry.finallyLoc) { |
| 2692 |
return handle(entry.finallyLoc); |
| 2693 |
} |
| 2694 |
} else if (hasCatch) { |
| 2695 |
if (this.prev < entry.catchLoc) { |
| 2696 |
return handle(entry.catchLoc, true); |
| 2697 |
} |
| 2698 |
} else if (hasFinally) { |
| 2699 |
if (this.prev < entry.finallyLoc) { |
| 2700 |
return handle(entry.finallyLoc); |
| 2701 |
} |
| 2702 |
} else { |
| 2703 |
throw new Error("try statement without catch or finally"); |
| 2704 |
} |
| 2705 |
} |
| 2706 |
} |
| 2707 |
}, |
| 2708 |
abrupt: function abrupt(type, arg) { |
| 2709 |
for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
| 2710 |
var entry = this.tryEntries[i]; |
| 2711 |
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { |
| 2712 |
var finallyEntry = entry; |
| 2713 |
break; |
| 2714 |
} |
| 2715 |
} |
| 2716 |
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) { |
| 2717 |
finallyEntry = null; |
| 2718 |
} |
| 2719 |
var record = finallyEntry ? finallyEntry.completion : {}; |
| 2720 |
record.type = type; |
| 2721 |
record.arg = arg; |
| 2722 |
if (finallyEntry) { |
| 2723 |
this.method = "next"; |
| 2724 |
this.next = finallyEntry.finallyLoc; |
| 2725 |
return ContinueSentinel; |
| 2726 |
} |
| 2727 |
return this.complete(record); |
| 2728 |
}, |
| 2729 |
complete: function complete(record, afterLoc) { |
| 2730 |
if (record.type === "throw") { |
| 2731 |
throw record.arg; |
| 2732 |
} |
| 2733 |
if (record.type === "break" || record.type === "continue") { |
| 2734 |
this.next = record.arg; |
| 2735 |
} else if (record.type === "return") { |
| 2736 |
this.rval = this.arg = record.arg; |
| 2737 |
this.method = "return"; |
| 2738 |
this.next = "end"; |
| 2739 |
} else if (record.type === "normal" && afterLoc) { |
| 2740 |
this.next = afterLoc; |
| 2741 |
} |
| 2742 |
return ContinueSentinel; |
| 2743 |
}, |
| 2744 |
finish: function finish(finallyLoc) { |
| 2745 |
for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
| 2746 |
var entry = this.tryEntries[i]; |
| 2747 |
if (entry.finallyLoc === finallyLoc) { |
| 2748 |
this.complete(entry.completion, entry.afterLoc); |
| 2749 |
resetTryEntry(entry); |
| 2750 |
return ContinueSentinel; |
| 2751 |
} |
| 2752 |
} |
| 2753 |
}, |
| 2754 |
"catch": function _catch(tryLoc) { |
| 2755 |
for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
| 2756 |
var entry = this.tryEntries[i]; |
| 2757 |
if (entry.tryLoc === tryLoc) { |
| 2758 |
var record = entry.completion; |
| 2759 |
if (record.type === "throw") { |
| 2760 |
var thrown = record.arg; |
| 2761 |
resetTryEntry(entry); |
| 2762 |
} |
| 2763 |
return thrown; |
| 2764 |
} |
| 2765 |
} |
| 2766 |
throw new Error("illegal catch attempt"); |
| 2767 |
}, |
| 2768 |
delegateYield: function delegateYield(iterable, resultName, nextLoc) { |
| 2769 |
this.delegate = { |
| 2770 |
iterator: values(iterable), |
| 2771 |
resultName: resultName, |
| 2772 |
nextLoc: nextLoc |
| 2773 |
}; |
| 2774 |
if (this.method === "next") { |
| 2775 |
this.arg = undefined; |
| 2776 |
} |
| 2777 |
return ContinueSentinel; |
| 2778 |
} |
| 2779 |
}; |
| 2780 |
}(function () { |
| 2781 |
return this; |
| 2782 |
}() || Function("return this")()); |
| 2783 |
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(5)(module))) |
| 2784 |
|
| 2785 |
/***/ }), |
| 2786 |
/* 5 */ |
| 2787 |
/***/ (function(module, exports, __webpack_require__) { |
| 2788 |
|
| 2789 |
"use strict"; |
| 2790 |
|
| 2791 |
|
| 2792 |
module.exports = function (module) { |
| 2793 |
if (!module.webpackPolyfill) { |
| 2794 |
module.deprecate = function () {}; |
| 2795 |
module.paths = []; |
| 2796 |
if (!module.children) module.children = []; |
| 2797 |
Object.defineProperty(module, "loaded", { |
| 2798 |
enumerable: true, |
| 2799 |
get: function get() { |
| 2800 |
return module.l; |
| 2801 |
} |
| 2802 |
}); |
| 2803 |
Object.defineProperty(module, "id", { |
| 2804 |
enumerable: true, |
| 2805 |
get: function get() { |
| 2806 |
return module.i; |
| 2807 |
} |
| 2808 |
}); |
| 2809 |
module.webpackPolyfill = 1; |
| 2810 |
} |
| 2811 |
return module; |
| 2812 |
}; |
| 2813 |
|
| 2814 |
/***/ }), |
| 2815 |
/* 6 */ |
| 2816 |
/***/ (function(module, exports, __webpack_require__) { |
| 2817 |
|
| 2818 |
"use strict"; |
| 2819 |
|
| 2820 |
|
| 2821 |
Object.defineProperty(exports, "__esModule", { |
| 2822 |
value: true |
| 2823 |
}); |
| 2824 |
exports.moveToEndOfArray = exports.waitOnEventOrTimeout = exports.WaitOnType = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.getPageSizeInches = exports.roundToDivide = exports.getVisibleElements = exports.backtrackBeforeAllVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = exports.isPortraitOrientation = exports.isValidRotation = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined; |
| 2825 |
|
| 2826 |
var _regenerator = __webpack_require__(2); |
| 2827 |
|
| 2828 |
var _regenerator2 = _interopRequireDefault(_regenerator); |
| 2829 |
|
| 2830 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 2831 |
|
| 2832 |
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; |
| 2833 |
|
| 2834 |
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); |
| 2835 |
|
| 2836 |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
| 2837 |
|
| 2838 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 2839 |
|
| 2840 |
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } |
| 2841 |
|
| 2842 |
var CSS_UNITS = 96.0 / 72.0; |
| 2843 |
var DEFAULT_SCALE_VALUE = 'auto'; |
| 2844 |
var DEFAULT_SCALE = 1.0; |
| 2845 |
var MIN_SCALE = 0.10; |
| 2846 |
var MAX_SCALE = 10.0; |
| 2847 |
var UNKNOWN_SCALE = 0; |
| 2848 |
var MAX_AUTO_SCALE = 1.25; |
| 2849 |
var SCROLLBAR_PADDING = 40; |
| 2850 |
var VERTICAL_PADDING = 5; |
| 2851 |
var PresentationModeState = { |
| 2852 |
UNKNOWN: 0, |
| 2853 |
NORMAL: 1, |
| 2854 |
CHANGING: 2, |
| 2855 |
FULLSCREEN: 3 |
| 2856 |
}; |
| 2857 |
var RendererType = { |
| 2858 |
CANVAS: 'canvas', |
| 2859 |
SVG: 'svg' |
| 2860 |
}; |
| 2861 |
var TextLayerMode = { |
| 2862 |
DISABLE: 0, |
| 2863 |
ENABLE: 1, |
| 2864 |
ENABLE_ENHANCE: 2 |
| 2865 |
}; |
| 2866 |
function formatL10nValue(text, args) { |
| 2867 |
if (!args) { |
| 2868 |
return text; |
| 2869 |
} |
| 2870 |
return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) { |
| 2871 |
return name in args ? args[name] : '{{' + name + '}}'; |
| 2872 |
}); |
| 2873 |
} |
| 2874 |
var NullL10n = { |
| 2875 |
getLanguage: function () { |
| 2876 |
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() { |
| 2877 |
return _regenerator2.default.wrap(function _callee$(_context) { |
| 2878 |
while (1) { |
| 2879 |
switch (_context.prev = _context.next) { |
| 2880 |
case 0: |
| 2881 |
return _context.abrupt('return', 'en-us'); |
| 2882 |
|
| 2883 |
case 1: |
| 2884 |
case 'end': |
| 2885 |
return _context.stop(); |
| 2886 |
} |
| 2887 |
} |
| 2888 |
}, _callee, this); |
| 2889 |
})); |
| 2890 |
|
| 2891 |
function getLanguage() { |
| 2892 |
return _ref.apply(this, arguments); |
| 2893 |
} |
| 2894 |
|
| 2895 |
return getLanguage; |
| 2896 |
}(), |
| 2897 |
getDirection: function () { |
| 2898 |
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() { |
| 2899 |
return _regenerator2.default.wrap(function _callee2$(_context2) { |
| 2900 |
while (1) { |
| 2901 |
switch (_context2.prev = _context2.next) { |
| 2902 |
case 0: |
| 2903 |
return _context2.abrupt('return', 'ltr'); |
| 2904 |
|
| 2905 |
case 1: |
| 2906 |
case 'end': |
| 2907 |
return _context2.stop(); |
| 2908 |
} |
| 2909 |
} |
| 2910 |
}, _callee2, this); |
| 2911 |
})); |
| 2912 |
|
| 2913 |
function getDirection() { |
| 2914 |
return _ref2.apply(this, arguments); |
| 2915 |
} |
| 2916 |
|
| 2917 |
return getDirection; |
| 2918 |
}(), |
| 2919 |
get: function () { |
| 2920 |
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3(property, args, fallback) { |
| 2921 |
return _regenerator2.default.wrap(function _callee3$(_context3) { |
| 2922 |
while (1) { |
| 2923 |
switch (_context3.prev = _context3.next) { |
| 2924 |
case 0: |
| 2925 |
return _context3.abrupt('return', formatL10nValue(fallback, args)); |
| 2926 |
|
| 2927 |
case 1: |
| 2928 |
case 'end': |
| 2929 |
return _context3.stop(); |
| 2930 |
} |
| 2931 |
} |
| 2932 |
}, _callee3, this); |
| 2933 |
})); |
| 2934 |
|
| 2935 |
function get(_x, _x2, _x3) { |
| 2936 |
return _ref3.apply(this, arguments); |
| 2937 |
} |
| 2938 |
|
| 2939 |
return get; |
| 2940 |
}(), |
| 2941 |
translate: function () { |
| 2942 |
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4(element) { |
| 2943 |
return _regenerator2.default.wrap(function _callee4$(_context4) { |
| 2944 |
while (1) { |
| 2945 |
switch (_context4.prev = _context4.next) { |
| 2946 |
case 0: |
| 2947 |
case 'end': |
| 2948 |
return _context4.stop(); |
| 2949 |
} |
| 2950 |
} |
| 2951 |
}, _callee4, this); |
| 2952 |
})); |
| 2953 |
|
| 2954 |
function translate(_x4) { |
| 2955 |
return _ref4.apply(this, arguments); |
| 2956 |
} |
| 2957 |
|
| 2958 |
return translate; |
| 2959 |
}() |
| 2960 |
}; |
| 2961 |
function getOutputScale(ctx) { |
| 2962 |
var devicePixelRatio = window.devicePixelRatio || 1; |
| 2963 |
var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1; |
| 2964 |
var pixelRatio = devicePixelRatio / backingStoreRatio; |
| 2965 |
return { |
| 2966 |
sx: pixelRatio, |
| 2967 |
sy: pixelRatio, |
| 2968 |
scaled: pixelRatio !== 1 |
| 2969 |
}; |
| 2970 |
} |
| 2971 |
function scrollIntoView(element, spot) { |
| 2972 |
var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; |
| 2973 |
|
| 2974 |
var parent = element.offsetParent; |
| 2975 |
if (!parent) { |
| 2976 |
console.error('offsetParent is not set -- cannot scroll'); |
| 2977 |
return; |
| 2978 |
} |
| 2979 |
var offsetY = element.offsetTop + element.clientTop; |
| 2980 |
var offsetX = element.offsetLeft + element.clientLeft; |
| 2981 |
while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') { |
| 2982 |
if (parent.dataset._scaleY) { |
| 2983 |
offsetY /= parent.dataset._scaleY; |
| 2984 |
offsetX /= parent.dataset._scaleX; |
| 2985 |
} |
| 2986 |
offsetY += parent.offsetTop; |
| 2987 |
offsetX += parent.offsetLeft; |
| 2988 |
parent = parent.offsetParent; |
| 2989 |
if (!parent) { |
| 2990 |
return; |
| 2991 |
} |
| 2992 |
} |
| 2993 |
if (spot) { |
| 2994 |
if (spot.top !== undefined) { |
| 2995 |
offsetY += spot.top; |
| 2996 |
} |
| 2997 |
if (spot.left !== undefined) { |
| 2998 |
offsetX += spot.left; |
| 2999 |
parent.scrollLeft = offsetX; |
| 3000 |
} |
| 3001 |
} |
| 3002 |
parent.scrollTop = offsetY; |
| 3003 |
} |
| 3004 |
function watchScroll(viewAreaElement, callback) { |
| 3005 |
var debounceScroll = function debounceScroll(evt) { |
| 3006 |
if (rAF) { |
| 3007 |
return; |
| 3008 |
} |
| 3009 |
rAF = window.requestAnimationFrame(function viewAreaElementScrolled() { |
| 3010 |
rAF = null; |
| 3011 |
var currentX = viewAreaElement.scrollLeft; |
| 3012 |
var lastX = state.lastX; |
| 3013 |
if (currentX !== lastX) { |
| 3014 |
state.right = currentX > lastX; |
| 3015 |
} |
| 3016 |
state.lastX = currentX; |
| 3017 |
var currentY = viewAreaElement.scrollTop; |
| 3018 |
var lastY = state.lastY; |
| 3019 |
if (currentY !== lastY) { |
| 3020 |
state.down = currentY > lastY; |
| 3021 |
} |
| 3022 |
state.lastY = currentY; |
| 3023 |
callback(state); |
| 3024 |
}); |
| 3025 |
}; |
| 3026 |
var state = { |
| 3027 |
right: true, |
| 3028 |
down: true, |
| 3029 |
lastX: viewAreaElement.scrollLeft, |
| 3030 |
lastY: viewAreaElement.scrollTop, |
| 3031 |
_eventHandler: debounceScroll |
| 3032 |
}; |
| 3033 |
var rAF = null; |
| 3034 |
viewAreaElement.addEventListener('scroll', debounceScroll, true); |
| 3035 |
return state; |
| 3036 |
} |
| 3037 |
function parseQueryString(query) { |
| 3038 |
var parts = query.split('&'); |
| 3039 |
var params = Object.create(null); |
| 3040 |
for (var i = 0, ii = parts.length; i < ii; ++i) { |
| 3041 |
var param = parts[i].split('='); |
| 3042 |
var key = param[0].toLowerCase(); |
| 3043 |
var value = param.length > 1 ? param[1] : null; |
| 3044 |
params[decodeURIComponent(key)] = decodeURIComponent(value); |
| 3045 |
} |
| 3046 |
return params; |
| 3047 |
} |
| 3048 |
function binarySearchFirstItem(items, condition) { |
| 3049 |
var minIndex = 0; |
| 3050 |
var maxIndex = items.length - 1; |
| 3051 |
if (items.length === 0 || !condition(items[maxIndex])) { |
| 3052 |
return items.length; |
| 3053 |
} |
| 3054 |
if (condition(items[minIndex])) { |
| 3055 |
return minIndex; |
| 3056 |
} |
| 3057 |
while (minIndex < maxIndex) { |
| 3058 |
var currentIndex = minIndex + maxIndex >> 1; |
| 3059 |
var currentItem = items[currentIndex]; |
| 3060 |
if (condition(currentItem)) { |
| 3061 |
maxIndex = currentIndex; |
| 3062 |
} else { |
| 3063 |
minIndex = currentIndex + 1; |
| 3064 |
} |
| 3065 |
} |
| 3066 |
return minIndex; |
| 3067 |
} |
| 3068 |
function approximateFraction(x) { |
| 3069 |
if (Math.floor(x) === x) { |
| 3070 |
return [x, 1]; |
| 3071 |
} |
| 3072 |
var xinv = 1 / x; |
| 3073 |
var limit = 8; |
| 3074 |
if (xinv > limit) { |
| 3075 |
return [1, limit]; |
| 3076 |
} else if (Math.floor(xinv) === xinv) { |
| 3077 |
return [1, xinv]; |
| 3078 |
} |
| 3079 |
var x_ = x > 1 ? xinv : x; |
| 3080 |
var a = 0, |
| 3081 |
b = 1, |
| 3082 |
c = 1, |
| 3083 |
d = 1; |
| 3084 |
while (true) { |
| 3085 |
var p = a + c, |
| 3086 |
q = b + d; |
| 3087 |
if (q > limit) { |
| 3088 |
break; |
| 3089 |
} |
| 3090 |
if (x_ <= p / q) { |
| 3091 |
c = p; |
| 3092 |
d = q; |
| 3093 |
} else { |
| 3094 |
a = p; |
| 3095 |
b = q; |
| 3096 |
} |
| 3097 |
} |
| 3098 |
var result = void 0; |
| 3099 |
if (x_ - a / b < c / d - x_) { |
| 3100 |
result = x_ === x ? [a, b] : [b, a]; |
| 3101 |
} else { |
| 3102 |
result = x_ === x ? [c, d] : [d, c]; |
| 3103 |
} |
| 3104 |
return result; |
| 3105 |
} |
| 3106 |
function roundToDivide(x, div) { |
| 3107 |
var r = x % div; |
| 3108 |
return r === 0 ? x : Math.round(x - r + div); |
| 3109 |
} |
| 3110 |
function getPageSizeInches(_ref5) { |
| 3111 |
var view = _ref5.view, |
| 3112 |
userUnit = _ref5.userUnit, |
| 3113 |
rotate = _ref5.rotate; |
| 3114 |
|
| 3115 |
var _view = _slicedToArray(view, 4), |
| 3116 |
x1 = _view[0], |
| 3117 |
y1 = _view[1], |
| 3118 |
x2 = _view[2], |
| 3119 |
y2 = _view[3]; |
| 3120 |
|
| 3121 |
var changeOrientation = rotate % 180 !== 0; |
| 3122 |
var width = (x2 - x1) / 72 * userUnit; |
| 3123 |
var height = (y2 - y1) / 72 * userUnit; |
| 3124 |
return { |
| 3125 |
width: changeOrientation ? height : width, |
| 3126 |
height: changeOrientation ? width : height |
| 3127 |
}; |
| 3128 |
} |
| 3129 |
function backtrackBeforeAllVisibleElements(index, views, top) { |
| 3130 |
if (index < 2) { |
| 3131 |
return index; |
| 3132 |
} |
| 3133 |
var elt = views[index].div; |
| 3134 |
var pageTop = elt.offsetTop + elt.clientTop; |
| 3135 |
if (pageTop >= top) { |
| 3136 |
elt = views[index - 1].div; |
| 3137 |
pageTop = elt.offsetTop + elt.clientTop; |
| 3138 |
} |
| 3139 |
for (var i = index - 2; i >= 0; --i) { |
| 3140 |
elt = views[i].div; |
| 3141 |
if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) { |
| 3142 |
break; |
| 3143 |
} |
| 3144 |
index = i; |
| 3145 |
} |
| 3146 |
return index; |
| 3147 |
} |
| 3148 |
function getVisibleElements(scrollEl, views) { |
| 3149 |
var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; |
| 3150 |
var horizontal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; |
| 3151 |
|
| 3152 |
var top = scrollEl.scrollTop, |
| 3153 |
bottom = top + scrollEl.clientHeight; |
| 3154 |
var left = scrollEl.scrollLeft, |
| 3155 |
right = left + scrollEl.clientWidth; |
| 3156 |
function isElementBottomAfterViewTop(view) { |
| 3157 |
var element = view.div; |
| 3158 |
var elementBottom = element.offsetTop + element.clientTop + element.clientHeight; |
| 3159 |
return elementBottom > top; |
| 3160 |
} |
| 3161 |
function isElementRightAfterViewLeft(view) { |
| 3162 |
var element = view.div; |
| 3163 |
var elementRight = element.offsetLeft + element.clientLeft + element.clientWidth; |
| 3164 |
return elementRight > left; |
| 3165 |
} |
| 3166 |
var visible = [], |
| 3167 |
view = void 0, |
| 3168 |
element = void 0; |
| 3169 |
var currentHeight = void 0, |
| 3170 |
viewHeight = void 0, |
| 3171 |
viewBottom = void 0, |
| 3172 |
hiddenHeight = void 0; |
| 3173 |
var currentWidth = void 0, |
| 3174 |
viewWidth = void 0, |
| 3175 |
viewRight = void 0, |
| 3176 |
hiddenWidth = void 0; |
| 3177 |
var percentVisible = void 0; |
| 3178 |
var firstVisibleElementInd = views.length === 0 ? 0 : binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop); |
| 3179 |
if (views.length > 0 && !horizontal) { |
| 3180 |
firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top); |
| 3181 |
} |
| 3182 |
var lastEdge = horizontal ? right : -1; |
| 3183 |
for (var i = firstVisibleElementInd, ii = views.length; i < ii; i++) { |
| 3184 |
view = views[i]; |
| 3185 |
element = view.div; |
| 3186 |
currentWidth = element.offsetLeft + element.clientLeft; |
| 3187 |
currentHeight = element.offsetTop + element.clientTop; |
| 3188 |
viewWidth = element.clientWidth; |
| 3189 |
viewHeight = element.clientHeight; |
| 3190 |
viewRight = currentWidth + viewWidth; |
| 3191 |
viewBottom = currentHeight + viewHeight; |
| 3192 |
if (lastEdge === -1) { |
| 3193 |
if (viewBottom >= bottom) { |
| 3194 |
lastEdge = viewBottom; |
| 3195 |
} |
| 3196 |
} else if ((horizontal ? currentWidth : currentHeight) > lastEdge) { |
| 3197 |
break; |
| 3198 |
} |
| 3199 |
if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) { |
| 3200 |
continue; |
| 3201 |
} |
| 3202 |
hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom); |
| 3203 |
hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right); |
| 3204 |
percentVisible = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight / viewWidth | 0; |
| 3205 |
visible.push({ |
| 3206 |
id: view.id, |
| 3207 |
x: currentWidth, |
| 3208 |
y: currentHeight, |
| 3209 |
view: view, |
| 3210 |
percent: percentVisible |
| 3211 |
}); |
| 3212 |
} |
| 3213 |
var first = visible[0]; |
| 3214 |
var last = visible[visible.length - 1]; |
| 3215 |
if (sortByVisibility) { |
| 3216 |
visible.sort(function (a, b) { |
| 3217 |
var pc = a.percent - b.percent; |
| 3218 |
if (Math.abs(pc) > 0.001) { |
| 3219 |
return -pc; |
| 3220 |
} |
| 3221 |
return a.id - b.id; |
| 3222 |
}); |
| 3223 |
} |
| 3224 |
return { |
| 3225 |
first: first, |
| 3226 |
last: last, |
| 3227 |
views: visible |
| 3228 |
}; |
| 3229 |
} |
| 3230 |
function noContextMenuHandler(evt) { |
| 3231 |
evt.preventDefault(); |
| 3232 |
} |
| 3233 |
function isDataSchema(url) { |
| 3234 |
var i = 0, |
| 3235 |
ii = url.length; |
| 3236 |
while (i < ii && url[i].trim() === '') { |
| 3237 |
i++; |
| 3238 |
} |
| 3239 |
return url.substring(i, i + 5).toLowerCase() === 'data:'; |
| 3240 |
} |
| 3241 |
function getPDFFileNameFromURL(url) { |
| 3242 |
var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf'; |
| 3243 |
|
| 3244 |
if (typeof url !== 'string') { |
| 3245 |
return defaultFilename; |
| 3246 |
} |
| 3247 |
if (isDataSchema(url)) { |
| 3248 |
console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.'); |
| 3249 |
return defaultFilename; |
| 3250 |
} |
| 3251 |
var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/; |
| 3252 |
var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i; |
| 3253 |
var splitURI = reURI.exec(url); |
| 3254 |
var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]); |
| 3255 |
if (suggestedFilename) { |
| 3256 |
suggestedFilename = suggestedFilename[0]; |
| 3257 |
if (suggestedFilename.includes('%')) { |
| 3258 |
try { |
| 3259 |
suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0]; |
| 3260 |
} catch (ex) {} |
| 3261 |
} |
| 3262 |
} |
| 3263 |
return suggestedFilename || defaultFilename; |
| 3264 |
} |
| 3265 |
function normalizeWheelEventDelta(evt) { |
| 3266 |
var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY); |
| 3267 |
var angle = Math.atan2(evt.deltaY, evt.deltaX); |
| 3268 |
if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) { |
| 3269 |
delta = -delta; |
| 3270 |
} |
| 3271 |
var MOUSE_DOM_DELTA_PIXEL_MODE = 0; |
| 3272 |
var MOUSE_DOM_DELTA_LINE_MODE = 1; |
| 3273 |
var MOUSE_PIXELS_PER_LINE = 30; |
| 3274 |
var MOUSE_LINES_PER_PAGE = 30; |
| 3275 |
if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) { |
| 3276 |
delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE; |
| 3277 |
} else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) { |
| 3278 |
delta /= MOUSE_LINES_PER_PAGE; |
| 3279 |
} |
| 3280 |
return delta; |
| 3281 |
} |
| 3282 |
function isValidRotation(angle) { |
| 3283 |
return Number.isInteger(angle) && angle % 90 === 0; |
| 3284 |
} |
| 3285 |
function isPortraitOrientation(size) { |
| 3286 |
return size.width <= size.height; |
| 3287 |
} |
| 3288 |
var WaitOnType = { |
| 3289 |
EVENT: 'event', |
| 3290 |
TIMEOUT: 'timeout' |
| 3291 |
}; |
| 3292 |
function waitOnEventOrTimeout(_ref6) { |
| 3293 |
var target = _ref6.target, |
| 3294 |
name = _ref6.name, |
| 3295 |
_ref6$delay = _ref6.delay, |
| 3296 |
delay = _ref6$delay === undefined ? 0 : _ref6$delay; |
| 3297 |
|
| 3298 |
return new Promise(function (resolve, reject) { |
| 3299 |
if ((typeof target === 'undefined' ? 'undefined' : _typeof(target)) !== 'object' || !(name && typeof name === 'string') || !(Number.isInteger(delay) && delay >= 0)) { |
| 3300 |
throw new Error('waitOnEventOrTimeout - invalid parameters.'); |
| 3301 |
} |
| 3302 |
function handler(type) { |
| 3303 |
if (target instanceof EventBus) { |
| 3304 |
target.off(name, eventHandler); |
| 3305 |
} else { |
| 3306 |
target.removeEventListener(name, eventHandler); |
| 3307 |
} |
| 3308 |
if (timeout) { |
| 3309 |
clearTimeout(timeout); |
| 3310 |
} |
| 3311 |
resolve(type); |
| 3312 |
} |
| 3313 |
var eventHandler = handler.bind(null, WaitOnType.EVENT); |
| 3314 |
if (target instanceof EventBus) { |
| 3315 |
target.on(name, eventHandler); |
| 3316 |
} else { |
| 3317 |
target.addEventListener(name, eventHandler); |
| 3318 |
} |
| 3319 |
var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT); |
| 3320 |
var timeout = setTimeout(timeoutHandler, delay); |
| 3321 |
}); |
| 3322 |
} |
| 3323 |
var animationStarted = new Promise(function (resolve) { |
| 3324 |
window.requestAnimationFrame(resolve); |
| 3325 |
}); |
| 3326 |
|
| 3327 |
var EventBus = function () { |
| 3328 |
function EventBus() { |
| 3329 |
var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, |
| 3330 |
_ref7$dispatchToDOM = _ref7.dispatchToDOM, |
| 3331 |
dispatchToDOM = _ref7$dispatchToDOM === undefined ? false : _ref7$dispatchToDOM; |
| 3332 |
|
| 3333 |
_classCallCheck(this, EventBus); |
| 3334 |
|
| 3335 |
this._listeners = Object.create(null); |
| 3336 |
this._dispatchToDOM = dispatchToDOM === true; |
| 3337 |
} |
| 3338 |
|
| 3339 |
_createClass(EventBus, [{ |
| 3340 |
key: 'on', |
| 3341 |
value: function on(eventName, listener) { |
| 3342 |
var eventListeners = this._listeners[eventName]; |
| 3343 |
if (!eventListeners) { |
| 3344 |
eventListeners = []; |
| 3345 |
this._listeners[eventName] = eventListeners; |
| 3346 |
} |
| 3347 |
eventListeners.push(listener); |
| 3348 |
} |
| 3349 |
}, { |
| 3350 |
key: 'off', |
| 3351 |
value: function off(eventName, listener) { |
| 3352 |
var eventListeners = this._listeners[eventName]; |
| 3353 |
var i = void 0; |
| 3354 |
if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) { |
| 3355 |
return; |
| 3356 |
} |
| 3357 |
eventListeners.splice(i, 1); |
| 3358 |
} |
| 3359 |
}, { |
| 3360 |
key: 'dispatch', |
| 3361 |
value: function dispatch(eventName) { |
| 3362 |
var eventListeners = this._listeners[eventName]; |
| 3363 |
if (!eventListeners || eventListeners.length === 0) { |
| 3364 |
if (this._dispatchToDOM) { |
| 3365 |
var _args5 = Array.prototype.slice.call(arguments, 1); |
| 3366 |
this._dispatchDOMEvent(eventName, _args5); |
| 3367 |
} |
| 3368 |
return; |
| 3369 |
} |
| 3370 |
var args = Array.prototype.slice.call(arguments, 1); |
| 3371 |
eventListeners.slice(0).forEach(function (listener) { |
| 3372 |
listener.apply(null, args); |
| 3373 |
}); |
| 3374 |
if (this._dispatchToDOM) { |
| 3375 |
this._dispatchDOMEvent(eventName, args); |
| 3376 |
} |
| 3377 |
} |
| 3378 |
}, { |
| 3379 |
key: '_dispatchDOMEvent', |
| 3380 |
value: function _dispatchDOMEvent(eventName) { |
| 3381 |
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; |
| 3382 |
|
| 3383 |
if (!this._dispatchToDOM) { |
| 3384 |
return; |
| 3385 |
} |
| 3386 |
var details = Object.create(null); |
| 3387 |
if (args && args.length > 0) { |
| 3388 |
var obj = args[0]; |
| 3389 |
for (var key in obj) { |
| 3390 |
var value = obj[key]; |
| 3391 |
if (key === 'source') { |
| 3392 |
if (value === window || value === document) { |
| 3393 |
return; |
| 3394 |
} |
| 3395 |
continue; |
| 3396 |
} |
| 3397 |
details[key] = value; |
| 3398 |
} |
| 3399 |
} |
| 3400 |
var event = document.createEvent('CustomEvent'); |
| 3401 |
event.initCustomEvent(eventName, true, true, details); |
| 3402 |
document.dispatchEvent(event); |
| 3403 |
} |
| 3404 |
}]); |
| 3405 |
|
| 3406 |
return EventBus; |
| 3407 |
}(); |
| 3408 |
|
| 3409 |
function clamp(v, min, max) { |
| 3410 |
return Math.min(Math.max(v, min), max); |
| 3411 |
} |
| 3412 |
|
| 3413 |
var ProgressBar = function () { |
| 3414 |
function ProgressBar(id) { |
| 3415 |
var _ref8 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, |
| 3416 |
height = _ref8.height, |
| 3417 |
width = _ref8.width, |
| 3418 |
units = _ref8.units; |
| 3419 |
|
| 3420 |
_classCallCheck(this, ProgressBar); |
| 3421 |
|
| 3422 |
this.visible = true; |
| 3423 |
this.div = document.querySelector(id + ' .progress'); |
| 3424 |
this.bar = this.div.parentNode; |
| 3425 |
this.height = height || 100; |
| 3426 |
this.width = width || 100; |
| 3427 |
this.units = units || '%'; |
| 3428 |
this.div.style.height = this.height + this.units; |
| 3429 |
this.percent = 0; |
| 3430 |
} |
| 3431 |
|
| 3432 |
_createClass(ProgressBar, [{ |
| 3433 |
key: '_updateBar', |
| 3434 |
value: function _updateBar() { |
| 3435 |
if (this._indeterminate) { |
| 3436 |
this.div.classList.add('indeterminate'); |
| 3437 |
this.div.style.width = this.width + this.units; |
| 3438 |
return; |
| 3439 |
} |
| 3440 |
this.div.classList.remove('indeterminate'); |
| 3441 |
var progressSize = this.width * this._percent / 100; |
| 3442 |
this.div.style.width = progressSize + this.units; |
| 3443 |
} |
| 3444 |
}, { |
| 3445 |
key: 'setWidth', |
| 3446 |
value: function setWidth(viewer) { |
| 3447 |
if (!viewer) { |
| 3448 |
return; |
| 3449 |
} |
| 3450 |
var container = viewer.parentNode; |
| 3451 |
var scrollbarWidth = container.offsetWidth - viewer.offsetWidth; |
| 3452 |
if (scrollbarWidth > 0) { |
| 3453 |
this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);'); |
| 3454 |
} |
| 3455 |
} |
| 3456 |
}, { |
| 3457 |
key: 'hide', |
| 3458 |
value: function hide() { |
| 3459 |
if (!this.visible) { |
| 3460 |
return; |
| 3461 |
} |
| 3462 |
this.visible = false; |
| 3463 |
this.bar.classList.add('hidden'); |
| 3464 |
document.body.classList.remove('loadingInProgress'); |
| 3465 |
} |
| 3466 |
}, { |
| 3467 |
key: 'show', |
| 3468 |
value: function show() { |
| 3469 |
if (this.visible) { |
| 3470 |
return; |
| 3471 |
} |
| 3472 |
this.visible = true; |
| 3473 |
document.body.classList.add('loadingInProgress'); |
| 3474 |
this.bar.classList.remove('hidden'); |
| 3475 |
} |
| 3476 |
}, { |
| 3477 |
key: 'percent', |
| 3478 |
get: function get() { |
| 3479 |
return this._percent; |
| 3480 |
}, |
| 3481 |
set: function set(val) { |
| 3482 |
this._indeterminate = isNaN(val); |
| 3483 |
this._percent = clamp(val, 0, 100); |
| 3484 |
this._updateBar(); |
| 3485 |
} |
| 3486 |
}]); |
| 3487 |
|
| 3488 |
return ProgressBar; |
| 3489 |
}(); |
| 3490 |
|
| 3491 |
function moveToEndOfArray(arr, condition) { |
| 3492 |
var moved = [], |
| 3493 |
len = arr.length; |
| 3494 |
var write = 0; |
| 3495 |
for (var read = 0; read < len; ++read) { |
| 3496 |
if (condition(arr[read])) { |
| 3497 |
moved.push(arr[read]); |
| 3498 |
} else { |
| 3499 |
arr[write] = arr[read]; |
| 3500 |
++write; |
| 3501 |
} |
| 3502 |
} |
| 3503 |
for (var _read = 0; write < len; ++_read, ++write) { |
| 3504 |
arr[write] = moved[_read]; |
| 3505 |
} |
| 3506 |
} |
| 3507 |
exports.CSS_UNITS = CSS_UNITS; |
| 3508 |
exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE; |
| 3509 |
exports.DEFAULT_SCALE = DEFAULT_SCALE; |
| 3510 |
exports.MIN_SCALE = MIN_SCALE; |
| 3511 |
exports.MAX_SCALE = MAX_SCALE; |
| 3512 |
exports.UNKNOWN_SCALE = UNKNOWN_SCALE; |
| 3513 |
exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE; |
| 3514 |
exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING; |
| 3515 |
exports.VERTICAL_PADDING = VERTICAL_PADDING; |
| 3516 |
exports.isValidRotation = isValidRotation; |
| 3517 |
exports.isPortraitOrientation = isPortraitOrientation; |
| 3518 |
exports.PresentationModeState = PresentationModeState; |
| 3519 |
exports.RendererType = RendererType; |
| 3520 |
exports.TextLayerMode = TextLayerMode; |
| 3521 |
exports.NullL10n = NullL10n; |
| 3522 |
exports.EventBus = EventBus; |
| 3523 |
exports.ProgressBar = ProgressBar; |
| 3524 |
exports.getPDFFileNameFromURL = getPDFFileNameFromURL; |
| 3525 |
exports.noContextMenuHandler = noContextMenuHandler; |
| 3526 |
exports.parseQueryString = parseQueryString; |
| 3527 |
exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements; |
| 3528 |
exports.getVisibleElements = getVisibleElements; |
| 3529 |
exports.roundToDivide = roundToDivide; |
| 3530 |
exports.getPageSizeInches = getPageSizeInches; |
| 3531 |
exports.approximateFraction = approximateFraction; |
| 3532 |
exports.getOutputScale = getOutputScale; |
| 3533 |
exports.scrollIntoView = scrollIntoView; |
| 3534 |
exports.watchScroll = watchScroll; |
| 3535 |
exports.binarySearchFirstItem = binarySearchFirstItem; |
| 3536 |
exports.normalizeWheelEventDelta = normalizeWheelEventDelta; |
| 3537 |
exports.animationStarted = animationStarted; |
| 3538 |
exports.WaitOnType = WaitOnType; |
| 3539 |
exports.waitOnEventOrTimeout = waitOnEventOrTimeout; |
| 3540 |
exports.moveToEndOfArray = moveToEndOfArray; |
| 3541 |
|
| 3542 |
/***/ }), |
| 3543 |
/* 7 */ |
| 3544 |
/***/ (function(module, exports, __webpack_require__) { |
| 3545 |
|
| 3546 |
"use strict"; |
| 3547 |
|
| 3548 |
|
| 3549 |
var pdfjsLib = void 0; |
| 3550 |
if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) { |
| 3551 |
pdfjsLib = window['pdfjs-dist/build/pdf']; |
| 3552 |
} else { |
| 3553 |
pdfjsLib = require('../build/pdf.js'); |
| 3554 |
} |
| 3555 |
module.exports = pdfjsLib; |
| 3556 |
|
| 3557 |
/***/ }), |
| 3558 |
/* 8 */ |
| 3559 |
/***/ (function(module, exports, __webpack_require__) { |
| 3560 |
|
| 3561 |
"use strict"; |
| 3562 |
|
| 3563 |
|
| 3564 |
Object.defineProperty(exports, "__esModule", { |
| 3565 |
value: true |
| 3566 |
}); |
| 3567 |
exports.PDFCursorTools = exports.CursorTool = undefined; |
| 3568 |
|
| 3569 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 3570 |
|
| 3571 |
var _grab_to_pan = __webpack_require__(9); |
| 3572 |
|
| 3573 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 3574 |
|
| 3575 |
var CursorTool = { |
| 3576 |
SELECT: 0, |
| 3577 |
HAND: 1, |
| 3578 |
ZOOM: 2 |
| 3579 |
}; |
| 3580 |
|
| 3581 |
var PDFCursorTools = function () { |
| 3582 |
function PDFCursorTools(_ref) { |
| 3583 |
var _this = this; |
| 3584 |
|
| 3585 |
var container = _ref.container, |
| 3586 |
eventBus = _ref.eventBus, |
| 3587 |
_ref$cursorToolOnLoad = _ref.cursorToolOnLoad, |
| 3588 |
cursorToolOnLoad = _ref$cursorToolOnLoad === undefined ? CursorTool.SELECT : _ref$cursorToolOnLoad; |
| 3589 |
|
| 3590 |
_classCallCheck(this, PDFCursorTools); |
| 3591 |
|
| 3592 |
this.container = container; |
| 3593 |
this.eventBus = eventBus; |
| 3594 |
this.active = CursorTool.SELECT; |
| 3595 |
this.activeBeforePresentationMode = null; |
| 3596 |
this.handTool = new _grab_to_pan.GrabToPan({ element: this.container }); |
| 3597 |
this._addEventListeners(); |
| 3598 |
Promise.resolve().then(function () { |
| 3599 |
_this.switchTool(cursorToolOnLoad); |
| 3600 |
}); |
| 3601 |
} |
| 3602 |
|
| 3603 |
_createClass(PDFCursorTools, [{ |
| 3604 |
key: 'switchTool', |
| 3605 |
value: function switchTool(tool) { |
| 3606 |
var _this2 = this; |
| 3607 |
|
| 3608 |
if (this.activeBeforePresentationMode !== null) { |
| 3609 |
return; |
| 3610 |
} |
| 3611 |
if (tool === this.active) { |
| 3612 |
return; |
| 3613 |
} |
| 3614 |
var disableActiveTool = function disableActiveTool() { |
| 3615 |
switch (_this2.active) { |
| 3616 |
case CursorTool.SELECT: |
| 3617 |
break; |
| 3618 |
case CursorTool.HAND: |
| 3619 |
_this2.handTool.deactivate(); |
| 3620 |
break; |
| 3621 |
case CursorTool.ZOOM: |
| 3622 |
} |
| 3623 |
}; |
| 3624 |
switch (tool) { |
| 3625 |
case CursorTool.SELECT: |
| 3626 |
disableActiveTool(); |
| 3627 |
break; |
| 3628 |
case CursorTool.HAND: |
| 3629 |
disableActiveTool(); |
| 3630 |
this.handTool.activate(); |
| 3631 |
break; |
| 3632 |
case CursorTool.ZOOM: |
| 3633 |
default: |
| 3634 |
console.error('switchTool: "' + tool + '" is an unsupported value.'); |
| 3635 |
return; |
| 3636 |
} |
| 3637 |
this.active = tool; |
| 3638 |
this._dispatchEvent(); |
| 3639 |
} |
| 3640 |
}, { |
| 3641 |
key: '_dispatchEvent', |
| 3642 |
value: function _dispatchEvent() { |
| 3643 |
this.eventBus.dispatch('cursortoolchanged', { |
| 3644 |
source: this, |
| 3645 |
tool: this.active |
| 3646 |
}); |
| 3647 |
} |
| 3648 |
}, { |
| 3649 |
key: '_addEventListeners', |
| 3650 |
value: function _addEventListeners() { |
| 3651 |
var _this3 = this; |
| 3652 |
|
| 3653 |
this.eventBus.on('switchcursortool', function (evt) { |
| 3654 |
_this3.switchTool(evt.tool); |
| 3655 |
}); |
| 3656 |
this.eventBus.on('presentationmodechanged', function (evt) { |
| 3657 |
if (evt.switchInProgress) { |
| 3658 |
return; |
| 3659 |
} |
| 3660 |
var previouslyActive = void 0; |
| 3661 |
if (evt.active) { |
| 3662 |
previouslyActive = _this3.active; |
| 3663 |
_this3.switchTool(CursorTool.SELECT); |
| 3664 |
_this3.activeBeforePresentationMode = previouslyActive; |
| 3665 |
} else { |
| 3666 |
previouslyActive = _this3.activeBeforePresentationMode; |
| 3667 |
_this3.activeBeforePresentationMode = null; |
| 3668 |
_this3.switchTool(previouslyActive); |
| 3669 |
} |
| 3670 |
}); |
| 3671 |
} |
| 3672 |
}, { |
| 3673 |
key: 'activeTool', |
| 3674 |
get: function get() { |
| 3675 |
return this.active; |
| 3676 |
} |
| 3677 |
}]); |
| 3678 |
|
| 3679 |
return PDFCursorTools; |
| 3680 |
}(); |
| 3681 |
|
| 3682 |
exports.CursorTool = CursorTool; |
| 3683 |
exports.PDFCursorTools = PDFCursorTools; |
| 3684 |
|
| 3685 |
/***/ }), |
| 3686 |
/* 9 */ |
| 3687 |
/***/ (function(module, exports, __webpack_require__) { |
| 3688 |
|
| 3689 |
"use strict"; |
| 3690 |
|
| 3691 |
|
| 3692 |
Object.defineProperty(exports, "__esModule", { |
| 3693 |
value: true |
| 3694 |
}); |
| 3695 |
function GrabToPan(options) { |
| 3696 |
this.element = options.element; |
| 3697 |
this.document = options.element.ownerDocument; |
| 3698 |
if (typeof options.ignoreTarget === 'function') { |
| 3699 |
this.ignoreTarget = options.ignoreTarget; |
| 3700 |
} |
| 3701 |
this.onActiveChanged = options.onActiveChanged; |
| 3702 |
this.activate = this.activate.bind(this); |
| 3703 |
this.deactivate = this.deactivate.bind(this); |
| 3704 |
this.toggle = this.toggle.bind(this); |
| 3705 |
this._onmousedown = this._onmousedown.bind(this); |
| 3706 |
this._onmousemove = this._onmousemove.bind(this); |
| 3707 |
this._endPan = this._endPan.bind(this); |
| 3708 |
var overlay = this.overlay = document.createElement('div'); |
| 3709 |
overlay.className = 'grab-to-pan-grabbing'; |
| 3710 |
} |
| 3711 |
GrabToPan.prototype = { |
| 3712 |
CSS_CLASS_GRAB: 'grab-to-pan-grab', |
| 3713 |
activate: function GrabToPan_activate() { |
| 3714 |
if (!this.active) { |
| 3715 |
this.active = true; |
| 3716 |
this.element.addEventListener('mousedown', this._onmousedown, true); |
| 3717 |
this.element.classList.add(this.CSS_CLASS_GRAB); |
| 3718 |
if (this.onActiveChanged) { |
| 3719 |
this.onActiveChanged(true); |
| 3720 |
} |
| 3721 |
} |
| 3722 |
}, |
| 3723 |
deactivate: function GrabToPan_deactivate() { |
| 3724 |
if (this.active) { |
| 3725 |
this.active = false; |
| 3726 |
this.element.removeEventListener('mousedown', this._onmousedown, true); |
| 3727 |
this._endPan(); |
| 3728 |
this.element.classList.remove(this.CSS_CLASS_GRAB); |
| 3729 |
if (this.onActiveChanged) { |
| 3730 |
this.onActiveChanged(false); |
| 3731 |
} |
| 3732 |
} |
| 3733 |
}, |
| 3734 |
toggle: function GrabToPan_toggle() { |
| 3735 |
if (this.active) { |
| 3736 |
this.deactivate(); |
| 3737 |
} else { |
| 3738 |
this.activate(); |
| 3739 |
} |
| 3740 |
}, |
| 3741 |
ignoreTarget: function GrabToPan_ignoreTarget(node) { |
| 3742 |
return node[matchesSelector]('a[href], a[href] *, input, textarea, button, button *, select, option'); |
| 3743 |
}, |
| 3744 |
_onmousedown: function GrabToPan__onmousedown(event) { |
| 3745 |
if (event.button !== 0 || this.ignoreTarget(event.target)) { |
| 3746 |
return; |
| 3747 |
} |
| 3748 |
if (event.originalTarget) { |
| 3749 |
try { |
| 3750 |
event.originalTarget.tagName; |
| 3751 |
} catch (e) { |
| 3752 |
return; |
| 3753 |
} |
| 3754 |
} |
| 3755 |
this.scrollLeftStart = this.element.scrollLeft; |
| 3756 |
this.scrollTopStart = this.element.scrollTop; |
| 3757 |
this.clientXStart = event.clientX; |
| 3758 |
this.clientYStart = event.clientY; |
| 3759 |
this.document.addEventListener('mousemove', this._onmousemove, true); |
| 3760 |
this.document.addEventListener('mouseup', this._endPan, true); |
| 3761 |
this.element.addEventListener('scroll', this._endPan, true); |
| 3762 |
event.preventDefault(); |
| 3763 |
event.stopPropagation(); |
| 3764 |
var focusedElement = document.activeElement; |
| 3765 |
if (focusedElement && !focusedElement.contains(event.target)) { |
| 3766 |
focusedElement.blur(); |
| 3767 |
} |
| 3768 |
}, |
| 3769 |
_onmousemove: function GrabToPan__onmousemove(event) { |
| 3770 |
this.element.removeEventListener('scroll', this._endPan, true); |
| 3771 |
if (isLeftMouseReleased(event)) { |
| 3772 |
this._endPan(); |
| 3773 |
return; |
| 3774 |
} |
| 3775 |
var xDiff = event.clientX - this.clientXStart; |
| 3776 |
var yDiff = event.clientY - this.clientYStart; |
| 3777 |
var scrollTop = this.scrollTopStart - yDiff; |
| 3778 |
var scrollLeft = this.scrollLeftStart - xDiff; |
| 3779 |
if (this.element.scrollTo) { |
| 3780 |
this.element.scrollTo({ |
| 3781 |
top: scrollTop, |
| 3782 |
left: scrollLeft, |
| 3783 |
behavior: 'instant' |
| 3784 |
}); |
| 3785 |
} else { |
| 3786 |
this.element.scrollTop = scrollTop; |
| 3787 |
this.element.scrollLeft = scrollLeft; |
| 3788 |
} |
| 3789 |
if (!this.overlay.parentNode) { |
| 3790 |
document.body.appendChild(this.overlay); |
| 3791 |
} |
| 3792 |
}, |
| 3793 |
_endPan: function GrabToPan__endPan() { |
| 3794 |
this.element.removeEventListener('scroll', this._endPan, true); |
| 3795 |
this.document.removeEventListener('mousemove', this._onmousemove, true); |
| 3796 |
this.document.removeEventListener('mouseup', this._endPan, true); |
| 3797 |
this.overlay.remove(); |
| 3798 |
} |
| 3799 |
}; |
| 3800 |
var matchesSelector; |
| 3801 |
['webkitM', 'mozM', 'msM', 'oM', 'm'].some(function (prefix) { |
| 3802 |
var name = prefix + 'atches'; |
| 3803 |
if (name in document.documentElement) { |
| 3804 |
matchesSelector = name; |
| 3805 |
} |
| 3806 |
name += 'Selector'; |
| 3807 |
if (name in document.documentElement) { |
| 3808 |
matchesSelector = name; |
| 3809 |
} |
| 3810 |
return matchesSelector; |
| 3811 |
}); |
| 3812 |
var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9; |
| 3813 |
var chrome = window.chrome; |
| 3814 |
var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app); |
| 3815 |
var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent); |
| 3816 |
function isLeftMouseReleased(event) { |
| 3817 |
if ('buttons' in event && isNotIEorIsIE10plus) { |
| 3818 |
return !(event.buttons & 1); |
| 3819 |
} |
| 3820 |
if (isChrome15OrOpera15plus || isSafari6plus) { |
| 3821 |
return event.which === 0; |
| 3822 |
} |
| 3823 |
} |
| 3824 |
exports.GrabToPan = GrabToPan; |
| 3825 |
|
| 3826 |
/***/ }), |
| 3827 |
/* 10 */ |
| 3828 |
/***/ (function(module, exports, __webpack_require__) { |
| 3829 |
|
| 3830 |
"use strict"; |
| 3831 |
|
| 3832 |
|
| 3833 |
Object.defineProperty(exports, "__esModule", { |
| 3834 |
value: true |
| 3835 |
}); |
| 3836 |
|
| 3837 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 3838 |
|
| 3839 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 3840 |
|
| 3841 |
var CLEANUP_TIMEOUT = 30000; |
| 3842 |
var RenderingStates = { |
| 3843 |
INITIAL: 0, |
| 3844 |
RUNNING: 1, |
| 3845 |
PAUSED: 2, |
| 3846 |
FINISHED: 3 |
| 3847 |
}; |
| 3848 |
|
| 3849 |
var PDFRenderingQueue = function () { |
| 3850 |
function PDFRenderingQueue() { |
| 3851 |
_classCallCheck(this, PDFRenderingQueue); |
| 3852 |
|
| 3853 |
this.pdfViewer = null; |
| 3854 |
this.pdfThumbnailViewer = null; |
| 3855 |
this.onIdle = null; |
| 3856 |
this.highestPriorityPage = null; |
| 3857 |
this.idleTimeout = null; |
| 3858 |
this.printing = false; |
| 3859 |
this.isThumbnailViewEnabled = false; |
| 3860 |
} |
| 3861 |
|
| 3862 |
_createClass(PDFRenderingQueue, [{ |
| 3863 |
key: "setViewer", |
| 3864 |
value: function setViewer(pdfViewer) { |
| 3865 |
this.pdfViewer = pdfViewer; |
| 3866 |
} |
| 3867 |
}, { |
| 3868 |
key: "setThumbnailViewer", |
| 3869 |
value: function setThumbnailViewer(pdfThumbnailViewer) { |
| 3870 |
this.pdfThumbnailViewer = pdfThumbnailViewer; |
| 3871 |
} |
| 3872 |
}, { |
| 3873 |
key: "isHighestPriority", |
| 3874 |
value: function isHighestPriority(view) { |
| 3875 |
return this.highestPriorityPage === view.renderingId; |
| 3876 |
} |
| 3877 |
}, { |
| 3878 |
key: "renderHighestPriority", |
| 3879 |
value: function renderHighestPriority(currentlyVisiblePages) { |
| 3880 |
if (this.idleTimeout) { |
| 3881 |
clearTimeout(this.idleTimeout); |
| 3882 |
this.idleTimeout = null; |
| 3883 |
} |
| 3884 |
if (this.pdfViewer.forceRendering(currentlyVisiblePages)) { |
| 3885 |
return; |
| 3886 |
} |
| 3887 |
if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) { |
| 3888 |
if (this.pdfThumbnailViewer.forceRendering()) { |
| 3889 |
return; |
| 3890 |
} |
| 3891 |
} |
| 3892 |
if (this.printing) { |
| 3893 |
return; |
| 3894 |
} |
| 3895 |
if (this.onIdle) { |
| 3896 |
this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT); |
| 3897 |
} |
| 3898 |
} |
| 3899 |
}, { |
| 3900 |
key: "getHighestPriority", |
| 3901 |
value: function getHighestPriority(visible, views, scrolledDown) { |
| 3902 |
var visibleViews = visible.views; |
| 3903 |
var numVisible = visibleViews.length; |
| 3904 |
if (numVisible === 0) { |
| 3905 |
return false; |
| 3906 |
} |
| 3907 |
for (var i = 0; i < numVisible; ++i) { |
| 3908 |
var view = visibleViews[i].view; |
| 3909 |
if (!this.isViewFinished(view)) { |
| 3910 |
return view; |
| 3911 |
} |
| 3912 |
} |
| 3913 |
if (scrolledDown) { |
| 3914 |
var nextPageIndex = visible.last.id; |
| 3915 |
if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) { |
| 3916 |
return views[nextPageIndex]; |
| 3917 |
} |
| 3918 |
} else { |
| 3919 |
var previousPageIndex = visible.first.id - 2; |
| 3920 |
if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) { |
| 3921 |
return views[previousPageIndex]; |
| 3922 |
} |
| 3923 |
} |
| 3924 |
return null; |
| 3925 |
} |
| 3926 |
}, { |
| 3927 |
key: "isViewFinished", |
| 3928 |
value: function isViewFinished(view) { |
| 3929 |
return view.renderingState === RenderingStates.FINISHED; |
| 3930 |
} |
| 3931 |
}, { |
| 3932 |
key: "renderView", |
| 3933 |
value: function renderView(view) { |
| 3934 |
var _this = this; |
| 3935 |
|
| 3936 |
switch (view.renderingState) { |
| 3937 |
case RenderingStates.FINISHED: |
| 3938 |
return false; |
| 3939 |
case RenderingStates.PAUSED: |
| 3940 |
this.highestPriorityPage = view.renderingId; |
| 3941 |
view.resume(); |
| 3942 |
break; |
| 3943 |
case RenderingStates.RUNNING: |
| 3944 |
this.highestPriorityPage = view.renderingId; |
| 3945 |
break; |
| 3946 |
case RenderingStates.INITIAL: |
| 3947 |
this.highestPriorityPage = view.renderingId; |
| 3948 |
var continueRendering = function continueRendering() { |
| 3949 |
_this.renderHighestPriority(); |
| 3950 |
}; |
| 3951 |
view.draw().then(continueRendering, continueRendering); |
| 3952 |
break; |
| 3953 |
} |
| 3954 |
return true; |
| 3955 |
} |
| 3956 |
}]); |
| 3957 |
|
| 3958 |
return PDFRenderingQueue; |
| 3959 |
}(); |
| 3960 |
|
| 3961 |
exports.RenderingStates = RenderingStates; |
| 3962 |
exports.PDFRenderingQueue = PDFRenderingQueue; |
| 3963 |
|
| 3964 |
/***/ }), |
| 3965 |
/* 11 */ |
| 3966 |
/***/ (function(module, exports, __webpack_require__) { |
| 3967 |
|
| 3968 |
"use strict"; |
| 3969 |
|
| 3970 |
|
| 3971 |
Object.defineProperty(exports, "__esModule", { |
| 3972 |
value: true |
| 3973 |
}); |
| 3974 |
exports.PDFSidebar = exports.SidebarView = undefined; |
| 3975 |
|
| 3976 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 3977 |
|
| 3978 |
var _ui_utils = __webpack_require__(6); |
| 3979 |
|
| 3980 |
var _pdf_rendering_queue = __webpack_require__(10); |
| 3981 |
|
| 3982 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 3983 |
|
| 3984 |
var UI_NOTIFICATION_CLASS = 'pdfSidebarNotification'; |
| 3985 |
var SidebarView = { |
| 3986 |
NONE: 0, |
| 3987 |
THUMBS: 1, |
| 3988 |
OUTLINE: 2, |
| 3989 |
ATTACHMENTS: 3 |
| 3990 |
}; |
| 3991 |
|
| 3992 |
var PDFSidebar = function () { |
| 3993 |
function PDFSidebar(options, eventBus) { |
| 3994 |
var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n; |
| 3995 |
|
| 3996 |
_classCallCheck(this, PDFSidebar); |
| 3997 |
|
| 3998 |
this.isOpen = false; |
| 3999 |
this.active = SidebarView.THUMBS; |
| 4000 |
this.isInitialViewSet = false; |
| 4001 |
this.onToggled = null; |
| 4002 |
this.pdfViewer = options.pdfViewer; |
| 4003 |
this.pdfThumbnailViewer = options.pdfThumbnailViewer; |
| 4004 |
this.outerContainer = options.outerContainer; |
| 4005 |
this.viewerContainer = options.viewerContainer; |
| 4006 |
this.toggleButton = options.toggleButton; |
| 4007 |
this.thumbnailButton = options.thumbnailButton; |
| 4008 |
this.outlineButton = options.outlineButton; |
| 4009 |
this.attachmentsButton = options.attachmentsButton; |
| 4010 |
this.thumbnailView = options.thumbnailView; |
| 4011 |
this.outlineView = options.outlineView; |
| 4012 |
this.attachmentsView = options.attachmentsView; |
| 4013 |
this.disableNotification = options.disableNotification || false; |
| 4014 |
this.eventBus = eventBus; |
| 4015 |
this.l10n = l10n; |
| 4016 |
this._addEventListeners(); |
| 4017 |
} |
| 4018 |
|
| 4019 |
_createClass(PDFSidebar, [{ |
| 4020 |
key: 'reset', |
| 4021 |
value: function reset() { |
| 4022 |
this.isInitialViewSet = false; |
| 4023 |
this._hideUINotification(null); |
| 4024 |
this.switchView(SidebarView.THUMBS); |
| 4025 |
this.outlineButton.disabled = false; |
| 4026 |
this.attachmentsButton.disabled = false; |
| 4027 |
} |
| 4028 |
}, { |
| 4029 |
key: 'setInitialView', |
| 4030 |
value: function setInitialView() { |
| 4031 |
var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SidebarView.NONE; |
| 4032 |
|
| 4033 |
if (this.isInitialViewSet) { |
| 4034 |
return; |
| 4035 |
} |
| 4036 |
this.isInitialViewSet = true; |
| 4037 |
if (this.isOpen && view === SidebarView.NONE) { |
| 4038 |
this._dispatchEvent(); |
| 4039 |
return; |
| 4040 |
} |
| 4041 |
var isViewPreserved = view === this.visibleView; |
| 4042 |
this.switchView(view, true); |
| 4043 |
if (isViewPreserved) { |
| 4044 |
this._dispatchEvent(); |
| 4045 |
} |
| 4046 |
} |
| 4047 |
}, { |
| 4048 |
key: 'switchView', |
| 4049 |
value: function switchView(view) { |
| 4050 |
var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; |
| 4051 |
|
| 4052 |
if (view === SidebarView.NONE) { |
| 4053 |
this.close(); |
| 4054 |
return; |
| 4055 |
} |
| 4056 |
var isViewChanged = view !== this.active; |
| 4057 |
var shouldForceRendering = false; |
| 4058 |
switch (view) { |
| 4059 |
case SidebarView.THUMBS: |
| 4060 |
this.thumbnailButton.classList.add('toggled'); |
| 4061 |
this.outlineButton.classList.remove('toggled'); |
| 4062 |
this.attachmentsButton.classList.remove('toggled'); |
| 4063 |
this.thumbnailView.classList.remove('hidden'); |
| 4064 |
this.outlineView.classList.add('hidden'); |
| 4065 |
this.attachmentsView.classList.add('hidden'); |
| 4066 |
if (this.isOpen && isViewChanged) { |
| 4067 |
this._updateThumbnailViewer(); |
| 4068 |
shouldForceRendering = true; |
| 4069 |
} |
| 4070 |
break; |
| 4071 |
case SidebarView.OUTLINE: |
| 4072 |
if (this.outlineButton.disabled) { |
| 4073 |
return; |
| 4074 |
} |
| 4075 |
this.thumbnailButton.classList.remove('toggled'); |
| 4076 |
this.outlineButton.classList.add('toggled'); |
| 4077 |
this.attachmentsButton.classList.remove('toggled'); |
| 4078 |
this.thumbnailView.classList.add('hidden'); |
| 4079 |
this.outlineView.classList.remove('hidden'); |
| 4080 |
this.attachmentsView.classList.add('hidden'); |
| 4081 |
break; |
| 4082 |
case SidebarView.ATTACHMENTS: |
| 4083 |
if (this.attachmentsButton.disabled) { |
| 4084 |
return; |
| 4085 |
} |
| 4086 |
this.thumbnailButton.classList.remove('toggled'); |
| 4087 |
this.outlineButton.classList.remove('toggled'); |
| 4088 |
this.attachmentsButton.classList.add('toggled'); |
| 4089 |
this.thumbnailView.classList.add('hidden'); |
| 4090 |
this.outlineView.classList.add('hidden'); |
| 4091 |
this.attachmentsView.classList.remove('hidden'); |
| 4092 |
break; |
| 4093 |
default: |
| 4094 |
console.error('PDFSidebar_switchView: "' + view + '" is an unsupported value.'); |
| 4095 |
return; |
| 4096 |
} |
| 4097 |
this.active = view | 0; |
| 4098 |
if (forceOpen && !this.isOpen) { |
| 4099 |
this.open(); |
| 4100 |
return; |
| 4101 |
} |
| 4102 |
if (shouldForceRendering) { |
| 4103 |
this._forceRendering(); |
| 4104 |
} |
| 4105 |
if (isViewChanged) { |
| 4106 |
this._dispatchEvent(); |
| 4107 |
} |
| 4108 |
this._hideUINotification(this.active); |
| 4109 |
} |
| 4110 |
}, { |
| 4111 |
key: 'open', |
| 4112 |
value: function open() { |
| 4113 |
if (this.isOpen) { |
| 4114 |
return; |
| 4115 |
} |
| 4116 |
this.isOpen = true; |
| 4117 |
this.toggleButton.classList.add('toggled'); |
| 4118 |
this.outerContainer.classList.add('sidebarMoving'); |
| 4119 |
this.outerContainer.classList.add('sidebarOpen'); |
| 4120 |
if (this.active === SidebarView.THUMBS) { |
| 4121 |
this._updateThumbnailViewer(); |
| 4122 |
} |
| 4123 |
this._forceRendering(); |
| 4124 |
this._dispatchEvent(); |
| 4125 |
this._hideUINotification(this.active); |
| 4126 |
} |
| 4127 |
}, { |
| 4128 |
key: 'close', |
| 4129 |
value: function close() { |
| 4130 |
if (!this.isOpen) { |
| 4131 |
return; |
| 4132 |
} |
| 4133 |
this.isOpen = false; |
| 4134 |
this.toggleButton.classList.remove('toggled'); |
| 4135 |
this.outerContainer.classList.add('sidebarMoving'); |
| 4136 |
this.outerContainer.classList.remove('sidebarOpen'); |
| 4137 |
this._forceRendering(); |
| 4138 |
this._dispatchEvent(); |
| 4139 |
} |
| 4140 |
}, { |
| 4141 |
key: 'toggle', |
| 4142 |
value: function toggle() { |
| 4143 |
if (this.isOpen) { |
| 4144 |
this.close(); |
| 4145 |
} else { |
| 4146 |
this.open(); |
| 4147 |
} |
| 4148 |
} |
| 4149 |
}, { |
| 4150 |
key: '_dispatchEvent', |
| 4151 |
value: function _dispatchEvent() { |
| 4152 |
this.eventBus.dispatch('sidebarviewchanged', { |
| 4153 |
source: this, |
| 4154 |
view: this.visibleView |
| 4155 |
}); |
| 4156 |
} |
| 4157 |
}, { |
| 4158 |
key: '_forceRendering', |
| 4159 |
value: function _forceRendering() { |
| 4160 |
if (this.onToggled) { |
| 4161 |
this.onToggled(); |
| 4162 |
} else { |
| 4163 |
this.pdfViewer.forceRendering(); |
| 4164 |
this.pdfThumbnailViewer.forceRendering(); |
| 4165 |
} |
| 4166 |
} |
| 4167 |
}, { |
| 4168 |
key: '_updateThumbnailViewer', |
| 4169 |
value: function _updateThumbnailViewer() { |
| 4170 |
var pdfViewer = this.pdfViewer, |
| 4171 |
pdfThumbnailViewer = this.pdfThumbnailViewer; |
| 4172 |
|
| 4173 |
var pagesCount = pdfViewer.pagesCount; |
| 4174 |
for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) { |
| 4175 |
var pageView = pdfViewer.getPageView(pageIndex); |
| 4176 |
if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) { |
| 4177 |
var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex); |
| 4178 |
thumbnailView.setImage(pageView); |
| 4179 |
} |
| 4180 |
} |
| 4181 |
pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber); |
| 4182 |
} |
| 4183 |
}, { |
| 4184 |
key: '_showUINotification', |
| 4185 |
value: function _showUINotification(view) { |
| 4186 |
var _this = this; |
| 4187 |
|
| 4188 |
if (this.disableNotification) { |
| 4189 |
return; |
| 4190 |
} |
| 4191 |
this.l10n.get('toggle_sidebar_notification.title', null, 'Toggle Sidebar (document contains outline/attachments)').then(function (msg) { |
| 4192 |
_this.toggleButton.title = msg; |
| 4193 |
}); |
| 4194 |
if (!this.isOpen) { |
| 4195 |
this.toggleButton.classList.add(UI_NOTIFICATION_CLASS); |
| 4196 |
} else if (view === this.active) { |
| 4197 |
return; |
| 4198 |
} |
| 4199 |
switch (view) { |
| 4200 |
case SidebarView.OUTLINE: |
| 4201 |
this.outlineButton.classList.add(UI_NOTIFICATION_CLASS); |
| 4202 |
break; |
| 4203 |
case SidebarView.ATTACHMENTS: |
| 4204 |
this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS); |
| 4205 |
break; |
| 4206 |
} |
| 4207 |
} |
| 4208 |
}, { |
| 4209 |
key: '_hideUINotification', |
| 4210 |
value: function _hideUINotification(view) { |
| 4211 |
var _this2 = this; |
| 4212 |
|
| 4213 |
if (this.disableNotification) { |
| 4214 |
return; |
| 4215 |
} |
| 4216 |
var removeNotification = function removeNotification(view) { |
| 4217 |
switch (view) { |
| 4218 |
case SidebarView.OUTLINE: |
| 4219 |
_this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS); |
| 4220 |
break; |
| 4221 |
case SidebarView.ATTACHMENTS: |
| 4222 |
_this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS); |
| 4223 |
break; |
| 4224 |
} |
| 4225 |
}; |
| 4226 |
if (!this.isOpen && view !== null) { |
| 4227 |
return; |
| 4228 |
} |
| 4229 |
this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS); |
| 4230 |
if (view !== null) { |
| 4231 |
removeNotification(view); |
| 4232 |
return; |
| 4233 |
} |
| 4234 |
for (view in SidebarView) { |
| 4235 |
removeNotification(SidebarView[view]); |
| 4236 |
} |
| 4237 |
this.l10n.get('toggle_sidebar.title', null, 'Toggle Sidebar').then(function (msg) { |
| 4238 |
_this2.toggleButton.title = msg; |
| 4239 |
}); |
| 4240 |
} |
| 4241 |
}, { |
| 4242 |
key: '_addEventListeners', |
| 4243 |
value: function _addEventListeners() { |
| 4244 |
var _this3 = this; |
| 4245 |
|
| 4246 |
this.viewerContainer.addEventListener('transitionend', function (evt) { |
| 4247 |
if (evt.target === _this3.viewerContainer) { |
| 4248 |
_this3.outerContainer.classList.remove('sidebarMoving'); |
| 4249 |
} |
| 4250 |
}); |
| 4251 |
this.thumbnailButton.addEventListener('click', function () { |
| 4252 |
_this3.switchView(SidebarView.THUMBS); |
| 4253 |
}); |
| 4254 |
this.outlineButton.addEventListener('click', function () { |
| 4255 |
_this3.switchView(SidebarView.OUTLINE); |
| 4256 |
}); |
| 4257 |
this.outlineButton.addEventListener('dblclick', function () { |
| 4258 |
_this3.eventBus.dispatch('toggleoutlinetree', { source: _this3 }); |
| 4259 |
}); |
| 4260 |
this.attachmentsButton.addEventListener('click', function () { |
| 4261 |
_this3.switchView(SidebarView.ATTACHMENTS); |
| 4262 |
}); |
| 4263 |
this.eventBus.on('outlineloaded', function (evt) { |
| 4264 |
var outlineCount = evt.outlineCount; |
| 4265 |
_this3.outlineButton.disabled = !outlineCount; |
| 4266 |
if (outlineCount) { |
| 4267 |
_this3._showUINotification(SidebarView.OUTLINE); |
| 4268 |
} else if (_this3.active === SidebarView.OUTLINE) { |
| 4269 |
_this3.switchView(SidebarView.THUMBS); |
| 4270 |
} |
| 4271 |
}); |
| 4272 |
this.eventBus.on('attachmentsloaded', function (evt) { |
| 4273 |
if (evt.attachmentsCount) { |
| 4274 |
_this3.attachmentsButton.disabled = false; |
| 4275 |
_this3._showUINotification(SidebarView.ATTACHMENTS); |
| 4276 |
return; |
| 4277 |
} |
| 4278 |
Promise.resolve().then(function () { |
| 4279 |
if (_this3.attachmentsView.hasChildNodes()) { |
| 4280 |
return; |
| 4281 |
} |
| 4282 |
_this3.attachmentsButton.disabled = true; |
| 4283 |
if (_this3.active === SidebarView.ATTACHMENTS) { |
| 4284 |
_this3.switchView(SidebarView.THUMBS); |
| 4285 |
} |
| 4286 |
}); |
| 4287 |
}); |
| 4288 |
this.eventBus.on('presentationmodechanged', function (evt) { |
| 4289 |
if (!evt.active && !evt.switchInProgress && _this3.isThumbnailViewVisible) { |
| 4290 |
_this3._updateThumbnailViewer(); |
| 4291 |
} |
| 4292 |
}); |
| 4293 |
} |
| 4294 |
}, { |
| 4295 |
key: 'visibleView', |
| 4296 |
get: function get() { |
| 4297 |
return this.isOpen ? this.active : SidebarView.NONE; |
| 4298 |
} |
| 4299 |
}, { |
| 4300 |
key: 'isThumbnailViewVisible', |
| 4301 |
get: function get() { |
| 4302 |
return this.isOpen && this.active === SidebarView.THUMBS; |
| 4303 |
} |
| 4304 |
}, { |
| 4305 |
key: 'isOutlineViewVisible', |
| 4306 |
get: function get() { |
| 4307 |
return this.isOpen && this.active === SidebarView.OUTLINE; |
| 4308 |
} |
| 4309 |
}, { |
| 4310 |
key: 'isAttachmentsViewVisible', |
| 4311 |
get: function get() { |
| 4312 |
return this.isOpen && this.active === SidebarView.ATTACHMENTS; |
| 4313 |
} |
| 4314 |
}]); |
| 4315 |
|
| 4316 |
return PDFSidebar; |
| 4317 |
}(); |
| 4318 |
|
| 4319 |
exports.SidebarView = SidebarView; |
| 4320 |
exports.PDFSidebar = PDFSidebar; |
| 4321 |
|
| 4322 |
/***/ }), |
| 4323 |
/* 12 */ |
| 4324 |
/***/ (function(module, exports, __webpack_require__) { |
| 4325 |
|
| 4326 |
"use strict"; |
| 4327 |
|
| 4328 |
|
| 4329 |
Object.defineProperty(exports, "__esModule", { |
| 4330 |
value: true |
| 4331 |
}); |
| 4332 |
exports.OptionKind = exports.AppOptions = undefined; |
| 4333 |
|
| 4334 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 4335 |
|
| 4336 |
var _pdfjsLib = __webpack_require__(7); |
| 4337 |
|
| 4338 |
var _viewer_compatibility = __webpack_require__(13); |
| 4339 |
|
| 4340 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 4341 |
|
| 4342 |
var OptionKind = { |
| 4343 |
VIEWER: 'viewer', |
| 4344 |
API: 'api', |
| 4345 |
WORKER: 'worker' |
| 4346 |
}; |
| 4347 |
var defaultOptions = { |
| 4348 |
cursorToolOnLoad: { |
| 4349 |
value: 0, |
| 4350 |
kind: OptionKind.VIEWER |
| 4351 |
}, |
| 4352 |
defaultUrl: { |
| 4353 |
value: 'compressed.tracemonkey-pldi-09.pdf', |
| 4354 |
kind: OptionKind.VIEWER |
| 4355 |
}, |
| 4356 |
defaultZoomValue: { |
| 4357 |
value: '', |
| 4358 |
kind: OptionKind.VIEWER |
| 4359 |
}, |
| 4360 |
disableHistory: { |
| 4361 |
value: false, |
| 4362 |
kind: OptionKind.VIEWER |
| 4363 |
}, |
| 4364 |
disablePageLabels: { |
| 4365 |
value: false, |
| 4366 |
kind: OptionKind.VIEWER |
| 4367 |
}, |
| 4368 |
disablePageMode: { |
| 4369 |
value: false, |
| 4370 |
kind: OptionKind.VIEWER |
| 4371 |
}, |
| 4372 |
enablePrintAutoRotate: { |
| 4373 |
value: false, |
| 4374 |
kind: OptionKind.VIEWER |
| 4375 |
}, |
| 4376 |
enableWebGL: { |
| 4377 |
value: false, |
| 4378 |
kind: OptionKind.VIEWER |
| 4379 |
}, |
| 4380 |
eventBusDispatchToDOM: { |
| 4381 |
value: false, |
| 4382 |
kind: OptionKind.VIEWER |
| 4383 |
}, |
| 4384 |
externalLinkRel: { |
| 4385 |
value: 'noopener noreferrer nofollow', |
| 4386 |
kind: OptionKind.VIEWER |
| 4387 |
}, |
| 4388 |
externalLinkTarget: { |
| 4389 |
value: 0, |
| 4390 |
kind: OptionKind.VIEWER |
| 4391 |
}, |
| 4392 |
imageResourcesPath: { |
| 4393 |
value: './images/', |
| 4394 |
kind: OptionKind.VIEWER |
| 4395 |
}, |
| 4396 |
maxCanvasPixels: { |
| 4397 |
value: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216, |
| 4398 |
kind: OptionKind.VIEWER |
| 4399 |
}, |
| 4400 |
pdfBugEnabled: { |
| 4401 |
value: false, |
| 4402 |
kind: OptionKind.VIEWER |
| 4403 |
}, |
| 4404 |
renderer: { |
| 4405 |
value: 'canvas', |
| 4406 |
kind: OptionKind.VIEWER |
| 4407 |
}, |
| 4408 |
renderInteractiveForms: { |
| 4409 |
value: false, |
| 4410 |
kind: OptionKind.VIEWER |
| 4411 |
}, |
| 4412 |
showPreviousViewOnLoad: { |
| 4413 |
value: true, |
| 4414 |
kind: OptionKind.VIEWER |
| 4415 |
}, |
| 4416 |
sidebarViewOnLoad: { |
| 4417 |
value: 0, |
| 4418 |
kind: OptionKind.VIEWER |
| 4419 |
}, |
| 4420 |
scrollModeOnLoad: { |
| 4421 |
value: 0, |
| 4422 |
kind: OptionKind.VIEWER |
| 4423 |
}, |
| 4424 |
spreadModeOnLoad: { |
| 4425 |
value: 0, |
| 4426 |
kind: OptionKind.VIEWER |
| 4427 |
}, |
| 4428 |
textLayerMode: { |
| 4429 |
value: 1, |
| 4430 |
kind: OptionKind.VIEWER |
| 4431 |
}, |
| 4432 |
useOnlyCssZoom: { |
| 4433 |
value: false, |
| 4434 |
kind: OptionKind.VIEWER |
| 4435 |
}, |
| 4436 |
cMapPacked: { |
| 4437 |
value: true, |
| 4438 |
kind: OptionKind.API |
| 4439 |
}, |
| 4440 |
cMapUrl: { |
| 4441 |
value: '../web/cmaps/', |
| 4442 |
kind: OptionKind.API |
| 4443 |
}, |
| 4444 |
disableAutoFetch: { |
| 4445 |
value: false, |
| 4446 |
kind: OptionKind.API |
| 4447 |
}, |
| 4448 |
disableCreateObjectURL: { |
| 4449 |
value: _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL || false, |
| 4450 |
kind: OptionKind.API |
| 4451 |
}, |
| 4452 |
disableFontFace: { |
| 4453 |
value: false, |
| 4454 |
kind: OptionKind.API |
| 4455 |
}, |
| 4456 |
disableRange: { |
| 4457 |
value: false, |
| 4458 |
kind: OptionKind.API |
| 4459 |
}, |
| 4460 |
disableStream: { |
| 4461 |
value: false, |
| 4462 |
kind: OptionKind.API |
| 4463 |
}, |
| 4464 |
isEvalSupported: { |
| 4465 |
value: true, |
| 4466 |
kind: OptionKind.API |
| 4467 |
}, |
| 4468 |
maxImageSize: { |
| 4469 |
value: -1, |
| 4470 |
kind: OptionKind.API |
| 4471 |
}, |
| 4472 |
pdfBug: { |
| 4473 |
value: false, |
| 4474 |
kind: OptionKind.API |
| 4475 |
}, |
| 4476 |
postMessageTransfers: { |
| 4477 |
value: true, |
| 4478 |
kind: OptionKind.API |
| 4479 |
}, |
| 4480 |
verbosity: { |
| 4481 |
value: 1, |
| 4482 |
kind: OptionKind.API |
| 4483 |
}, |
| 4484 |
workerPort: { |
| 4485 |
value: null, |
| 4486 |
kind: OptionKind.WORKER |
| 4487 |
}, |
| 4488 |
workerSrc: { |
| 4489 |
value: '../build/pdf.worker.js', |
| 4490 |
kind: OptionKind.WORKER |
| 4491 |
} |
| 4492 |
}; |
| 4493 |
{ |
| 4494 |
defaultOptions.locale = { |
| 4495 |
value: typeof navigator !== 'undefined' ? navigator.language : 'en-US', |
| 4496 |
kind: OptionKind.VIEWER |
| 4497 |
}; |
| 4498 |
} |
| 4499 |
var userOptions = Object.create(null); |
| 4500 |
|
| 4501 |
var AppOptions = function () { |
| 4502 |
function AppOptions() { |
| 4503 |
_classCallCheck(this, AppOptions); |
| 4504 |
|
| 4505 |
throw new Error('Cannot initialize AppOptions.'); |
| 4506 |
} |
| 4507 |
|
| 4508 |
_createClass(AppOptions, null, [{ |
| 4509 |
key: 'get', |
| 4510 |
value: function get(name) { |
| 4511 |
var defaultOption = defaultOptions[name], |
| 4512 |
userOption = userOptions[name]; |
| 4513 |
if (userOption !== undefined) { |
| 4514 |
return userOption; |
| 4515 |
} |
| 4516 |
return defaultOption !== undefined ? defaultOption.value : undefined; |
| 4517 |
} |
| 4518 |
}, { |
| 4519 |
key: 'getAll', |
| 4520 |
value: function getAll() { |
| 4521 |
var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; |
| 4522 |
|
| 4523 |
var options = Object.create(null); |
| 4524 |
for (var name in defaultOptions) { |
| 4525 |
var defaultOption = defaultOptions[name], |
| 4526 |
userOption = userOptions[name]; |
| 4527 |
if (kind && defaultOption.kind !== kind) { |
| 4528 |
continue; |
| 4529 |
} |
| 4530 |
options[name] = userOption !== undefined ? userOption : defaultOption.value; |
| 4531 |
} |
| 4532 |
return options; |
| 4533 |
} |
| 4534 |
}, { |
| 4535 |
key: 'set', |
| 4536 |
value: function set(name, value) { |
| 4537 |
userOptions[name] = value; |
| 4538 |
} |
| 4539 |
}, { |
| 4540 |
key: 'remove', |
| 4541 |
value: function remove(name) { |
| 4542 |
delete userOptions[name]; |
| 4543 |
} |
| 4544 |
}]); |
| 4545 |
|
| 4546 |
return AppOptions; |
| 4547 |
}(); |
| 4548 |
|
| 4549 |
exports.AppOptions = AppOptions; |
| 4550 |
exports.OptionKind = OptionKind; |
| 4551 |
|
| 4552 |
/***/ }), |
| 4553 |
/* 13 */ |
| 4554 |
/***/ (function(module, exports, __webpack_require__) { |
| 4555 |
|
| 4556 |
"use strict"; |
| 4557 |
|
| 4558 |
|
| 4559 |
var compatibilityParams = Object.create(null); |
| 4560 |
{ |
| 4561 |
var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || ''; |
| 4562 |
var isAndroid = /Android/.test(userAgent); |
| 4563 |
var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent); |
| 4564 |
(function checkCanvasSizeLimitation() { |
| 4565 |
if (isIOS || isAndroid) { |
| 4566 |
compatibilityParams.maxCanvasPixels = 5242880; |
| 4567 |
} |
| 4568 |
})(); |
| 4569 |
} |
| 4570 |
exports.viewerCompatibilityParams = Object.freeze(compatibilityParams); |
| 4571 |
|
| 4572 |
/***/ }), |
| 4573 |
/* 14 */ |
| 4574 |
/***/ (function(module, exports, __webpack_require__) { |
| 4575 |
|
| 4576 |
"use strict"; |
| 4577 |
|
| 4578 |
|
| 4579 |
Object.defineProperty(exports, "__esModule", { |
| 4580 |
value: true |
| 4581 |
}); |
| 4582 |
exports.getGlobalEventBus = exports.attachDOMEventsToEventBus = undefined; |
| 4583 |
|
| 4584 |
var _ui_utils = __webpack_require__(6); |
| 4585 |
|
| 4586 |
function attachDOMEventsToEventBus(eventBus) { |
| 4587 |
eventBus.on('documentload', function () { |
| 4588 |
var event = document.createEvent('CustomEvent'); |
| 4589 |
event.initCustomEvent('documentload', true, true, {}); |
| 4590 |
window.dispatchEvent(event); |
| 4591 |
}); |
| 4592 |
eventBus.on('pagerendered', function (evt) { |
| 4593 |
var event = document.createEvent('CustomEvent'); |
| 4594 |
event.initCustomEvent('pagerendered', true, true, { |
| 4595 |
pageNumber: evt.pageNumber, |
| 4596 |
cssTransform: evt.cssTransform |
| 4597 |
}); |
| 4598 |
evt.source.div.dispatchEvent(event); |
| 4599 |
}); |
| 4600 |
eventBus.on('textlayerrendered', function (evt) { |
| 4601 |
var event = document.createEvent('CustomEvent'); |
| 4602 |
event.initCustomEvent('textlayerrendered', true, true, { pageNumber: evt.pageNumber }); |
| 4603 |
evt.source.textLayerDiv.dispatchEvent(event); |
| 4604 |
}); |
| 4605 |
eventBus.on('pagechange', function (evt) { |
| 4606 |
var event = document.createEvent('UIEvents'); |
| 4607 |
event.initUIEvent('pagechange', true, true, window, 0); |
| 4608 |
event.pageNumber = evt.pageNumber; |
| 4609 |
evt.source.container.dispatchEvent(event); |
| 4610 |
}); |
| 4611 |
eventBus.on('pagesinit', function (evt) { |
| 4612 |
var event = document.createEvent('CustomEvent'); |
| 4613 |
event.initCustomEvent('pagesinit', true, true, null); |
| 4614 |
evt.source.container.dispatchEvent(event); |
| 4615 |
}); |
| 4616 |
eventBus.on('pagesloaded', function (evt) { |
| 4617 |
var event = document.createEvent('CustomEvent'); |
| 4618 |
event.initCustomEvent('pagesloaded', true, true, { pagesCount: evt.pagesCount }); |
| 4619 |
evt.source.container.dispatchEvent(event); |
| 4620 |
}); |
| 4621 |
eventBus.on('scalechange', function (evt) { |
| 4622 |
var event = document.createEvent('UIEvents'); |
| 4623 |
event.initUIEvent('scalechange', true, true, window, 0); |
| 4624 |
event.scale = evt.scale; |
| 4625 |
event.presetValue = evt.presetValue; |
| 4626 |
evt.source.container.dispatchEvent(event); |
| 4627 |
}); |
| 4628 |
eventBus.on('updateviewarea', function (evt) { |
| 4629 |
var event = document.createEvent('UIEvents'); |
| 4630 |
event.initUIEvent('updateviewarea', true, true, window, 0); |
| 4631 |
event.location = evt.location; |
| 4632 |
evt.source.container.dispatchEvent(event); |
| 4633 |
}); |
| 4634 |
eventBus.on('find', function (evt) { |
| 4635 |
if (evt.source === window) { |
| 4636 |
return; |
| 4637 |
} |
| 4638 |
var event = document.createEvent('CustomEvent'); |
| 4639 |
event.initCustomEvent('find' + evt.type, true, true, { |
| 4640 |
query: evt.query, |
| 4641 |
phraseSearch: evt.phraseSearch, |
| 4642 |
caseSensitive: evt.caseSensitive, |
| 4643 |
highlightAll: evt.highlightAll, |
| 4644 |
findPrevious: evt.findPrevious |
| 4645 |
}); |
| 4646 |
window.dispatchEvent(event); |
| 4647 |
}); |
| 4648 |
eventBus.on('attachmentsloaded', function (evt) { |
| 4649 |
var event = document.createEvent('CustomEvent'); |
| 4650 |
event.initCustomEvent('attachmentsloaded', true, true, { attachmentsCount: evt.attachmentsCount }); |
| 4651 |
evt.source.container.dispatchEvent(event); |
| 4652 |
}); |
| 4653 |
eventBus.on('sidebarviewchanged', function (evt) { |
| 4654 |
var event = document.createEvent('CustomEvent'); |
| 4655 |
event.initCustomEvent('sidebarviewchanged', true, true, { view: evt.view }); |
| 4656 |
evt.source.outerContainer.dispatchEvent(event); |
| 4657 |
}); |
| 4658 |
eventBus.on('pagemode', function (evt) { |
| 4659 |
var event = document.createEvent('CustomEvent'); |
| 4660 |
event.initCustomEvent('pagemode', true, true, { mode: evt.mode }); |
| 4661 |
evt.source.pdfViewer.container.dispatchEvent(event); |
| 4662 |
}); |
| 4663 |
eventBus.on('namedaction', function (evt) { |
| 4664 |
var event = document.createEvent('CustomEvent'); |
| 4665 |
event.initCustomEvent('namedaction', true, true, { action: evt.action }); |
| 4666 |
evt.source.pdfViewer.container.dispatchEvent(event); |
| 4667 |
}); |
| 4668 |
eventBus.on('presentationmodechanged', function (evt) { |
| 4669 |
var event = document.createEvent('CustomEvent'); |
| 4670 |
event.initCustomEvent('presentationmodechanged', true, true, { |
| 4671 |
active: evt.active, |
| 4672 |
switchInProgress: evt.switchInProgress |
| 4673 |
}); |
| 4674 |
window.dispatchEvent(event); |
| 4675 |
}); |
| 4676 |
eventBus.on('outlineloaded', function (evt) { |
| 4677 |
var event = document.createEvent('CustomEvent'); |
| 4678 |
event.initCustomEvent('outlineloaded', true, true, { outlineCount: evt.outlineCount }); |
| 4679 |
evt.source.container.dispatchEvent(event); |
| 4680 |
}); |
| 4681 |
} |
| 4682 |
var globalEventBus = null; |
| 4683 |
function getGlobalEventBus() { |
| 4684 |
var dispatchToDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
| 4685 |
|
| 4686 |
if (!globalEventBus) { |
| 4687 |
globalEventBus = new _ui_utils.EventBus({ dispatchToDOM: dispatchToDOM }); |
| 4688 |
if (!dispatchToDOM) { |
| 4689 |
attachDOMEventsToEventBus(globalEventBus); |
| 4690 |
} |
| 4691 |
} |
| 4692 |
return globalEventBus; |
| 4693 |
} |
| 4694 |
exports.attachDOMEventsToEventBus = attachDOMEventsToEventBus; |
| 4695 |
exports.getGlobalEventBus = getGlobalEventBus; |
| 4696 |
|
| 4697 |
/***/ }), |
| 4698 |
/* 15 */ |
| 4699 |
/***/ (function(module, exports, __webpack_require__) { |
| 4700 |
|
| 4701 |
"use strict"; |
| 4702 |
|
| 4703 |
|
| 4704 |
Object.defineProperty(exports, "__esModule", { |
| 4705 |
value: true |
| 4706 |
}); |
| 4707 |
exports.OverlayManager = undefined; |
| 4708 |
|
| 4709 |
var _regenerator = __webpack_require__(2); |
| 4710 |
|
| 4711 |
var _regenerator2 = _interopRequireDefault(_regenerator); |
| 4712 |
|
| 4713 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 4714 |
|
| 4715 |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
| 4716 |
|
| 4717 |
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } |
| 4718 |
|
| 4719 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 4720 |
|
| 4721 |
var OverlayManager = function () { |
| 4722 |
function OverlayManager() { |
| 4723 |
_classCallCheck(this, OverlayManager); |
| 4724 |
|
| 4725 |
this._overlays = {}; |
| 4726 |
this._active = null; |
| 4727 |
this._keyDownBound = this._keyDown.bind(this); |
| 4728 |
} |
| 4729 |
|
| 4730 |
_createClass(OverlayManager, [{ |
| 4731 |
key: 'register', |
| 4732 |
value: function () { |
| 4733 |
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(name, element) { |
| 4734 |
var callerCloseMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; |
| 4735 |
var canForceClose = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; |
| 4736 |
var container; |
| 4737 |
return _regenerator2.default.wrap(function _callee$(_context) { |
| 4738 |
while (1) { |
| 4739 |
switch (_context.prev = _context.next) { |
| 4740 |
case 0: |
| 4741 |
container = void 0; |
| 4742 |
|
| 4743 |
if (!(!name || !element || !(container = element.parentNode))) { |
| 4744 |
_context.next = 5; |
| 4745 |
break; |
| 4746 |
} |
| 4747 |
|
| 4748 |
throw new Error('Not enough parameters.'); |
| 4749 |
|
| 4750 |
case 5: |
| 4751 |
if (!this._overlays[name]) { |
| 4752 |
_context.next = 7; |
| 4753 |
break; |
| 4754 |
} |
| 4755 |
|
| 4756 |
throw new Error('The overlay is already registered.'); |
| 4757 |
|
| 4758 |
case 7: |
| 4759 |
this._overlays[name] = { |
| 4760 |
element: element, |
| 4761 |
container: container, |
| 4762 |
callerCloseMethod: callerCloseMethod, |
| 4763 |
canForceClose: canForceClose |
| 4764 |
}; |
| 4765 |
|
| 4766 |
case 8: |
| 4767 |
case 'end': |
| 4768 |
return _context.stop(); |
| 4769 |
} |
| 4770 |
} |
| 4771 |
}, _callee, this); |
| 4772 |
})); |
| 4773 |
|
| 4774 |
function register(_x3, _x4) { |
| 4775 |
return _ref.apply(this, arguments); |
| 4776 |
} |
| 4777 |
|
| 4778 |
return register; |
| 4779 |
}() |
| 4780 |
}, { |
| 4781 |
key: 'unregister', |
| 4782 |
value: function () { |
| 4783 |
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2(name) { |
| 4784 |
return _regenerator2.default.wrap(function _callee2$(_context2) { |
| 4785 |
while (1) { |
| 4786 |
switch (_context2.prev = _context2.next) { |
| 4787 |
case 0: |
| 4788 |
if (this._overlays[name]) { |
| 4789 |
_context2.next = 4; |
| 4790 |
break; |
| 4791 |
} |
| 4792 |
|
| 4793 |
throw new Error('The overlay does not exist.'); |
| 4794 |
|
| 4795 |
case 4: |
| 4796 |
if (!(this._active === name)) { |
| 4797 |
_context2.next = 6; |
| 4798 |
break; |
| 4799 |
} |
| 4800 |
|
| 4801 |
throw new Error('The overlay cannot be removed while it is active.'); |
| 4802 |
|
| 4803 |
case 6: |
| 4804 |
delete this._overlays[name]; |
| 4805 |
|
| 4806 |
case 7: |
| 4807 |
case 'end': |
| 4808 |
return _context2.stop(); |
| 4809 |
} |
| 4810 |
} |
| 4811 |
}, _callee2, this); |
| 4812 |
})); |
| 4813 |
|
| 4814 |
function unregister(_x5) { |
| 4815 |
return _ref2.apply(this, arguments); |
| 4816 |
} |
| 4817 |
|
| 4818 |
return unregister; |
| 4819 |
}() |
| 4820 |
}, { |
| 4821 |
key: 'open', |
| 4822 |
value: function () { |
| 4823 |
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3(name) { |
| 4824 |
return _regenerator2.default.wrap(function _callee3$(_context3) { |
| 4825 |
while (1) { |
| 4826 |
switch (_context3.prev = _context3.next) { |
| 4827 |
case 0: |
| 4828 |
if (this._overlays[name]) { |
| 4829 |
_context3.next = 4; |
| 4830 |
break; |
| 4831 |
} |
| 4832 |
|
| 4833 |
throw new Error('The overlay does not exist.'); |
| 4834 |
|
| 4835 |
case 4: |
| 4836 |
if (!this._active) { |
| 4837 |
_context3.next = 14; |
| 4838 |
break; |
| 4839 |
} |
| 4840 |
|
| 4841 |
if (!this._overlays[name].canForceClose) { |
| 4842 |
_context3.next = 9; |
| 4843 |
break; |
| 4844 |
} |
| 4845 |
|
| 4846 |
this._closeThroughCaller(); |
| 4847 |
_context3.next = 14; |
| 4848 |
break; |
| 4849 |
|
| 4850 |
case 9: |
| 4851 |
if (!(this._active === name)) { |
| 4852 |
_context3.next = 13; |
| 4853 |
break; |
| 4854 |
} |
| 4855 |
|
| 4856 |
throw new Error('The overlay is already active.'); |
| 4857 |
|
| 4858 |
case 13: |
| 4859 |
throw new Error('Another overlay is currently active.'); |
| 4860 |
|
| 4861 |
case 14: |
| 4862 |
this._active = name; |
| 4863 |
this._overlays[this._active].element.classList.remove('hidden'); |
| 4864 |
this._overlays[this._active].container.classList.remove('hidden'); |
| 4865 |
window.addEventListener('keydown', this._keyDownBound); |
| 4866 |
|
| 4867 |
case 18: |
| 4868 |
case 'end': |
| 4869 |
return _context3.stop(); |
| 4870 |
} |
| 4871 |
} |
| 4872 |
}, _callee3, this); |
| 4873 |
})); |
| 4874 |
|
| 4875 |
function open(_x6) { |
| 4876 |
return _ref3.apply(this, arguments); |
| 4877 |
} |
| 4878 |
|
| 4879 |
return open; |
| 4880 |
}() |
| 4881 |
}, { |
| 4882 |
key: 'close', |
| 4883 |
value: function () { |
| 4884 |
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4(name) { |
| 4885 |
return _regenerator2.default.wrap(function _callee4$(_context4) { |
| 4886 |
while (1) { |
| 4887 |
switch (_context4.prev = _context4.next) { |
| 4888 |
case 0: |
| 4889 |
if (this._overlays[name]) { |
| 4890 |
_context4.next = 4; |
| 4891 |
break; |
| 4892 |
} |
| 4893 |
|
| 4894 |
throw new Error('The overlay does not exist.'); |
| 4895 |
|
| 4896 |
case 4: |
| 4897 |
if (this._active) { |
| 4898 |
_context4.next = 8; |
| 4899 |
break; |
| 4900 |
} |
| 4901 |
|
| 4902 |
throw new Error('The overlay is currently not active.'); |
| 4903 |
|
| 4904 |
case 8: |
| 4905 |
if (!(this._active !== name)) { |
| 4906 |
_context4.next = 10; |
| 4907 |
break; |
| 4908 |
} |
| 4909 |
|
| 4910 |
throw new Error('Another overlay is currently active.'); |
| 4911 |
|
| 4912 |
case 10: |
| 4913 |
this._overlays[this._active].container.classList.add('hidden'); |
| 4914 |
this._overlays[this._active].element.classList.add('hidden'); |
| 4915 |
this._active = null; |
| 4916 |
window.removeEventListener('keydown', this._keyDownBound); |
| 4917 |
|
| 4918 |
case 14: |
| 4919 |
case 'end': |
| 4920 |
return _context4.stop(); |
| 4921 |
} |
| 4922 |
} |
| 4923 |
}, _callee4, this); |
| 4924 |
})); |
| 4925 |
|
| 4926 |
function close(_x7) { |
| 4927 |
return _ref4.apply(this, arguments); |
| 4928 |
} |
| 4929 |
|
| 4930 |
return close; |
| 4931 |
}() |
| 4932 |
}, { |
| 4933 |
key: '_keyDown', |
| 4934 |
value: function _keyDown(evt) { |
| 4935 |
if (this._active && evt.keyCode === 27) { |
| 4936 |
this._closeThroughCaller(); |
| 4937 |
evt.preventDefault(); |
| 4938 |
} |
| 4939 |
} |
| 4940 |
}, { |
| 4941 |
key: '_closeThroughCaller', |
| 4942 |
value: function _closeThroughCaller() { |
| 4943 |
if (this._overlays[this._active].callerCloseMethod) { |
| 4944 |
this._overlays[this._active].callerCloseMethod(); |
| 4945 |
} |
| 4946 |
if (this._active) { |
| 4947 |
this.close(this._active); |
| 4948 |
} |
| 4949 |
} |
| 4950 |
}, { |
| 4951 |
key: 'active', |
| 4952 |
get: function get() { |
| 4953 |
return this._active; |
| 4954 |
} |
| 4955 |
}]); |
| 4956 |
|
| 4957 |
return OverlayManager; |
| 4958 |
}(); |
| 4959 |
|
| 4960 |
exports.OverlayManager = OverlayManager; |
| 4961 |
|
| 4962 |
/***/ }), |
| 4963 |
/* 16 */ |
| 4964 |
/***/ (function(module, exports, __webpack_require__) { |
| 4965 |
|
| 4966 |
"use strict"; |
| 4967 |
|
| 4968 |
|
| 4969 |
Object.defineProperty(exports, "__esModule", { |
| 4970 |
value: true |
| 4971 |
}); |
| 4972 |
exports.PasswordPrompt = undefined; |
| 4973 |
|
| 4974 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 4975 |
|
| 4976 |
var _ui_utils = __webpack_require__(6); |
| 4977 |
|
| 4978 |
var _pdfjsLib = __webpack_require__(7); |
| 4979 |
|
| 4980 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 4981 |
|
| 4982 |
var PasswordPrompt = function () { |
| 4983 |
function PasswordPrompt(options, overlayManager) { |
| 4984 |
var _this = this; |
| 4985 |
|
| 4986 |
var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n; |
| 4987 |
|
| 4988 |
_classCallCheck(this, PasswordPrompt); |
| 4989 |
|
| 4990 |
this.overlayName = options.overlayName; |
| 4991 |
this.container = options.container; |
| 4992 |
this.label = options.label; |
| 4993 |
this.input = options.input; |
| 4994 |
this.submitButton = options.submitButton; |
| 4995 |
this.cancelButton = options.cancelButton; |
| 4996 |
this.overlayManager = overlayManager; |
| 4997 |
this.l10n = l10n; |
| 4998 |
this.updateCallback = null; |
| 4999 |
this.reason = null; |
| 5000 |
this.submitButton.addEventListener('click', this.verify.bind(this)); |
| 5001 |
this.cancelButton.addEventListener('click', this.close.bind(this)); |
| 5002 |
this.input.addEventListener('keydown', function (e) { |
| 5003 |
if (e.keyCode === 13) { |
| 5004 |
_this.verify(); |
| 5005 |
} |
| 5006 |
}); |
| 5007 |
this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true); |
| 5008 |
} |
| 5009 |
|
| 5010 |
_createClass(PasswordPrompt, [{ |
| 5011 |
key: 'open', |
| 5012 |
value: function open() { |
| 5013 |
var _this2 = this; |
| 5014 |
|
| 5015 |
this.overlayManager.open(this.overlayName).then(function () { |
| 5016 |
_this2.input.focus(); |
| 5017 |
var promptString = void 0; |
| 5018 |
if (_this2.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) { |
| 5019 |
promptString = _this2.l10n.get('password_invalid', null, 'Invalid password. Please try again.'); |
| 5020 |
} else { |
| 5021 |
promptString = _this2.l10n.get('password_label', null, 'Enter the password to open this PDF file.'); |
| 5022 |
} |
| 5023 |
promptString.then(function (msg) { |
| 5024 |
_this2.label.textContent = msg; |
| 5025 |
}); |
| 5026 |
}); |
| 5027 |
} |
| 5028 |
}, { |
| 5029 |
key: 'close', |
| 5030 |
value: function close() { |
| 5031 |
var _this3 = this; |
| 5032 |
|
| 5033 |
this.overlayManager.close(this.overlayName).then(function () { |
| 5034 |
_this3.input.value = ''; |
| 5035 |
}); |
| 5036 |
} |
| 5037 |
}, { |
| 5038 |
key: 'verify', |
| 5039 |
value: function verify() { |
| 5040 |
var password = this.input.value; |
| 5041 |
if (password && password.length > 0) { |
| 5042 |
this.close(); |
| 5043 |
return this.updateCallback(password); |
| 5044 |
} |
| 5045 |
} |
| 5046 |
}, { |
| 5047 |
key: 'setUpdateCallback', |
| 5048 |
value: function setUpdateCallback(updateCallback, reason) { |
| 5049 |
this.updateCallback = updateCallback; |
| 5050 |
this.reason = reason; |
| 5051 |
} |
| 5052 |
}]); |
| 5053 |
|
| 5054 |
return PasswordPrompt; |
| 5055 |
}(); |
| 5056 |
|
| 5057 |
exports.PasswordPrompt = PasswordPrompt; |
| 5058 |
|
| 5059 |
/***/ }), |
| 5060 |
/* 17 */ |
| 5061 |
/***/ (function(module, exports, __webpack_require__) { |
| 5062 |
|
| 5063 |
"use strict"; |
| 5064 |
|
| 5065 |
|
| 5066 |
Object.defineProperty(exports, "__esModule", { |
| 5067 |
value: true |
| 5068 |
}); |
| 5069 |
exports.PDFAttachmentViewer = undefined; |
| 5070 |
|
| 5071 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 5072 |
|
| 5073 |
var _pdfjsLib = __webpack_require__(7); |
| 5074 |
|
| 5075 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 5076 |
|
| 5077 |
var PDFAttachmentViewer = function () { |
| 5078 |
function PDFAttachmentViewer(_ref) { |
| 5079 |
var container = _ref.container, |
| 5080 |
eventBus = _ref.eventBus, |
| 5081 |
downloadManager = _ref.downloadManager; |
| 5082 |
|
| 5083 |
_classCallCheck(this, PDFAttachmentViewer); |
| 5084 |
|
| 5085 |
this.container = container; |
| 5086 |
this.eventBus = eventBus; |
| 5087 |
this.downloadManager = downloadManager; |
| 5088 |
this.reset(); |
| 5089 |
this.eventBus.on('fileattachmentannotation', this._appendAttachment.bind(this)); |
| 5090 |
} |
| 5091 |
|
| 5092 |
_createClass(PDFAttachmentViewer, [{ |
| 5093 |
key: 'reset', |
| 5094 |
value: function reset() { |
| 5095 |
var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
| 5096 |
|
| 5097 |
this.attachments = null; |
| 5098 |
this.container.textContent = ''; |
| 5099 |
if (!keepRenderedCapability) { |
| 5100 |
this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)(); |
| 5101 |
} |
| 5102 |
} |
| 5103 |
}, { |
| 5104 |
key: '_dispatchEvent', |
| 5105 |
value: function _dispatchEvent(attachmentsCount) { |
| 5106 |
this._renderedCapability.resolve(); |
| 5107 |
this.eventBus.dispatch('attachmentsloaded', { |
| 5108 |
source: this, |
| 5109 |
attachmentsCount: attachmentsCount |
| 5110 |
}); |
| 5111 |
} |
| 5112 |
}, { |
| 5113 |
key: '_bindPdfLink', |
| 5114 |
value: function _bindPdfLink(button, content, filename) { |
| 5115 |
if (this.downloadManager.disableCreateObjectURL) { |
| 5116 |
throw new Error('bindPdfLink: Unsupported "disableCreateObjectURL" value.'); |
| 5117 |
} |
| 5118 |
var blobUrl = void 0; |
| 5119 |
button.onclick = function () { |
| 5120 |
if (!blobUrl) { |
| 5121 |
blobUrl = (0, _pdfjsLib.createObjectURL)(content, 'application/pdf'); |
| 5122 |
} |
| 5123 |
var viewerUrl = void 0; |
| 5124 |
viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' + filename); |
| 5125 |
window.open(viewerUrl); |
| 5126 |
return false; |
| 5127 |
}; |
| 5128 |
} |
| 5129 |
}, { |
| 5130 |
key: '_bindLink', |
| 5131 |
value: function _bindLink(button, content, filename) { |
| 5132 |
var _this = this; |
| 5133 |
|
| 5134 |
button.onclick = function () { |
| 5135 |
_this.downloadManager.downloadData(content, filename, ''); |
| 5136 |
return false; |
| 5137 |
}; |
| 5138 |
} |
| 5139 |
}, { |
| 5140 |
key: 'render', |
| 5141 |
value: function render(_ref2) { |
| 5142 |
var attachments = _ref2.attachments, |
| 5143 |
_ref2$keepRenderedCap = _ref2.keepRenderedCapability, |
| 5144 |
keepRenderedCapability = _ref2$keepRenderedCap === undefined ? false : _ref2$keepRenderedCap; |
| 5145 |
|
| 5146 |
var attachmentsCount = 0; |
| 5147 |
if (this.attachments) { |
| 5148 |
this.reset(keepRenderedCapability === true); |
| 5149 |
} |
| 5150 |
this.attachments = attachments || null; |
| 5151 |
if (!attachments) { |
| 5152 |
this._dispatchEvent(attachmentsCount); |
| 5153 |
return; |
| 5154 |
} |
| 5155 |
var names = Object.keys(attachments).sort(function (a, b) { |
| 5156 |
return a.toLowerCase().localeCompare(b.toLowerCase()); |
| 5157 |
}); |
| 5158 |
attachmentsCount = names.length; |
| 5159 |
for (var i = 0; i < attachmentsCount; i++) { |
| 5160 |
var item = attachments[names[i]]; |
| 5161 |
var filename = (0, _pdfjsLib.removeNullCharacters)((0, _pdfjsLib.getFilenameFromUrl)(item.filename)); |
| 5162 |
var div = document.createElement('div'); |
| 5163 |
div.className = 'attachmentsItem'; |
| 5164 |
var button = document.createElement('button'); |
| 5165 |
button.textContent = filename; |
| 5166 |
if (/\.pdf$/i.test(filename) && !this.downloadManager.disableCreateObjectURL) { |
| 5167 |
this._bindPdfLink(button, item.content, filename); |
| 5168 |
} else { |
| 5169 |
this._bindLink(button, item.content, filename); |
| 5170 |
} |
| 5171 |
div.appendChild(button); |
| 5172 |
this.container.appendChild(div); |
| 5173 |
} |
| 5174 |
this._dispatchEvent(attachmentsCount); |
| 5175 |
} |
| 5176 |
}, { |
| 5177 |
key: '_appendAttachment', |
| 5178 |
value: function _appendAttachment(_ref3) { |
| 5179 |
var _this2 = this; |
| 5180 |
|
| 5181 |
var id = _ref3.id, |
| 5182 |
filename = _ref3.filename, |
| 5183 |
content = _ref3.content; |
| 5184 |
|
| 5185 |
this._renderedCapability.promise.then(function () { |
| 5186 |
var attachments = _this2.attachments; |
| 5187 |
if (!attachments) { |
| 5188 |
attachments = Object.create(null); |
| 5189 |
} else { |
| 5190 |
for (var name in attachments) { |
| 5191 |
if (id === name) { |
| 5192 |
return; |
| 5193 |
} |
| 5194 |
} |
| 5195 |
} |
| 5196 |
attachments[id] = { |
| 5197 |
filename: filename, |
| 5198 |
content: content |
| 5199 |
}; |
| 5200 |
_this2.render({ |
| 5201 |
attachments: attachments, |
| 5202 |
keepRenderedCapability: true |
| 5203 |
}); |
| 5204 |
}); |
| 5205 |
} |
| 5206 |
}]); |
| 5207 |
|
| 5208 |
return PDFAttachmentViewer; |
| 5209 |
}(); |
| 5210 |
|
| 5211 |
exports.PDFAttachmentViewer = PDFAttachmentViewer; |
| 5212 |
|
| 5213 |
/***/ }), |
| 5214 |
/* 18 */ |
| 5215 |
/***/ (function(module, exports, __webpack_require__) { |
| 5216 |
|
| 5217 |
"use strict"; |
| 5218 |
|
| 5219 |
|
| 5220 |
Object.defineProperty(exports, "__esModule", { |
| 5221 |
value: true |
| 5222 |
}); |
| 5223 |
exports.PDFDocumentProperties = undefined; |
| 5224 |
|
| 5225 |
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); |
| 5226 |
|
| 5227 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 5228 |
|
| 5229 |
var _ui_utils = __webpack_require__(6); |
| 5230 |
|
| 5231 |
var _pdfjsLib = __webpack_require__(7); |
| 5232 |
|
| 5233 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 5234 |
|
| 5235 |
var DEFAULT_FIELD_CONTENT = '-'; |
| 5236 |
var NON_METRIC_LOCALES = ['en-us', 'en-lr', 'my']; |
| 5237 |
var US_PAGE_NAMES = { |
| 5238 |
'8.5x11': 'Letter', |
| 5239 |
'8.5x14': 'Legal' |
| 5240 |
}; |
| 5241 |
var METRIC_PAGE_NAMES = { |
| 5242 |
'297x420': 'A3', |
| 5243 |
'210x297': 'A4' |
| 5244 |
}; |
| 5245 |
function getPageName(size, isPortrait, pageNames) { |
| 5246 |
var width = isPortrait ? size.width : size.height; |
| 5247 |
var height = isPortrait ? size.height : size.width; |
| 5248 |
return pageNames[width + 'x' + height]; |
| 5249 |
} |
| 5250 |
|
| 5251 |
var PDFDocumentProperties = function () { |
| 5252 |
function PDFDocumentProperties(_ref, overlayManager, eventBus) { |
| 5253 |
var overlayName = _ref.overlayName, |
| 5254 |
fields = _ref.fields, |
| 5255 |
container = _ref.container, |
| 5256 |
closeButton = _ref.closeButton; |
| 5257 |
|
| 5258 |
var _this = this; |
| 5259 |
|
| 5260 |
var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n; |
| 5261 |
|
| 5262 |
_classCallCheck(this, PDFDocumentProperties); |
| 5263 |
|
| 5264 |
this.overlayName = overlayName; |
| 5265 |
this.fields = fields; |
| 5266 |
this.container = container; |
| 5267 |
this.overlayManager = overlayManager; |
| 5268 |
this.l10n = l10n; |
| 5269 |
this._reset(); |
| 5270 |
if (closeButton) { |
| 5271 |
closeButton.addEventListener('click', this.close.bind(this)); |
| 5272 |
} |
| 5273 |
this.overlayManager.register(this.overlayName, this.container, this.close.bind(this)); |
| 5274 |
if (eventBus) { |
| 5275 |
eventBus.on('pagechanging', function (evt) { |
| 5276 |
_this._currentPageNumber = evt.pageNumber; |
| 5277 |
}); |
| 5278 |
eventBus.on('rotationchanging', function (evt) { |
| 5279 |
_this._pagesRotation = evt.pagesRotation; |
| 5280 |
}); |
| 5281 |
} |
| 5282 |
this._isNonMetricLocale = true; |
| 5283 |
l10n.getLanguage().then(function (locale) { |
| 5284 |
_this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale); |
| 5285 |
}); |
| 5286 |
} |
| 5287 |
|
| 5288 |
_createClass(PDFDocumentProperties, [{ |
| 5289 |
key: 'open', |
| 5290 |
value: function open() { |
| 5291 |
var _this2 = this; |
| 5292 |
|
| 5293 |
var freezeFieldData = function freezeFieldData(data) { |
| 5294 |
Object.defineProperty(_this2, 'fieldData', { |
| 5295 |
value: Object.freeze(data), |
| 5296 |
writable: false, |
| 5297 |
enumerable: true, |
| 5298 |
configurable: true |
| 5299 |
}); |
| 5300 |
}; |
| 5301 |
Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () { |
| 5302 |
var currentPageNumber = _this2._currentPageNumber; |
| 5303 |
var pagesRotation = _this2._pagesRotation; |
| 5304 |
if (_this2.fieldData && currentPageNumber === _this2.fieldData['_currentPageNumber'] && pagesRotation === _this2.fieldData['_pagesRotation']) { |
| 5305 |
_this2._updateUI(); |
| 5306 |
return; |
| 5307 |
} |
| 5308 |
_this2.pdfDocument.getMetadata().then(function (_ref2) { |
| 5309 |
var info = _ref2.info, |
| 5310 |
metadata = _ref2.metadata, |
| 5311 |
contentDispositionFilename = _ref2.contentDispositionFilename; |
| 5312 |
|
| 5313 |
return Promise.all([info, metadata, contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(_this2.url || ''), _this2._parseFileSize(_this2.maybeFileSize), _this2._parseDate(info.CreationDate), _this2._parseDate(info.ModDate), _this2.pdfDocument.getPage(currentPageNumber).then(function (pdfPage) { |
| 5314 |
return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation); |
| 5315 |
}), _this2._parseLinearization(info.IsLinearized)]); |
| 5316 |
}).then(function (_ref3) { |
| 5317 |
var _ref4 = _slicedToArray(_ref3, 8), |
| 5318 |
info = _ref4[0], |
| 5319 |
metadata = _ref4[1], |
| 5320 |
fileName = _ref4[2], |
| 5321 |
fileSize = _ref4[3], |
| 5322 |
creationDate = _ref4[4], |
| 5323 |
modDate = _ref4[5], |
| 5324 |
pageSize = _ref4[6], |
| 5325 |
isLinearized = _ref4[7]; |
| 5326 |
|
| 5327 |
freezeFieldData({ |
| 5328 |
'fileName': fileName, |
| 5329 |
'fileSize': fileSize, |
| 5330 |
'title': info.Title, |
| 5331 |
'author': info.Author, |
| 5332 |
'subject': info.Subject, |
| 5333 |
'keywords': info.Keywords, |
| 5334 |
'creationDate': creationDate, |
| 5335 |
'modificationDate': modDate, |
| 5336 |
'creator': info.Creator, |
| 5337 |
'producer': info.Producer, |
| 5338 |
'version': info.PDFFormatVersion, |
| 5339 |
'pageCount': _this2.pdfDocument.numPages, |
| 5340 |
'pageSize': pageSize, |
| 5341 |
'linearized': isLinearized, |
| 5342 |
'_currentPageNumber': currentPageNumber, |
| 5343 |
'_pagesRotation': pagesRotation |
| 5344 |
}); |
| 5345 |
_this2._updateUI(); |
| 5346 |
return _this2.pdfDocument.getDownloadInfo(); |
| 5347 |
}).then(function (_ref5) { |
| 5348 |
var length = _ref5.length; |
| 5349 |
|
| 5350 |
_this2.maybeFileSize = length; |
| 5351 |
return _this2._parseFileSize(length); |
| 5352 |
}).then(function (fileSize) { |
| 5353 |
if (fileSize === _this2.fieldData['fileSize']) { |
| 5354 |
return; |
| 5355 |
} |
| 5356 |
var data = Object.assign(Object.create(null), _this2.fieldData); |
| 5357 |
data['fileSize'] = fileSize; |
| 5358 |
freezeFieldData(data); |
| 5359 |
_this2._updateUI(); |
| 5360 |
}); |
| 5361 |
}); |
| 5362 |
} |
| 5363 |
}, { |
| 5364 |
key: 'close', |
| 5365 |
value: function close() { |
| 5366 |
this.overlayManager.close(this.overlayName); |
| 5367 |
} |
| 5368 |
}, { |
| 5369 |
key: 'setDocument', |
| 5370 |
value: function setDocument(pdfDocument) { |
| 5371 |
var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; |
| 5372 |
|
| 5373 |
if (this.pdfDocument) { |
| 5374 |
this._reset(); |
| 5375 |
this._updateUI(true); |
| 5376 |
} |
| 5377 |
if (!pdfDocument) { |
| 5378 |
return; |
| 5379 |
} |
| 5380 |
this.pdfDocument = pdfDocument; |
| 5381 |
this.url = url; |
| 5382 |
this._dataAvailableCapability.resolve(); |
| 5383 |
} |
| 5384 |
}, { |
| 5385 |
key: 'setFileSize', |
| 5386 |
value: function setFileSize(fileSize) { |
| 5387 |
if (Number.isInteger(fileSize) && fileSize > 0) { |
| 5388 |
this.maybeFileSize = fileSize; |
| 5389 |
} |
| 5390 |
} |
| 5391 |
}, { |
| 5392 |
key: '_reset', |
| 5393 |
value: function _reset() { |
| 5394 |
this.pdfDocument = null; |
| 5395 |
this.url = null; |
| 5396 |
this.maybeFileSize = 0; |
| 5397 |
delete this.fieldData; |
| 5398 |
this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)(); |
| 5399 |
this._currentPageNumber = 1; |
| 5400 |
this._pagesRotation = 0; |
| 5401 |
} |
| 5402 |
}, { |
| 5403 |
key: '_updateUI', |
| 5404 |
value: function _updateUI() { |
| 5405 |
var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
| 5406 |
|
| 5407 |
if (reset || !this.fieldData) { |
| 5408 |
for (var id in this.fields) { |
| 5409 |
this.fields[id].textContent = DEFAULT_FIELD_CONTENT; |
| 5410 |
} |
| 5411 |
return; |
| 5412 |
} |
| 5413 |
if (this.overlayManager.active !== this.overlayName) { |
| 5414 |
return; |
| 5415 |
} |
| 5416 |
for (var _id in this.fields) { |
| 5417 |
var content = this.fieldData[_id]; |
| 5418 |
this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT; |
| 5419 |
} |
| 5420 |
} |
| 5421 |
}, { |
| 5422 |
key: '_parseFileSize', |
| 5423 |
value: function _parseFileSize() { |
| 5424 |
var fileSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; |
| 5425 |
|
| 5426 |
var kb = fileSize / 1024; |
| 5427 |
if (!kb) { |
| 5428 |
return Promise.resolve(undefined); |
| 5429 |
} else if (kb < 1024) { |
| 5430 |
return this.l10n.get('document_properties_kb', { |
| 5431 |
size_kb: (+kb.toPrecision(3)).toLocaleString(), |
| 5432 |
size_b: fileSize.toLocaleString() |
| 5433 |
}, '{{size_kb}} KB ({{size_b}} bytes)'); |
| 5434 |
} |
| 5435 |
return this.l10n.get('document_properties_mb', { |
| 5436 |
size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(), |
| 5437 |
size_b: fileSize.toLocaleString() |
| 5438 |
}, '{{size_mb}} MB ({{size_b}} bytes)'); |
| 5439 |
} |
| 5440 |
}, { |
| 5441 |
key: '_parsePageSize', |
| 5442 |
value: function _parsePageSize(pageSizeInches, pagesRotation) { |
| 5443 |
var _this3 = this; |
| 5444 |
|
| 5445 |
if (!pageSizeInches) { |
| 5446 |
return Promise.resolve(undefined); |
| 5447 |
} |
| 5448 |
if (pagesRotation % 180 !== 0) { |
| 5449 |
pageSizeInches = { |
| 5450 |
width: pageSizeInches.height, |
| 5451 |
height: pageSizeInches.width |
| 5452 |
}; |
| 5453 |
} |
| 5454 |
var isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches); |
| 5455 |
var sizeInches = { |
| 5456 |
width: Math.round(pageSizeInches.width * 100) / 100, |
| 5457 |
height: Math.round(pageSizeInches.height * 100) / 100 |
| 5458 |
}; |
| 5459 |
var sizeMillimeters = { |
| 5460 |
width: Math.round(pageSizeInches.width * 25.4 * 10) / 10, |
| 5461 |
height: Math.round(pageSizeInches.height * 25.4 * 10) / 10 |
| 5462 |
}; |
| 5463 |
var pageName = null; |
| 5464 |
var name = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES); |
| 5465 |
if (!name && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) { |
| 5466 |
var exactMillimeters = { |
| 5467 |
width: pageSizeInches.width * 25.4, |
| 5468 |
height: pageSizeInches.height * 25.4 |
| 5469 |
}; |
| 5470 |
var intMillimeters = { |
| 5471 |
width: Math.round(sizeMillimeters.width), |
| 5472 |
height: Math.round(sizeMillimeters.height) |
| 5473 |
}; |
| 5474 |
if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) { |
| 5475 |
name = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES); |
| 5476 |
if (name) { |
| 5477 |
sizeInches = { |
| 5478 |
width: Math.round(intMillimeters.width / 25.4 * 100) / 100, |
| 5479 |
height: Math.round(intMillimeters.height / 25.4 * 100) / 100 |
| 5480 |
}; |
| 5481 |
sizeMillimeters = intMillimeters; |
| 5482 |
} |
| 5483 |
} |
| 5484 |
} |
| 5485 |
if (name) { |
| 5486 |
pageName = this.l10n.get('document_properties_page_size_name_' + name.toLowerCase(), null, name); |
| 5487 |
} |
| 5488 |
return Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get('document_properties_page_size_unit_' + (this._isNonMetricLocale ? 'inches' : 'millimeters'), null, this._isNonMetricLocale ? 'in' : 'mm'), pageName, this.l10n.get('document_properties_page_size_orientation_' + (isPortrait ? 'portrait' : 'landscape'), null, isPortrait ? 'portrait' : 'landscape')]).then(function (_ref6) { |
| 5489 |
var _ref7 = _slicedToArray(_ref6, 4), |
| 5490 |
_ref7$ = _ref7[0], |
| 5491 |
width = _ref7$.width, |
| 5492 |
height = _ref7$.height, |
| 5493 |
unit = _ref7[1], |
| 5494 |
name = _ref7[2], |
| 5495 |
orientation = _ref7[3]; |
| 5496 |
|
| 5497 |
return _this3.l10n.get('document_properties_page_size_dimension_' + (name ? 'name_' : '') + 'string', { |
| 5498 |
width: width.toLocaleString(), |
| 5499 |
height: height.toLocaleString(), |
| 5500 |
unit: unit, |
| 5501 |
name: name, |
| 5502 |
orientation: orientation |
| 5503 |
}, '{{width}} × {{height}} {{unit}} (' + (name ? '{{name}}, ' : '') + '{{orientation}})'); |
| 5504 |
}); |
| 5505 |
} |
| 5506 |
}, { |
| 5507 |
key: '_parseDate', |
| 5508 |
value: function _parseDate(inputDate) { |
| 5509 |
if (!inputDate) { |
| 5510 |
return; |
| 5511 |
} |
| 5512 |
var dateToParse = inputDate; |
| 5513 |
if (dateToParse.substring(0, 2) === 'D:') { |
| 5514 |
dateToParse = dateToParse.substring(2); |
| 5515 |
} |
| 5516 |
var year = parseInt(dateToParse.substring(0, 4), 10); |
| 5517 |
var month = parseInt(dateToParse.substring(4, 6), 10) - 1; |
| 5518 |
var day = parseInt(dateToParse.substring(6, 8), 10); |
| 5519 |
var hours = parseInt(dateToParse.substring(8, 10), 10); |
| 5520 |
var minutes = parseInt(dateToParse.substring(10, 12), 10); |
| 5521 |
var seconds = parseInt(dateToParse.substring(12, 14), 10); |
| 5522 |
var utRel = dateToParse.substring(14, 15); |
| 5523 |
var offsetHours = parseInt(dateToParse.substring(15, 17), 10); |
| 5524 |
var offsetMinutes = parseInt(dateToParse.substring(18, 20), 10); |
| 5525 |
if (utRel === '-') { |
| 5526 |
hours += offsetHours; |
| 5527 |
minutes += offsetMinutes; |
| 5528 |
} else if (utRel === '+') { |
| 5529 |
hours -= offsetHours; |
| 5530 |
minutes -= offsetMinutes; |
| 5531 |
} |
| 5532 |
var date = new Date(Date.UTC(year, month, day, hours, minutes, seconds)); |
| 5533 |
var dateString = date.toLocaleDateString(); |
| 5534 |
var timeString = date.toLocaleTimeString(); |
| 5535 |
return this.l10n.get('document_properties_date_string', { |
| 5536 |
date: dateString, |
| 5537 |
time: timeString |
| 5538 |
}, '{{date}}, {{time}}'); |
| 5539 |
} |
| 5540 |
}, { |
| 5541 |
key: '_parseLinearization', |
| 5542 |
value: function _parseLinearization(isLinearized) { |
| 5543 |
return this.l10n.get('document_properties_linearized_' + (isLinearized ? 'yes' : 'no'), null, isLinearized ? 'Yes' : 'No'); |
| 5544 |
} |
| 5545 |
}]); |
| 5546 |
|
| 5547 |
return PDFDocumentProperties; |
| 5548 |
}(); |
| 5549 |
|
| 5550 |
exports.PDFDocumentProperties = PDFDocumentProperties; |
| 5551 |
|
| 5552 |
/***/ }), |
| 5553 |
/* 19 */ |
| 5554 |
/***/ (function(module, exports, __webpack_require__) { |
| 5555 |
|
| 5556 |
"use strict"; |
| 5557 |
|
| 5558 |
|
| 5559 |
Object.defineProperty(exports, "__esModule", { |
| 5560 |
value: true |
| 5561 |
}); |
| 5562 |
exports.PDFFindBar = undefined; |
| 5563 |
|
| 5564 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 5565 |
|
| 5566 |
var _ui_utils = __webpack_require__(6); |
| 5567 |
|
| 5568 |
var _pdf_find_controller = __webpack_require__(20); |
| 5569 |
|
| 5570 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 5571 |
|
| 5572 |
var MATCHES_COUNT_LIMIT = 1000; |
| 5573 |
|
| 5574 |
var PDFFindBar = function () { |
| 5575 |
function PDFFindBar(options) { |
| 5576 |
var _this = this; |
| 5577 |
|
| 5578 |
var eventBus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (0, _ui_utils.getGlobalEventBus)(); |
| 5579 |
var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n; |
| 5580 |
|
| 5581 |
_classCallCheck(this, PDFFindBar); |
| 5582 |
|
| 5583 |
this.opened = false; |
| 5584 |
this.bar = options.bar || null; |
| 5585 |
this.toggleButton = options.toggleButton || null; |
| 5586 |
this.findField = options.findField || null; |
| 5587 |
this.highlightAll = options.highlightAllCheckbox || null; |
| 5588 |
this.caseSensitive = options.caseSensitiveCheckbox || null; |
| 5589 |
this.entireWord = options.entireWordCheckbox || null; |
| 5590 |
this.findMsg = options.findMsg || null; |
| 5591 |
this.findResultsCount = options.findResultsCount || null; |
| 5592 |
this.findPreviousButton = options.findPreviousButton || null; |
| 5593 |
this.findNextButton = options.findNextButton || null; |
| 5594 |
this.eventBus = eventBus; |
| 5595 |
this.l10n = l10n; |
| 5596 |
this.toggleButton.addEventListener('click', function () { |
| 5597 |
_this.toggle(); |
| 5598 |
}); |
| 5599 |
this.findField.addEventListener('input', function () { |
| 5600 |
_this.dispatchEvent(''); |
| 5601 |
}); |
| 5602 |
this.bar.addEventListener('keydown', function (e) { |
| 5603 |
switch (e.keyCode) { |
| 5604 |
case 13: |
| 5605 |
if (e.target === _this.findField) { |
| 5606 |
_this.dispatchEvent('again', e.shiftKey); |
| 5607 |
} |
| 5608 |
break; |
| 5609 |
case 27: |
| 5610 |
_this.close(); |
| 5611 |
break; |
| 5612 |
} |
| 5613 |
}); |
| 5614 |
this.findPreviousButton.addEventListener('click', function () { |
| 5615 |
_this.dispatchEvent('again', true); |
| 5616 |
}); |
| 5617 |
this.findNextButton.addEventListener('click', function () { |
| 5618 |
_this.dispatchEvent('again', false); |
| 5619 |
}); |
| 5620 |
this.highlightAll.addEventListener('click', function () { |
| 5621 |
_this.dispatchEvent('highlightallchange'); |
| 5622 |
}); |
| 5623 |
this.caseSensitive.addEventListener('click', function () { |
| 5624 |
_this.dispatchEvent('casesensitivitychange'); |
| 5625 |
}); |
| 5626 |
this.entireWord.addEventListener('click', function () { |
| 5627 |
_this.dispatchEvent('entirewordchange'); |
| 5628 |
}); |
| 5629 |
this.eventBus.on('resize', this._adjustWidth.bind(this)); |
| 5630 |
} |
| 5631 |
|
| 5632 |
_createClass(PDFFindBar, [{ |
| 5633 |
key: 'reset', |
| 5634 |
value: function reset() { |
| 5635 |
this.updateUIState(); |
| 5636 |
} |
| 5637 |
}, { |
| 5638 |
key: 'dispatchEvent', |
| 5639 |
value: function dispatchEvent(type, findPrev) { |
| 5640 |
this.eventBus.dispatch('find', { |
| 5641 |
source: this, |
| 5642 |
type: type, |
| 5643 |
query: this.findField.value, |
| 5644 |
phraseSearch: true, |
| 5645 |
caseSensitive: this.caseSensitive.checked, |
| 5646 |
entireWord: this.entireWord.checked, |
| 5647 |
highlightAll: this.highlightAll.checked, |
| 5648 |
findPrevious: findPrev |
| 5649 |
}); |
| 5650 |
} |
| 5651 |
}, { |
| 5652 |
key: 'updateUIState', |
| 5653 |
value: function updateUIState(state, previous, matchesCount) { |
| 5654 |
var _this2 = this; |
| 5655 |
|
| 5656 |
var notFound = false; |
| 5657 |
var findMsg = ''; |
| 5658 |
var status = ''; |
| 5659 |
switch (state) { |
| 5660 |
case _pdf_find_controller.FindState.FOUND: |
| 5661 |
break; |
| 5662 |
case _pdf_find_controller.FindState.PENDING: |
| 5663 |
status = 'pending'; |
| 5664 |
break; |
| 5665 |
case _pdf_find_controller.FindState.NOT_FOUND: |
| 5666 |
findMsg = this.l10n.get('find_not_found', null, 'Phrase not found'); |
| 5667 |
notFound = true; |
| 5668 |
break; |
| 5669 |
case _pdf_find_controller.FindState.WRAPPED: |
| 5670 |
if (previous) { |
| 5671 |
findMsg = this.l10n.get('find_reached_top', null, 'Reached top of document, continued from bottom'); |
| 5672 |
} else { |
| 5673 |
findMsg = this.l10n.get('find_reached_bottom', null, 'Reached end of document, continued from top'); |
| 5674 |
} |
| 5675 |
break; |
| 5676 |
} |
| 5677 |
this.findField.classList.toggle('notFound', notFound); |
| 5678 |
this.findField.setAttribute('data-status', status); |
| 5679 |
Promise.resolve(findMsg).then(function (msg) { |
| 5680 |
_this2.findMsg.textContent = msg; |
| 5681 |
_this2._adjustWidth(); |
| 5682 |
}); |
| 5683 |
this.updateResultsCount(matchesCount); |
| 5684 |
} |
| 5685 |
}, { |
| 5686 |
key: 'updateResultsCount', |
| 5687 |
value: function updateResultsCount() { |
| 5688 |
var _this3 = this; |
| 5689 |
|
| 5690 |
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, |
| 5691 |
_ref$current = _ref.current, |
| 5692 |
current = _ref$current === undefined ? 0 : _ref$current, |
| 5693 |
_ref$total = _ref.total, |
| 5694 |
total = _ref$total === undefined ? 0 : _ref$total; |
| 5695 |
|
| 5696 |
if (!this.findResultsCount) { |
| 5697 |
return; |
| 5698 |
} |
| 5699 |
var matchesCountMsg = '', |
| 5700 |
limit = MATCHES_COUNT_LIMIT; |
| 5701 |
if (total > 0) { |
| 5702 |
if (total > limit) { |
| 5703 |
matchesCountMsg = this.l10n.get('find_match_count_limit', { limit: limit }, 'More than {{limit}} match' + (limit !== 1 ? 'es' : '')); |
| 5704 |
} else { |
| 5705 |
matchesCountMsg = this.l10n.get('find_match_count', { |
| 5706 |
current: current, |
| 5707 |
total: total |
| 5708 |
}, '{{current}} of {{total}} match' + (total !== 1 ? 'es' : '')); |
| 5709 |
} |
| 5710 |
} |
| 5711 |
Promise.resolve(matchesCountMsg).then(function (msg) { |
| 5712 |
_this3.findResultsCount.textContent = msg; |
| 5713 |
_this3.findResultsCount.classList[!total ? 'add' : 'remove']('hidden'); |
| 5714 |
_this3._adjustWidth(); |
| 5715 |
}); |
| 5716 |
} |
| 5717 |
}, { |
| 5718 |
key: 'open', |
| 5719 |
value: function open() { |
| 5720 |
if (!this.opened) { |
| 5721 |
this.opened = true; |
| 5722 |
this.toggleButton.classList.add('toggled'); |
| 5723 |
this.bar.classList.remove('hidden'); |
| 5724 |
} |
| 5725 |
this.findField.select(); |
| 5726 |
this.findField.focus(); |
| 5727 |
this._adjustWidth(); |
| 5728 |
} |
| 5729 |
}, { |
| 5730 |
key: 'close', |
| 5731 |
value: function close() { |
| 5732 |
if (!this.opened) { |
| 5733 |
return; |
| 5734 |
} |
| 5735 |
this.opened = false; |
| 5736 |
this.toggleButton.classList.remove('toggled'); |
| 5737 |
this.bar.classList.add('hidden'); |
| 5738 |
this.eventBus.dispatch('findbarclose', { source: this }); |
| 5739 |
} |
| 5740 |
}, { |
| 5741 |
key: 'toggle', |
| 5742 |
value: function toggle() { |
| 5743 |
if (this.opened) { |
| 5744 |
this.close(); |
| 5745 |
} else { |
| 5746 |
this.open(); |
| 5747 |
} |
| 5748 |
} |
| 5749 |
}, { |
| 5750 |
key: '_adjustWidth', |
| 5751 |
value: function _adjustWidth() { |
| 5752 |
if (!this.opened) { |
| 5753 |
return; |
| 5754 |
} |
| 5755 |
this.bar.classList.remove('wrapContainers'); |
| 5756 |
var findbarHeight = this.bar.clientHeight; |
| 5757 |
var inputContainerHeight = this.bar.firstElementChild.clientHeight; |
| 5758 |
if (findbarHeight > inputContainerHeight) { |
| 5759 |
this.bar.classList.add('wrapContainers'); |
| 5760 |
} |
| 5761 |
} |
| 5762 |
}]); |
| 5763 |
|
| 5764 |
return PDFFindBar; |
| 5765 |
}(); |
| 5766 |
|
| 5767 |
exports.PDFFindBar = PDFFindBar; |
| 5768 |
|
| 5769 |
/***/ }), |
| 5770 |
/* 20 */ |
| 5771 |
/***/ (function(module, exports, __webpack_require__) { |
| 5772 |
|
| 5773 |
"use strict"; |
| 5774 |
|
| 5775 |
|
| 5776 |
Object.defineProperty(exports, "__esModule", { |
| 5777 |
value: true |
| 5778 |
}); |
| 5779 |
exports.PDFFindController = exports.FindState = undefined; |
| 5780 |
|
| 5781 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 5782 |
|
| 5783 |
var _pdfjsLib = __webpack_require__(7); |
| 5784 |
|
| 5785 |
var _pdf_find_utils = __webpack_require__(21); |
| 5786 |
|
| 5787 |
var _dom_events = __webpack_require__(14); |
| 5788 |
|
| 5789 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 5790 |
|
| 5791 |
var FindState = { |
| 5792 |
FOUND: 0, |
| 5793 |
NOT_FOUND: 1, |
| 5794 |
WRAPPED: 2, |
| 5795 |
PENDING: 3 |
| 5796 |
}; |
| 5797 |
var FIND_TIMEOUT = 250; |
| 5798 |
var CHARACTERS_TO_NORMALIZE = { |
| 5799 |
'\u2018': '\'', |
| 5800 |
'\u2019': '\'', |
| 5801 |
'\u201A': '\'', |
| 5802 |
'\u201B': '\'', |
| 5803 |
'\u201C': '"', |
| 5804 |
'\u201D': '"', |
| 5805 |
'\u201E': '"', |
| 5806 |
'\u201F': '"', |
| 5807 |
'\xBC': '1/4', |
| 5808 |
'\xBD': '1/2', |
| 5809 |
'\xBE': '3/4' |
| 5810 |
}; |
| 5811 |
|
| 5812 |
var PDFFindController = function () { |
| 5813 |
function PDFFindController(_ref) { |
| 5814 |
var linkService = _ref.linkService, |
| 5815 |
_ref$eventBus = _ref.eventBus, |
| 5816 |
eventBus = _ref$eventBus === undefined ? (0, _dom_events.getGlobalEventBus)() : _ref$eventBus; |
| 5817 |
|
| 5818 |
_classCallCheck(this, PDFFindController); |
| 5819 |
|
| 5820 |
this._linkService = linkService; |
| 5821 |
this._eventBus = eventBus; |
| 5822 |
this._reset(); |
| 5823 |
eventBus.on('findbarclose', this._onFindBarClose.bind(this)); |
| 5824 |
var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join(''); |
| 5825 |
this._normalizationRegex = new RegExp('[' + replace + ']', 'g'); |
| 5826 |
} |
| 5827 |
|
| 5828 |
_createClass(PDFFindController, [{ |
| 5829 |
key: 'setDocument', |
| 5830 |
value: function setDocument(pdfDocument) { |
| 5831 |
if (this._pdfDocument) { |
| 5832 |
this._reset(); |
| 5833 |
} |
| 5834 |
if (!pdfDocument) { |
| 5835 |
return; |
| 5836 |
} |
| 5837 |
this._pdfDocument = pdfDocument; |
| 5838 |
this._firstPageCapability.resolve(); |
| 5839 |
} |
| 5840 |
}, { |
| 5841 |
key: 'executeCommand', |
| 5842 |
value: function executeCommand(cmd, state) { |
| 5843 |
var _this = this; |
| 5844 |
|
| 5845 |
var pdfDocument = this._pdfDocument; |
| 5846 |
if (this._state === null || cmd !== 'findagain') { |
| 5847 |
this._dirtyMatch = true; |
| 5848 |
} |
| 5849 |
this._state = state; |
| 5850 |
this._updateUIState(FindState.PENDING); |
| 5851 |
this._firstPageCapability.promise.then(function () { |
| 5852 |
if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) { |
| 5853 |
return; |
| 5854 |
} |
| 5855 |
_this._extractText(); |
| 5856 |
if (_this._findTimeout) { |
| 5857 |
clearTimeout(_this._findTimeout); |
| 5858 |
_this._findTimeout = null; |
| 5859 |
} |
| 5860 |
if (cmd === 'find') { |
| 5861 |
_this._findTimeout = setTimeout(function () { |
| 5862 |
_this._nextMatch(); |
| 5863 |
_this._findTimeout = null; |
| 5864 |
}, FIND_TIMEOUT); |
| 5865 |
} else { |
| 5866 |
_this._nextMatch(); |
| 5867 |
} |
| 5868 |
}); |
| 5869 |
} |
| 5870 |
}, { |
| 5871 |
key: '_reset', |
| 5872 |
value: function _reset() { |
| 5873 |
this._highlightMatches = false; |
| 5874 |
this._pdfDocument = null; |
| 5875 |
this._pageMatches = []; |
| 5876 |
this._pageMatchesLength = null; |
| 5877 |
this._state = null; |
| 5878 |
this._selected = { |
| 5879 |
pageIdx: -1, |
| 5880 |
matchIdx: -1 |
| 5881 |
}; |
| 5882 |
this._offset = { |
| 5883 |
pageIdx: null, |
| 5884 |
matchIdx: null |
| 5885 |
}; |
| 5886 |
this._extractTextPromises = []; |
| 5887 |
this._pageContents = []; |
| 5888 |
this._matchesCountTotal = 0; |
| 5889 |
this._pagesToSearch = null; |
| 5890 |
this._pendingFindMatches = Object.create(null); |
| 5891 |
this._resumePageIdx = null; |
| 5892 |
this._dirtyMatch = false; |
| 5893 |
clearTimeout(this._findTimeout); |
| 5894 |
this._findTimeout = null; |
| 5895 |
this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)(); |
| 5896 |
} |
| 5897 |
}, { |
| 5898 |
key: '_normalize', |
| 5899 |
value: function _normalize(text) { |
| 5900 |
return text.replace(this._normalizationRegex, function (ch) { |
| 5901 |
return CHARACTERS_TO_NORMALIZE[ch]; |
| 5902 |
}); |
| 5903 |
} |
| 5904 |
}, { |
| 5905 |
key: '_prepareMatches', |
| 5906 |
value: function _prepareMatches(matchesWithLength, matches, matchesLength) { |
| 5907 |
function isSubTerm(matchesWithLength, currentIndex) { |
| 5908 |
var currentElem = matchesWithLength[currentIndex]; |
| 5909 |
var nextElem = matchesWithLength[currentIndex + 1]; |
| 5910 |
if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) { |
| 5911 |
currentElem.skipped = true; |
| 5912 |
return true; |
| 5913 |
} |
| 5914 |
for (var i = currentIndex - 1; i >= 0; i--) { |
| 5915 |
var prevElem = matchesWithLength[i]; |
| 5916 |
if (prevElem.skipped) { |
| 5917 |
continue; |
| 5918 |
} |
| 5919 |
if (prevElem.match + prevElem.matchLength < currentElem.match) { |
| 5920 |
break; |
| 5921 |
} |
| 5922 |
if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) { |
| 5923 |
currentElem.skipped = true; |
| 5924 |
return true; |
| 5925 |
} |
| 5926 |
} |
| 5927 |
return false; |
| 5928 |
} |
| 5929 |
matchesWithLength.sort(function (a, b) { |
| 5930 |
return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match; |
| 5931 |
}); |
| 5932 |
for (var i = 0, len = matchesWithLength.length; i < len; i++) { |
| 5933 |
if (isSubTerm(matchesWithLength, i)) { |
| 5934 |
continue; |
| 5935 |
} |
| 5936 |
matches.push(matchesWithLength[i].match); |
| 5937 |
matchesLength.push(matchesWithLength[i].matchLength); |
| 5938 |
} |
| 5939 |
} |
| 5940 |
}, { |
| 5941 |
key: '_isEntireWord', |
| 5942 |
value: function _isEntireWord(content, startIdx, length) { |
| 5943 |
if (startIdx > 0) { |
| 5944 |
var first = content.charCodeAt(startIdx); |
| 5945 |
var limit = content.charCodeAt(startIdx - 1); |
| 5946 |
if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) { |
| 5947 |
return false; |
| 5948 |
} |
| 5949 |
} |
| 5950 |
var endIdx = startIdx + length - 1; |
| 5951 |
if (endIdx < content.length - 1) { |
| 5952 |
var last = content.charCodeAt(endIdx); |
| 5953 |
var _limit = content.charCodeAt(endIdx + 1); |
| 5954 |
if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) { |
| 5955 |
return false; |
| 5956 |
} |
| 5957 |
} |
| 5958 |
return true; |
| 5959 |
} |
| 5960 |
}, { |
| 5961 |
key: '_calculatePhraseMatch', |
| 5962 |
value: function _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) { |
| 5963 |
var matches = []; |
| 5964 |
var queryLen = query.length; |
| 5965 |
var matchIdx = -queryLen; |
| 5966 |
while (true) { |
| 5967 |
matchIdx = pageContent.indexOf(query, matchIdx + queryLen); |
| 5968 |
if (matchIdx === -1) { |
| 5969 |
break; |
| 5970 |
} |
| 5971 |
if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) { |
| 5972 |
continue; |
| 5973 |
} |
| 5974 |
matches.push(matchIdx); |
| 5975 |
} |
| 5976 |
this._pageMatches[pageIndex] = matches; |
| 5977 |
} |
| 5978 |
}, { |
| 5979 |
key: '_calculateWordMatch', |
| 5980 |
value: function _calculateWordMatch(query, pageIndex, pageContent, entireWord) { |
| 5981 |
var matchesWithLength = []; |
| 5982 |
var queryArray = query.match(/\S+/g); |
| 5983 |
for (var i = 0, len = queryArray.length; i < len; i++) { |
| 5984 |
var subquery = queryArray[i]; |
| 5985 |
var subqueryLen = subquery.length; |
| 5986 |
var matchIdx = -subqueryLen; |
| 5987 |
while (true) { |
| 5988 |
matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen); |
| 5989 |
if (matchIdx === -1) { |
| 5990 |
break; |
| 5991 |
} |
| 5992 |
if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) { |
| 5993 |
continue; |
| 5994 |
} |
| 5995 |
matchesWithLength.push({ |
| 5996 |
match: matchIdx, |
| 5997 |
matchLength: subqueryLen, |
| 5998 |
skipped: false |
| 5999 |
}); |
| 6000 |
} |
| 6001 |
} |
| 6002 |
if (!this._pageMatchesLength) { |
| 6003 |
this._pageMatchesLength = []; |
| 6004 |
} |
| 6005 |
this._pageMatchesLength[pageIndex] = []; |
| 6006 |
this._pageMatches[pageIndex] = []; |
| 6007 |
this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]); |
| 6008 |
} |
| 6009 |
}, { |
| 6010 |
key: '_calculateMatch', |
| 6011 |
value: function _calculateMatch(pageIndex) { |
| 6012 |
var pageContent = this._normalize(this._pageContents[pageIndex]); |
| 6013 |
var query = this._normalize(this._state.query); |
| 6014 |
var _state = this._state, |
| 6015 |
caseSensitive = _state.caseSensitive, |
| 6016 |
entireWord = _state.entireWord, |
| 6017 |
phraseSearch = _state.phraseSearch; |
| 6018 |
|
| 6019 |
if (query.length === 0) { |
| 6020 |
return; |
| 6021 |
} |
| 6022 |
if (!caseSensitive) { |
| 6023 |
pageContent = pageContent.toLowerCase(); |
| 6024 |
query = query.toLowerCase(); |
| 6025 |
} |
| 6026 |
if (phraseSearch) { |
| 6027 |
this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord); |
| 6028 |
} else { |
| 6029 |
this._calculateWordMatch(query, pageIndex, pageContent, entireWord); |
| 6030 |
} |
| 6031 |
this._updatePage(pageIndex); |
| 6032 |
if (this._resumePageIdx === pageIndex) { |
| 6033 |
this._resumePageIdx = null; |
| 6034 |
this._nextPageMatch(); |
| 6035 |
} |
| 6036 |
var pageMatchesCount = this._pageMatches[pageIndex].length; |
| 6037 |
if (pageMatchesCount > 0) { |
| 6038 |
this._matchesCountTotal += pageMatchesCount; |
| 6039 |
this._updateUIResultsCount(); |
| 6040 |
} |
| 6041 |
} |
| 6042 |
}, { |
| 6043 |
key: '_extractText', |
| 6044 |
value: function _extractText() { |
| 6045 |
var _this2 = this; |
| 6046 |
|
| 6047 |
if (this._extractTextPromises.length > 0) { |
| 6048 |
return; |
| 6049 |
} |
| 6050 |
var promise = Promise.resolve(); |
| 6051 |
|
| 6052 |
var _loop = function _loop(i, ii) { |
| 6053 |
var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)(); |
| 6054 |
_this2._extractTextPromises[i] = extractTextCapability.promise; |
| 6055 |
promise = promise.then(function () { |
| 6056 |
return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) { |
| 6057 |
return pdfPage.getTextContent({ normalizeWhitespace: true }); |
| 6058 |
}).then(function (textContent) { |
| 6059 |
var textItems = textContent.items; |
| 6060 |
var strBuf = []; |
| 6061 |
for (var j = 0, jj = textItems.length; j < jj; j++) { |
| 6062 |
strBuf.push(textItems[j].str); |
| 6063 |
} |
| 6064 |
_this2._pageContents[i] = strBuf.join(''); |
| 6065 |
extractTextCapability.resolve(i); |
| 6066 |
}, function (reason) { |
| 6067 |
console.error('Unable to get text content for page ' + (i + 1), reason); |
| 6068 |
_this2._pageContents[i] = ''; |
| 6069 |
extractTextCapability.resolve(i); |
| 6070 |
}); |
| 6071 |
}); |
| 6072 |
}; |
| 6073 |
|
| 6074 |
for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) { |
| 6075 |
_loop(i, ii); |
| 6076 |
} |
| 6077 |
} |
| 6078 |
}, { |
| 6079 |
key: '_updatePage', |
| 6080 |
value: function _updatePage(index) { |
| 6081 |
if (this._selected.pageIdx === index) { |
| 6082 |
this._linkService.page = index + 1; |
| 6083 |
} |
| 6084 |
this._eventBus.dispatch('updatetextlayermatches', { |
| 6085 |
source: this, |
| 6086 |
pageIndex: index |
| 6087 |
}); |
| 6088 |
} |
| 6089 |
}, { |
| 6090 |
key: '_nextMatch', |
| 6091 |
value: function _nextMatch() { |
| 6092 |
var _this3 = this; |
| 6093 |
|
| 6094 |
var previous = this._state.findPrevious; |
| 6095 |
var currentPageIndex = this._linkService.page - 1; |
| 6096 |
var numPages = this._linkService.pagesCount; |
| 6097 |
this._highlightMatches = true; |
| 6098 |
if (this._dirtyMatch) { |
| 6099 |
this._dirtyMatch = false; |
| 6100 |
this._selected.pageIdx = this._selected.matchIdx = -1; |
| 6101 |
this._offset.pageIdx = currentPageIndex; |
| 6102 |
this._offset.matchIdx = null; |
| 6103 |
this._resumePageIdx = null; |
| 6104 |
this._pageMatches.length = 0; |
| 6105 |
this._pageMatchesLength = null; |
| 6106 |
this._matchesCountTotal = 0; |
| 6107 |
for (var i = 0; i < numPages; i++) { |
| 6108 |
this._updatePage(i); |
| 6109 |
if (!(i in this._pendingFindMatches)) { |
| 6110 |
this._pendingFindMatches[i] = true; |
| 6111 |
this._extractTextPromises[i].then(function (pageIdx) { |
| 6112 |
delete _this3._pendingFindMatches[pageIdx]; |
| 6113 |
_this3._calculateMatch(pageIdx); |
| 6114 |
}); |
| 6115 |
} |
| 6116 |
} |
| 6117 |
} |
| 6118 |
if (this._state.query === '') { |
| 6119 |
this._updateUIState(FindState.FOUND); |
| 6120 |
return; |
| 6121 |
} |
| 6122 |
if (this._resumePageIdx) { |
| 6123 |
return; |
| 6124 |
} |
| 6125 |
var offset = this._offset; |
| 6126 |
this._pagesToSearch = numPages; |
| 6127 |
if (offset.matchIdx !== null) { |
| 6128 |
var numPageMatches = this._pageMatches[offset.pageIdx].length; |
| 6129 |
if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) { |
| 6130 |
offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1; |
| 6131 |
this._updateMatch(true); |
| 6132 |
return; |
| 6133 |
} |
| 6134 |
this._advanceOffsetPage(previous); |
| 6135 |
} |
| 6136 |
this._nextPageMatch(); |
| 6137 |
} |
| 6138 |
}, { |
| 6139 |
key: '_matchesReady', |
| 6140 |
value: function _matchesReady(matches) { |
| 6141 |
var offset = this._offset; |
| 6142 |
var numMatches = matches.length; |
| 6143 |
var previous = this._state.findPrevious; |
| 6144 |
if (numMatches) { |
| 6145 |
offset.matchIdx = previous ? numMatches - 1 : 0; |
| 6146 |
this._updateMatch(true); |
| 6147 |
return true; |
| 6148 |
} |
| 6149 |
this._advanceOffsetPage(previous); |
| 6150 |
if (offset.wrapped) { |
| 6151 |
offset.matchIdx = null; |
| 6152 |
if (this._pagesToSearch < 0) { |
| 6153 |
this._updateMatch(false); |
| 6154 |
return true; |
| 6155 |
} |
| 6156 |
} |
| 6157 |
return false; |
| 6158 |
} |
| 6159 |
}, { |
| 6160 |
key: '_nextPageMatch', |
| 6161 |
value: function _nextPageMatch() { |
| 6162 |
if (this._resumePageIdx !== null) { |
| 6163 |
console.error('There can only be one pending page.'); |
| 6164 |
} |
| 6165 |
var matches = null; |
| 6166 |
do { |
| 6167 |
var pageIdx = this._offset.pageIdx; |
| 6168 |
matches = this._pageMatches[pageIdx]; |
| 6169 |
if (!matches) { |
| 6170 |
this._resumePageIdx = pageIdx; |
| 6171 |
break; |
| 6172 |
} |
| 6173 |
} while (!this._matchesReady(matches)); |
| 6174 |
} |
| 6175 |
}, { |
| 6176 |
key: '_advanceOffsetPage', |
| 6177 |
value: function _advanceOffsetPage(previous) { |
| 6178 |
var offset = this._offset; |
| 6179 |
var numPages = this._linkService.pagesCount; |
| 6180 |
offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1; |
| 6181 |
offset.matchIdx = null; |
| 6182 |
this._pagesToSearch--; |
| 6183 |
if (offset.pageIdx >= numPages || offset.pageIdx < 0) { |
| 6184 |
offset.pageIdx = previous ? numPages - 1 : 0; |
| 6185 |
offset.wrapped = true; |
| 6186 |
} |
| 6187 |
} |
| 6188 |
}, { |
| 6189 |
key: '_updateMatch', |
| 6190 |
value: function _updateMatch() { |
| 6191 |
var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
| 6192 |
|
| 6193 |
var state = FindState.NOT_FOUND; |
| 6194 |
var wrapped = this._offset.wrapped; |
| 6195 |
this._offset.wrapped = false; |
| 6196 |
if (found) { |
| 6197 |
var previousPage = this._selected.pageIdx; |
| 6198 |
this._selected.pageIdx = this._offset.pageIdx; |
| 6199 |
this._selected.matchIdx = this._offset.matchIdx; |
| 6200 |
state = wrapped ? FindState.WRAPPED : FindState.FOUND; |
| 6201 |
if (previousPage !== -1 && previousPage !== this._selected.pageIdx) { |
| 6202 |
this._updatePage(previousPage); |
| 6203 |
} |
| 6204 |
} |
| 6205 |
this._updateUIState(state, this._state.findPrevious); |
| 6206 |
if (this._selected.pageIdx !== -1) { |
| 6207 |
this._updatePage(this._selected.pageIdx); |
| 6208 |
} |
| 6209 |
} |
| 6210 |
}, { |
| 6211 |
key: '_onFindBarClose', |
| 6212 |
value: function _onFindBarClose(evt) { |
| 6213 |
var _this4 = this; |
| 6214 |
|
| 6215 |
var pdfDocument = this._pdfDocument; |
| 6216 |
this._firstPageCapability.promise.then(function () { |
| 6217 |
if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) { |
| 6218 |
return; |
| 6219 |
} |
| 6220 |
if (_this4._findTimeout) { |
| 6221 |
clearTimeout(_this4._findTimeout); |
| 6222 |
_this4._findTimeout = null; |
| 6223 |
_this4._updateUIState(FindState.FOUND); |
| 6224 |
} |
| 6225 |
_this4._highlightMatches = false; |
| 6226 |
_this4._eventBus.dispatch('updatetextlayermatches', { |
| 6227 |
source: _this4, |
| 6228 |
pageIndex: -1 |
| 6229 |
}); |
| 6230 |
}); |
| 6231 |
} |
| 6232 |
}, { |
| 6233 |
key: '_requestMatchesCount', |
| 6234 |
value: function _requestMatchesCount() { |
| 6235 |
var _selected = this._selected, |
| 6236 |
pageIdx = _selected.pageIdx, |
| 6237 |
matchIdx = _selected.matchIdx; |
| 6238 |
|
| 6239 |
var current = 0, |
| 6240 |
total = this._matchesCountTotal; |
| 6241 |
if (matchIdx !== -1) { |
| 6242 |
for (var i = 0; i < pageIdx; i++) { |
| 6243 |
current += this._pageMatches[i] && this._pageMatches[i].length || 0; |
| 6244 |
} |
| 6245 |
current += matchIdx + 1; |
| 6246 |
} |
| 6247 |
if (current < 1 || current > total) { |
| 6248 |
current = total = 0; |
| 6249 |
} |
| 6250 |
return { |
| 6251 |
current: current, |
| 6252 |
total: total |
| 6253 |
}; |
| 6254 |
} |
| 6255 |
}, { |
| 6256 |
key: '_updateUIResultsCount', |
| 6257 |
value: function _updateUIResultsCount() { |
| 6258 |
this._eventBus.dispatch('updatefindmatchescount', { |
| 6259 |
source: this, |
| 6260 |
matchesCount: this._requestMatchesCount() |
| 6261 |
}); |
| 6262 |
} |
| 6263 |
}, { |
| 6264 |
key: '_updateUIState', |
| 6265 |
value: function _updateUIState(state, previous) { |
| 6266 |
this._eventBus.dispatch('updatefindcontrolstate', { |
| 6267 |
source: this, |
| 6268 |
state: state, |
| 6269 |
previous: previous, |
| 6270 |
matchesCount: this._requestMatchesCount() |
| 6271 |
}); |
| 6272 |
} |
| 6273 |
}, { |
| 6274 |
key: 'highlightMatches', |
| 6275 |
get: function get() { |
| 6276 |
return this._highlightMatches; |
| 6277 |
} |
| 6278 |
}, { |
| 6279 |
key: 'pageMatches', |
| 6280 |
get: function get() { |
| 6281 |
return this._pageMatches; |
| 6282 |
} |
| 6283 |
}, { |
| 6284 |
key: 'pageMatchesLength', |
| 6285 |
get: function get() { |
| 6286 |
return this._pageMatchesLength; |
| 6287 |
} |
| 6288 |
}, { |
| 6289 |
key: 'selected', |
| 6290 |
get: function get() { |
| 6291 |
return this._selected; |
| 6292 |
} |
| 6293 |
}, { |
| 6294 |
key: 'state', |
| 6295 |
get: function get() { |
| 6296 |
return this._state; |
| 6297 |
} |
| 6298 |
}]); |
| 6299 |
|
| 6300 |
return PDFFindController; |
| 6301 |
}(); |
| 6302 |
|
| 6303 |
exports.FindState = FindState; |
| 6304 |
exports.PDFFindController = PDFFindController; |
| 6305 |
|
| 6306 |
/***/ }), |
| 6307 |
/* 21 */ |
| 6308 |
/***/ (function(module, exports, __webpack_require__) { |
| 6309 |
|
| 6310 |
"use strict"; |
| 6311 |
|
| 6312 |
|
| 6313 |
Object.defineProperty(exports, "__esModule", { |
| 6314 |
value: true |
| 6315 |
}); |
| 6316 |
var CharacterType = { |
| 6317 |
SPACE: 0, |
| 6318 |
ALPHA_LETTER: 1, |
| 6319 |
PUNCT: 2, |
| 6320 |
HAN_LETTER: 3, |
| 6321 |
KATAKANA_LETTER: 4, |
| 6322 |
HIRAGANA_LETTER: 5, |
| 6323 |
HALFWIDTH_KATAKANA_LETTER: 6, |
| 6324 |
THAI_LETTER: 7 |
| 6325 |
}; |
| 6326 |
function isAlphabeticalScript(charCode) { |
| 6327 |
return charCode < 0x2E80; |
| 6328 |
} |
| 6329 |
function isAscii(charCode) { |
| 6330 |
return (charCode & 0xFF80) === 0; |
| 6331 |
} |
| 6332 |
function isAsciiAlpha(charCode) { |
| 6333 |
return charCode >= 0x61 && charCode <= 0x7A || charCode >= 0x41 && charCode <= 0x5A; |
| 6334 |
} |
| 6335 |
function isAsciiDigit(charCode) { |
| 6336 |
return charCode >= 0x30 && charCode <= 0x39; |
| 6337 |
} |
| 6338 |
function isAsciiSpace(charCode) { |
| 6339 |
return charCode === 0x20 || charCode === 0x09 || charCode === 0x0D || charCode === 0x0A; |
| 6340 |
} |
| 6341 |
function isHan(charCode) { |
| 6342 |
return charCode >= 0x3400 && charCode <= 0x9FFF || charCode >= 0xF900 && charCode <= 0xFAFF; |
| 6343 |
} |
| 6344 |
function isKatakana(charCode) { |
| 6345 |
return charCode >= 0x30A0 && charCode <= 0x30FF; |
| 6346 |
} |
| 6347 |
function isHiragana(charCode) { |
| 6348 |
return charCode >= 0x3040 && charCode <= 0x309F; |
| 6349 |
} |
| 6350 |
function isHalfwidthKatakana(charCode) { |
| 6351 |
return charCode >= 0xFF60 && charCode <= 0xFF9F; |
| 6352 |
} |
| 6353 |
function isThai(charCode) { |
| 6354 |
return (charCode & 0xFF80) === 0x0E00; |
| 6355 |
} |
| 6356 |
function getCharacterType(charCode) { |
| 6357 |
if (isAlphabeticalScript(charCode)) { |
| 6358 |
if (isAscii(charCode)) { |
| 6359 |
if (isAsciiSpace(charCode)) { |
| 6360 |
return CharacterType.SPACE; |
| 6361 |
} else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5F) { |
| 6362 |
return CharacterType.ALPHA_LETTER; |
| 6363 |
} |
| 6364 |
return CharacterType.PUNCT; |
| 6365 |
} else if (isThai(charCode)) { |
| 6366 |
return CharacterType.THAI_LETTER; |
| 6367 |
} else if (charCode === 0xA0) { |
| 6368 |
return CharacterType.SPACE; |
| 6369 |
} |
| 6370 |
return CharacterType.ALPHA_LETTER; |
| 6371 |
} |
| 6372 |
if (isHan(charCode)) { |
| 6373 |
return CharacterType.HAN_LETTER; |
| 6374 |
} else if (isKatakana(charCode)) { |
| 6375 |
return CharacterType.KATAKANA_LETTER; |
| 6376 |
} else if (isHiragana(charCode)) { |
| 6377 |
return CharacterType.HIRAGANA_LETTER; |
| 6378 |
} else if (isHalfwidthKatakana(charCode)) { |
| 6379 |
return CharacterType.HALFWIDTH_KATAKANA_LETTER; |
| 6380 |
} |
| 6381 |
return CharacterType.ALPHA_LETTER; |
| 6382 |
} |
| 6383 |
exports.CharacterType = CharacterType; |
| 6384 |
exports.getCharacterType = getCharacterType; |
| 6385 |
|
| 6386 |
/***/ }), |
| 6387 |
/* 22 */ |
| 6388 |
/***/ (function(module, exports, __webpack_require__) { |
| 6389 |
|
| 6390 |
"use strict"; |
| 6391 |
|
| 6392 |
|
| 6393 |
Object.defineProperty(exports, "__esModule", { |
| 6394 |
value: true |
| 6395 |
}); |
| 6396 |
exports.isDestArraysEqual = exports.isDestHashesEqual = exports.PDFHistory = undefined; |
| 6397 |
|
| 6398 |
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; |
| 6399 |
|
| 6400 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 6401 |
|
| 6402 |
var _ui_utils = __webpack_require__(6); |
| 6403 |
|
| 6404 |
var _dom_events = __webpack_require__(14); |
| 6405 |
|
| 6406 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 6407 |
|
| 6408 |
var HASH_CHANGE_TIMEOUT = 1000; |
| 6409 |
var POSITION_UPDATED_THRESHOLD = 50; |
| 6410 |
var UPDATE_VIEWAREA_TIMEOUT = 1000; |
| 6411 |
function getCurrentHash() { |
| 6412 |
return document.location.hash; |
| 6413 |
} |
| 6414 |
function parseCurrentHash(linkService) { |
| 6415 |
var hash = unescape(getCurrentHash()).substring(1); |
| 6416 |
var params = (0, _ui_utils.parseQueryString)(hash); |
| 6417 |
var page = params.page | 0; |
| 6418 |
if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) { |
| 6419 |
page = null; |
| 6420 |
} |
| 6421 |
return { |
| 6422 |
hash: hash, |
| 6423 |
page: page, |
| 6424 |
rotation: linkService.rotation |
| 6425 |
}; |
| 6426 |
} |
| 6427 |
|
| 6428 |
var PDFHistory = function () { |
| 6429 |
function PDFHistory(_ref) { |
| 6430 |
var _this = this; |
| 6431 |
|
| 6432 |
var linkService = _ref.linkService, |
| 6433 |
eventBus = _ref.eventBus; |
| 6434 |
|
| 6435 |
_classCallCheck(this, PDFHistory); |
| 6436 |
|
| 6437 |
this.linkService = linkService; |
| 6438 |
this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)(); |
| 6439 |
this.initialized = false; |
| 6440 |
this.initialBookmark = null; |
| 6441 |
this.initialRotation = null; |
| 6442 |
this._boundEvents = Object.create(null); |
| 6443 |
this._isViewerInPresentationMode = false; |
| 6444 |
this._isPagesLoaded = false; |
| 6445 |
this.eventBus.on('presentationmodechanged', function (evt) { |
| 6446 |
_this._isViewerInPresentationMode = evt.active || evt.switchInProgress; |
| 6447 |
}); |
| 6448 |
this.eventBus.on('pagesloaded', function (evt) { |
| 6449 |
_this._isPagesLoaded = !!evt.pagesCount; |
| 6450 |
}); |
| 6451 |
} |
| 6452 |
|
| 6453 |
_createClass(PDFHistory, [{ |
| 6454 |
key: 'initialize', |
| 6455 |
value: function initialize(fingerprint) { |
| 6456 |
var resetHistory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; |
| 6457 |
|
| 6458 |
if (!fingerprint || typeof fingerprint !== 'string') { |
| 6459 |
console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.'); |
| 6460 |
return; |
| 6461 |
} |
| 6462 |
var reInitialized = this.initialized && this.fingerprint !== fingerprint; |
| 6463 |
this.fingerprint = fingerprint; |
| 6464 |
if (!this.initialized) { |
| 6465 |
this._bindEvents(); |
| 6466 |
} |
| 6467 |
var state = window.history.state; |
| 6468 |
this.initialized = true; |
| 6469 |
this.initialBookmark = null; |
| 6470 |
this.initialRotation = null; |
| 6471 |
this._popStateInProgress = false; |
| 6472 |
this._blockHashChange = 0; |
| 6473 |
this._currentHash = getCurrentHash(); |
| 6474 |
this._numPositionUpdates = 0; |
| 6475 |
this._uid = this._maxUid = 0; |
| 6476 |
this._destination = null; |
| 6477 |
this._position = null; |
| 6478 |
if (!this._isValidState(state) || resetHistory) { |
| 6479 |
var _parseCurrentHash = parseCurrentHash(this.linkService), |
| 6480 |
hash = _parseCurrentHash.hash, |
| 6481 |
page = _parseCurrentHash.page, |
| 6482 |
rotation = _parseCurrentHash.rotation; |
| 6483 |
|
| 6484 |
if (!hash || reInitialized || resetHistory) { |
| 6485 |
this._pushOrReplaceState(null, true); |
| 6486 |
return; |
| 6487 |
} |
| 6488 |
this._pushOrReplaceState({ |
| 6489 |
hash: hash, |
| 6490 |
page: page, |
| 6491 |
rotation: rotation |
| 6492 |
}, true); |
| 6493 |
return; |
| 6494 |
} |
| 6495 |
var destination = state.destination; |
| 6496 |
this._updateInternalState(destination, state.uid, true); |
| 6497 |
if (this._uid > this._maxUid) { |
| 6498 |
this._maxUid = this._uid; |
| 6499 |
} |
| 6500 |
if (destination.rotation !== undefined) { |
| 6501 |
this.initialRotation = destination.rotation; |
| 6502 |
} |
| 6503 |
if (destination.dest) { |
| 6504 |
this.initialBookmark = JSON.stringify(destination.dest); |
| 6505 |
this._destination.page = null; |
| 6506 |
} else if (destination.hash) { |
| 6507 |
this.initialBookmark = destination.hash; |
| 6508 |
} else if (destination.page) { |
| 6509 |
this.initialBookmark = 'page=' + destination.page; |
| 6510 |
} |
| 6511 |
} |
| 6512 |
}, { |
| 6513 |
key: 'push', |
| 6514 |
value: function push(_ref2) { |
| 6515 |
var _this2 = this; |
| 6516 |
|
| 6517 |
var namedDest = _ref2.namedDest, |
| 6518 |
explicitDest = _ref2.explicitDest, |
| 6519 |
pageNumber = _ref2.pageNumber; |
| 6520 |
|
| 6521 |
if (!this.initialized) { |
| 6522 |
return; |
| 6523 |
} |
| 6524 |
if (namedDest && typeof namedDest !== 'string' || !Array.isArray(explicitDest) || !(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) { |
| 6525 |
console.error('PDFHistory.push: Invalid parameters.'); |
| 6526 |
return; |
| 6527 |
} |
| 6528 |
var hash = namedDest || JSON.stringify(explicitDest); |
| 6529 |
if (!hash) { |
| 6530 |
return; |
| 6531 |
} |
| 6532 |
var forceReplace = false; |
| 6533 |
if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) { |
| 6534 |
if (this._destination.page) { |
| 6535 |
return; |
| 6536 |
} |
| 6537 |
forceReplace = true; |
| 6538 |
} |
| 6539 |
if (this._popStateInProgress && !forceReplace) { |
| 6540 |
return; |
| 6541 |
} |
| 6542 |
this._pushOrReplaceState({ |
| 6543 |
dest: explicitDest, |
| 6544 |
hash: hash, |
| 6545 |
page: pageNumber, |
| 6546 |
rotation: this.linkService.rotation |
| 6547 |
}, forceReplace); |
| 6548 |
if (!this._popStateInProgress) { |
| 6549 |
this._popStateInProgress = true; |
| 6550 |
Promise.resolve().then(function () { |
| 6551 |
_this2._popStateInProgress = false; |
| 6552 |
}); |
| 6553 |
} |
| 6554 |
} |
| 6555 |
}, { |
| 6556 |
key: 'pushCurrentPosition', |
| 6557 |
value: function pushCurrentPosition() { |
| 6558 |
if (!this.initialized || this._popStateInProgress) { |
| 6559 |
return; |
| 6560 |
} |
| 6561 |
this._tryPushCurrentPosition(); |
| 6562 |
} |
| 6563 |
}, { |
| 6564 |
key: 'back', |
| 6565 |
value: function back() { |
| 6566 |
if (!this.initialized || this._popStateInProgress) { |
| 6567 |
return; |
| 6568 |
} |
| 6569 |
var state = window.history.state; |
| 6570 |
if (this._isValidState(state) && state.uid > 0) { |
| 6571 |
window.history.back(); |
| 6572 |
} |
| 6573 |
} |
| 6574 |
}, { |
| 6575 |
key: 'forward', |
| 6576 |
value: function forward() { |
| 6577 |
if (!this.initialized || this._popStateInProgress) { |
| 6578 |
return; |
| 6579 |
} |
| 6580 |
var state = window.history.state; |
| 6581 |
if (this._isValidState(state) && state.uid < this._maxUid) { |
| 6582 |
window.history.forward(); |
| 6583 |
} |
| 6584 |
} |
| 6585 |
}, { |
| 6586 |
key: '_pushOrReplaceState', |
| 6587 |
value: function _pushOrReplaceState(destination) { |
| 6588 |
var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; |
| 6589 |
|
| 6590 |
var shouldReplace = forceReplace || !this._destination; |
| 6591 |
var newState = { |
| 6592 |
fingerprint: this.fingerprint, |
| 6593 |
uid: shouldReplace ? this._uid : this._uid + 1, |
| 6594 |
destination: destination |
| 6595 |
}; |
| 6596 |
this._updateInternalState(destination, newState.uid); |
| 6597 |
if (shouldReplace) { |
| 6598 |
window.history.replaceState(newState, ''); |
| 6599 |
} else { |
| 6600 |
this._maxUid = this._uid; |
| 6601 |
window.history.pushState(newState, ''); |
| 6602 |
} |
| 6603 |
} |
| 6604 |
}, { |
| 6605 |
key: '_tryPushCurrentPosition', |
| 6606 |
value: function _tryPushCurrentPosition() { |
| 6607 |
var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
| 6608 |
|
| 6609 |
if (!this._position) { |
| 6610 |
return; |
| 6611 |
} |
| 6612 |
var position = this._position; |
| 6613 |
if (temporary) { |
| 6614 |
position = Object.assign(Object.create(null), this._position); |
| 6615 |
position.temporary = true; |
| 6616 |
} |
| 6617 |
if (!this._destination) { |
| 6618 |
this._pushOrReplaceState(position); |
| 6619 |
return; |
| 6620 |
} |
| 6621 |
if (this._destination.temporary) { |
| 6622 |
this._pushOrReplaceState(position, true); |
| 6623 |
return; |
| 6624 |
} |
| 6625 |
if (this._destination.hash === position.hash) { |
| 6626 |
return; |
| 6627 |
} |
| 6628 |
if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) { |
| 6629 |
return; |
| 6630 |
} |
| 6631 |
var forceReplace = false; |
| 6632 |
if (this._destination.page === position.first || this._destination.page === position.page) { |
| 6633 |
if (this._destination.dest || !this._destination.first) { |
| 6634 |
return; |
| 6635 |
} |
| 6636 |
forceReplace = true; |
| 6637 |
} |
| 6638 |
this._pushOrReplaceState(position, forceReplace); |
| 6639 |
} |
| 6640 |
}, { |
| 6641 |
key: '_isValidState', |
| 6642 |
value: function _isValidState(state) { |
| 6643 |
if (!state) { |
| 6644 |
return false; |
| 6645 |
} |
| 6646 |
if (state.fingerprint !== this.fingerprint) { |
| 6647 |
return false; |
| 6648 |
} |
| 6649 |
if (!Number.isInteger(state.uid) || state.uid < 0) { |
| 6650 |
return false; |
| 6651 |
} |
| 6652 |
if (state.destination === null || _typeof(state.destination) !== 'object') { |
| 6653 |
return false; |
| 6654 |
} |
| 6655 |
return true; |
| 6656 |
} |
| 6657 |
}, { |
| 6658 |
key: '_updateInternalState', |
| 6659 |
value: function _updateInternalState(destination, uid) { |
| 6660 |
var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; |
| 6661 |
|
| 6662 |
if (this._updateViewareaTimeout) { |
| 6663 |
clearTimeout(this._updateViewareaTimeout); |
| 6664 |
this._updateViewareaTimeout = null; |
| 6665 |
} |
| 6666 |
if (removeTemporary && destination && destination.temporary) { |
| 6667 |
delete destination.temporary; |
| 6668 |
} |
| 6669 |
this._destination = destination; |
| 6670 |
this._uid = uid; |
| 6671 |
this._numPositionUpdates = 0; |
| 6672 |
} |
| 6673 |
}, { |
| 6674 |
key: '_updateViewarea', |
| 6675 |
value: function _updateViewarea(_ref3) { |
| 6676 |
var _this3 = this; |
| 6677 |
|
| 6678 |
var location = _ref3.location; |
| 6679 |
|
| 6680 |
if (this._updateViewareaTimeout) { |
| 6681 |
clearTimeout(this._updateViewareaTimeout); |
| 6682 |
this._updateViewareaTimeout = null; |
| 6683 |
} |
| 6684 |
this._position = { |
| 6685 |
hash: this._isViewerInPresentationMode ? 'page=' + location.pageNumber : location.pdfOpenParams.substring(1), |
| 6686 |
page: this.linkService.page, |
| 6687 |
first: location.pageNumber, |
| 6688 |
rotation: location.rotation |
| 6689 |
}; |
| 6690 |
if (this._popStateInProgress) { |
| 6691 |
return; |
| 6692 |
} |
| 6693 |
if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) { |
| 6694 |
this._numPositionUpdates++; |
| 6695 |
} |
| 6696 |
if (UPDATE_VIEWAREA_TIMEOUT > 0) { |
| 6697 |
this._updateViewareaTimeout = setTimeout(function () { |
| 6698 |
if (!_this3._popStateInProgress) { |
| 6699 |
_this3._tryPushCurrentPosition(true); |
| 6700 |
} |
| 6701 |
_this3._updateViewareaTimeout = null; |
| 6702 |
}, UPDATE_VIEWAREA_TIMEOUT); |
| 6703 |
} |
| 6704 |
} |
| 6705 |
}, { |
| 6706 |
key: '_popState', |
| 6707 |
value: function _popState(_ref4) { |
| 6708 |
var _this4 = this; |
| 6709 |
|
| 6710 |
var state = _ref4.state; |
| 6711 |
|
| 6712 |
var newHash = getCurrentHash(), |
| 6713 |
hashChanged = this._currentHash !== newHash; |
| 6714 |
this._currentHash = newHash; |
| 6715 |
if (!state || false) { |
| 6716 |
this._uid++; |
| 6717 |
|
| 6718 |
var _parseCurrentHash2 = parseCurrentHash(this.linkService), |
| 6719 |
hash = _parseCurrentHash2.hash, |
| 6720 |
page = _parseCurrentHash2.page, |
| 6721 |
rotation = _parseCurrentHash2.rotation; |
| 6722 |
|
| 6723 |
this._pushOrReplaceState({ |
| 6724 |
hash: hash, |
| 6725 |
page: page, |
| 6726 |
rotation: rotation |
| 6727 |
}, true); |
| 6728 |
return; |
| 6729 |
} |
| 6730 |
if (!this._isValidState(state)) { |
| 6731 |
return; |
| 6732 |
} |
| 6733 |
this._popStateInProgress = true; |
| 6734 |
if (hashChanged) { |
| 6735 |
this._blockHashChange++; |
| 6736 |
(0, _ui_utils.waitOnEventOrTimeout)({ |
| 6737 |
target: window, |
| 6738 |
name: 'hashchange', |
| 6739 |
delay: HASH_CHANGE_TIMEOUT |
| 6740 |
}).then(function () { |
| 6741 |
_this4._blockHashChange--; |
| 6742 |
}); |
| 6743 |
} |
| 6744 |
var destination = state.destination; |
| 6745 |
this._updateInternalState(destination, state.uid, true); |
| 6746 |
if (this._uid > this._maxUid) { |
| 6747 |
this._maxUid = this._uid; |
| 6748 |
} |
| 6749 |
if ((0, _ui_utils.isValidRotation)(destination.rotation)) { |
| 6750 |
this.linkService.rotation = destination.rotation; |
| 6751 |
} |
| 6752 |
if (destination.dest) { |
| 6753 |
this.linkService.navigateTo(destination.dest); |
| 6754 |
} else if (destination.hash) { |
| 6755 |
this.linkService.setHash(destination.hash); |
| 6756 |
} else if (destination.page) { |
| 6757 |
this.linkService.page = destination.page; |
| 6758 |
} |
| 6759 |
Promise.resolve().then(function () { |
| 6760 |
_this4._popStateInProgress = false; |
| 6761 |
}); |
| 6762 |
} |
| 6763 |
}, { |
| 6764 |
key: '_bindEvents', |
| 6765 |
value: function _bindEvents() { |
| 6766 |
var _this5 = this; |
| 6767 |
|
| 6768 |
var _boundEvents = this._boundEvents, |
| 6769 |
eventBus = this.eventBus; |
| 6770 |
|
| 6771 |
_boundEvents.updateViewarea = this._updateViewarea.bind(this); |
| 6772 |
_boundEvents.popState = this._popState.bind(this); |
| 6773 |
_boundEvents.pageHide = function (evt) { |
| 6774 |
if (!_this5._destination || _this5._destination.temporary) { |
| 6775 |
_this5._tryPushCurrentPosition(); |
| 6776 |
} |
| 6777 |
}; |
| 6778 |
eventBus.on('updateviewarea', _boundEvents.updateViewarea); |
| 6779 |
window.addEventListener('popstate', _boundEvents.popState); |
| 6780 |
window.addEventListener('pagehide', _boundEvents.pageHide); |
| 6781 |
} |
| 6782 |
}, { |
| 6783 |
key: 'popStateInProgress', |
| 6784 |
get: function get() { |
| 6785 |
return this.initialized && (this._popStateInProgress || this._blockHashChange > 0); |
| 6786 |
} |
| 6787 |
}]); |
| 6788 |
|
| 6789 |
return PDFHistory; |
| 6790 |
}(); |
| 6791 |
|
| 6792 |
function isDestHashesEqual(destHash, pushHash) { |
| 6793 |
if (typeof destHash !== 'string' || typeof pushHash !== 'string') { |
| 6794 |
return false; |
| 6795 |
} |
| 6796 |
if (destHash === pushHash) { |
| 6797 |
return true; |
| 6798 |
} |
| 6799 |
|
| 6800 |
var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash), |
| 6801 |
nameddest = _parseQueryString.nameddest; |
| 6802 |
|
| 6803 |
if (nameddest === pushHash) { |
| 6804 |
return true; |
| 6805 |
} |
| 6806 |
return false; |
| 6807 |
} |
| 6808 |
function isDestArraysEqual(firstDest, secondDest) { |
| 6809 |
function isEntryEqual(first, second) { |
| 6810 |
if ((typeof first === 'undefined' ? 'undefined' : _typeof(first)) !== (typeof second === 'undefined' ? 'undefined' : _typeof(second))) { |
| 6811 |
return false; |
| 6812 |
} |
| 6813 |
if (Array.isArray(first) || Array.isArray(second)) { |
| 6814 |
return false; |
| 6815 |
} |
| 6816 |
if (first !== null && (typeof first === 'undefined' ? 'undefined' : _typeof(first)) === 'object' && second !== null) { |
| 6817 |
if (Object.keys(first).length !== Object.keys(second).length) { |
| 6818 |
return false; |
| 6819 |
} |
| 6820 |
for (var key in first) { |
| 6821 |
if (!isEntryEqual(first[key], second[key])) { |
| 6822 |
return false; |
| 6823 |
} |
| 6824 |
} |
| 6825 |
return true; |
| 6826 |
} |
| 6827 |
return first === second || Number.isNaN(first) && Number.isNaN(second); |
| 6828 |
} |
| 6829 |
if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) { |
| 6830 |
return false; |
| 6831 |
} |
| 6832 |
if (firstDest.length !== secondDest.length) { |
| 6833 |
return false; |
| 6834 |
} |
| 6835 |
for (var i = 0, ii = firstDest.length; i < ii; i++) { |
| 6836 |
if (!isEntryEqual(firstDest[i], secondDest[i])) { |
| 6837 |
return false; |
| 6838 |
} |
| 6839 |
} |
| 6840 |
return true; |
| 6841 |
} |
| 6842 |
exports.PDFHistory = PDFHistory; |
| 6843 |
exports.isDestHashesEqual = isDestHashesEqual; |
| 6844 |
exports.isDestArraysEqual = isDestArraysEqual; |
| 6845 |
|
| 6846 |
/***/ }), |
| 6847 |
/* 23 */ |
| 6848 |
/***/ (function(module, exports, __webpack_require__) { |
| 6849 |
|
| 6850 |
"use strict"; |
| 6851 |
|
| 6852 |
|
| 6853 |
Object.defineProperty(exports, "__esModule", { |
| 6854 |
value: true |
| 6855 |
}); |
| 6856 |
exports.SimpleLinkService = exports.PDFLinkService = undefined; |
| 6857 |
|
| 6858 |
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; |
| 6859 |
|
| 6860 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 6861 |
|
| 6862 |
var _dom_events = __webpack_require__(14); |
| 6863 |
|
| 6864 |
var _ui_utils = __webpack_require__(6); |
| 6865 |
|
| 6866 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 6867 |
|
| 6868 |
var PDFLinkService = function () { |
| 6869 |
function PDFLinkService() { |
| 6870 |
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, |
| 6871 |
eventBus = _ref.eventBus, |
| 6872 |
_ref$externalLinkTarg = _ref.externalLinkTarget, |
| 6873 |
externalLinkTarget = _ref$externalLinkTarg === undefined ? null : _ref$externalLinkTarg, |
| 6874 |
_ref$externalLinkRel = _ref.externalLinkRel, |
| 6875 |
externalLinkRel = _ref$externalLinkRel === undefined ? null : _ref$externalLinkRel; |
| 6876 |
|
| 6877 |
_classCallCheck(this, PDFLinkService); |
| 6878 |
|
| 6879 |
this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)(); |
| 6880 |
this.externalLinkTarget = externalLinkTarget; |
| 6881 |
this.externalLinkRel = externalLinkRel; |
| 6882 |
this.baseUrl = null; |
| 6883 |
this.pdfDocument = null; |
| 6884 |
this.pdfViewer = null; |
| 6885 |
this.pdfHistory = null; |
| 6886 |
this._pagesRefCache = null; |
| 6887 |
} |
| 6888 |
|
| 6889 |
_createClass(PDFLinkService, [{ |
| 6890 |
key: 'setDocument', |
| 6891 |
value: function setDocument(pdfDocument) { |
| 6892 |
var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; |
| 6893 |
|
| 6894 |
this.baseUrl = baseUrl; |
| 6895 |
this.pdfDocument = pdfDocument; |
| 6896 |
this._pagesRefCache = Object.create(null); |
| 6897 |
} |
| 6898 |
}, { |
| 6899 |
key: 'setViewer', |
| 6900 |
value: function setViewer(pdfViewer) { |
| 6901 |
this.pdfViewer = pdfViewer; |
| 6902 |
} |
| 6903 |
}, { |
| 6904 |
key: 'setHistory', |
| 6905 |
value: function setHistory(pdfHistory) { |
| 6906 |
this.pdfHistory = pdfHistory; |
| 6907 |
} |
| 6908 |
}, { |
| 6909 |
key: 'navigateTo', |
| 6910 |
value: function navigateTo(dest) { |
| 6911 |
var _this = this; |
| 6912 |
|
| 6913 |
var goToDestination = function goToDestination(_ref2) { |
| 6914 |
var namedDest = _ref2.namedDest, |
| 6915 |
explicitDest = _ref2.explicitDest; |
| 6916 |
|
| 6917 |
var destRef = explicitDest[0], |
| 6918 |
pageNumber = void 0; |
| 6919 |
if (destRef instanceof Object) { |
| 6920 |
pageNumber = _this._cachedPageNumber(destRef); |
| 6921 |
if (pageNumber === null) { |
| 6922 |
_this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) { |
| 6923 |
_this.cachePageRef(pageIndex + 1, destRef); |
| 6924 |
goToDestination({ |
| 6925 |
namedDest: namedDest, |
| 6926 |
explicitDest: explicitDest |
| 6927 |
}); |
| 6928 |
}).catch(function () { |
| 6929 |
console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid page reference, for dest="' + dest + '".')); |
| 6930 |
}); |
| 6931 |
return; |
| 6932 |
} |
| 6933 |
} else if (Number.isInteger(destRef)) { |
| 6934 |
pageNumber = destRef + 1; |
| 6935 |
} else { |
| 6936 |
console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid destination reference, for dest="' + dest + '".')); |
| 6937 |
return; |
| 6938 |
} |
| 6939 |
if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) { |
| 6940 |
console.error('PDFLinkService.navigateTo: "' + pageNumber + '" is not ' + ('a valid page number, for dest="' + dest + '".')); |
| 6941 |
return; |
| 6942 |
} |
| 6943 |
if (_this.pdfHistory) { |
| 6944 |
_this.pdfHistory.pushCurrentPosition(); |
| 6945 |
_this.pdfHistory.push({ |
| 6946 |
namedDest: namedDest, |
| 6947 |
explicitDest: explicitDest, |
| 6948 |
pageNumber: pageNumber |
| 6949 |
}); |
| 6950 |
} |
| 6951 |
_this.pdfViewer.scrollPageIntoView({ |
| 6952 |
pageNumber: pageNumber, |
| 6953 |
destArray: explicitDest |
| 6954 |
}); |
| 6955 |
}; |
| 6956 |
new Promise(function (resolve, reject) { |
| 6957 |
if (typeof dest === 'string') { |
| 6958 |
_this.pdfDocument.getDestination(dest).then(function (destArray) { |
| 6959 |
resolve({ |
| 6960 |
namedDest: dest, |
| 6961 |
explicitDest: destArray |
| 6962 |
}); |
| 6963 |
}); |
| 6964 |
return; |
| 6965 |
} |
| 6966 |
resolve({ |
| 6967 |
namedDest: '', |
| 6968 |
explicitDest: dest |
| 6969 |
}); |
| 6970 |
}).then(function (data) { |
| 6971 |
if (!Array.isArray(data.explicitDest)) { |
| 6972 |
console.error('PDFLinkService.navigateTo: "' + data.explicitDest + '" is' + (' not a valid destination array, for dest="' + dest + '".')); |
| 6973 |
return; |
| 6974 |
} |
| 6975 |
goToDestination(data); |
| 6976 |
}); |
| 6977 |
} |
| 6978 |
}, { |
| 6979 |
key: 'getDestinationHash', |
| 6980 |
value: function getDestinationHash(dest) { |
| 6981 |
if (typeof dest === 'string') { |
| 6982 |
return this.getAnchorUrl('#' + escape(dest)); |
| 6983 |
} |
| 6984 |
if (Array.isArray(dest)) { |
| 6985 |
var str = JSON.stringify(dest); |
| 6986 |
return this.getAnchorUrl('#' + escape(str)); |
| 6987 |
} |
| 6988 |
return this.getAnchorUrl(''); |
| 6989 |
} |
| 6990 |
}, { |
| 6991 |
key: 'getAnchorUrl', |
| 6992 |
value: function getAnchorUrl(anchor) { |
| 6993 |
return (this.baseUrl || '') + anchor; |
| 6994 |
} |
| 6995 |
}, { |
| 6996 |
key: 'setHash', |
| 6997 |
value: function setHash(hash) { |
| 6998 |
var pageNumber = void 0, |
| 6999 |
dest = void 0; |
| 7000 |
if (hash.includes('=')) { |
| 7001 |
var params = (0, _ui_utils.parseQueryString)(hash); |
| 7002 |
if ('search' in params) { |
| 7003 |
this.eventBus.dispatch('findfromurlhash', { |
| 7004 |
source: this, |
| 7005 |
query: params['search'].replace(/"/g, ''), |
| 7006 |
phraseSearch: params['phrase'] === 'true' |
| 7007 |
}); |
| 7008 |
} |
| 7009 |
if ('nameddest' in params) { |
| 7010 |
this.navigateTo(params.nameddest); |
| 7011 |
return; |
| 7012 |
} |
| 7013 |
if ('page' in params) { |
| 7014 |
pageNumber = params.page | 0 || 1; |
| 7015 |
} |
| 7016 |
if ('zoom' in params) { |
| 7017 |
var zoomArgs = params.zoom.split(','); |
| 7018 |
var zoomArg = zoomArgs[0]; |
| 7019 |
var zoomArgNumber = parseFloat(zoomArg); |
| 7020 |
if (!zoomArg.includes('Fit')) { |
| 7021 |
dest = [null, { name: 'XYZ' }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg]; |
| 7022 |
} else { |
| 7023 |
if (zoomArg === 'Fit' || zoomArg === 'FitB') { |
| 7024 |
dest = [null, { name: zoomArg }]; |
| 7025 |
} else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') { |
| 7026 |
dest = [null, { name: zoomArg }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null]; |
| 7027 |
} else if (zoomArg === 'FitR') { |
| 7028 |
if (zoomArgs.length !== 5) { |
| 7029 |
console.error('PDFLinkService.setHash: Not enough parameters for "FitR".'); |
| 7030 |
} else { |
| 7031 |
dest = [null, { name: zoomArg }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0]; |
| 7032 |
} |
| 7033 |
} else { |
| 7034 |
console.error('PDFLinkService.setHash: "' + zoomArg + '" is not ' + 'a valid zoom value.'); |
| 7035 |
} |
| 7036 |
} |
| 7037 |
} |
| 7038 |
if (dest) { |
| 7039 |
this.pdfViewer.scrollPageIntoView({ |
| 7040 |
pageNumber: pageNumber || this.page, |
| 7041 |
destArray: dest, |
| 7042 |
allowNegativeOffset: true |
| 7043 |
}); |
| 7044 |
} else if (pageNumber) { |
| 7045 |
this.page = pageNumber; |
| 7046 |
} |
| 7047 |
if ('pagemode' in params) { |
| 7048 |
this.eventBus.dispatch('pagemode', { |
| 7049 |
source: this, |
| 7050 |
mode: params.pagemode |
| 7051 |
}); |
| 7052 |
} |
| 7053 |
} else { |
| 7054 |
dest = unescape(hash); |
| 7055 |
try { |
| 7056 |
dest = JSON.parse(dest); |
| 7057 |
if (!Array.isArray(dest)) { |
| 7058 |
dest = dest.toString(); |
| 7059 |
} |
| 7060 |
} catch (ex) {} |
| 7061 |
if (typeof dest === 'string' || isValidExplicitDestination(dest)) { |
| 7062 |
this.navigateTo(dest); |
| 7063 |
return; |
| 7064 |
} |
| 7065 |
console.error('PDFLinkService.setHash: "' + unescape(hash) + '" is not ' + 'a valid destination.'); |
| 7066 |
} |
| 7067 |
} |
| 7068 |
}, { |
| 7069 |
key: 'executeNamedAction', |
| 7070 |
value: function executeNamedAction(action) { |
| 7071 |
switch (action) { |
| 7072 |
case 'GoBack': |
| 7073 |
if (this.pdfHistory) { |
| 7074 |
this.pdfHistory.back(); |
| 7075 |
} |
| 7076 |
break; |
| 7077 |
case 'GoForward': |
| 7078 |
if (this.pdfHistory) { |
| 7079 |
this.pdfHistory.forward(); |
| 7080 |
} |
| 7081 |
break; |
| 7082 |
case 'NextPage': |
| 7083 |
if (this.page < this.pagesCount) { |
| 7084 |
this.page++; |
| 7085 |
} |
| 7086 |
break; |
| 7087 |
case 'PrevPage': |
| 7088 |
if (this.page > 1) { |
| 7089 |
this.page--; |
| 7090 |
} |
| 7091 |
break; |
| 7092 |
case 'LastPage': |
| 7093 |
this.page = this.pagesCount; |
| 7094 |
break; |
| 7095 |
case 'FirstPage': |
| 7096 |
this.page = 1; |
| 7097 |
break; |
| 7098 |
default: |
| 7099 |
break; |
| 7100 |
} |
| 7101 |
this.eventBus.dispatch('namedaction', { |
| 7102 |
source: this, |
| 7103 |
action: action |
| 7104 |
}); |
| 7105 |
} |
| 7106 |
}, { |
| 7107 |
key: 'cachePageRef', |
| 7108 |
value: function cachePageRef(pageNum, pageRef) { |
| 7109 |
if (!pageRef) { |
| 7110 |
return; |
| 7111 |
} |
| 7112 |
var refStr = pageRef.num + ' ' + pageRef.gen + ' R'; |
| 7113 |
this._pagesRefCache[refStr] = pageNum; |
| 7114 |
} |
| 7115 |
}, { |
| 7116 |
key: '_cachedPageNumber', |
| 7117 |
value: function _cachedPageNumber(pageRef) { |
| 7118 |
var refStr = pageRef.num + ' ' + pageRef.gen + ' R'; |
| 7119 |
return this._pagesRefCache && this._pagesRefCache[refStr] || null; |
| 7120 |
} |
| 7121 |
}, { |
| 7122 |
key: 'pagesCount', |
| 7123 |
get: function get() { |
| 7124 |
return this.pdfDocument ? this.pdfDocument.numPages : 0; |
| 7125 |
} |
| 7126 |
}, { |
| 7127 |
key: 'page', |
| 7128 |
get: function get() { |
| 7129 |
return this.pdfViewer.currentPageNumber; |
| 7130 |
}, |
| 7131 |
set: function set(value) { |
| 7132 |
this.pdfViewer.currentPageNumber = value; |
| 7133 |
} |
| 7134 |
}, { |
| 7135 |
key: 'rotation', |
| 7136 |
get: function get() { |
| 7137 |
return this.pdfViewer.pagesRotation; |
| 7138 |
}, |
| 7139 |
set: function set(value) { |
| 7140 |
this.pdfViewer.pagesRotation = value; |
| 7141 |
} |
| 7142 |
}]); |
| 7143 |
|
| 7144 |
return PDFLinkService; |
| 7145 |
}(); |
| 7146 |
|
| 7147 |
function isValidExplicitDestination(dest) { |
| 7148 |
if (!Array.isArray(dest)) { |
| 7149 |
return false; |
| 7150 |
} |
| 7151 |
var destLength = dest.length, |
| 7152 |
allowNull = true; |
| 7153 |
if (destLength < 2) { |
| 7154 |
return false; |
| 7155 |
} |
| 7156 |
var page = dest[0]; |
| 7157 |
if (!((typeof page === 'undefined' ? 'undefined' : _typeof(page)) === 'object' && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) { |
| 7158 |
return false; |
| 7159 |
} |
| 7160 |
var zoom = dest[1]; |
| 7161 |
if (!((typeof zoom === 'undefined' ? 'undefined' : _typeof(zoom)) === 'object' && typeof zoom.name === 'string')) { |
| 7162 |
return false; |
| 7163 |
} |
| 7164 |
switch (zoom.name) { |
| 7165 |
case 'XYZ': |
| 7166 |
if (destLength !== 5) { |
| 7167 |
return false; |
| 7168 |
} |
| 7169 |
break; |
| 7170 |
case 'Fit': |
| 7171 |
case 'FitB': |
| 7172 |
return destLength === 2; |
| 7173 |
case 'FitH': |
| 7174 |
case 'FitBH': |
| 7175 |
case 'FitV': |
| 7176 |
case 'FitBV': |
| 7177 |
if (destLength !== 3) { |
| 7178 |
return false; |
| 7179 |
} |
| 7180 |
break; |
| 7181 |
case 'FitR': |
| 7182 |
if (destLength !== 6) { |
| 7183 |
return false; |
| 7184 |
} |
| 7185 |
allowNull = false; |
| 7186 |
break; |
| 7187 |
default: |
| 7188 |
return false; |
| 7189 |
} |
| 7190 |
for (var i = 2; i < destLength; i++) { |
| 7191 |
var param = dest[i]; |
| 7192 |
if (!(typeof param === 'number' || allowNull && param === null)) { |
| 7193 |
return false; |
| 7194 |
} |
| 7195 |
} |
| 7196 |
return true; |
| 7197 |
} |
| 7198 |
|
| 7199 |
var SimpleLinkService = function () { |
| 7200 |
function SimpleLinkService() { |
| 7201 |
_classCallCheck(this, SimpleLinkService); |
| 7202 |
|
| 7203 |
this.externalLinkTarget = null; |
| 7204 |
this.externalLinkRel = null; |
| 7205 |
} |
| 7206 |
|
| 7207 |
_createClass(SimpleLinkService, [{ |
| 7208 |
key: 'navigateTo', |
| 7209 |
value: function navigateTo(dest) {} |
| 7210 |
}, { |
| 7211 |
key: 'getDestinationHash', |
| 7212 |
value: function getDestinationHash(dest) { |
| 7213 |
return '#'; |
| 7214 |
} |
| 7215 |
}, { |
| 7216 |
key: 'getAnchorUrl', |
| 7217 |
value: function getAnchorUrl(hash) { |
| 7218 |
return '#'; |
| 7219 |
} |
| 7220 |
}, { |
| 7221 |
key: 'setHash', |
| 7222 |
value: function setHash(hash) {} |
| 7223 |
}, { |
| 7224 |
key: 'executeNamedAction', |
| 7225 |
value: function executeNamedAction(action) {} |
| 7226 |
}, { |
| 7227 |
key: 'cachePageRef', |
| 7228 |
value: function cachePageRef(pageNum, pageRef) {} |
| 7229 |
}, { |
| 7230 |
key: 'pagesCount', |
| 7231 |
get: function get() { |
| 7232 |
return 0; |
| 7233 |
} |
| 7234 |
}, { |
| 7235 |
key: 'page', |
| 7236 |
get: function get() { |
| 7237 |
return 0; |
| 7238 |
}, |
| 7239 |
set: function set(value) {} |
| 7240 |
}, { |
| 7241 |
key: 'rotation', |
| 7242 |
get: function get() { |
| 7243 |
return 0; |
| 7244 |
}, |
| 7245 |
set: function set(value) {} |
| 7246 |
}]); |
| 7247 |
|
| 7248 |
return SimpleLinkService; |
| 7249 |
}(); |
| 7250 |
|
| 7251 |
exports.PDFLinkService = PDFLinkService; |
| 7252 |
exports.SimpleLinkService = SimpleLinkService; |
| 7253 |
|
| 7254 |
/***/ }), |
| 7255 |
/* 24 */ |
| 7256 |
/***/ (function(module, exports, __webpack_require__) { |
| 7257 |
|
| 7258 |
"use strict"; |
| 7259 |
|
| 7260 |
|
| 7261 |
Object.defineProperty(exports, "__esModule", { |
| 7262 |
value: true |
| 7263 |
}); |
| 7264 |
exports.PDFOutlineViewer = undefined; |
| 7265 |
|
| 7266 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 7267 |
|
| 7268 |
var _pdfjsLib = __webpack_require__(7); |
| 7269 |
|
| 7270 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 7271 |
|
| 7272 |
var DEFAULT_TITLE = '\u2013'; |
| 7273 |
|
| 7274 |
var PDFOutlineViewer = function () { |
| 7275 |
function PDFOutlineViewer(_ref) { |
| 7276 |
var container = _ref.container, |
| 7277 |
linkService = _ref.linkService, |
| 7278 |
eventBus = _ref.eventBus; |
| 7279 |
|
| 7280 |
_classCallCheck(this, PDFOutlineViewer); |
| 7281 |
|
| 7282 |
this.container = container; |
| 7283 |
this.linkService = linkService; |
| 7284 |
this.eventBus = eventBus; |
| 7285 |
this.reset(); |
| 7286 |
eventBus.on('toggleoutlinetree', this.toggleOutlineTree.bind(this)); |
| 7287 |
} |
| 7288 |
|
| 7289 |
_createClass(PDFOutlineViewer, [{ |
| 7290 |
key: 'reset', |
| 7291 |
value: function reset() { |
| 7292 |
this.outline = null; |
| 7293 |
this.lastToggleIsShow = true; |
| 7294 |
this.container.textContent = ''; |
| 7295 |
this.container.classList.remove('outlineWithDeepNesting'); |
| 7296 |
} |
| 7297 |
}, { |
| 7298 |
key: '_dispatchEvent', |
| 7299 |
value: function _dispatchEvent(outlineCount) { |
| 7300 |
this.eventBus.dispatch('outlineloaded', { |
| 7301 |
source: this, |
| 7302 |
outlineCount: outlineCount |
| 7303 |
}); |
| 7304 |
} |
| 7305 |
}, { |
| 7306 |
key: '_bindLink', |
| 7307 |
value: function _bindLink(element, _ref2) { |
| 7308 |
var url = _ref2.url, |
| 7309 |
newWindow = _ref2.newWindow, |
| 7310 |
dest = _ref2.dest; |
| 7311 |
var linkService = this.linkService; |
| 7312 |
|
| 7313 |
if (url) { |
| 7314 |
(0, _pdfjsLib.addLinkAttributes)(element, { |
| 7315 |
url: url, |
| 7316 |
target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService.externalLinkTarget, |
| 7317 |
rel: linkService.externalLinkRel |
| 7318 |
}); |
| 7319 |
return; |
| 7320 |
} |
| 7321 |
element.href = linkService.getDestinationHash(dest); |
| 7322 |
element.onclick = function () { |
| 7323 |
if (dest) { |
| 7324 |
linkService.navigateTo(dest); |
| 7325 |
} |
| 7326 |
return false; |
| 7327 |
}; |
| 7328 |
} |
| 7329 |
}, { |
| 7330 |
key: '_setStyles', |
| 7331 |
value: function _setStyles(element, _ref3) { |
| 7332 |
var bold = _ref3.bold, |
| 7333 |
italic = _ref3.italic; |
| 7334 |
|
| 7335 |
var styleStr = ''; |
| 7336 |
if (bold) { |
| 7337 |
styleStr += 'font-weight: bold;'; |
| 7338 |
} |
| 7339 |
if (italic) { |
| 7340 |
styleStr += 'font-style: italic;'; |
| 7341 |
} |
| 7342 |
if (styleStr) { |
| 7343 |
element.setAttribute('style', styleStr); |
| 7344 |
} |
| 7345 |
} |
| 7346 |
}, { |
| 7347 |
key: '_addToggleButton', |
| 7348 |
value: function _addToggleButton(div) { |
| 7349 |
var _this = this; |
| 7350 |
|
| 7351 |
var toggler = document.createElement('div'); |
| 7352 |
toggler.className = 'outlineItemToggler'; |
| 7353 |
toggler.onclick = function (evt) { |
| 7354 |
evt.stopPropagation(); |
| 7355 |
toggler.classList.toggle('outlineItemsHidden'); |
| 7356 |
if (evt.shiftKey) { |
| 7357 |
var shouldShowAll = !toggler.classList.contains('outlineItemsHidden'); |
| 7358 |
_this._toggleOutlineItem(div, shouldShowAll); |
| 7359 |
} |
| 7360 |
}; |
| 7361 |
div.insertBefore(toggler, div.firstChild); |
| 7362 |
} |
| 7363 |
}, { |
| 7364 |
key: '_toggleOutlineItem', |
| 7365 |
value: function _toggleOutlineItem(root, show) { |
| 7366 |
this.lastToggleIsShow = show; |
| 7367 |
var togglers = root.querySelectorAll('.outlineItemToggler'); |
| 7368 |
for (var i = 0, ii = togglers.length; i < ii; ++i) { |
| 7369 |
togglers[i].classList[show ? 'remove' : 'add']('outlineItemsHidden'); |
| 7370 |
} |
| 7371 |
} |
| 7372 |
}, { |
| 7373 |
key: 'toggleOutlineTree', |
| 7374 |
value: function toggleOutlineTree() { |
| 7375 |
if (!this.outline) { |
| 7376 |
return; |
| 7377 |
} |
| 7378 |
this._toggleOutlineItem(this.container, !this.lastToggleIsShow); |
| 7379 |
} |
| 7380 |
}, { |
| 7381 |
key: 'render', |
| 7382 |
value: function render(_ref4) { |
| 7383 |
var outline = _ref4.outline; |
| 7384 |
|
| 7385 |
var outlineCount = 0; |
| 7386 |
if (this.outline) { |
| 7387 |
this.reset(); |
| 7388 |
} |
| 7389 |
this.outline = outline || null; |
| 7390 |
if (!outline) { |
| 7391 |
this._dispatchEvent(outlineCount); |
| 7392 |
return; |
| 7393 |
} |
| 7394 |
var fragment = document.createDocumentFragment(); |
| 7395 |
var queue = [{ |
| 7396 |
parent: fragment, |
| 7397 |
items: this.outline |
| 7398 |
}]; |
| 7399 |
var hasAnyNesting = false; |
| 7400 |
while (queue.length > 0) { |
| 7401 |
var levelData = queue.shift(); |
| 7402 |
for (var i = 0, len = levelData.items.length; i < len; i++) { |
| 7403 |
var item = levelData.items[i]; |
| 7404 |
var div = document.createElement('div'); |
| 7405 |
div.className = 'outlineItem'; |
| 7406 |
var element = document.createElement('a'); |
| 7407 |
this._bindLink(element, item); |
| 7408 |
this._setStyles(element, item); |
| 7409 |
element.textContent = (0, _pdfjsLib.removeNullCharacters)(item.title) || DEFAULT_TITLE; |
| 7410 |
div.appendChild(element); |
| 7411 |
if (item.items.length > 0) { |
| 7412 |
hasAnyNesting = true; |
| 7413 |
this._addToggleButton(div); |
| 7414 |
var itemsDiv = document.createElement('div'); |
| 7415 |
itemsDiv.className = 'outlineItems'; |
| 7416 |
div.appendChild(itemsDiv); |
| 7417 |
queue.push({ |
| 7418 |
parent: itemsDiv, |
| 7419 |
items: item.items |
| 7420 |
}); |
| 7421 |
} |
| 7422 |
levelData.parent.appendChild(div); |
| 7423 |
outlineCount++; |
| 7424 |
} |
| 7425 |
} |
| 7426 |
if (hasAnyNesting) { |
| 7427 |
this.container.classList.add('outlineWithDeepNesting'); |
| 7428 |
} |
| 7429 |
this.container.appendChild(fragment); |
| 7430 |
this._dispatchEvent(outlineCount); |
| 7431 |
} |
| 7432 |
}]); |
| 7433 |
|
| 7434 |
return PDFOutlineViewer; |
| 7435 |
}(); |
| 7436 |
|
| 7437 |
exports.PDFOutlineViewer = PDFOutlineViewer; |
| 7438 |
|
| 7439 |
/***/ }), |
| 7440 |
/* 25 */ |
| 7441 |
/***/ (function(module, exports, __webpack_require__) { |
| 7442 |
|
| 7443 |
"use strict"; |
| 7444 |
|
| 7445 |
|
| 7446 |
Object.defineProperty(exports, "__esModule", { |
| 7447 |
value: true |
| 7448 |
}); |
| 7449 |
exports.PDFPresentationMode = undefined; |
| 7450 |
|
| 7451 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 7452 |
|
| 7453 |
var _ui_utils = __webpack_require__(6); |
| 7454 |
|
| 7455 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 7456 |
|
| 7457 |
var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500; |
| 7458 |
var DELAY_BEFORE_HIDING_CONTROLS = 3000; |
| 7459 |
var ACTIVE_SELECTOR = 'pdfPresentationMode'; |
| 7460 |
var CONTROLS_SELECTOR = 'pdfPresentationModeControls'; |
| 7461 |
var MOUSE_SCROLL_COOLDOWN_TIME = 50; |
| 7462 |
var PAGE_SWITCH_THRESHOLD = 0.1; |
| 7463 |
var SWIPE_MIN_DISTANCE_THRESHOLD = 50; |
| 7464 |
var SWIPE_ANGLE_THRESHOLD = Math.PI / 6; |
| 7465 |
|
| 7466 |
var PDFPresentationMode = function () { |
| 7467 |
function PDFPresentationMode(_ref) { |
| 7468 |
var _this = this; |
| 7469 |
|
| 7470 |
var container = _ref.container, |
| 7471 |
_ref$viewer = _ref.viewer, |
| 7472 |
viewer = _ref$viewer === undefined ? null : _ref$viewer, |
| 7473 |
pdfViewer = _ref.pdfViewer, |
| 7474 |
eventBus = _ref.eventBus, |
| 7475 |
_ref$contextMenuItems = _ref.contextMenuItems, |
| 7476 |
contextMenuItems = _ref$contextMenuItems === undefined ? null : _ref$contextMenuItems; |
| 7477 |
|
| 7478 |
_classCallCheck(this, PDFPresentationMode); |
| 7479 |
|
| 7480 |
this.container = container; |
| 7481 |
this.viewer = viewer || container.firstElementChild; |
| 7482 |
this.pdfViewer = pdfViewer; |
| 7483 |
this.eventBus = eventBus; |
| 7484 |
this.active = false; |
| 7485 |
this.args = null; |
| 7486 |
this.contextMenuOpen = false; |
| 7487 |
this.mouseScrollTimeStamp = 0; |
| 7488 |
this.mouseScrollDelta = 0; |
| 7489 |
this.touchSwipeState = null; |
| 7490 |
if (contextMenuItems) { |
| 7491 |
contextMenuItems.contextFirstPage.addEventListener('click', function () { |
| 7492 |
_this.contextMenuOpen = false; |
| 7493 |
_this.eventBus.dispatch('firstpage', { source: _this }); |
| 7494 |
}); |
| 7495 |
contextMenuItems.contextLastPage.addEventListener('click', function () { |
| 7496 |
_this.contextMenuOpen = false; |
| 7497 |
_this.eventBus.dispatch('lastpage', { source: _this }); |
| 7498 |
}); |
| 7499 |
contextMenuItems.contextPageRotateCw.addEventListener('click', function () { |
| 7500 |
_this.contextMenuOpen = false; |
| 7501 |
_this.eventBus.dispatch('rotatecw', { source: _this }); |
| 7502 |
}); |
| 7503 |
contextMenuItems.contextPageRotateCcw.addEventListener('click', function () { |
| 7504 |
_this.contextMenuOpen = false; |
| 7505 |
_this.eventBus.dispatch('rotateccw', { source: _this }); |
| 7506 |
}); |
| 7507 |
} |
| 7508 |
} |
| 7509 |
|
| 7510 |
_createClass(PDFPresentationMode, [{ |
| 7511 |
key: 'request', |
| 7512 |
value: function request() { |
| 7513 |
if (this.switchInProgress || this.active || !this.viewer.hasChildNodes()) { |
| 7514 |
return false; |
| 7515 |
} |
| 7516 |
this._addFullscreenChangeListeners(); |
| 7517 |
this._setSwitchInProgress(); |
| 7518 |
this._notifyStateChange(); |
| 7519 |
if (this.container.requestFullscreen) { |
| 7520 |
this.container.requestFullscreen(); |
| 7521 |
} else if (this.container.mozRequestFullScreen) { |
| 7522 |
this.container.mozRequestFullScreen(); |
| 7523 |
} else if (this.container.webkitRequestFullscreen) { |
| 7524 |
this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); |
| 7525 |
} else if (this.container.msRequestFullscreen) { |
| 7526 |
this.container.msRequestFullscreen(); |
| 7527 |
} else { |
| 7528 |
return false; |
| 7529 |
} |
| 7530 |
this.args = { |
| 7531 |
page: this.pdfViewer.currentPageNumber, |
| 7532 |
previousScale: this.pdfViewer.currentScaleValue |
| 7533 |
}; |
| 7534 |
return true; |
| 7535 |
} |
| 7536 |
}, { |
| 7537 |
key: '_mouseWheel', |
| 7538 |
value: function _mouseWheel(evt) { |
| 7539 |
if (!this.active) { |
| 7540 |
return; |
| 7541 |
} |
| 7542 |
evt.preventDefault(); |
| 7543 |
var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt); |
| 7544 |
var currentTime = new Date().getTime(); |
| 7545 |
var storedTime = this.mouseScrollTimeStamp; |
| 7546 |
if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) { |
| 7547 |
return; |
| 7548 |
} |
| 7549 |
if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) { |
| 7550 |
this._resetMouseScrollState(); |
| 7551 |
} |
| 7552 |
this.mouseScrollDelta += delta; |
| 7553 |
if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) { |
| 7554 |
var totalDelta = this.mouseScrollDelta; |
| 7555 |
this._resetMouseScrollState(); |
| 7556 |
var success = totalDelta > 0 ? this._goToPreviousPage() : this._goToNextPage(); |
| 7557 |
if (success) { |
| 7558 |
this.mouseScrollTimeStamp = currentTime; |
| 7559 |
} |
| 7560 |
} |
| 7561 |
} |
| 7562 |
}, { |
| 7563 |
key: '_goToPreviousPage', |
| 7564 |
value: function _goToPreviousPage() { |
| 7565 |
var page = this.pdfViewer.currentPageNumber; |
| 7566 |
if (page <= 1) { |
| 7567 |
return false; |
| 7568 |
} |
| 7569 |
this.pdfViewer.currentPageNumber = page - 1; |
| 7570 |
return true; |
| 7571 |
} |
| 7572 |
}, { |
| 7573 |
key: '_goToNextPage', |
| 7574 |
value: function _goToNextPage() { |
| 7575 |
var page = this.pdfViewer.currentPageNumber; |
| 7576 |
if (page >= this.pdfViewer.pagesCount) { |
| 7577 |
return false; |
| 7578 |
} |
| 7579 |
this.pdfViewer.currentPageNumber = page + 1; |
| 7580 |
return true; |
| 7581 |
} |
| 7582 |
}, { |
| 7583 |
key: '_notifyStateChange', |
| 7584 |
value: function _notifyStateChange() { |
| 7585 |
this.eventBus.dispatch('presentationmodechanged', { |
| 7586 |
source: this, |
| 7587 |
active: this.active, |
| 7588 |
switchInProgress: !!this.switchInProgress |
| 7589 |
}); |
| 7590 |
} |
| 7591 |
}, { |
| 7592 |
key: '_setSwitchInProgress', |
| 7593 |
value: function _setSwitchInProgress() { |
| 7594 |
var _this2 = this; |
| 7595 |
|
| 7596 |
if (this.switchInProgress) { |
| 7597 |
clearTimeout(this.switchInProgress); |
| 7598 |
} |
| 7599 |
this.switchInProgress = setTimeout(function () { |
| 7600 |
_this2._removeFullscreenChangeListeners(); |
| 7601 |
delete _this2.switchInProgress; |
| 7602 |
_this2._notifyStateChange(); |
| 7603 |
}, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS); |
| 7604 |
} |
| 7605 |
}, { |
| 7606 |
key: '_resetSwitchInProgress', |
| 7607 |
value: function _resetSwitchInProgress() { |
| 7608 |
if (this.switchInProgress) { |
| 7609 |
clearTimeout(this.switchInProgress); |
| 7610 |
delete this.switchInProgress; |
| 7611 |
} |
| 7612 |
} |
| 7613 |
}, { |
| 7614 |
key: '_enter', |
| 7615 |
value: function _enter() { |
| 7616 |
var _this3 = this; |
| 7617 |
|
| 7618 |
this.active = true; |
| 7619 |
this._resetSwitchInProgress(); |
| 7620 |
this._notifyStateChange(); |
| 7621 |
this.container.classList.add(ACTIVE_SELECTOR); |
| 7622 |
setTimeout(function () { |
| 7623 |
_this3.pdfViewer.currentPageNumber = _this3.args.page; |
| 7624 |
_this3.pdfViewer.currentScaleValue = 'page-fit'; |
| 7625 |
}, 0); |
| 7626 |
this._addWindowListeners(); |
| 7627 |
this._showControls(); |
| 7628 |
this.contextMenuOpen = false; |
| 7629 |
this.container.setAttribute('contextmenu', 'viewerContextMenu'); |
| 7630 |
window.getSelection().removeAllRanges(); |
| 7631 |
} |
| 7632 |
}, { |
| 7633 |
key: '_exit', |
| 7634 |
value: function _exit() { |
| 7635 |
var _this4 = this; |
| 7636 |
|
| 7637 |
var page = this.pdfViewer.currentPageNumber; |
| 7638 |
this.container.classList.remove(ACTIVE_SELECTOR); |
| 7639 |
setTimeout(function () { |
| 7640 |
_this4.active = false; |
| 7641 |
_this4._removeFullscreenChangeListeners(); |
| 7642 |
_this4._notifyStateChange(); |
| 7643 |
_this4.pdfViewer.currentScaleValue = _this4.args.previousScale; |
| 7644 |
_this4.pdfViewer.currentPageNumber = page; |
| 7645 |
_this4.args = null; |
| 7646 |
}, 0); |
| 7647 |
this._removeWindowListeners(); |
| 7648 |
this._hideControls(); |
| 7649 |
this._resetMouseScrollState(); |
| 7650 |
this.container.removeAttribute('contextmenu'); |
| 7651 |
this.contextMenuOpen = false; |
| 7652 |
} |
| 7653 |
}, { |
| 7654 |
key: '_mouseDown', |
| 7655 |
value: function _mouseDown(evt) { |
| 7656 |
if (this.contextMenuOpen) { |
| 7657 |
this.contextMenuOpen = false; |
| 7658 |
evt.preventDefault(); |
| 7659 |
return; |
| 7660 |
} |
| 7661 |
if (evt.button === 0) { |
| 7662 |
var isInternalLink = evt.target.href && evt.target.classList.contains('internalLink'); |
| 7663 |
if (!isInternalLink) { |
| 7664 |
evt.preventDefault(); |
| 7665 |
if (evt.shiftKey) { |
| 7666 |
this._goToPreviousPage(); |
| 7667 |
} else { |
| 7668 |
this._goToNextPage(); |
| 7669 |
} |
| 7670 |
} |
| 7671 |
} |
| 7672 |
} |
| 7673 |
}, { |
| 7674 |
key: '_contextMenu', |
| 7675 |
value: function _contextMenu() { |
| 7676 |
this.contextMenuOpen = true; |
| 7677 |
} |
| 7678 |
}, { |
| 7679 |
key: '_showControls', |
| 7680 |
value: function _showControls() { |
| 7681 |
var _this5 = this; |
| 7682 |
|
| 7683 |
if (this.controlsTimeout) { |
| 7684 |
clearTimeout(this.controlsTimeout); |
| 7685 |
} else { |
| 7686 |
this.container.classList.add(CONTROLS_SELECTOR); |
| 7687 |
} |
| 7688 |
this.controlsTimeout = setTimeout(function () { |
| 7689 |
_this5.container.classList.remove(CONTROLS_SELECTOR); |
| 7690 |
delete _this5.controlsTimeout; |
| 7691 |
}, DELAY_BEFORE_HIDING_CONTROLS); |
| 7692 |
} |
| 7693 |
}, { |
| 7694 |
key: '_hideControls', |
| 7695 |
value: function _hideControls() { |
| 7696 |
if (!this.controlsTimeout) { |
| 7697 |
return; |
| 7698 |
} |
| 7699 |
clearTimeout(this.controlsTimeout); |
| 7700 |
this.container.classList.remove(CONTROLS_SELECTOR); |
| 7701 |
delete this.controlsTimeout; |
| 7702 |
} |
| 7703 |
}, { |
| 7704 |
key: '_resetMouseScrollState', |
| 7705 |
value: function _resetMouseScrollState() { |
| 7706 |
this.mouseScrollTimeStamp = 0; |
| 7707 |
this.mouseScrollDelta = 0; |
| 7708 |
} |
| 7709 |
}, { |
| 7710 |
key: '_touchSwipe', |
| 7711 |
value: function _touchSwipe(evt) { |
| 7712 |
if (!this.active) { |
| 7713 |
return; |
| 7714 |
} |
| 7715 |
if (evt.touches.length > 1) { |
| 7716 |
this.touchSwipeState = null; |
| 7717 |
return; |
| 7718 |
} |
| 7719 |
switch (evt.type) { |
| 7720 |
case 'touchstart': |
| 7721 |
this.touchSwipeState = { |
| 7722 |
startX: evt.touches[0].pageX, |
| 7723 |
startY: evt.touches[0].pageY, |
| 7724 |
endX: evt.touches[0].pageX, |
| 7725 |
endY: evt.touches[0].pageY |
| 7726 |
}; |
| 7727 |
break; |
| 7728 |
case 'touchmove': |
| 7729 |
if (this.touchSwipeState === null) { |
| 7730 |
return; |
| 7731 |
} |
| 7732 |
this.touchSwipeState.endX = evt.touches[0].pageX; |
| 7733 |
this.touchSwipeState.endY = evt.touches[0].pageY; |
| 7734 |
evt.preventDefault(); |
| 7735 |
break; |
| 7736 |
case 'touchend': |
| 7737 |
if (this.touchSwipeState === null) { |
| 7738 |
return; |
| 7739 |
} |
| 7740 |
var delta = 0; |
| 7741 |
var dx = this.touchSwipeState.endX - this.touchSwipeState.startX; |
| 7742 |
var dy = this.touchSwipeState.endY - this.touchSwipeState.startY; |
| 7743 |
var absAngle = Math.abs(Math.atan2(dy, dx)); |
| 7744 |
if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) { |
| 7745 |
delta = dx; |
| 7746 |
} else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) { |
| 7747 |
delta = dy; |
| 7748 |
} |
| 7749 |
if (delta > 0) { |
| 7750 |
this._goToPreviousPage(); |
| 7751 |
} else if (delta < 0) { |
| 7752 |
this._goToNextPage(); |
| 7753 |
} |
| 7754 |
break; |
| 7755 |
} |
| 7756 |
} |
| 7757 |
}, { |
| 7758 |
key: '_addWindowListeners', |
| 7759 |
value: function _addWindowListeners() { |
| 7760 |
this.showControlsBind = this._showControls.bind(this); |
| 7761 |
this.mouseDownBind = this._mouseDown.bind(this); |
| 7762 |
this.mouseWheelBind = this._mouseWheel.bind(this); |
| 7763 |
this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this); |
| 7764 |
this.contextMenuBind = this._contextMenu.bind(this); |
| 7765 |
this.touchSwipeBind = this._touchSwipe.bind(this); |
| 7766 |
window.addEventListener('mousemove', this.showControlsBind); |
| 7767 |
window.addEventListener('mousedown', this.mouseDownBind); |
| 7768 |
window.addEventListener('wheel', this.mouseWheelBind); |
| 7769 |
window.addEventListener('keydown', this.resetMouseScrollStateBind); |
| 7770 |
window.addEventListener('contextmenu', this.contextMenuBind); |
| 7771 |
window.addEventListener('touchstart', this.touchSwipeBind); |
| 7772 |
window.addEventListener('touchmove', this.touchSwipeBind); |
| 7773 |
window.addEventListener('touchend', this.touchSwipeBind); |
| 7774 |
} |
| 7775 |
}, { |
| 7776 |
key: '_removeWindowListeners', |
| 7777 |
value: function _removeWindowListeners() { |
| 7778 |
window.removeEventListener('mousemove', this.showControlsBind); |
| 7779 |
window.removeEventListener('mousedown', this.mouseDownBind); |
| 7780 |
window.removeEventListener('wheel', this.mouseWheelBind); |
| 7781 |
window.removeEventListener('keydown', this.resetMouseScrollStateBind); |
| 7782 |
window.removeEventListener('contextmenu', this.contextMenuBind); |
| 7783 |
window.removeEventListener('touchstart', this.touchSwipeBind); |
| 7784 |
window.removeEventListener('touchmove', this.touchSwipeBind); |
| 7785 |
window.removeEventListener('touchend', this.touchSwipeBind); |
| 7786 |
delete this.showControlsBind; |
| 7787 |
delete this.mouseDownBind; |
| 7788 |
delete this.mouseWheelBind; |
| 7789 |
delete this.resetMouseScrollStateBind; |
| 7790 |
delete this.contextMenuBind; |
| 7791 |
delete this.touchSwipeBind; |
| 7792 |
} |
| 7793 |
}, { |
| 7794 |
key: '_fullscreenChange', |
| 7795 |
value: function _fullscreenChange() { |
| 7796 |
if (this.isFullscreen) { |
| 7797 |
this._enter(); |
| 7798 |
} else { |
| 7799 |
this._exit(); |
| 7800 |
} |
| 7801 |
} |
| 7802 |
}, { |
| 7803 |
key: '_addFullscreenChangeListeners', |
| 7804 |
value: function _addFullscreenChangeListeners() { |
| 7805 |
this.fullscreenChangeBind = this._fullscreenChange.bind(this); |
| 7806 |
window.addEventListener('fullscreenchange', this.fullscreenChangeBind); |
| 7807 |
window.addEventListener('mozfullscreenchange', this.fullscreenChangeBind); |
| 7808 |
window.addEventListener('webkitfullscreenchange', this.fullscreenChangeBind); |
| 7809 |
window.addEventListener('MSFullscreenChange', this.fullscreenChangeBind); |
| 7810 |
} |
| 7811 |
}, { |
| 7812 |
key: '_removeFullscreenChangeListeners', |
| 7813 |
value: function _removeFullscreenChangeListeners() { |
| 7814 |
window.removeEventListener('fullscreenchange', this.fullscreenChangeBind); |
| 7815 |
window.removeEventListener('mozfullscreenchange', this.fullscreenChangeBind); |
| 7816 |
window.removeEventListener('webkitfullscreenchange', this.fullscreenChangeBind); |
| 7817 |
window.removeEventListener('MSFullscreenChange', this.fullscreenChangeBind); |
| 7818 |
delete this.fullscreenChangeBind; |
| 7819 |
} |
| 7820 |
}, { |
| 7821 |
key: 'isFullscreen', |
| 7822 |
get: function get() { |
| 7823 |
return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement); |
| 7824 |
} |
| 7825 |
}]); |
| 7826 |
|
| 7827 |
return PDFPresentationMode; |
| 7828 |
}(); |
| 7829 |
|
| 7830 |
exports.PDFPresentationMode = PDFPresentationMode; |
| 7831 |
|
| 7832 |
/***/ }), |
| 7833 |
/* 26 */ |
| 7834 |
/***/ (function(module, exports, __webpack_require__) { |
| 7835 |
|
| 7836 |
"use strict"; |
| 7837 |
|
| 7838 |
|
| 7839 |
Object.defineProperty(exports, "__esModule", { |
| 7840 |
value: true |
| 7841 |
}); |
| 7842 |
exports.PDFSidebarResizer = undefined; |
| 7843 |
|
| 7844 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 7845 |
|
| 7846 |
var _ui_utils = __webpack_require__(6); |
| 7847 |
|
| 7848 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 7849 |
|
| 7850 |
var SIDEBAR_WIDTH_VAR = '--sidebar-width'; |
| 7851 |
var SIDEBAR_MIN_WIDTH = 200; |
| 7852 |
var SIDEBAR_RESIZING_CLASS = 'sidebarResizing'; |
| 7853 |
|
| 7854 |
var PDFSidebarResizer = function () { |
| 7855 |
function PDFSidebarResizer(options, eventBus) { |
| 7856 |
var _this = this; |
| 7857 |
|
| 7858 |
var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n; |
| 7859 |
|
| 7860 |
_classCallCheck(this, PDFSidebarResizer); |
| 7861 |
|
| 7862 |
this.enabled = false; |
| 7863 |
this.isRTL = false; |
| 7864 |
this.sidebarOpen = false; |
| 7865 |
this.doc = document.documentElement; |
| 7866 |
this._width = null; |
| 7867 |
this._outerContainerWidth = null; |
| 7868 |
this._boundEvents = Object.create(null); |
| 7869 |
this.outerContainer = options.outerContainer; |
| 7870 |
this.resizer = options.resizer; |
| 7871 |
this.eventBus = eventBus; |
| 7872 |
this.l10n = l10n; |
| 7873 |
if (typeof CSS === 'undefined' || typeof CSS.supports !== 'function' || !CSS.supports(SIDEBAR_WIDTH_VAR, 'calc(-1 * ' + SIDEBAR_MIN_WIDTH + 'px)')) { |
| 7874 |
console.warn('PDFSidebarResizer: ' + 'The browser does not support resizing of the sidebar.'); |
| 7875 |
return; |
| 7876 |
} |
| 7877 |
this.enabled = true; |
| 7878 |
this.resizer.classList.remove('hidden'); |
| 7879 |
this.l10n.getDirection().then(function (dir) { |
| 7880 |
_this.isRTL = dir === 'rtl'; |
| 7881 |
}); |
| 7882 |
this._addEventListeners(); |
| 7883 |
} |
| 7884 |
|
| 7885 |
_createClass(PDFSidebarResizer, [{ |
| 7886 |
key: '_updateWidth', |
| 7887 |
value: function _updateWidth() { |
| 7888 |
var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; |
| 7889 |
|
| 7890 |
if (!this.enabled) { |
| 7891 |
return false; |
| 7892 |
} |
| 7893 |
var maxWidth = Math.floor(this.outerContainerWidth / 2); |
| 7894 |
if (width > maxWidth) { |
| 7895 |
width = maxWidth; |
| 7896 |
} |
| 7897 |
if (width < SIDEBAR_MIN_WIDTH) { |
| 7898 |
width = SIDEBAR_MIN_WIDTH; |
| 7899 |
} |
| 7900 |
if (width === this._width) { |
| 7901 |
return false; |
| 7902 |
} |
| 7903 |
this._width = width; |
| 7904 |
this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, width + 'px'); |
| 7905 |
return true; |
| 7906 |
} |
| 7907 |
}, { |
| 7908 |
key: '_mouseMove', |
| 7909 |
value: function _mouseMove(evt) { |
| 7910 |
var width = evt.clientX; |
| 7911 |
if (this.isRTL) { |
| 7912 |
width = this.outerContainerWidth - width; |
| 7913 |
} |
| 7914 |
this._updateWidth(width); |
| 7915 |
} |
| 7916 |
}, { |
| 7917 |
key: '_mouseUp', |
| 7918 |
value: function _mouseUp(evt) { |
| 7919 |
this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS); |
| 7920 |
this.eventBus.dispatch('resize', { source: this }); |
| 7921 |
var _boundEvents = this._boundEvents; |
| 7922 |
window.removeEventListener('mousemove', _boundEvents.mouseMove); |
| 7923 |
window.removeEventListener('mouseup', _boundEvents.mouseUp); |
| 7924 |
} |
| 7925 |
}, { |
| 7926 |
key: '_addEventListeners', |
| 7927 |
value: function _addEventListeners() { |
| 7928 |
var _this2 = this; |
| 7929 |
|
| 7930 |
if (!this.enabled) { |
| 7931 |
return; |
| 7932 |
} |
| 7933 |
var _boundEvents = this._boundEvents; |
| 7934 |
_boundEvents.mouseMove = this._mouseMove.bind(this); |
| 7935 |
_boundEvents.mouseUp = this._mouseUp.bind(this); |
| 7936 |
this.resizer.addEventListener('mousedown', function (evt) { |
| 7937 |
if (evt.button !== 0) { |
| 7938 |
return; |
| 7939 |
} |
| 7940 |
_this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS); |
| 7941 |
window.addEventListener('mousemove', _boundEvents.mouseMove); |
| 7942 |
window.addEventListener('mouseup', _boundEvents.mouseUp); |
| 7943 |
}); |
| 7944 |
this.eventBus.on('sidebarviewchanged', function (evt) { |
| 7945 |
_this2.sidebarOpen = !!(evt && evt.view); |
| 7946 |
}); |
| 7947 |
this.eventBus.on('resize', function (evt) { |
| 7948 |
if (evt && evt.source === window) { |
| 7949 |
_this2._outerContainerWidth = null; |
| 7950 |
if (_this2._width) { |
| 7951 |
if (_this2.sidebarOpen) { |
| 7952 |
_this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS); |
| 7953 |
var updated = _this2._updateWidth(_this2._width); |
| 7954 |
Promise.resolve().then(function () { |
| 7955 |
_this2.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS); |
| 7956 |
if (updated) { |
| 7957 |
_this2.eventBus.dispatch('resize', { source: _this2 }); |
| 7958 |
} |
| 7959 |
}); |
| 7960 |
} else { |
| 7961 |
_this2._updateWidth(_this2._width); |
| 7962 |
} |
| 7963 |
} |
| 7964 |
} |
| 7965 |
}); |
| 7966 |
} |
| 7967 |
}, { |
| 7968 |
key: 'outerContainerWidth', |
| 7969 |
get: function get() { |
| 7970 |
if (!this._outerContainerWidth) { |
| 7971 |
this._outerContainerWidth = this.outerContainer.clientWidth; |
| 7972 |
} |
| 7973 |
return this._outerContainerWidth; |
| 7974 |
} |
| 7975 |
}]); |
| 7976 |
|
| 7977 |
return PDFSidebarResizer; |
| 7978 |
}(); |
| 7979 |
|
| 7980 |
exports.PDFSidebarResizer = PDFSidebarResizer; |
| 7981 |
|
| 7982 |
/***/ }), |
| 7983 |
/* 27 */ |
| 7984 |
/***/ (function(module, exports, __webpack_require__) { |
| 7985 |
|
| 7986 |
"use strict"; |
| 7987 |
|
| 7988 |
|
| 7989 |
Object.defineProperty(exports, "__esModule", { |
| 7990 |
value: true |
| 7991 |
}); |
| 7992 |
exports.PDFThumbnailViewer = undefined; |
| 7993 |
|
| 7994 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 7995 |
|
| 7996 |
var _ui_utils = __webpack_require__(6); |
| 7997 |
|
| 7998 |
var _pdf_thumbnail_view = __webpack_require__(28); |
| 7999 |
|
| 8000 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 8001 |
|
| 8002 |
var THUMBNAIL_SCROLL_MARGIN = -19; |
| 8003 |
var THUMBNAIL_SELECTED_CLASS = 'selected'; |
| 8004 |
|
| 8005 |
var PDFThumbnailViewer = function () { |
| 8006 |
function PDFThumbnailViewer(_ref) { |
| 8007 |
var container = _ref.container, |
| 8008 |
linkService = _ref.linkService, |
| 8009 |
renderingQueue = _ref.renderingQueue, |
| 8010 |
_ref$l10n = _ref.l10n, |
| 8011 |
l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n; |
| 8012 |
|
| 8013 |
_classCallCheck(this, PDFThumbnailViewer); |
| 8014 |
|
| 8015 |
this.container = container; |
| 8016 |
this.linkService = linkService; |
| 8017 |
this.renderingQueue = renderingQueue; |
| 8018 |
this.l10n = l10n; |
| 8019 |
this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this)); |
| 8020 |
this._resetView(); |
| 8021 |
} |
| 8022 |
|
| 8023 |
_createClass(PDFThumbnailViewer, [{ |
| 8024 |
key: '_scrollUpdated', |
| 8025 |
value: function _scrollUpdated() { |
| 8026 |
this.renderingQueue.renderHighestPriority(); |
| 8027 |
} |
| 8028 |
}, { |
| 8029 |
key: 'getThumbnail', |
| 8030 |
value: function getThumbnail(index) { |
| 8031 |
return this._thumbnails[index]; |
| 8032 |
} |
| 8033 |
}, { |
| 8034 |
key: '_getVisibleThumbs', |
| 8035 |
value: function _getVisibleThumbs() { |
| 8036 |
return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails); |
| 8037 |
} |
| 8038 |
}, { |
| 8039 |
key: 'scrollThumbnailIntoView', |
| 8040 |
value: function scrollThumbnailIntoView(pageNumber) { |
| 8041 |
if (!this.pdfDocument) { |
| 8042 |
return; |
| 8043 |
} |
| 8044 |
var thumbnailView = this._thumbnails[pageNumber - 1]; |
| 8045 |
if (!thumbnailView) { |
| 8046 |
console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.'); |
| 8047 |
return; |
| 8048 |
} |
| 8049 |
if (pageNumber !== this._currentPageNumber) { |
| 8050 |
var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1]; |
| 8051 |
prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS); |
| 8052 |
thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS); |
| 8053 |
} |
| 8054 |
var visibleThumbs = this._getVisibleThumbs(); |
| 8055 |
var numVisibleThumbs = visibleThumbs.views.length; |
| 8056 |
if (numVisibleThumbs > 0) { |
| 8057 |
var first = visibleThumbs.first.id; |
| 8058 |
var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first; |
| 8059 |
var shouldScroll = false; |
| 8060 |
if (pageNumber <= first || pageNumber >= last) { |
| 8061 |
shouldScroll = true; |
| 8062 |
} else { |
| 8063 |
visibleThumbs.views.some(function (view) { |
| 8064 |
if (view.id !== pageNumber) { |
| 8065 |
return false; |
| 8066 |
} |
| 8067 |
shouldScroll = view.percent < 100; |
| 8068 |
return true; |
| 8069 |
}); |
| 8070 |
} |
| 8071 |
if (shouldScroll) { |
| 8072 |
(0, _ui_utils.scrollIntoView)(thumbnailView.div, { top: THUMBNAIL_SCROLL_MARGIN }); |
| 8073 |
} |
| 8074 |
} |
| 8075 |
this._currentPageNumber = pageNumber; |
| 8076 |
} |
| 8077 |
}, { |
| 8078 |
key: 'cleanup', |
| 8079 |
value: function cleanup() { |
| 8080 |
_pdf_thumbnail_view.PDFThumbnailView.cleanup(); |
| 8081 |
} |
| 8082 |
}, { |
| 8083 |
key: '_resetView', |
| 8084 |
value: function _resetView() { |
| 8085 |
this._thumbnails = []; |
| 8086 |
this._currentPageNumber = 1; |
| 8087 |
this._pageLabels = null; |
| 8088 |
this._pagesRotation = 0; |
| 8089 |
this._pagesRequests = []; |
| 8090 |
this.container.textContent = ''; |
| 8091 |
} |
| 8092 |
}, { |
| 8093 |
key: 'setDocument', |
| 8094 |
value: function setDocument(pdfDocument) { |
| 8095 |
var _this = this; |
| 8096 |
|
| 8097 |
if (this.pdfDocument) { |
| 8098 |
this._cancelRendering(); |
| 8099 |
this._resetView(); |
| 8100 |
} |
| 8101 |
this.pdfDocument = pdfDocument; |
| 8102 |
if (!pdfDocument) { |
| 8103 |
return; |
| 8104 |
} |
| 8105 |
pdfDocument.getPage(1).then(function (firstPage) { |
| 8106 |
var pagesCount = pdfDocument.numPages; |
| 8107 |
var viewport = firstPage.getViewport(1.0); |
| 8108 |
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) { |
| 8109 |
var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({ |
| 8110 |
container: _this.container, |
| 8111 |
id: pageNum, |
| 8112 |
defaultViewport: viewport.clone(), |
| 8113 |
linkService: _this.linkService, |
| 8114 |
renderingQueue: _this.renderingQueue, |
| 8115 |
disableCanvasToImageConversion: false, |
| 8116 |
l10n: _this.l10n |
| 8117 |
}); |
| 8118 |
_this._thumbnails.push(thumbnail); |
| 8119 |
} |
| 8120 |
var thumbnailView = _this._thumbnails[_this._currentPageNumber - 1]; |
| 8121 |
thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS); |
| 8122 |
}).catch(function (reason) { |
| 8123 |
console.error('Unable to initialize thumbnail viewer', reason); |
| 8124 |
}); |
| 8125 |
} |
| 8126 |
}, { |
| 8127 |
key: '_cancelRendering', |
| 8128 |
value: function _cancelRendering() { |
| 8129 |
for (var i = 0, ii = this._thumbnails.length; i < ii; i++) { |
| 8130 |
if (this._thumbnails[i]) { |
| 8131 |
this._thumbnails[i].cancelRendering(); |
| 8132 |
} |
| 8133 |
} |
| 8134 |
} |
| 8135 |
}, { |
| 8136 |
key: 'setPageLabels', |
| 8137 |
value: function setPageLabels(labels) { |
| 8138 |
if (!this.pdfDocument) { |
| 8139 |
return; |
| 8140 |
} |
| 8141 |
if (!labels) { |
| 8142 |
this._pageLabels = null; |
| 8143 |
} else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) { |
| 8144 |
this._pageLabels = null; |
| 8145 |
console.error('PDFThumbnailViewer_setPageLabels: Invalid page labels.'); |
| 8146 |
} else { |
| 8147 |
this._pageLabels = labels; |
| 8148 |
} |
| 8149 |
for (var i = 0, ii = this._thumbnails.length; i < ii; i++) { |
| 8150 |
var label = this._pageLabels && this._pageLabels[i]; |
| 8151 |
this._thumbnails[i].setPageLabel(label); |
| 8152 |
} |
| 8153 |
} |
| 8154 |
}, { |
| 8155 |
key: '_ensurePdfPageLoaded', |
| 8156 |
value: function _ensurePdfPageLoaded(thumbView) { |
| 8157 |
var _this2 = this; |
| 8158 |
|
| 8159 |
if (thumbView.pdfPage) { |
| 8160 |
return Promise.resolve(thumbView.pdfPage); |
| 8161 |
} |
| 8162 |
var pageNumber = thumbView.id; |
| 8163 |
if (this._pagesRequests[pageNumber]) { |
| 8164 |
return this._pagesRequests[pageNumber]; |
| 8165 |
} |
| 8166 |
var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) { |
| 8167 |
thumbView.setPdfPage(pdfPage); |
| 8168 |
_this2._pagesRequests[pageNumber] = null; |
| 8169 |
return pdfPage; |
| 8170 |
}).catch(function (reason) { |
| 8171 |
console.error('Unable to get page for thumb view', reason); |
| 8172 |
_this2._pagesRequests[pageNumber] = null; |
| 8173 |
}); |
| 8174 |
this._pagesRequests[pageNumber] = promise; |
| 8175 |
return promise; |
| 8176 |
} |
| 8177 |
}, { |
| 8178 |
key: 'forceRendering', |
| 8179 |
value: function forceRendering() { |
| 8180 |
var _this3 = this; |
| 8181 |
|
| 8182 |
var visibleThumbs = this._getVisibleThumbs(); |
| 8183 |
var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down); |
| 8184 |
if (thumbView) { |
| 8185 |
this._ensurePdfPageLoaded(thumbView).then(function () { |
| 8186 |
_this3.renderingQueue.renderView(thumbView); |
| 8187 |
}); |
| 8188 |
return true; |
| 8189 |
} |
| 8190 |
return false; |
| 8191 |
} |
| 8192 |
}, { |
| 8193 |
key: 'pagesRotation', |
| 8194 |
get: function get() { |
| 8195 |
return this._pagesRotation; |
| 8196 |
}, |
| 8197 |
set: function set(rotation) { |
| 8198 |
if (!(0, _ui_utils.isValidRotation)(rotation)) { |
| 8199 |
throw new Error('Invalid thumbnails rotation angle.'); |
| 8200 |
} |
| 8201 |
if (!this.pdfDocument) { |
| 8202 |
return; |
| 8203 |
} |
| 8204 |
if (this._pagesRotation === rotation) { |
| 8205 |
return; |
| 8206 |
} |
| 8207 |
this._pagesRotation = rotation; |
| 8208 |
for (var i = 0, ii = this._thumbnails.length; i < ii; i++) { |
| 8209 |
this._thumbnails[i].update(rotation); |
| 8210 |
} |
| 8211 |
} |
| 8212 |
}]); |
| 8213 |
|
| 8214 |
return PDFThumbnailViewer; |
| 8215 |
}(); |
| 8216 |
|
| 8217 |
exports.PDFThumbnailViewer = PDFThumbnailViewer; |
| 8218 |
|
| 8219 |
/***/ }), |
| 8220 |
/* 28 */ |
| 8221 |
/***/ (function(module, exports, __webpack_require__) { |
| 8222 |
|
| 8223 |
"use strict"; |
| 8224 |
|
| 8225 |
|
| 8226 |
Object.defineProperty(exports, "__esModule", { |
| 8227 |
value: true |
| 8228 |
}); |
| 8229 |
exports.PDFThumbnailView = undefined; |
| 8230 |
|
| 8231 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 8232 |
|
| 8233 |
var _pdfjsLib = __webpack_require__(7); |
| 8234 |
|
| 8235 |
var _ui_utils = __webpack_require__(6); |
| 8236 |
|
| 8237 |
var _pdf_rendering_queue = __webpack_require__(10); |
| 8238 |
|
| 8239 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 8240 |
|
| 8241 |
var MAX_NUM_SCALING_STEPS = 3; |
| 8242 |
var THUMBNAIL_CANVAS_BORDER_WIDTH = 1; |
| 8243 |
var THUMBNAIL_WIDTH = 98; |
| 8244 |
var TempImageFactory = function TempImageFactoryClosure() { |
| 8245 |
var tempCanvasCache = null; |
| 8246 |
return { |
| 8247 |
getCanvas: function getCanvas(width, height) { |
| 8248 |
var tempCanvas = tempCanvasCache; |
| 8249 |
if (!tempCanvas) { |
| 8250 |
tempCanvas = document.createElement('canvas'); |
| 8251 |
tempCanvasCache = tempCanvas; |
| 8252 |
} |
| 8253 |
tempCanvas.width = width; |
| 8254 |
tempCanvas.height = height; |
| 8255 |
tempCanvas.mozOpaque = true; |
| 8256 |
var ctx = tempCanvas.getContext('2d', { alpha: false }); |
| 8257 |
ctx.save(); |
| 8258 |
ctx.fillStyle = 'rgb(255, 255, 255)'; |
| 8259 |
ctx.fillRect(0, 0, width, height); |
| 8260 |
ctx.restore(); |
| 8261 |
return tempCanvas; |
| 8262 |
}, |
| 8263 |
destroyCanvas: function destroyCanvas() { |
| 8264 |
var tempCanvas = tempCanvasCache; |
| 8265 |
if (tempCanvas) { |
| 8266 |
tempCanvas.width = 0; |
| 8267 |
tempCanvas.height = 0; |
| 8268 |
} |
| 8269 |
tempCanvasCache = null; |
| 8270 |
} |
| 8271 |
}; |
| 8272 |
}(); |
| 8273 |
|
| 8274 |
var PDFThumbnailView = function () { |
| 8275 |
function PDFThumbnailView(_ref) { |
| 8276 |
var container = _ref.container, |
| 8277 |
id = _ref.id, |
| 8278 |
defaultViewport = _ref.defaultViewport, |
| 8279 |
linkService = _ref.linkService, |
| 8280 |
renderingQueue = _ref.renderingQueue, |
| 8281 |
_ref$disableCanvasToI = _ref.disableCanvasToImageConversion, |
| 8282 |
disableCanvasToImageConversion = _ref$disableCanvasToI === undefined ? false : _ref$disableCanvasToI, |
| 8283 |
_ref$l10n = _ref.l10n, |
| 8284 |
l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n; |
| 8285 |
|
| 8286 |
_classCallCheck(this, PDFThumbnailView); |
| 8287 |
|
| 8288 |
this.id = id; |
| 8289 |
this.renderingId = 'thumbnail' + id; |
| 8290 |
this.pageLabel = null; |
| 8291 |
this.pdfPage = null; |
| 8292 |
this.rotation = 0; |
| 8293 |
this.viewport = defaultViewport; |
| 8294 |
this.pdfPageRotate = defaultViewport.rotation; |
| 8295 |
this.linkService = linkService; |
| 8296 |
this.renderingQueue = renderingQueue; |
| 8297 |
this.renderTask = null; |
| 8298 |
this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL; |
| 8299 |
this.resume = null; |
| 8300 |
this.disableCanvasToImageConversion = disableCanvasToImageConversion; |
| 8301 |
this.pageWidth = this.viewport.width; |
| 8302 |
this.pageHeight = this.viewport.height; |
| 8303 |
this.pageRatio = this.pageWidth / this.pageHeight; |
| 8304 |
this.canvasWidth = THUMBNAIL_WIDTH; |
| 8305 |
this.canvasHeight = this.canvasWidth / this.pageRatio | 0; |
| 8306 |
this.scale = this.canvasWidth / this.pageWidth; |
| 8307 |
this.l10n = l10n; |
| 8308 |
var anchor = document.createElement('a'); |
| 8309 |
anchor.href = linkService.getAnchorUrl('#page=' + id); |
| 8310 |
this.l10n.get('thumb_page_title', { page: id }, 'Page {{page}}').then(function (msg) { |
| 8311 |
anchor.title = msg; |
| 8312 |
}); |
| 8313 |
anchor.onclick = function () { |
| 8314 |
linkService.page = id; |
| 8315 |
return false; |
| 8316 |
}; |
| 8317 |
this.anchor = anchor; |
| 8318 |
var div = document.createElement('div'); |
| 8319 |
div.className = 'thumbnail'; |
| 8320 |
div.setAttribute('data-page-number', this.id); |
| 8321 |
this.div = div; |
| 8322 |
var ring = document.createElement('div'); |
| 8323 |
ring.className = 'thumbnailSelectionRing'; |
| 8324 |
var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH; |
| 8325 |
ring.style.width = this.canvasWidth + borderAdjustment + 'px'; |
| 8326 |
ring.style.height = this.canvasHeight + borderAdjustment + 'px'; |
| 8327 |
this.ring = ring; |
| 8328 |
div.appendChild(ring); |
| 8329 |
anchor.appendChild(div); |
| 8330 |
container.appendChild(anchor); |
| 8331 |
} |
| 8332 |
|
| 8333 |
_createClass(PDFThumbnailView, [{ |
| 8334 |
key: 'setPdfPage', |
| 8335 |
value: function setPdfPage(pdfPage) { |
| 8336 |
this.pdfPage = pdfPage; |
| 8337 |
this.pdfPageRotate = pdfPage.rotate; |
| 8338 |
var totalRotation = (this.rotation + this.pdfPageRotate) % 360; |
| 8339 |
this.viewport = pdfPage.getViewport(1, totalRotation); |
| 8340 |
this.reset(); |
| 8341 |
} |
| 8342 |
}, { |
| 8343 |
key: 'reset', |
| 8344 |
value: function reset() { |
| 8345 |
this.cancelRendering(); |
| 8346 |
this.pageWidth = this.viewport.width; |
| 8347 |
this.pageHeight = this.viewport.height; |
| 8348 |
this.pageRatio = this.pageWidth / this.pageHeight; |
| 8349 |
this.canvasHeight = this.canvasWidth / this.pageRatio | 0; |
| 8350 |
this.scale = this.canvasWidth / this.pageWidth; |
| 8351 |
this.div.removeAttribute('data-loaded'); |
| 8352 |
var ring = this.ring; |
| 8353 |
var childNodes = ring.childNodes; |
| 8354 |
for (var i = childNodes.length - 1; i >= 0; i--) { |
| 8355 |
ring.removeChild(childNodes[i]); |
| 8356 |
} |
| 8357 |
var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH; |
| 8358 |
ring.style.width = this.canvasWidth + borderAdjustment + 'px'; |
| 8359 |
ring.style.height = this.canvasHeight + borderAdjustment + 'px'; |
| 8360 |
if (this.canvas) { |
| 8361 |
this.canvas.width = 0; |
| 8362 |
this.canvas.height = 0; |
| 8363 |
delete this.canvas; |
| 8364 |
} |
| 8365 |
if (this.image) { |
| 8366 |
this.image.removeAttribute('src'); |
| 8367 |
delete this.image; |
| 8368 |
} |
| 8369 |
} |
| 8370 |
}, { |
| 8371 |
key: 'update', |
| 8372 |
value: function update(rotation) { |
| 8373 |
if (typeof rotation !== 'undefined') { |
| 8374 |
this.rotation = rotation; |
| 8375 |
} |
| 8376 |
var totalRotation = (this.rotation + this.pdfPageRotate) % 360; |
| 8377 |
this.viewport = this.viewport.clone({ |
| 8378 |
scale: 1, |
| 8379 |
rotation: totalRotation |
| 8380 |
}); |
| 8381 |
this.reset(); |
| 8382 |
} |
| 8383 |
}, { |
| 8384 |
key: 'cancelRendering', |
| 8385 |
value: function cancelRendering() { |
| 8386 |
if (this.renderTask) { |
| 8387 |
this.renderTask.cancel(); |
| 8388 |
this.renderTask = null; |
| 8389 |
} |
| 8390 |
this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL; |
| 8391 |
this.resume = null; |
| 8392 |
} |
| 8393 |
}, { |
| 8394 |
key: '_getPageDrawContext', |
| 8395 |
value: function _getPageDrawContext() { |
| 8396 |
var noCtxScale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
| 8397 |
|
| 8398 |
var canvas = document.createElement('canvas'); |
| 8399 |
this.canvas = canvas; |
| 8400 |
canvas.mozOpaque = true; |
| 8401 |
var ctx = canvas.getContext('2d', { alpha: false }); |
| 8402 |
var outputScale = (0, _ui_utils.getOutputScale)(ctx); |
| 8403 |
canvas.width = this.canvasWidth * outputScale.sx | 0; |
| 8404 |
canvas.height = this.canvasHeight * outputScale.sy | 0; |
| 8405 |
canvas.style.width = this.canvasWidth + 'px'; |
| 8406 |
canvas.style.height = this.canvasHeight + 'px'; |
| 8407 |
if (!noCtxScale && outputScale.scaled) { |
| 8408 |
ctx.scale(outputScale.sx, outputScale.sy); |
| 8409 |
} |
| 8410 |
return ctx; |
| 8411 |
} |
| 8412 |
}, { |
| 8413 |
key: '_convertCanvasToImage', |
| 8414 |
value: function _convertCanvasToImage() { |
| 8415 |
var _this = this; |
| 8416 |
|
| 8417 |
if (!this.canvas) { |
| 8418 |
return; |
| 8419 |
} |
| 8420 |
if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) { |
| 8421 |
return; |
| 8422 |
} |
| 8423 |
var id = this.renderingId; |
| 8424 |
var className = 'thumbnailImage'; |
| 8425 |
if (this.disableCanvasToImageConversion) { |
| 8426 |
this.canvas.id = id; |
| 8427 |
this.canvas.className = className; |
| 8428 |
this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (msg) { |
| 8429 |
_this.canvas.setAttribute('aria-label', msg); |
| 8430 |
}); |
| 8431 |
this.div.setAttribute('data-loaded', true); |
| 8432 |
this.ring.appendChild(this.canvas); |
| 8433 |
return; |
| 8434 |
} |
| 8435 |
var image = document.createElement('img'); |
| 8436 |
image.id = id; |
| 8437 |
image.className = className; |
| 8438 |
this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (msg) { |
| 8439 |
image.setAttribute('aria-label', msg); |
| 8440 |
}); |
| 8441 |
image.style.width = this.canvasWidth + 'px'; |
| 8442 |
image.style.height = this.canvasHeight + 'px'; |
| 8443 |
image.src = this.canvas.toDataURL(); |
| 8444 |
this.image = image; |
| 8445 |
this.div.setAttribute('data-loaded', true); |
| 8446 |
this.ring.appendChild(image); |
| 8447 |
this.canvas.width = 0; |
| 8448 |
this.canvas.height = 0; |
| 8449 |
delete this.canvas; |
| 8450 |
} |
| 8451 |
}, { |
| 8452 |
key: 'draw', |
| 8453 |
value: function draw() { |
| 8454 |
var _this2 = this; |
| 8455 |
|
| 8456 |
if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) { |
| 8457 |
console.error('Must be in new state before drawing'); |
| 8458 |
return Promise.resolve(undefined); |
| 8459 |
} |
| 8460 |
this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING; |
| 8461 |
var renderCapability = (0, _pdfjsLib.createPromiseCapability)(); |
| 8462 |
var finishRenderTask = function finishRenderTask(error) { |
| 8463 |
if (renderTask === _this2.renderTask) { |
| 8464 |
_this2.renderTask = null; |
| 8465 |
} |
| 8466 |
if (error instanceof _pdfjsLib.RenderingCancelledException) { |
| 8467 |
renderCapability.resolve(undefined); |
| 8468 |
return; |
| 8469 |
} |
| 8470 |
_this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED; |
| 8471 |
_this2._convertCanvasToImage(); |
| 8472 |
if (!error) { |
| 8473 |
renderCapability.resolve(undefined); |
| 8474 |
} else { |
| 8475 |
renderCapability.reject(error); |
| 8476 |
} |
| 8477 |
}; |
| 8478 |
var ctx = this._getPageDrawContext(); |
| 8479 |
var drawViewport = this.viewport.clone({ scale: this.scale }); |
| 8480 |
var renderContinueCallback = function renderContinueCallback(cont) { |
| 8481 |
if (!_this2.renderingQueue.isHighestPriority(_this2)) { |
| 8482 |
_this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED; |
| 8483 |
_this2.resume = function () { |
| 8484 |
_this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING; |
| 8485 |
cont(); |
| 8486 |
}; |
| 8487 |
return; |
| 8488 |
} |
| 8489 |
cont(); |
| 8490 |
}; |
| 8491 |
var renderContext = { |
| 8492 |
canvasContext: ctx, |
| 8493 |
viewport: drawViewport |
| 8494 |
}; |
| 8495 |
var renderTask = this.renderTask = this.pdfPage.render(renderContext); |
| 8496 |
renderTask.onContinue = renderContinueCallback; |
| 8497 |
renderTask.promise.then(function () { |
| 8498 |
finishRenderTask(null); |
| 8499 |
}, function (error) { |
| 8500 |
finishRenderTask(error); |
| 8501 |
}); |
| 8502 |
return renderCapability.promise; |
| 8503 |
} |
| 8504 |
}, { |
| 8505 |
key: 'setImage', |
| 8506 |
value: function setImage(pageView) { |
| 8507 |
if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) { |
| 8508 |
return; |
| 8509 |
} |
| 8510 |
var img = pageView.canvas; |
| 8511 |
if (!img) { |
| 8512 |
return; |
| 8513 |
} |
| 8514 |
if (!this.pdfPage) { |
| 8515 |
this.setPdfPage(pageView.pdfPage); |
| 8516 |
} |
| 8517 |
this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED; |
| 8518 |
var ctx = this._getPageDrawContext(true); |
| 8519 |
var canvas = ctx.canvas; |
| 8520 |
if (img.width <= 2 * canvas.width) { |
| 8521 |
ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height); |
| 8522 |
this._convertCanvasToImage(); |
| 8523 |
return; |
| 8524 |
} |
| 8525 |
var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS; |
| 8526 |
var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS; |
| 8527 |
var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight); |
| 8528 |
var reducedImageCtx = reducedImage.getContext('2d'); |
| 8529 |
while (reducedWidth > img.width || reducedHeight > img.height) { |
| 8530 |
reducedWidth >>= 1; |
| 8531 |
reducedHeight >>= 1; |
| 8532 |
} |
| 8533 |
reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight); |
| 8534 |
while (reducedWidth > 2 * canvas.width) { |
| 8535 |
reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1); |
| 8536 |
reducedWidth >>= 1; |
| 8537 |
reducedHeight >>= 1; |
| 8538 |
} |
| 8539 |
ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height); |
| 8540 |
this._convertCanvasToImage(); |
| 8541 |
} |
| 8542 |
}, { |
| 8543 |
key: 'setPageLabel', |
| 8544 |
value: function setPageLabel(label) { |
| 8545 |
var _this3 = this; |
| 8546 |
|
| 8547 |
this.pageLabel = typeof label === 'string' ? label : null; |
| 8548 |
this.l10n.get('thumb_page_title', { page: this.pageId }, 'Page {{page}}').then(function (msg) { |
| 8549 |
_this3.anchor.title = msg; |
| 8550 |
}); |
| 8551 |
if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) { |
| 8552 |
return; |
| 8553 |
} |
| 8554 |
this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (ariaLabel) { |
| 8555 |
if (_this3.image) { |
| 8556 |
_this3.image.setAttribute('aria-label', ariaLabel); |
| 8557 |
} else if (_this3.disableCanvasToImageConversion && _this3.canvas) { |
| 8558 |
_this3.canvas.setAttribute('aria-label', ariaLabel); |
| 8559 |
} |
| 8560 |
}); |
| 8561 |
} |
| 8562 |
}, { |
| 8563 |
key: 'pageId', |
| 8564 |
get: function get() { |
| 8565 |
return this.pageLabel !== null ? this.pageLabel : this.id; |
| 8566 |
} |
| 8567 |
}], [{ |
| 8568 |
key: 'cleanup', |
| 8569 |
value: function cleanup() { |
| 8570 |
TempImageFactory.destroyCanvas(); |
| 8571 |
} |
| 8572 |
}]); |
| 8573 |
|
| 8574 |
return PDFThumbnailView; |
| 8575 |
}(); |
| 8576 |
|
| 8577 |
exports.PDFThumbnailView = PDFThumbnailView; |
| 8578 |
|
| 8579 |
/***/ }), |
| 8580 |
/* 29 */ |
| 8581 |
/***/ (function(module, exports, __webpack_require__) { |
| 8582 |
|
| 8583 |
"use strict"; |
| 8584 |
|
| 8585 |
|
| 8586 |
Object.defineProperty(exports, "__esModule", { |
| 8587 |
value: true |
| 8588 |
}); |
| 8589 |
exports.PDFViewer = undefined; |
| 8590 |
|
| 8591 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 8592 |
|
| 8593 |
var _base_viewer = __webpack_require__(30); |
| 8594 |
|
| 8595 |
var _ui_utils = __webpack_require__(6); |
| 8596 |
|
| 8597 |
var _pdfjsLib = __webpack_require__(7); |
| 8598 |
|
| 8599 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 8600 |
|
| 8601 |
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } |
| 8602 |
|
| 8603 |
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
| 8604 |
|
| 8605 |
var PDFViewer = function (_BaseViewer) { |
| 8606 |
_inherits(PDFViewer, _BaseViewer); |
| 8607 |
|
| 8608 |
function PDFViewer() { |
| 8609 |
_classCallCheck(this, PDFViewer); |
| 8610 |
|
| 8611 |
return _possibleConstructorReturn(this, (PDFViewer.__proto__ || Object.getPrototypeOf(PDFViewer)).apply(this, arguments)); |
| 8612 |
} |
| 8613 |
|
| 8614 |
_createClass(PDFViewer, [{ |
| 8615 |
key: '_scrollIntoView', |
| 8616 |
value: function _scrollIntoView(_ref) { |
| 8617 |
var pageDiv = _ref.pageDiv, |
| 8618 |
_ref$pageSpot = _ref.pageSpot, |
| 8619 |
pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot; |
| 8620 |
|
| 8621 |
if (!pageSpot && !this.isInPresentationMode) { |
| 8622 |
var left = pageDiv.offsetLeft + pageDiv.clientLeft; |
| 8623 |
var right = left + pageDiv.clientWidth; |
| 8624 |
var _container = this.container, |
| 8625 |
scrollLeft = _container.scrollLeft, |
| 8626 |
clientWidth = _container.clientWidth; |
| 8627 |
|
| 8628 |
if (this._scrollMode === _base_viewer.ScrollMode.HORIZONTAL || left < scrollLeft || right > scrollLeft + clientWidth) { |
| 8629 |
pageSpot = { |
| 8630 |
left: 0, |
| 8631 |
top: 0 |
| 8632 |
}; |
| 8633 |
} |
| 8634 |
} |
| 8635 |
(0, _ui_utils.scrollIntoView)(pageDiv, pageSpot); |
| 8636 |
} |
| 8637 |
}, { |
| 8638 |
key: '_getVisiblePages', |
| 8639 |
value: function _getVisiblePages() { |
| 8640 |
if (!this.isInPresentationMode) { |
| 8641 |
return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true, this._scrollMode === _base_viewer.ScrollMode.HORIZONTAL); |
| 8642 |
} |
| 8643 |
var currentPage = this._pages[this._currentPageNumber - 1]; |
| 8644 |
var visible = [{ |
| 8645 |
id: currentPage.id, |
| 8646 |
view: currentPage |
| 8647 |
}]; |
| 8648 |
return { |
| 8649 |
first: currentPage, |
| 8650 |
last: currentPage, |
| 8651 |
views: visible |
| 8652 |
}; |
| 8653 |
} |
| 8654 |
}, { |
| 8655 |
key: 'update', |
| 8656 |
value: function update() { |
| 8657 |
var visible = this._getVisiblePages(); |
| 8658 |
var visiblePages = visible.views, |
| 8659 |
numVisiblePages = visiblePages.length; |
| 8660 |
if (numVisiblePages === 0) { |
| 8661 |
return; |
| 8662 |
} |
| 8663 |
this._resizeBuffer(numVisiblePages, visiblePages); |
| 8664 |
this.renderingQueue.renderHighestPriority(visible); |
| 8665 |
var currentId = this._currentPageNumber; |
| 8666 |
var stillFullyVisible = false; |
| 8667 |
for (var i = 0; i < numVisiblePages; ++i) { |
| 8668 |
var page = visiblePages[i]; |
| 8669 |
if (page.percent < 100) { |
| 8670 |
break; |
| 8671 |
} |
| 8672 |
if (page.id === currentId) { |
| 8673 |
stillFullyVisible = true; |
| 8674 |
break; |
| 8675 |
} |
| 8676 |
} |
| 8677 |
if (!stillFullyVisible) { |
| 8678 |
currentId = visiblePages[0].id; |
| 8679 |
} |
| 8680 |
if (!this.isInPresentationMode) { |
| 8681 |
this._setCurrentPageNumber(currentId); |
| 8682 |
} |
| 8683 |
this._updateLocation(visible.first); |
| 8684 |
this.eventBus.dispatch('updateviewarea', { |
| 8685 |
source: this, |
| 8686 |
location: this._location |
| 8687 |
}); |
| 8688 |
} |
| 8689 |
}, { |
| 8690 |
key: '_setDocumentViewerElement', |
| 8691 |
get: function get() { |
| 8692 |
return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this.viewer); |
| 8693 |
} |
| 8694 |
}, { |
| 8695 |
key: '_isScrollModeHorizontal', |
| 8696 |
get: function get() { |
| 8697 |
return this.isInPresentationMode ? false : this._scrollMode === _base_viewer.ScrollMode.HORIZONTAL; |
| 8698 |
} |
| 8699 |
}]); |
| 8700 |
|
| 8701 |
return PDFViewer; |
| 8702 |
}(_base_viewer.BaseViewer); |
| 8703 |
|
| 8704 |
exports.PDFViewer = PDFViewer; |
| 8705 |
|
| 8706 |
/***/ }), |
| 8707 |
/* 30 */ |
| 8708 |
/***/ (function(module, exports, __webpack_require__) { |
| 8709 |
|
| 8710 |
"use strict"; |
| 8711 |
|
| 8712 |
|
| 8713 |
Object.defineProperty(exports, "__esModule", { |
| 8714 |
value: true |
| 8715 |
}); |
| 8716 |
exports.SpreadMode = exports.ScrollMode = exports.BaseViewer = undefined; |
| 8717 |
|
| 8718 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 8719 |
|
| 8720 |
var _ui_utils = __webpack_require__(6); |
| 8721 |
|
| 8722 |
var _pdf_rendering_queue = __webpack_require__(10); |
| 8723 |
|
| 8724 |
var _annotation_layer_builder = __webpack_require__(31); |
| 8725 |
|
| 8726 |
var _pdfjsLib = __webpack_require__(7); |
| 8727 |
|
| 8728 |
var _dom_events = __webpack_require__(14); |
| 8729 |
|
| 8730 |
var _pdf_page_view = __webpack_require__(32); |
| 8731 |
|
| 8732 |
var _pdf_link_service = __webpack_require__(23); |
| 8733 |
|
| 8734 |
var _text_layer_builder = __webpack_require__(33); |
| 8735 |
|
| 8736 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 8737 |
|
| 8738 |
var DEFAULT_CACHE_SIZE = 10; |
| 8739 |
var ScrollMode = { |
| 8740 |
VERTICAL: 0, |
| 8741 |
HORIZONTAL: 1, |
| 8742 |
WRAPPED: 2 |
| 8743 |
}; |
| 8744 |
var SpreadMode = { |
| 8745 |
NONE: 0, |
| 8746 |
ODD: 1, |
| 8747 |
EVEN: 2 |
| 8748 |
}; |
| 8749 |
function PDFPageViewBuffer(size) { |
| 8750 |
var data = []; |
| 8751 |
this.push = function (view) { |
| 8752 |
var i = data.indexOf(view); |
| 8753 |
if (i >= 0) { |
| 8754 |
data.splice(i, 1); |
| 8755 |
} |
| 8756 |
data.push(view); |
| 8757 |
if (data.length > size) { |
| 8758 |
data.shift().destroy(); |
| 8759 |
} |
| 8760 |
}; |
| 8761 |
this.resize = function (newSize, pagesToKeep) { |
| 8762 |
size = newSize; |
| 8763 |
if (pagesToKeep) { |
| 8764 |
var pageIdsToKeep = new Set(); |
| 8765 |
for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) { |
| 8766 |
pageIdsToKeep.add(pagesToKeep[i].id); |
| 8767 |
} |
| 8768 |
(0, _ui_utils.moveToEndOfArray)(data, function (page) { |
| 8769 |
return pageIdsToKeep.has(page.id); |
| 8770 |
}); |
| 8771 |
} |
| 8772 |
while (data.length > size) { |
| 8773 |
data.shift().destroy(); |
| 8774 |
} |
| 8775 |
}; |
| 8776 |
} |
| 8777 |
function isSameScale(oldScale, newScale) { |
| 8778 |
if (newScale === oldScale) { |
| 8779 |
return true; |
| 8780 |
} |
| 8781 |
if (Math.abs(newScale - oldScale) < 1e-15) { |
| 8782 |
return true; |
| 8783 |
} |
| 8784 |
return false; |
| 8785 |
} |
| 8786 |
|
| 8787 |
var BaseViewer = function () { |
| 8788 |
function BaseViewer(options) { |
| 8789 |
var _this = this; |
| 8790 |
|
| 8791 |
_classCallCheck(this, BaseViewer); |
| 8792 |
|
| 8793 |
if (this.constructor === BaseViewer) { |
| 8794 |
throw new Error('Cannot initialize BaseViewer.'); |
| 8795 |
} |
| 8796 |
this._name = this.constructor.name; |
| 8797 |
this.container = options.container; |
| 8798 |
this.viewer = options.viewer || options.container.firstElementChild; |
| 8799 |
this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)(); |
| 8800 |
this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService(); |
| 8801 |
this.downloadManager = options.downloadManager || null; |
| 8802 |
this.findController = options.findController || null; |
| 8803 |
this.removePageBorders = options.removePageBorders || false; |
| 8804 |
this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE; |
| 8805 |
this.imageResourcesPath = options.imageResourcesPath || ''; |
| 8806 |
this.renderInteractiveForms = options.renderInteractiveForms || false; |
| 8807 |
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false; |
| 8808 |
this.renderer = options.renderer || _ui_utils.RendererType.CANVAS; |
| 8809 |
this.enableWebGL = options.enableWebGL || false; |
| 8810 |
this.useOnlyCssZoom = options.useOnlyCssZoom || false; |
| 8811 |
this.maxCanvasPixels = options.maxCanvasPixels; |
| 8812 |
this.l10n = options.l10n || _ui_utils.NullL10n; |
| 8813 |
this.defaultRenderingQueue = !options.renderingQueue; |
| 8814 |
if (this.defaultRenderingQueue) { |
| 8815 |
this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue(); |
| 8816 |
this.renderingQueue.setViewer(this); |
| 8817 |
} else { |
| 8818 |
this.renderingQueue = options.renderingQueue; |
| 8819 |
} |
| 8820 |
this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this)); |
| 8821 |
this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN; |
| 8822 |
this._resetView(); |
| 8823 |
if (this.removePageBorders) { |
| 8824 |
this.viewer.classList.add('removePageBorders'); |
| 8825 |
} |
| 8826 |
Promise.resolve().then(function () { |
| 8827 |
_this.eventBus.dispatch('baseviewerinit', { source: _this }); |
| 8828 |
}); |
| 8829 |
} |
| 8830 |
|
| 8831 |
_createClass(BaseViewer, [{ |
| 8832 |
key: 'getPageView', |
| 8833 |
value: function getPageView(index) { |
| 8834 |
return this._pages[index]; |
| 8835 |
} |
| 8836 |
}, { |
| 8837 |
key: '_setCurrentPageNumber', |
| 8838 |
value: function _setCurrentPageNumber(val) { |
| 8839 |
var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; |
| 8840 |
|
| 8841 |
if (this._currentPageNumber === val) { |
| 8842 |
if (resetCurrentPageView) { |
| 8843 |
this._resetCurrentPageView(); |
| 8844 |
} |
| 8845 |
return; |
| 8846 |
} |
| 8847 |
if (!(0 < val && val <= this.pagesCount)) { |
| 8848 |
console.error(this._name + '._setCurrentPageNumber: "' + val + '" is out of bounds.'); |
| 8849 |
return; |
| 8850 |
} |
| 8851 |
var arg = { |
| 8852 |
source: this, |
| 8853 |
pageNumber: val, |
| 8854 |
pageLabel: this._pageLabels && this._pageLabels[val - 1] |
| 8855 |
}; |
| 8856 |
this._currentPageNumber = val; |
| 8857 |
this.eventBus.dispatch('pagechanging', arg); |
| 8858 |
this.eventBus.dispatch('pagechange', arg); |
| 8859 |
if (resetCurrentPageView) { |
| 8860 |
this._resetCurrentPageView(); |
| 8861 |
} |
| 8862 |
} |
| 8863 |
}, { |
| 8864 |
key: 'setDocument', |
| 8865 |
value: function setDocument(pdfDocument) { |
| 8866 |
var _this2 = this; |
| 8867 |
|
| 8868 |
if (this.pdfDocument) { |
| 8869 |
this._cancelRendering(); |
| 8870 |
this._resetView(); |
| 8871 |
if (this.findController) { |
| 8872 |
this.findController.setDocument(null); |
| 8873 |
} |
| 8874 |
} |
| 8875 |
this.pdfDocument = pdfDocument; |
| 8876 |
if (!pdfDocument) { |
| 8877 |
return; |
| 8878 |
} |
| 8879 |
var pagesCount = pdfDocument.numPages; |
| 8880 |
var pagesCapability = (0, _pdfjsLib.createPromiseCapability)(); |
| 8881 |
this.pagesPromise = pagesCapability.promise; |
| 8882 |
pagesCapability.promise.then(function () { |
| 8883 |
_this2._pageViewsReady = true; |
| 8884 |
_this2.eventBus.dispatch('pagesloaded', { |
| 8885 |
source: _this2, |
| 8886 |
pagesCount: pagesCount |
| 8887 |
}); |
| 8888 |
}); |
| 8889 |
var isOnePageRenderedResolved = false; |
| 8890 |
var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)(); |
| 8891 |
this.onePageRendered = onePageRenderedCapability.promise; |
| 8892 |
var bindOnAfterAndBeforeDraw = function bindOnAfterAndBeforeDraw(pageView) { |
| 8893 |
pageView.onBeforeDraw = function () { |
| 8894 |
_this2._buffer.push(pageView); |
| 8895 |
}; |
| 8896 |
pageView.onAfterDraw = function () { |
| 8897 |
if (!isOnePageRenderedResolved) { |
| 8898 |
isOnePageRenderedResolved = true; |
| 8899 |
onePageRenderedCapability.resolve(); |
| 8900 |
} |
| 8901 |
}; |
| 8902 |
}; |
| 8903 |
var firstPagePromise = pdfDocument.getPage(1); |
| 8904 |
this.firstPagePromise = firstPagePromise; |
| 8905 |
firstPagePromise.then(function (pdfPage) { |
| 8906 |
var scale = _this2.currentScale; |
| 8907 |
var viewport = pdfPage.getViewport(scale * _ui_utils.CSS_UNITS); |
| 8908 |
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) { |
| 8909 |
var textLayerFactory = null; |
| 8910 |
if (_this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE) { |
| 8911 |
textLayerFactory = _this2; |
| 8912 |
} |
| 8913 |
var pageView = new _pdf_page_view.PDFPageView({ |
| 8914 |
container: _this2._setDocumentViewerElement, |
| 8915 |
eventBus: _this2.eventBus, |
| 8916 |
id: pageNum, |
| 8917 |
scale: scale, |
| 8918 |
defaultViewport: viewport.clone(), |
| 8919 |
renderingQueue: _this2.renderingQueue, |
| 8920 |
textLayerFactory: textLayerFactory, |
| 8921 |
textLayerMode: _this2.textLayerMode, |
| 8922 |
annotationLayerFactory: _this2, |
| 8923 |
imageResourcesPath: _this2.imageResourcesPath, |
| 8924 |
renderInteractiveForms: _this2.renderInteractiveForms, |
| 8925 |
renderer: _this2.renderer, |
| 8926 |
enableWebGL: _this2.enableWebGL, |
| 8927 |
useOnlyCssZoom: _this2.useOnlyCssZoom, |
| 8928 |
maxCanvasPixels: _this2.maxCanvasPixels, |
| 8929 |
l10n: _this2.l10n |
| 8930 |
}); |
| 8931 |
bindOnAfterAndBeforeDraw(pageView); |
| 8932 |
_this2._pages.push(pageView); |
| 8933 |
} |
| 8934 |
if (_this2._spreadMode !== SpreadMode.NONE) { |
| 8935 |
_this2._updateSpreadMode(); |
| 8936 |
} |
| 8937 |
onePageRenderedCapability.promise.then(function () { |
| 8938 |
if (pdfDocument.loadingParams['disableAutoFetch']) { |
| 8939 |
pagesCapability.resolve(); |
| 8940 |
return; |
| 8941 |
} |
| 8942 |
var getPagesLeft = pagesCount; |
| 8943 |
|
| 8944 |
var _loop = function _loop(_pageNum) { |
| 8945 |
pdfDocument.getPage(_pageNum).then(function (pdfPage) { |
| 8946 |
var pageView = _this2._pages[_pageNum - 1]; |
| 8947 |
if (!pageView.pdfPage) { |
| 8948 |
pageView.setPdfPage(pdfPage); |
| 8949 |
} |
| 8950 |
_this2.linkService.cachePageRef(_pageNum, pdfPage.ref); |
| 8951 |
if (--getPagesLeft === 0) { |
| 8952 |
pagesCapability.resolve(); |
| 8953 |
} |
| 8954 |
}, function (reason) { |
| 8955 |
console.error('Unable to get page ' + _pageNum + ' to initialize viewer', reason); |
| 8956 |
if (--getPagesLeft === 0) { |
| 8957 |
pagesCapability.resolve(); |
| 8958 |
} |
| 8959 |
}); |
| 8960 |
}; |
| 8961 |
|
| 8962 |
for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) { |
| 8963 |
_loop(_pageNum); |
| 8964 |
} |
| 8965 |
}); |
| 8966 |
_this2.eventBus.dispatch('pagesinit', { source: _this2 }); |
| 8967 |
if (_this2.findController) { |
| 8968 |
_this2.findController.setDocument(pdfDocument); |
| 8969 |
} |
| 8970 |
if (_this2.defaultRenderingQueue) { |
| 8971 |
_this2.update(); |
| 8972 |
} |
| 8973 |
}).catch(function (reason) { |
| 8974 |
console.error('Unable to initialize viewer', reason); |
| 8975 |
}); |
| 8976 |
} |
| 8977 |
}, { |
| 8978 |
key: 'setPageLabels', |
| 8979 |
value: function setPageLabels(labels) { |
| 8980 |
if (!this.pdfDocument) { |
| 8981 |
return; |
| 8982 |
} |
| 8983 |
if (!labels) { |
| 8984 |
this._pageLabels = null; |
| 8985 |
} else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) { |
| 8986 |
this._pageLabels = null; |
| 8987 |
console.error(this._name + '.setPageLabels: Invalid page labels.'); |
| 8988 |
} else { |
| 8989 |
this._pageLabels = labels; |
| 8990 |
} |
| 8991 |
for (var i = 0, ii = this._pages.length; i < ii; i++) { |
| 8992 |
var pageView = this._pages[i]; |
| 8993 |
var label = this._pageLabels && this._pageLabels[i]; |
| 8994 |
pageView.setPageLabel(label); |
| 8995 |
} |
| 8996 |
} |
| 8997 |
}, { |
| 8998 |
key: '_resetView', |
| 8999 |
value: function _resetView() { |
| 9000 |
this._pages = []; |
| 9001 |
this._currentPageNumber = 1; |
| 9002 |
this._currentScale = _ui_utils.UNKNOWN_SCALE; |
| 9003 |
this._currentScaleValue = null; |
| 9004 |
this._pageLabels = null; |
| 9005 |
this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE); |
| 9006 |
this._location = null; |
| 9007 |
this._pagesRotation = 0; |
| 9008 |
this._pagesRequests = []; |
| 9009 |
this._pageViewsReady = false; |
| 9010 |
this._scrollMode = ScrollMode.VERTICAL; |
| 9011 |
this._spreadMode = SpreadMode.NONE; |
| 9012 |
this.viewer.textContent = ''; |
| 9013 |
this._updateScrollMode(); |
| 9014 |
} |
| 9015 |
}, { |
| 9016 |
key: '_scrollUpdate', |
| 9017 |
value: function _scrollUpdate() { |
| 9018 |
if (this.pagesCount === 0) { |
| 9019 |
return; |
| 9020 |
} |
| 9021 |
this.update(); |
| 9022 |
} |
| 9023 |
}, { |
| 9024 |
key: '_scrollIntoView', |
| 9025 |
value: function _scrollIntoView(_ref) { |
| 9026 |
var pageDiv = _ref.pageDiv, |
| 9027 |
_ref$pageSpot = _ref.pageSpot, |
| 9028 |
pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot, |
| 9029 |
_ref$pageNumber = _ref.pageNumber, |
| 9030 |
pageNumber = _ref$pageNumber === undefined ? null : _ref$pageNumber; |
| 9031 |
|
| 9032 |
throw new Error('Not implemented: _scrollIntoView'); |
| 9033 |
} |
| 9034 |
}, { |
| 9035 |
key: '_setScaleDispatchEvent', |
| 9036 |
value: function _setScaleDispatchEvent(newScale, newValue) { |
| 9037 |
var preset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; |
| 9038 |
|
| 9039 |
var arg = { |
| 9040 |
source: this, |
| 9041 |
scale: newScale, |
| 9042 |
presetValue: preset ? newValue : undefined |
| 9043 |
}; |
| 9044 |
this.eventBus.dispatch('scalechanging', arg); |
| 9045 |
this.eventBus.dispatch('scalechange', arg); |
| 9046 |
} |
| 9047 |
}, { |
| 9048 |
key: '_setScaleUpdatePages', |
| 9049 |
value: function _setScaleUpdatePages(newScale, newValue) { |
| 9050 |
var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; |
| 9051 |
var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; |
| 9052 |
|
| 9053 |
this._currentScaleValue = newValue.toString(); |
| 9054 |
if (isSameScale(this._currentScale, newScale)) { |
| 9055 |
if (preset) { |
| 9056 |
this._setScaleDispatchEvent(newScale, newValue, true); |
| 9057 |
} |
| 9058 |
return; |
| 9059 |
} |
| 9060 |
for (var i = 0, ii = this._pages.length; i < ii; i++) { |
| 9061 |
this._pages[i].update(newScale); |
| 9062 |
} |
| 9063 |
this._currentScale = newScale; |
| 9064 |
if (!noScroll) { |
| 9065 |
var page = this._currentPageNumber, |
| 9066 |
dest = void 0; |
| 9067 |
if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) { |
| 9068 |
page = this._location.pageNumber; |
| 9069 |
dest = [null, { name: 'XYZ' }, this._location.left, this._location.top, null]; |
| 9070 |
} |
| 9071 |
this.scrollPageIntoView({ |
| 9072 |
pageNumber: page, |
| 9073 |
destArray: dest, |
| 9074 |
allowNegativeOffset: true |
| 9075 |
}); |
| 9076 |
} |
| 9077 |
this._setScaleDispatchEvent(newScale, newValue, preset); |
| 9078 |
if (this.defaultRenderingQueue) { |
| 9079 |
this.update(); |
| 9080 |
} |
| 9081 |
} |
| 9082 |
}, { |
| 9083 |
key: '_setScale', |
| 9084 |
value: function _setScale(value) { |
| 9085 |
var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; |
| 9086 |
|
| 9087 |
var scale = parseFloat(value); |
| 9088 |
if (scale > 0) { |
| 9089 |
this._setScaleUpdatePages(scale, value, noScroll, false); |
| 9090 |
} else { |
| 9091 |
var currentPage = this._pages[this._currentPageNumber - 1]; |
| 9092 |
if (!currentPage) { |
| 9093 |
return; |
| 9094 |
} |
| 9095 |
var noPadding = this.isInPresentationMode || this.removePageBorders; |
| 9096 |
var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING; |
| 9097 |
var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING; |
| 9098 |
if (!noPadding && this._isScrollModeHorizontal) { |
| 9099 |
var _ref2 = [vPadding, hPadding]; |
| 9100 |
hPadding = _ref2[0]; |
| 9101 |
vPadding = _ref2[1]; |
| 9102 |
} |
| 9103 |
var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale; |
| 9104 |
var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale; |
| 9105 |
switch (value) { |
| 9106 |
case 'page-actual': |
| 9107 |
scale = 1; |
| 9108 |
break; |
| 9109 |
case 'page-width': |
| 9110 |
scale = pageWidthScale; |
| 9111 |
break; |
| 9112 |
case 'page-height': |
| 9113 |
scale = pageHeightScale; |
| 9114 |
break; |
| 9115 |
case 'page-fit': |
| 9116 |
scale = Math.min(pageWidthScale, pageHeightScale); |
| 9117 |
break; |
| 9118 |
case 'auto': |
| 9119 |
var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale); |
| 9120 |
scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale); |
| 9121 |
break; |
| 9122 |
default: |
| 9123 |
console.error(this._name + '._setScale: "' + value + '" is an unknown zoom value.'); |
| 9124 |
return; |
| 9125 |
} |
| 9126 |
this._setScaleUpdatePages(scale, value, noScroll, true); |
| 9127 |
} |
| 9128 |
} |
| 9129 |
}, { |
| 9130 |
key: '_resetCurrentPageView', |
| 9131 |
value: function _resetCurrentPageView() { |
| 9132 |
if (this.isInPresentationMode) { |
| 9133 |
this._setScale(this._currentScaleValue, true); |
| 9134 |
} |
| 9135 |
var pageView = this._pages[this._currentPageNumber - 1]; |
| 9136 |
this._scrollIntoView({ pageDiv: pageView.div }); |
| 9137 |
} |
| 9138 |
}, { |
| 9139 |
key: 'scrollPageIntoView', |
| 9140 |
value: function scrollPageIntoView(params) { |
| 9141 |
if (!this.pdfDocument) { |
| 9142 |
return; |
| 9143 |
} |
| 9144 |
var pageNumber = params.pageNumber || 0; |
| 9145 |
var dest = params.destArray || null; |
| 9146 |
var allowNegativeOffset = params.allowNegativeOffset || false; |
| 9147 |
if (this.isInPresentationMode || !dest) { |
| 9148 |
this._setCurrentPageNumber(pageNumber, true); |
| 9149 |
return; |
| 9150 |
} |
| 9151 |
var pageView = this._pages[pageNumber - 1]; |
| 9152 |
if (!pageView) { |
| 9153 |
console.error(this._name + '.scrollPageIntoView: Invalid "pageNumber" parameter.'); |
| 9154 |
return; |
| 9155 |
} |
| 9156 |
var x = 0, |
| 9157 |
y = 0; |
| 9158 |
var width = 0, |
| 9159 |
height = 0, |
| 9160 |
widthScale = void 0, |
| 9161 |
heightScale = void 0; |
| 9162 |
var changeOrientation = pageView.rotation % 180 === 0 ? false : true; |
| 9163 |
var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS; |
| 9164 |
var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS; |
| 9165 |
var scale = 0; |
| 9166 |
switch (dest[1].name) { |
| 9167 |
case 'XYZ': |
| 9168 |
x = dest[2]; |
| 9169 |
y = dest[3]; |
| 9170 |
scale = dest[4]; |
| 9171 |
x = x !== null ? x : 0; |
| 9172 |
y = y !== null ? y : pageHeight; |
| 9173 |
break; |
| 9174 |
case 'Fit': |
| 9175 |
case 'FitB': |
| 9176 |
scale = 'page-fit'; |
| 9177 |
break; |
| 9178 |
case 'FitH': |
| 9179 |
case 'FitBH': |
| 9180 |
y = dest[2]; |
| 9181 |
scale = 'page-width'; |
| 9182 |
if (y === null && this._location) { |
| 9183 |
x = this._location.left; |
| 9184 |
y = this._location.top; |
| 9185 |
} |
| 9186 |
break; |
| 9187 |
case 'FitV': |
| 9188 |
case 'FitBV': |
| 9189 |
x = dest[2]; |
| 9190 |
width = pageWidth; |
| 9191 |
height = pageHeight; |
| 9192 |
scale = 'page-height'; |
| 9193 |
break; |
| 9194 |
case 'FitR': |
| 9195 |
x = dest[2]; |
| 9196 |
y = dest[3]; |
| 9197 |
width = dest[4] - x; |
| 9198 |
height = dest[5] - y; |
| 9199 |
var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING; |
| 9200 |
var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING; |
| 9201 |
widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS; |
| 9202 |
heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS; |
| 9203 |
scale = Math.min(Math.abs(widthScale), Math.abs(heightScale)); |
| 9204 |
break; |
| 9205 |
default: |
| 9206 |
console.error(this._name + '.scrollPageIntoView: "' + dest[1].name + '" ' + 'is not a valid destination type.'); |
| 9207 |
return; |
| 9208 |
} |
| 9209 |
if (scale && scale !== this._currentScale) { |
| 9210 |
this.currentScaleValue = scale; |
| 9211 |
} else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) { |
| 9212 |
this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE; |
| 9213 |
} |
| 9214 |
if (scale === 'page-fit' && !dest[4]) { |
| 9215 |
this._scrollIntoView({ |
| 9216 |
pageDiv: pageView.div, |
| 9217 |
pageNumber: pageNumber |
| 9218 |
}); |
| 9219 |
return; |
| 9220 |
} |
| 9221 |
var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)]; |
| 9222 |
var left = Math.min(boundingRect[0][0], boundingRect[1][0]); |
| 9223 |
var top = Math.min(boundingRect[0][1], boundingRect[1][1]); |
| 9224 |
if (!allowNegativeOffset) { |
| 9225 |
left = Math.max(left, 0); |
| 9226 |
top = Math.max(top, 0); |
| 9227 |
} |
| 9228 |
this._scrollIntoView({ |
| 9229 |
pageDiv: pageView.div, |
| 9230 |
pageSpot: { |
| 9231 |
left: left, |
| 9232 |
top: top |
| 9233 |
}, |
| 9234 |
pageNumber: pageNumber |
| 9235 |
}); |
| 9236 |
} |
| 9237 |
}, { |
| 9238 |
key: '_resizeBuffer', |
| 9239 |
value: function _resizeBuffer(numVisiblePages, visiblePages) { |
| 9240 |
var suggestedCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1); |
| 9241 |
this._buffer.resize(suggestedCacheSize, visiblePages); |
| 9242 |
} |
| 9243 |
}, { |
| 9244 |
key: '_updateLocation', |
| 9245 |
value: function _updateLocation(firstPage) { |
| 9246 |
var currentScale = this._currentScale; |
| 9247 |
var currentScaleValue = this._currentScaleValue; |
| 9248 |
var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue; |
| 9249 |
var pageNumber = firstPage.id; |
| 9250 |
var pdfOpenParams = '#page=' + pageNumber; |
| 9251 |
pdfOpenParams += '&zoom=' + normalizedScaleValue; |
| 9252 |
var currentPageView = this._pages[pageNumber - 1]; |
| 9253 |
var container = this.container; |
| 9254 |
var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y); |
| 9255 |
var intLeft = Math.round(topLeft[0]); |
| 9256 |
var intTop = Math.round(topLeft[1]); |
| 9257 |
pdfOpenParams += ',' + intLeft + ',' + intTop; |
| 9258 |
this._location = { |
| 9259 |
pageNumber: pageNumber, |
| 9260 |
scale: normalizedScaleValue, |
| 9261 |
top: intTop, |
| 9262 |
left: intLeft, |
| 9263 |
rotation: this._pagesRotation, |
| 9264 |
pdfOpenParams: pdfOpenParams |
| 9265 |
}; |
| 9266 |
} |
| 9267 |
}, { |
| 9268 |
key: 'update', |
| 9269 |
value: function update() { |
| 9270 |
throw new Error('Not implemented: update'); |
| 9271 |
} |
| 9272 |
}, { |
| 9273 |
key: 'containsElement', |
| 9274 |
value: function containsElement(element) { |
| 9275 |
return this.container.contains(element); |
| 9276 |
} |
| 9277 |
}, { |
| 9278 |
key: 'focus', |
| 9279 |
value: function focus() { |
| 9280 |
this.container.focus(); |
| 9281 |
} |
| 9282 |
}, { |
| 9283 |
key: '_getVisiblePages', |
| 9284 |
value: function _getVisiblePages() { |
| 9285 |
throw new Error('Not implemented: _getVisiblePages'); |
| 9286 |
} |
| 9287 |
}, { |
| 9288 |
key: 'cleanup', |
| 9289 |
value: function cleanup() { |
| 9290 |
for (var i = 0, ii = this._pages.length; i < ii; i++) { |
| 9291 |
if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) { |
| 9292 |
this._pages[i].reset(); |
| 9293 |
} |
| 9294 |
} |
| 9295 |
} |
| 9296 |
}, { |
| 9297 |
key: '_cancelRendering', |
| 9298 |
value: function _cancelRendering() { |
| 9299 |
for (var i = 0, ii = this._pages.length; i < ii; i++) { |
| 9300 |
if (this._pages[i]) { |
| 9301 |
this._pages[i].cancelRendering(); |
| 9302 |
} |
| 9303 |
} |
| 9304 |
} |
| 9305 |
}, { |
| 9306 |
key: '_ensurePdfPageLoaded', |
| 9307 |
value: function _ensurePdfPageLoaded(pageView) { |
| 9308 |
var _this3 = this; |
| 9309 |
|
| 9310 |
if (pageView.pdfPage) { |
| 9311 |
return Promise.resolve(pageView.pdfPage); |
| 9312 |
} |
| 9313 |
var pageNumber = pageView.id; |
| 9314 |
if (this._pagesRequests[pageNumber]) { |
| 9315 |
return this._pagesRequests[pageNumber]; |
| 9316 |
} |
| 9317 |
var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) { |
| 9318 |
if (!pageView.pdfPage) { |
| 9319 |
pageView.setPdfPage(pdfPage); |
| 9320 |
} |
| 9321 |
_this3._pagesRequests[pageNumber] = null; |
| 9322 |
return pdfPage; |
| 9323 |
}).catch(function (reason) { |
| 9324 |
console.error('Unable to get page for page view', reason); |
| 9325 |
_this3._pagesRequests[pageNumber] = null; |
| 9326 |
}); |
| 9327 |
this._pagesRequests[pageNumber] = promise; |
| 9328 |
return promise; |
| 9329 |
} |
| 9330 |
}, { |
| 9331 |
key: 'forceRendering', |
| 9332 |
value: function forceRendering(currentlyVisiblePages) { |
| 9333 |
var _this4 = this; |
| 9334 |
|
| 9335 |
var visiblePages = currentlyVisiblePages || this._getVisiblePages(); |
| 9336 |
var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down; |
| 9337 |
var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead); |
| 9338 |
if (pageView) { |
| 9339 |
this._ensurePdfPageLoaded(pageView).then(function () { |
| 9340 |
_this4.renderingQueue.renderView(pageView); |
| 9341 |
}); |
| 9342 |
return true; |
| 9343 |
} |
| 9344 |
return false; |
| 9345 |
} |
| 9346 |
}, { |
| 9347 |
key: 'createTextLayerBuilder', |
| 9348 |
value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) { |
| 9349 |
var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; |
| 9350 |
|
| 9351 |
return new _text_layer_builder.TextLayerBuilder({ |
| 9352 |
textLayerDiv: textLayerDiv, |
| 9353 |
eventBus: this.eventBus, |
| 9354 |
pageIndex: pageIndex, |
| 9355 |
viewport: viewport, |
| 9356 |
findController: this.isInPresentationMode ? null : this.findController, |
| 9357 |
enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection |
| 9358 |
}); |
| 9359 |
} |
| 9360 |
}, { |
| 9361 |
key: 'createAnnotationLayerBuilder', |
| 9362 |
value: function createAnnotationLayerBuilder(pageDiv, pdfPage) { |
| 9363 |
var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; |
| 9364 |
var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; |
| 9365 |
var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n; |
| 9366 |
|
| 9367 |
return new _annotation_layer_builder.AnnotationLayerBuilder({ |
| 9368 |
pageDiv: pageDiv, |
| 9369 |
pdfPage: pdfPage, |
| 9370 |
imageResourcesPath: imageResourcesPath, |
| 9371 |
renderInteractiveForms: renderInteractiveForms, |
| 9372 |
linkService: this.linkService, |
| 9373 |
downloadManager: this.downloadManager, |
| 9374 |
l10n: l10n |
| 9375 |
}); |
| 9376 |
} |
| 9377 |
}, { |
| 9378 |
key: 'getPagesOverview', |
| 9379 |
value: function getPagesOverview() { |
| 9380 |
var pagesOverview = this._pages.map(function (pageView) { |
| 9381 |
var viewport = pageView.pdfPage.getViewport(1); |
| 9382 |
return { |
| 9383 |
width: viewport.width, |
| 9384 |
height: viewport.height, |
| 9385 |
rotation: viewport.rotation |
| 9386 |
}; |
| 9387 |
}); |
| 9388 |
if (!this.enablePrintAutoRotate) { |
| 9389 |
return pagesOverview; |
| 9390 |
} |
| 9391 |
var isFirstPagePortrait = (0, _ui_utils.isPortraitOrientation)(pagesOverview[0]); |
| 9392 |
return pagesOverview.map(function (size) { |
| 9393 |
if (isFirstPagePortrait === (0, _ui_utils.isPortraitOrientation)(size)) { |
| 9394 |
return size; |
| 9395 |
} |
| 9396 |
return { |
| 9397 |
width: size.height, |
| 9398 |
height: size.width, |
| 9399 |
rotation: (size.rotation + 90) % 360 |
| 9400 |
}; |
| 9401 |
}); |
| 9402 |
} |
| 9403 |
}, { |
| 9404 |
key: '_updateScrollMode', |
| 9405 |
value: function _updateScrollMode() { |
| 9406 |
var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; |
| 9407 |
|
| 9408 |
var scrollMode = this._scrollMode, |
| 9409 |
viewer = this.viewer; |
| 9410 |
viewer.classList.toggle('scrollHorizontal', scrollMode === ScrollMode.HORIZONTAL); |
| 9411 |
viewer.classList.toggle('scrollWrapped', scrollMode === ScrollMode.WRAPPED); |
| 9412 |
if (!this.pdfDocument || !pageNumber) { |
| 9413 |
return; |
| 9414 |
} |
| 9415 |
if (this._currentScaleValue && isNaN(this._currentScaleValue)) { |
| 9416 |
this._setScale(this._currentScaleValue, true); |
| 9417 |
} |
| 9418 |
this.scrollPageIntoView({ pageNumber: pageNumber }); |
| 9419 |
this.update(); |
| 9420 |
} |
| 9421 |
}, { |
| 9422 |
key: '_updateSpreadMode', |
| 9423 |
value: function _updateSpreadMode() { |
| 9424 |
var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; |
| 9425 |
|
| 9426 |
if (!this.pdfDocument) { |
| 9427 |
return; |
| 9428 |
} |
| 9429 |
var viewer = this.viewer, |
| 9430 |
pages = this._pages; |
| 9431 |
viewer.textContent = ''; |
| 9432 |
if (this._spreadMode === SpreadMode.NONE) { |
| 9433 |
for (var i = 0, iMax = pages.length; i < iMax; ++i) { |
| 9434 |
viewer.appendChild(pages[i].div); |
| 9435 |
} |
| 9436 |
} else { |
| 9437 |
var parity = this._spreadMode - 1; |
| 9438 |
var spread = null; |
| 9439 |
for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) { |
| 9440 |
if (spread === null) { |
| 9441 |
spread = document.createElement('div'); |
| 9442 |
spread.className = 'spread'; |
| 9443 |
viewer.appendChild(spread); |
| 9444 |
} else if (_i % 2 === parity) { |
| 9445 |
spread = spread.cloneNode(false); |
| 9446 |
viewer.appendChild(spread); |
| 9447 |
} |
| 9448 |
spread.appendChild(pages[_i].div); |
| 9449 |
} |
| 9450 |
} |
| 9451 |
if (!pageNumber) { |
| 9452 |
return; |
| 9453 |
} |
| 9454 |
this.scrollPageIntoView({ pageNumber: pageNumber }); |
| 9455 |
this.update(); |
| 9456 |
} |
| 9457 |
}, { |
| 9458 |
key: 'pagesCount', |
| 9459 |
get: function get() { |
| 9460 |
return this._pages.length; |
| 9461 |
} |
| 9462 |
}, { |
| 9463 |
key: 'pageViewsReady', |
| 9464 |
get: function get() { |
| 9465 |
return this._pageViewsReady; |
| 9466 |
} |
| 9467 |
}, { |
| 9468 |
key: 'currentPageNumber', |
| 9469 |
get: function get() { |
| 9470 |
return this._currentPageNumber; |
| 9471 |
}, |
| 9472 |
set: function set(val) { |
| 9473 |
if (!Number.isInteger(val)) { |
| 9474 |
throw new Error('Invalid page number.'); |
| 9475 |
} |
| 9476 |
if (!this.pdfDocument) { |
| 9477 |
return; |
| 9478 |
} |
| 9479 |
this._setCurrentPageNumber(val, true); |
| 9480 |
} |
| 9481 |
}, { |
| 9482 |
key: 'currentPageLabel', |
| 9483 |
get: function get() { |
| 9484 |
return this._pageLabels && this._pageLabels[this._currentPageNumber - 1]; |
| 9485 |
}, |
| 9486 |
set: function set(val) { |
| 9487 |
var pageNumber = val | 0; |
| 9488 |
if (this._pageLabels) { |
| 9489 |
var i = this._pageLabels.indexOf(val); |
| 9490 |
if (i >= 0) { |
| 9491 |
pageNumber = i + 1; |
| 9492 |
} |
| 9493 |
} |
| 9494 |
this.currentPageNumber = pageNumber; |
| 9495 |
} |
| 9496 |
}, { |
| 9497 |
key: 'currentScale', |
| 9498 |
get: function get() { |
| 9499 |
return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE; |
| 9500 |
}, |
| 9501 |
set: function set(val) { |
| 9502 |
if (isNaN(val)) { |
| 9503 |
throw new Error('Invalid numeric scale'); |
| 9504 |
} |
| 9505 |
if (!this.pdfDocument) { |
| 9506 |
return; |
| 9507 |
} |
| 9508 |
this._setScale(val, false); |
| 9509 |
} |
| 9510 |
}, { |
| 9511 |
key: 'currentScaleValue', |
| 9512 |
get: function get() { |
| 9513 |
return this._currentScaleValue; |
| 9514 |
}, |
| 9515 |
set: function set(val) { |
| 9516 |
if (!this.pdfDocument) { |
| 9517 |
return; |
| 9518 |
} |
| 9519 |
this._setScale(val, false); |
| 9520 |
} |
| 9521 |
}, { |
| 9522 |
key: 'pagesRotation', |
| 9523 |
get: function get() { |
| 9524 |
return this._pagesRotation; |
| 9525 |
}, |
| 9526 |
set: function set(rotation) { |
| 9527 |
if (!(0, _ui_utils.isValidRotation)(rotation)) { |
| 9528 |
throw new Error('Invalid pages rotation angle.'); |
| 9529 |
} |
| 9530 |
if (!this.pdfDocument) { |
| 9531 |
return; |
| 9532 |
} |
| 9533 |
if (this._pagesRotation === rotation) { |
| 9534 |
return; |
| 9535 |
} |
| 9536 |
this._pagesRotation = rotation; |
| 9537 |
var pageNumber = this._currentPageNumber; |
| 9538 |
for (var i = 0, ii = this._pages.length; i < ii; i++) { |
| 9539 |
var pageView = this._pages[i]; |
| 9540 |
pageView.update(pageView.scale, rotation); |
| 9541 |
} |
| 9542 |
if (this._currentScaleValue) { |
| 9543 |
this._setScale(this._currentScaleValue, true); |
| 9544 |
} |
| 9545 |
this.eventBus.dispatch('rotationchanging', { |
| 9546 |
source: this, |
| 9547 |
pagesRotation: rotation, |
| 9548 |
pageNumber: pageNumber |
| 9549 |
}); |
| 9550 |
if (this.defaultRenderingQueue) { |
| 9551 |
this.update(); |
| 9552 |
} |
| 9553 |
} |
| 9554 |
}, { |
| 9555 |
key: '_setDocumentViewerElement', |
| 9556 |
get: function get() { |
| 9557 |
throw new Error('Not implemented: _setDocumentViewerElement'); |
| 9558 |
} |
| 9559 |
}, { |
| 9560 |
key: '_isScrollModeHorizontal', |
| 9561 |
get: function get() { |
| 9562 |
throw new Error('Not implemented: _isScrollModeHorizontal'); |
| 9563 |
} |
| 9564 |
}, { |
| 9565 |
key: 'isInPresentationMode', |
| 9566 |
get: function get() { |
| 9567 |
return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN; |
| 9568 |
} |
| 9569 |
}, { |
| 9570 |
key: 'isChangingPresentationMode', |
| 9571 |
get: function get() { |
| 9572 |
return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING; |
| 9573 |
} |
| 9574 |
}, { |
| 9575 |
key: 'isHorizontalScrollbarEnabled', |
| 9576 |
get: function get() { |
| 9577 |
return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth; |
| 9578 |
} |
| 9579 |
}, { |
| 9580 |
key: 'isVerticalScrollbarEnabled', |
| 9581 |
get: function get() { |
| 9582 |
return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight; |
| 9583 |
} |
| 9584 |
}, { |
| 9585 |
key: 'hasEqualPageSizes', |
| 9586 |
get: function get() { |
| 9587 |
var firstPageView = this._pages[0]; |
| 9588 |
for (var i = 1, ii = this._pages.length; i < ii; ++i) { |
| 9589 |
var pageView = this._pages[i]; |
| 9590 |
if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) { |
| 9591 |
return false; |
| 9592 |
} |
| 9593 |
} |
| 9594 |
return true; |
| 9595 |
} |
| 9596 |
}, { |
| 9597 |
key: 'scrollMode', |
| 9598 |
get: function get() { |
| 9599 |
return this._scrollMode; |
| 9600 |
}, |
| 9601 |
set: function set(mode) { |
| 9602 |
if (this._scrollMode === mode) { |
| 9603 |
return; |
| 9604 |
} |
| 9605 |
if (!Number.isInteger(mode) || !Object.values(ScrollMode).includes(mode)) { |
| 9606 |
throw new Error('Invalid scroll mode: ' + mode); |
| 9607 |
} |
| 9608 |
this._scrollMode = mode; |
| 9609 |
this.eventBus.dispatch('scrollmodechanged', { |
| 9610 |
source: this, |
| 9611 |
mode: mode |
| 9612 |
}); |
| 9613 |
this._updateScrollMode(this._currentPageNumber); |
| 9614 |
} |
| 9615 |
}, { |
| 9616 |
key: 'spreadMode', |
| 9617 |
get: function get() { |
| 9618 |
return this._spreadMode; |
| 9619 |
}, |
| 9620 |
set: function set(mode) { |
| 9621 |
if (this._spreadMode === mode) { |
| 9622 |
return; |
| 9623 |
} |
| 9624 |
if (!Number.isInteger(mode) || !Object.values(SpreadMode).includes(mode)) { |
| 9625 |
throw new Error('Invalid spread mode: ' + mode); |
| 9626 |
} |
| 9627 |
this._spreadMode = mode; |
| 9628 |
this.eventBus.dispatch('spreadmodechanged', { |
| 9629 |
source: this, |
| 9630 |
mode: mode |
| 9631 |
}); |
| 9632 |
this._updateSpreadMode(this._currentPageNumber); |
| 9633 |
} |
| 9634 |
}]); |
| 9635 |
|
| 9636 |
return BaseViewer; |
| 9637 |
}(); |
| 9638 |
|
| 9639 |
exports.BaseViewer = BaseViewer; |
| 9640 |
exports.ScrollMode = ScrollMode; |
| 9641 |
exports.SpreadMode = SpreadMode; |
| 9642 |
|
| 9643 |
/***/ }), |
| 9644 |
/* 31 */ |
| 9645 |
/***/ (function(module, exports, __webpack_require__) { |
| 9646 |
|
| 9647 |
"use strict"; |
| 9648 |
|
| 9649 |
|
| 9650 |
Object.defineProperty(exports, "__esModule", { |
| 9651 |
value: true |
| 9652 |
}); |
| 9653 |
exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = undefined; |
| 9654 |
|
| 9655 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 9656 |
|
| 9657 |
var _pdfjsLib = __webpack_require__(7); |
| 9658 |
|
| 9659 |
var _ui_utils = __webpack_require__(6); |
| 9660 |
|
| 9661 |
var _pdf_link_service = __webpack_require__(23); |
| 9662 |
|
| 9663 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 9664 |
|
| 9665 |
var AnnotationLayerBuilder = function () { |
| 9666 |
function AnnotationLayerBuilder(_ref) { |
| 9667 |
var pageDiv = _ref.pageDiv, |
| 9668 |
pdfPage = _ref.pdfPage, |
| 9669 |
linkService = _ref.linkService, |
| 9670 |
downloadManager = _ref.downloadManager, |
| 9671 |
_ref$imageResourcesPa = _ref.imageResourcesPath, |
| 9672 |
imageResourcesPath = _ref$imageResourcesPa === undefined ? '' : _ref$imageResourcesPa, |
| 9673 |
_ref$renderInteractiv = _ref.renderInteractiveForms, |
| 9674 |
renderInteractiveForms = _ref$renderInteractiv === undefined ? false : _ref$renderInteractiv, |
| 9675 |
_ref$l10n = _ref.l10n, |
| 9676 |
l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n; |
| 9677 |
|
| 9678 |
_classCallCheck(this, AnnotationLayerBuilder); |
| 9679 |
|
| 9680 |
this.pageDiv = pageDiv; |
| 9681 |
this.pdfPage = pdfPage; |
| 9682 |
this.linkService = linkService; |
| 9683 |
this.downloadManager = downloadManager; |
| 9684 |
this.imageResourcesPath = imageResourcesPath; |
| 9685 |
this.renderInteractiveForms = renderInteractiveForms; |
| 9686 |
this.l10n = l10n; |
| 9687 |
this.div = null; |
| 9688 |
this._cancelled = false; |
| 9689 |
} |
| 9690 |
|
| 9691 |
_createClass(AnnotationLayerBuilder, [{ |
| 9692 |
key: 'render', |
| 9693 |
value: function render(viewport) { |
| 9694 |
var _this = this; |
| 9695 |
|
| 9696 |
var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display'; |
| 9697 |
|
| 9698 |
this.pdfPage.getAnnotations({ intent: intent }).then(function (annotations) { |
| 9699 |
if (_this._cancelled) { |
| 9700 |
return; |
| 9701 |
} |
| 9702 |
var parameters = { |
| 9703 |
viewport: viewport.clone({ dontFlip: true }), |
| 9704 |
div: _this.div, |
| 9705 |
annotations: annotations, |
| 9706 |
page: _this.pdfPage, |
| 9707 |
imageResourcesPath: _this.imageResourcesPath, |
| 9708 |
renderInteractiveForms: _this.renderInteractiveForms, |
| 9709 |
linkService: _this.linkService, |
| 9710 |
downloadManager: _this.downloadManager |
| 9711 |
}; |
| 9712 |
if (_this.div) { |
| 9713 |
_pdfjsLib.AnnotationLayer.update(parameters); |
| 9714 |
} else { |
| 9715 |
if (annotations.length === 0) { |
| 9716 |
return; |
| 9717 |
} |
| 9718 |
_this.div = document.createElement('div'); |
| 9719 |
_this.div.className = 'annotationLayer'; |
| 9720 |
_this.pageDiv.appendChild(_this.div); |
| 9721 |
parameters.div = _this.div; |
| 9722 |
_pdfjsLib.AnnotationLayer.render(parameters); |
| 9723 |
_this.l10n.translate(_this.div); |
| 9724 |
} |
| 9725 |
}); |
| 9726 |
} |
| 9727 |
}, { |
| 9728 |
key: 'cancel', |
| 9729 |
value: function cancel() { |
| 9730 |
this._cancelled = true; |
| 9731 |
} |
| 9732 |
}, { |
| 9733 |
key: 'hide', |
| 9734 |
value: function hide() { |
| 9735 |
if (!this.div) { |
| 9736 |
return; |
| 9737 |
} |
| 9738 |
this.div.setAttribute('hidden', 'true'); |
| 9739 |
} |
| 9740 |
}]); |
| 9741 |
|
| 9742 |
return AnnotationLayerBuilder; |
| 9743 |
}(); |
| 9744 |
|
| 9745 |
var DefaultAnnotationLayerFactory = function () { |
| 9746 |
function DefaultAnnotationLayerFactory() { |
| 9747 |
_classCallCheck(this, DefaultAnnotationLayerFactory); |
| 9748 |
} |
| 9749 |
|
| 9750 |
_createClass(DefaultAnnotationLayerFactory, [{ |
| 9751 |
key: 'createAnnotationLayerBuilder', |
| 9752 |
value: function createAnnotationLayerBuilder(pageDiv, pdfPage) { |
| 9753 |
var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; |
| 9754 |
var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; |
| 9755 |
var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n; |
| 9756 |
|
| 9757 |
return new AnnotationLayerBuilder({ |
| 9758 |
pageDiv: pageDiv, |
| 9759 |
pdfPage: pdfPage, |
| 9760 |
imageResourcesPath: imageResourcesPath, |
| 9761 |
renderInteractiveForms: renderInteractiveForms, |
| 9762 |
linkService: new _pdf_link_service.SimpleLinkService(), |
| 9763 |
l10n: l10n |
| 9764 |
}); |
| 9765 |
} |
| 9766 |
}]); |
| 9767 |
|
| 9768 |
return DefaultAnnotationLayerFactory; |
| 9769 |
}(); |
| 9770 |
|
| 9771 |
exports.AnnotationLayerBuilder = AnnotationLayerBuilder; |
| 9772 |
exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory; |
| 9773 |
|
| 9774 |
/***/ }), |
| 9775 |
/* 32 */ |
| 9776 |
/***/ (function(module, exports, __webpack_require__) { |
| 9777 |
|
| 9778 |
"use strict"; |
| 9779 |
|
| 9780 |
|
| 9781 |
Object.defineProperty(exports, "__esModule", { |
| 9782 |
value: true |
| 9783 |
}); |
| 9784 |
exports.PDFPageView = undefined; |
| 9785 |
|
| 9786 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 9787 |
|
| 9788 |
var _ui_utils = __webpack_require__(6); |
| 9789 |
|
| 9790 |
var _pdfjsLib = __webpack_require__(7); |
| 9791 |
|
| 9792 |
var _dom_events = __webpack_require__(14); |
| 9793 |
|
| 9794 |
var _pdf_rendering_queue = __webpack_require__(10); |
| 9795 |
|
| 9796 |
var _viewer_compatibility = __webpack_require__(13); |
| 9797 |
|
| 9798 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 9799 |
|
| 9800 |
var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216; |
| 9801 |
|
| 9802 |
var PDFPageView = function () { |
| 9803 |
function PDFPageView(options) { |
| 9804 |
_classCallCheck(this, PDFPageView); |
| 9805 |
|
| 9806 |
var container = options.container; |
| 9807 |
var defaultViewport = options.defaultViewport; |
| 9808 |
this.id = options.id; |
| 9809 |
this.renderingId = 'page' + this.id; |
| 9810 |
this.pdfPage = null; |
| 9811 |
this.pageLabel = null; |
| 9812 |
this.rotation = 0; |
| 9813 |
this.scale = options.scale || _ui_utils.DEFAULT_SCALE; |
| 9814 |
this.viewport = defaultViewport; |
| 9815 |
this.pdfPageRotate = defaultViewport.rotation; |
| 9816 |
this.hasRestrictedScaling = false; |
| 9817 |
this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE; |
| 9818 |
this.imageResourcesPath = options.imageResourcesPath || ''; |
| 9819 |
this.renderInteractiveForms = options.renderInteractiveForms || false; |
| 9820 |
this.useOnlyCssZoom = options.useOnlyCssZoom || false; |
| 9821 |
this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS; |
| 9822 |
this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)(); |
| 9823 |
this.renderingQueue = options.renderingQueue; |
| 9824 |
this.textLayerFactory = options.textLayerFactory; |
| 9825 |
this.annotationLayerFactory = options.annotationLayerFactory; |
| 9826 |
this.renderer = options.renderer || _ui_utils.RendererType.CANVAS; |
| 9827 |
this.enableWebGL = options.enableWebGL || false; |
| 9828 |
this.l10n = options.l10n || _ui_utils.NullL10n; |
| 9829 |
this.paintTask = null; |
| 9830 |
this.paintedViewportMap = new WeakMap(); |
| 9831 |
this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL; |
| 9832 |
this.resume = null; |
| 9833 |
this.error = null; |
| 9834 |
this.onBeforeDraw = null; |
| 9835 |
this.onAfterDraw = null; |
| 9836 |
this.annotationLayer = null; |
| 9837 |
this.textLayer = null; |
| 9838 |
this.zoomLayer = null; |
| 9839 |
var div = document.createElement('div'); |
| 9840 |
div.className = 'page'; |
| 9841 |
div.style.width = Math.floor(this.viewport.width) + 'px'; |
| 9842 |
div.style.height = Math.floor(this.viewport.height) + 'px'; |
| 9843 |
div.setAttribute('data-page-number', this.id); |
| 9844 |
this.div = div; |
| 9845 |
container.appendChild(div); |
| 9846 |
} |
| 9847 |
|
| 9848 |
_createClass(PDFPageView, [{ |
| 9849 |
key: 'setPdfPage', |
| 9850 |
value: function setPdfPage(pdfPage) { |
| 9851 |
this.pdfPage = pdfPage; |
| 9852 |
this.pdfPageRotate = pdfPage.rotate; |
| 9853 |
var totalRotation = (this.rotation + this.pdfPageRotate) % 360; |
| 9854 |
this.viewport = pdfPage.getViewport(this.scale * _ui_utils.CSS_UNITS, totalRotation); |
| 9855 |
this.stats = pdfPage.stats; |
| 9856 |
this.reset(); |
| 9857 |
} |
| 9858 |
}, { |
| 9859 |
key: 'destroy', |
| 9860 |
value: function destroy() { |
| 9861 |
this.reset(); |
| 9862 |
if (this.pdfPage) { |
| 9863 |
this.pdfPage.cleanup(); |
| 9864 |
} |
| 9865 |
} |
| 9866 |
}, { |
| 9867 |
key: '_resetZoomLayer', |
| 9868 |
value: function _resetZoomLayer() { |
| 9869 |
var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
| 9870 |
|
| 9871 |
if (!this.zoomLayer) { |
| 9872 |
return; |
| 9873 |
} |
| 9874 |
var zoomLayerCanvas = this.zoomLayer.firstChild; |
| 9875 |
this.paintedViewportMap.delete(zoomLayerCanvas); |
| 9876 |
zoomLayerCanvas.width = 0; |
| 9877 |
zoomLayerCanvas.height = 0; |
| 9878 |
if (removeFromDOM) { |
| 9879 |
this.zoomLayer.remove(); |
| 9880 |
} |
| 9881 |
this.zoomLayer = null; |
| 9882 |
} |
| 9883 |
}, { |
| 9884 |
key: 'reset', |
| 9885 |
value: function reset() { |
| 9886 |
var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
| 9887 |
var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; |
| 9888 |
|
| 9889 |
this.cancelRendering(keepAnnotations); |
| 9890 |
var div = this.div; |
| 9891 |
div.style.width = Math.floor(this.viewport.width) + 'px'; |
| 9892 |
div.style.height = Math.floor(this.viewport.height) + 'px'; |
| 9893 |
var childNodes = div.childNodes; |
| 9894 |
var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null; |
| 9895 |
var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null; |
| 9896 |
for (var i = childNodes.length - 1; i >= 0; i--) { |
| 9897 |
var node = childNodes[i]; |
| 9898 |
if (currentZoomLayerNode === node || currentAnnotationNode === node) { |
| 9899 |
continue; |
| 9900 |
} |
| 9901 |
div.removeChild(node); |
| 9902 |
} |
| 9903 |
div.removeAttribute('data-loaded'); |
| 9904 |
if (currentAnnotationNode) { |
| 9905 |
this.annotationLayer.hide(); |
| 9906 |
} else if (this.annotationLayer) { |
| 9907 |
this.annotationLayer.cancel(); |
| 9908 |
this.annotationLayer = null; |
| 9909 |
} |
| 9910 |
if (!currentZoomLayerNode) { |
| 9911 |
if (this.canvas) { |
| 9912 |
this.paintedViewportMap.delete(this.canvas); |
| 9913 |
this.canvas.width = 0; |
| 9914 |
this.canvas.height = 0; |
| 9915 |
delete this.canvas; |
| 9916 |
} |
| 9917 |
this._resetZoomLayer(); |
| 9918 |
} |
| 9919 |
if (this.svg) { |
| 9920 |
this.paintedViewportMap.delete(this.svg); |
| 9921 |
delete this.svg; |
| 9922 |
} |
| 9923 |
this.loadingIconDiv = document.createElement('div'); |
| 9924 |
this.loadingIconDiv.className = 'loadingIcon'; |
| 9925 |
div.appendChild(this.loadingIconDiv); |
| 9926 |
} |
| 9927 |
}, { |
| 9928 |
key: 'update', |
| 9929 |
value: function update(scale, rotation) { |
| 9930 |
this.scale = scale || this.scale; |
| 9931 |
if (typeof rotation !== 'undefined') { |
| 9932 |
this.rotation = rotation; |
| 9933 |
} |
| 9934 |
var totalRotation = (this.rotation + this.pdfPageRotate) % 360; |
| 9935 |
this.viewport = this.viewport.clone({ |
| 9936 |
scale: this.scale * _ui_utils.CSS_UNITS, |
| 9937 |
rotation: totalRotation |
| 9938 |
}); |
| 9939 |
if (this.svg) { |
| 9940 |
this.cssTransform(this.svg, true); |
| 9941 |
this.eventBus.dispatch('pagerendered', { |
| 9942 |
source: this, |
| 9943 |
pageNumber: this.id, |
| 9944 |
cssTransform: true |
| 9945 |
}); |
| 9946 |
return; |
| 9947 |
} |
| 9948 |
var isScalingRestricted = false; |
| 9949 |
if (this.canvas && this.maxCanvasPixels > 0) { |
| 9950 |
var outputScale = this.outputScale; |
| 9951 |
if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) { |
| 9952 |
isScalingRestricted = true; |
| 9953 |
} |
| 9954 |
} |
| 9955 |
if (this.canvas) { |
| 9956 |
if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) { |
| 9957 |
this.cssTransform(this.canvas, true); |
| 9958 |
this.eventBus.dispatch('pagerendered', { |
| 9959 |
source: this, |
| 9960 |
pageNumber: this.id, |
| 9961 |
cssTransform: true |
| 9962 |
}); |
| 9963 |
return; |
| 9964 |
} |
| 9965 |
if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) { |
| 9966 |
this.zoomLayer = this.canvas.parentNode; |
| 9967 |
this.zoomLayer.style.position = 'absolute'; |
| 9968 |
} |
| 9969 |
} |
| 9970 |
if (this.zoomLayer) { |
| 9971 |
this.cssTransform(this.zoomLayer.firstChild); |
| 9972 |
} |
| 9973 |
this.reset(true, true); |
| 9974 |
} |
| 9975 |
}, { |
| 9976 |
key: 'cancelRendering', |
| 9977 |
value: function cancelRendering() { |
| 9978 |
var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
| 9979 |
|
| 9980 |
var renderingState = this.renderingState; |
| 9981 |
if (this.paintTask) { |
| 9982 |
this.paintTask.cancel(); |
| 9983 |
this.paintTask = null; |
| 9984 |
} |
| 9985 |
this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL; |
| 9986 |
this.resume = null; |
| 9987 |
if (this.textLayer) { |
| 9988 |
this.textLayer.cancel(); |
| 9989 |
this.textLayer = null; |
| 9990 |
} |
| 9991 |
if (!keepAnnotations && this.annotationLayer) { |
| 9992 |
this.annotationLayer.cancel(); |
| 9993 |
this.annotationLayer = null; |
| 9994 |
} |
| 9995 |
if (renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) { |
| 9996 |
this.eventBus.dispatch('pagecancelled', { |
| 9997 |
source: this, |
| 9998 |
pageNumber: this.id, |
| 9999 |
renderingState: renderingState |
| 10000 |
}); |
| 10001 |
} |
| 10002 |
} |
| 10003 |
}, { |
| 10004 |
key: 'cssTransform', |
| 10005 |
value: function cssTransform(target) { |
| 10006 |
var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; |
| 10007 |
|
| 10008 |
var width = this.viewport.width; |
| 10009 |
var height = this.viewport.height; |
| 10010 |
var div = this.div; |
| 10011 |
target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px'; |
| 10012 |
target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px'; |
| 10013 |
var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation; |
| 10014 |
var absRotation = Math.abs(relativeRotation); |
| 10015 |
var scaleX = 1, |
| 10016 |
scaleY = 1; |
| 10017 |
if (absRotation === 90 || absRotation === 270) { |
| 10018 |
scaleX = height / width; |
| 10019 |
scaleY = width / height; |
| 10020 |
} |
| 10021 |
var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')'; |
| 10022 |
target.style.transform = cssTransform; |
| 10023 |
if (this.textLayer) { |
| 10024 |
var textLayerViewport = this.textLayer.viewport; |
| 10025 |
var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation; |
| 10026 |
var textAbsRotation = Math.abs(textRelativeRotation); |
| 10027 |
var scale = width / textLayerViewport.width; |
| 10028 |
if (textAbsRotation === 90 || textAbsRotation === 270) { |
| 10029 |
scale = width / textLayerViewport.height; |
| 10030 |
} |
| 10031 |
var textLayerDiv = this.textLayer.textLayerDiv; |
| 10032 |
var transX = void 0, |
| 10033 |
transY = void 0; |
| 10034 |
switch (textAbsRotation) { |
| 10035 |
case 0: |
| 10036 |
transX = transY = 0; |
| 10037 |
break; |
| 10038 |
case 90: |
| 10039 |
transX = 0; |
| 10040 |
transY = '-' + textLayerDiv.style.height; |
| 10041 |
break; |
| 10042 |
case 180: |
| 10043 |
transX = '-' + textLayerDiv.style.width; |
| 10044 |
transY = '-' + textLayerDiv.style.height; |
| 10045 |
break; |
| 10046 |
case 270: |
| 10047 |
transX = '-' + textLayerDiv.style.width; |
| 10048 |
transY = 0; |
| 10049 |
break; |
| 10050 |
default: |
| 10051 |
console.error('Bad rotation value.'); |
| 10052 |
break; |
| 10053 |
} |
| 10054 |
textLayerDiv.style.transform = 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')'; |
| 10055 |
textLayerDiv.style.transformOrigin = '0% 0%'; |
| 10056 |
} |
| 10057 |
if (redrawAnnotations && this.annotationLayer) { |
| 10058 |
this.annotationLayer.render(this.viewport, 'display'); |
| 10059 |
} |
| 10060 |
} |
| 10061 |
}, { |
| 10062 |
key: 'getPagePoint', |
| 10063 |
value: function getPagePoint(x, y) { |
| 10064 |
return this.viewport.convertToPdfPoint(x, y); |
| 10065 |
} |
| 10066 |
}, { |
| 10067 |
key: 'draw', |
| 10068 |
value: function draw() { |
| 10069 |
var _this = this; |
| 10070 |
|
| 10071 |
if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) { |
| 10072 |
console.error('Must be in new state before drawing'); |
| 10073 |
this.reset(); |
| 10074 |
} |
| 10075 |
if (!this.pdfPage) { |
| 10076 |
this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED; |
| 10077 |
return Promise.reject(new Error('Page is not loaded')); |
| 10078 |
} |
| 10079 |
this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING; |
| 10080 |
var pdfPage = this.pdfPage; |
| 10081 |
var div = this.div; |
| 10082 |
var canvasWrapper = document.createElement('div'); |
| 10083 |
canvasWrapper.style.width = div.style.width; |
| 10084 |
canvasWrapper.style.height = div.style.height; |
| 10085 |
canvasWrapper.classList.add('canvasWrapper'); |
| 10086 |
if (this.annotationLayer && this.annotationLayer.div) { |
| 10087 |
div.insertBefore(canvasWrapper, this.annotationLayer.div); |
| 10088 |
} else { |
| 10089 |
div.appendChild(canvasWrapper); |
| 10090 |
} |
| 10091 |
var textLayer = null; |
| 10092 |
if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) { |
| 10093 |
var textLayerDiv = document.createElement('div'); |
| 10094 |
textLayerDiv.className = 'textLayer'; |
| 10095 |
textLayerDiv.style.width = canvasWrapper.style.width; |
| 10096 |
textLayerDiv.style.height = canvasWrapper.style.height; |
| 10097 |
if (this.annotationLayer && this.annotationLayer.div) { |
| 10098 |
div.insertBefore(textLayerDiv, this.annotationLayer.div); |
| 10099 |
} else { |
| 10100 |
div.appendChild(textLayerDiv); |
| 10101 |
} |
| 10102 |
textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE); |
| 10103 |
} |
| 10104 |
this.textLayer = textLayer; |
| 10105 |
var renderContinueCallback = null; |
| 10106 |
if (this.renderingQueue) { |
| 10107 |
renderContinueCallback = function renderContinueCallback(cont) { |
| 10108 |
if (!_this.renderingQueue.isHighestPriority(_this)) { |
| 10109 |
_this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED; |
| 10110 |
_this.resume = function () { |
| 10111 |
_this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING; |
| 10112 |
cont(); |
| 10113 |
}; |
| 10114 |
return; |
| 10115 |
} |
| 10116 |
cont(); |
| 10117 |
}; |
| 10118 |
} |
| 10119 |
var finishPaintTask = function finishPaintTask(error) { |
| 10120 |
if (paintTask === _this.paintTask) { |
| 10121 |
_this.paintTask = null; |
| 10122 |
} |
| 10123 |
if (error instanceof _pdfjsLib.RenderingCancelledException) { |
| 10124 |
_this.error = null; |
| 10125 |
return Promise.resolve(undefined); |
| 10126 |
} |
| 10127 |
_this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED; |
| 10128 |
if (_this.loadingIconDiv) { |
| 10129 |
div.removeChild(_this.loadingIconDiv); |
| 10130 |
delete _this.loadingIconDiv; |
| 10131 |
} |
| 10132 |
_this._resetZoomLayer(true); |
| 10133 |
_this.error = error; |
| 10134 |
_this.stats = pdfPage.stats; |
| 10135 |
if (_this.onAfterDraw) { |
| 10136 |
_this.onAfterDraw(); |
| 10137 |
} |
| 10138 |
_this.eventBus.dispatch('pagerendered', { |
| 10139 |
source: _this, |
| 10140 |
pageNumber: _this.id, |
| 10141 |
cssTransform: false |
| 10142 |
}); |
| 10143 |
if (error) { |
| 10144 |
return Promise.reject(error); |
| 10145 |
} |
| 10146 |
return Promise.resolve(undefined); |
| 10147 |
}; |
| 10148 |
var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper); |
| 10149 |
paintTask.onRenderContinue = renderContinueCallback; |
| 10150 |
this.paintTask = paintTask; |
| 10151 |
var resultPromise = paintTask.promise.then(function () { |
| 10152 |
return finishPaintTask(null).then(function () { |
| 10153 |
if (textLayer) { |
| 10154 |
var readableStream = pdfPage.streamTextContent({ normalizeWhitespace: true }); |
| 10155 |
textLayer.setTextContentStream(readableStream); |
| 10156 |
textLayer.render(); |
| 10157 |
} |
| 10158 |
}); |
| 10159 |
}, function (reason) { |
| 10160 |
return finishPaintTask(reason); |
| 10161 |
}); |
| 10162 |
if (this.annotationLayerFactory) { |
| 10163 |
if (!this.annotationLayer) { |
| 10164 |
this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n); |
| 10165 |
} |
| 10166 |
this.annotationLayer.render(this.viewport, 'display'); |
| 10167 |
} |
| 10168 |
div.setAttribute('data-loaded', true); |
| 10169 |
if (this.onBeforeDraw) { |
| 10170 |
this.onBeforeDraw(); |
| 10171 |
} |
| 10172 |
return resultPromise; |
| 10173 |
} |
| 10174 |
}, { |
| 10175 |
key: 'paintOnCanvas', |
| 10176 |
value: function paintOnCanvas(canvasWrapper) { |
| 10177 |
var renderCapability = (0, _pdfjsLib.createPromiseCapability)(); |
| 10178 |
var result = { |
| 10179 |
promise: renderCapability.promise, |
| 10180 |
onRenderContinue: function onRenderContinue(cont) { |
| 10181 |
cont(); |
| 10182 |
}, |
| 10183 |
cancel: function cancel() { |
| 10184 |
renderTask.cancel(); |
| 10185 |
} |
| 10186 |
}; |
| 10187 |
var viewport = this.viewport; |
| 10188 |
var canvas = document.createElement('canvas'); |
| 10189 |
canvas.id = this.renderingId; |
| 10190 |
canvas.setAttribute('hidden', 'hidden'); |
| 10191 |
var isCanvasHidden = true; |
| 10192 |
var showCanvas = function showCanvas() { |
| 10193 |
if (isCanvasHidden) { |
| 10194 |
canvas.removeAttribute('hidden'); |
| 10195 |
isCanvasHidden = false; |
| 10196 |
} |
| 10197 |
}; |
| 10198 |
canvasWrapper.appendChild(canvas); |
| 10199 |
this.canvas = canvas; |
| 10200 |
canvas.mozOpaque = true; |
| 10201 |
var ctx = canvas.getContext('2d', { alpha: false }); |
| 10202 |
var outputScale = (0, _ui_utils.getOutputScale)(ctx); |
| 10203 |
this.outputScale = outputScale; |
| 10204 |
if (this.useOnlyCssZoom) { |
| 10205 |
var actualSizeViewport = viewport.clone({ scale: _ui_utils.CSS_UNITS }); |
| 10206 |
outputScale.sx *= actualSizeViewport.width / viewport.width; |
| 10207 |
outputScale.sy *= actualSizeViewport.height / viewport.height; |
| 10208 |
outputScale.scaled = true; |
| 10209 |
} |
| 10210 |
if (this.maxCanvasPixels > 0) { |
| 10211 |
var pixelsInViewport = viewport.width * viewport.height; |
| 10212 |
var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport); |
| 10213 |
if (outputScale.sx > maxScale || outputScale.sy > maxScale) { |
| 10214 |
outputScale.sx = maxScale; |
| 10215 |
outputScale.sy = maxScale; |
| 10216 |
outputScale.scaled = true; |
| 10217 |
this.hasRestrictedScaling = true; |
| 10218 |
} else { |
| 10219 |
this.hasRestrictedScaling = false; |
| 10220 |
} |
| 10221 |
} |
| 10222 |
var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx); |
| 10223 |
var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy); |
| 10224 |
canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]); |
| 10225 |
canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]); |
| 10226 |
canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px'; |
| 10227 |
canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px'; |
| 10228 |
this.paintedViewportMap.set(canvas, viewport); |
| 10229 |
var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0]; |
| 10230 |
var renderContext = { |
| 10231 |
canvasContext: ctx, |
| 10232 |
transform: transform, |
| 10233 |
viewport: this.viewport, |
| 10234 |
enableWebGL: this.enableWebGL, |
| 10235 |
renderInteractiveForms: this.renderInteractiveForms |
| 10236 |
}; |
| 10237 |
var renderTask = this.pdfPage.render(renderContext); |
| 10238 |
renderTask.onContinue = function (cont) { |
| 10239 |
showCanvas(); |
| 10240 |
if (result.onRenderContinue) { |
| 10241 |
result.onRenderContinue(cont); |
| 10242 |
} else { |
| 10243 |
cont(); |
| 10244 |
} |
| 10245 |
}; |
| 10246 |
renderTask.promise.then(function () { |
| 10247 |
showCanvas(); |
| 10248 |
renderCapability.resolve(undefined); |
| 10249 |
}, function (error) { |
| 10250 |
showCanvas(); |
| 10251 |
renderCapability.reject(error); |
| 10252 |
}); |
| 10253 |
return result; |
| 10254 |
} |
| 10255 |
}, { |
| 10256 |
key: 'paintOnSvg', |
| 10257 |
value: function paintOnSvg(wrapper) { |
| 10258 |
var _this2 = this; |
| 10259 |
|
| 10260 |
var cancelled = false; |
| 10261 |
var ensureNotCancelled = function ensureNotCancelled() { |
| 10262 |
if (cancelled) { |
| 10263 |
throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg'); |
| 10264 |
} |
| 10265 |
}; |
| 10266 |
var pdfPage = this.pdfPage; |
| 10267 |
var actualSizeViewport = this.viewport.clone({ scale: _ui_utils.CSS_UNITS }); |
| 10268 |
var promise = pdfPage.getOperatorList().then(function (opList) { |
| 10269 |
ensureNotCancelled(); |
| 10270 |
var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs); |
| 10271 |
return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) { |
| 10272 |
ensureNotCancelled(); |
| 10273 |
_this2.svg = svg; |
| 10274 |
_this2.paintedViewportMap.set(svg, actualSizeViewport); |
| 10275 |
svg.style.width = wrapper.style.width; |
| 10276 |
svg.style.height = wrapper.style.height; |
| 10277 |
_this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED; |
| 10278 |
wrapper.appendChild(svg); |
| 10279 |
}); |
| 10280 |
}); |
| 10281 |
return { |
| 10282 |
promise: promise, |
| 10283 |
onRenderContinue: function onRenderContinue(cont) { |
| 10284 |
cont(); |
| 10285 |
}, |
| 10286 |
cancel: function cancel() { |
| 10287 |
cancelled = true; |
| 10288 |
} |
| 10289 |
}; |
| 10290 |
} |
| 10291 |
}, { |
| 10292 |
key: 'setPageLabel', |
| 10293 |
value: function setPageLabel(label) { |
| 10294 |
this.pageLabel = typeof label === 'string' ? label : null; |
| 10295 |
if (this.pageLabel !== null) { |
| 10296 |
this.div.setAttribute('data-page-label', this.pageLabel); |
| 10297 |
} else { |
| 10298 |
this.div.removeAttribute('data-page-label'); |
| 10299 |
} |
| 10300 |
} |
| 10301 |
}, { |
| 10302 |
key: 'width', |
| 10303 |
get: function get() { |
| 10304 |
return this.viewport.width; |
| 10305 |
} |
| 10306 |
}, { |
| 10307 |
key: 'height', |
| 10308 |
get: function get() { |
| 10309 |
return this.viewport.height; |
| 10310 |
} |
| 10311 |
}]); |
| 10312 |
|
| 10313 |
return PDFPageView; |
| 10314 |
}(); |
| 10315 |
|
| 10316 |
exports.PDFPageView = PDFPageView; |
| 10317 |
|
| 10318 |
/***/ }), |
| 10319 |
/* 33 */ |
| 10320 |
/***/ (function(module, exports, __webpack_require__) { |
| 10321 |
|
| 10322 |
"use strict"; |
| 10323 |
|
| 10324 |
|
| 10325 |
Object.defineProperty(exports, "__esModule", { |
| 10326 |
value: true |
| 10327 |
}); |
| 10328 |
exports.DefaultTextLayerFactory = exports.TextLayerBuilder = undefined; |
| 10329 |
|
| 10330 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 10331 |
|
| 10332 |
var _dom_events = __webpack_require__(14); |
| 10333 |
|
| 10334 |
var _pdfjsLib = __webpack_require__(7); |
| 10335 |
|
| 10336 |
var _ui_utils = __webpack_require__(6); |
| 10337 |
|
| 10338 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 10339 |
|
| 10340 |
var EXPAND_DIVS_TIMEOUT = 300; |
| 10341 |
var MATCH_SCROLL_OFFSET_TOP = -50; |
| 10342 |
var MATCH_SCROLL_OFFSET_LEFT = -400; |
| 10343 |
|
| 10344 |
var TextLayerBuilder = function () { |
| 10345 |
function TextLayerBuilder(_ref) { |
| 10346 |
var textLayerDiv = _ref.textLayerDiv, |
| 10347 |
eventBus = _ref.eventBus, |
| 10348 |
pageIndex = _ref.pageIndex, |
| 10349 |
viewport = _ref.viewport, |
| 10350 |
_ref$findController = _ref.findController, |
| 10351 |
findController = _ref$findController === undefined ? null : _ref$findController, |
| 10352 |
_ref$enhanceTextSelec = _ref.enhanceTextSelection, |
| 10353 |
enhanceTextSelection = _ref$enhanceTextSelec === undefined ? false : _ref$enhanceTextSelec; |
| 10354 |
|
| 10355 |
_classCallCheck(this, TextLayerBuilder); |
| 10356 |
|
| 10357 |
this.textLayerDiv = textLayerDiv; |
| 10358 |
this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)(); |
| 10359 |
this.textContent = null; |
| 10360 |
this.textContentItemsStr = []; |
| 10361 |
this.textContentStream = null; |
| 10362 |
this.renderingDone = false; |
| 10363 |
this.pageIdx = pageIndex; |
| 10364 |
this.pageNumber = this.pageIdx + 1; |
| 10365 |
this.matches = []; |
| 10366 |
this.viewport = viewport; |
| 10367 |
this.textDivs = []; |
| 10368 |
this.findController = findController; |
| 10369 |
this.textLayerRenderTask = null; |
| 10370 |
this.enhanceTextSelection = enhanceTextSelection; |
| 10371 |
this._boundEvents = Object.create(null); |
| 10372 |
this._bindEvents(); |
| 10373 |
this._bindMouse(); |
| 10374 |
} |
| 10375 |
|
| 10376 |
_createClass(TextLayerBuilder, [{ |
| 10377 |
key: '_finishRendering', |
| 10378 |
value: function _finishRendering() { |
| 10379 |
this.renderingDone = true; |
| 10380 |
if (!this.enhanceTextSelection) { |
| 10381 |
var endOfContent = document.createElement('div'); |
| 10382 |
endOfContent.className = 'endOfContent'; |
| 10383 |
this.textLayerDiv.appendChild(endOfContent); |
| 10384 |
} |
| 10385 |
this.eventBus.dispatch('textlayerrendered', { |
| 10386 |
source: this, |
| 10387 |
pageNumber: this.pageNumber, |
| 10388 |
numTextDivs: this.textDivs.length |
| 10389 |
}); |
| 10390 |
} |
| 10391 |
}, { |
| 10392 |
key: 'render', |
| 10393 |
value: function render() { |
| 10394 |
var _this = this; |
| 10395 |
|
| 10396 |
var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; |
| 10397 |
|
| 10398 |
if (!(this.textContent || this.textContentStream) || this.renderingDone) { |
| 10399 |
return; |
| 10400 |
} |
| 10401 |
this.cancel(); |
| 10402 |
this.textDivs = []; |
| 10403 |
var textLayerFrag = document.createDocumentFragment(); |
| 10404 |
this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({ |
| 10405 |
textContent: this.textContent, |
| 10406 |
textContentStream: this.textContentStream, |
| 10407 |
container: textLayerFrag, |
| 10408 |
viewport: this.viewport, |
| 10409 |
textDivs: this.textDivs, |
| 10410 |
textContentItemsStr: this.textContentItemsStr, |
| 10411 |
timeout: timeout, |
| 10412 |
enhanceTextSelection: this.enhanceTextSelection |
| 10413 |
}); |
| 10414 |
this.textLayerRenderTask.promise.then(function () { |
| 10415 |
_this.textLayerDiv.appendChild(textLayerFrag); |
| 10416 |
_this._finishRendering(); |
| 10417 |
_this.updateMatches(); |
| 10418 |
}, function (reason) {}); |
| 10419 |
} |
| 10420 |
}, { |
| 10421 |
key: 'cancel', |
| 10422 |
value: function cancel() { |
| 10423 |
if (this.textLayerRenderTask) { |
| 10424 |
this.textLayerRenderTask.cancel(); |
| 10425 |
this.textLayerRenderTask = null; |
| 10426 |
} |
| 10427 |
} |
| 10428 |
}, { |
| 10429 |
key: 'setTextContentStream', |
| 10430 |
value: function setTextContentStream(readableStream) { |
| 10431 |
this.cancel(); |
| 10432 |
this.textContentStream = readableStream; |
| 10433 |
} |
| 10434 |
}, { |
| 10435 |
key: 'setTextContent', |
| 10436 |
value: function setTextContent(textContent) { |
| 10437 |
this.cancel(); |
| 10438 |
this.textContent = textContent; |
| 10439 |
} |
| 10440 |
}, { |
| 10441 |
key: 'convertMatches', |
| 10442 |
value: function convertMatches(matches, matchesLength) { |
| 10443 |
var i = 0; |
| 10444 |
var iIndex = 0; |
| 10445 |
var textContentItemsStr = this.textContentItemsStr; |
| 10446 |
var end = textContentItemsStr.length - 1; |
| 10447 |
var queryLen = this.findController === null ? 0 : this.findController.state.query.length; |
| 10448 |
var ret = []; |
| 10449 |
if (!matches) { |
| 10450 |
return ret; |
| 10451 |
} |
| 10452 |
for (var m = 0, len = matches.length; m < len; m++) { |
| 10453 |
var matchIdx = matches[m]; |
| 10454 |
while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) { |
| 10455 |
iIndex += textContentItemsStr[i].length; |
| 10456 |
i++; |
| 10457 |
} |
| 10458 |
if (i === textContentItemsStr.length) { |
| 10459 |
console.error('Could not find a matching mapping'); |
| 10460 |
} |
| 10461 |
var match = { |
| 10462 |
begin: { |
| 10463 |
divIdx: i, |
| 10464 |
offset: matchIdx - iIndex |
| 10465 |
} |
| 10466 |
}; |
| 10467 |
if (matchesLength) { |
| 10468 |
matchIdx += matchesLength[m]; |
| 10469 |
} else { |
| 10470 |
matchIdx += queryLen; |
| 10471 |
} |
| 10472 |
while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) { |
| 10473 |
iIndex += textContentItemsStr[i].length; |
| 10474 |
i++; |
| 10475 |
} |
| 10476 |
match.end = { |
| 10477 |
divIdx: i, |
| 10478 |
offset: matchIdx - iIndex |
| 10479 |
}; |
| 10480 |
ret.push(match); |
| 10481 |
} |
| 10482 |
return ret; |
| 10483 |
} |
| 10484 |
}, { |
| 10485 |
key: 'renderMatches', |
| 10486 |
value: function renderMatches(matches) { |
| 10487 |
if (matches.length === 0) { |
| 10488 |
return; |
| 10489 |
} |
| 10490 |
var textContentItemsStr = this.textContentItemsStr; |
| 10491 |
var textDivs = this.textDivs; |
| 10492 |
var prevEnd = null; |
| 10493 |
var pageIdx = this.pageIdx; |
| 10494 |
var isSelectedPage = this.findController === null ? false : pageIdx === this.findController.selected.pageIdx; |
| 10495 |
var selectedMatchIdx = this.findController === null ? -1 : this.findController.selected.matchIdx; |
| 10496 |
var highlightAll = this.findController === null ? false : this.findController.state.highlightAll; |
| 10497 |
var infinity = { |
| 10498 |
divIdx: -1, |
| 10499 |
offset: undefined |
| 10500 |
}; |
| 10501 |
function beginText(begin, className) { |
| 10502 |
var divIdx = begin.divIdx; |
| 10503 |
textDivs[divIdx].textContent = ''; |
| 10504 |
appendTextToDiv(divIdx, 0, begin.offset, className); |
| 10505 |
} |
| 10506 |
function appendTextToDiv(divIdx, fromOffset, toOffset, className) { |
| 10507 |
var div = textDivs[divIdx]; |
| 10508 |
var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset); |
| 10509 |
var node = document.createTextNode(content); |
| 10510 |
if (className) { |
| 10511 |
var span = document.createElement('span'); |
| 10512 |
span.className = className; |
| 10513 |
span.appendChild(node); |
| 10514 |
div.appendChild(span); |
| 10515 |
return; |
| 10516 |
} |
| 10517 |
div.appendChild(node); |
| 10518 |
} |
| 10519 |
var i0 = selectedMatchIdx, |
| 10520 |
i1 = i0 + 1; |
| 10521 |
if (highlightAll) { |
| 10522 |
i0 = 0; |
| 10523 |
i1 = matches.length; |
| 10524 |
} else if (!isSelectedPage) { |
| 10525 |
return; |
| 10526 |
} |
| 10527 |
for (var i = i0; i < i1; i++) { |
| 10528 |
var match = matches[i]; |
| 10529 |
var begin = match.begin; |
| 10530 |
var end = match.end; |
| 10531 |
var isSelected = isSelectedPage && i === selectedMatchIdx; |
| 10532 |
var highlightSuffix = isSelected ? ' selected' : ''; |
| 10533 |
if (this.findController) { |
| 10534 |
if (this.findController.selected.matchIdx === i && this.findController.selected.pageIdx === pageIdx) { |
| 10535 |
var spot = { |
| 10536 |
top: MATCH_SCROLL_OFFSET_TOP, |
| 10537 |
left: MATCH_SCROLL_OFFSET_LEFT |
| 10538 |
}; |
| 10539 |
(0, _ui_utils.scrollIntoView)(textDivs[begin.divIdx], spot, true); |
| 10540 |
} |
| 10541 |
} |
| 10542 |
if (!prevEnd || begin.divIdx !== prevEnd.divIdx) { |
| 10543 |
if (prevEnd !== null) { |
| 10544 |
appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset); |
| 10545 |
} |
| 10546 |
beginText(begin); |
| 10547 |
} else { |
| 10548 |
appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset); |
| 10549 |
} |
| 10550 |
if (begin.divIdx === end.divIdx) { |
| 10551 |
appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix); |
| 10552 |
} else { |
| 10553 |
appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix); |
| 10554 |
for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) { |
| 10555 |
textDivs[n0].className = 'highlight middle' + highlightSuffix; |
| 10556 |
} |
| 10557 |
beginText(end, 'highlight end' + highlightSuffix); |
| 10558 |
} |
| 10559 |
prevEnd = end; |
| 10560 |
} |
| 10561 |
if (prevEnd) { |
| 10562 |
appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset); |
| 10563 |
} |
| 10564 |
} |
| 10565 |
}, { |
| 10566 |
key: 'updateMatches', |
| 10567 |
value: function updateMatches() { |
| 10568 |
if (!this.renderingDone) { |
| 10569 |
return; |
| 10570 |
} |
| 10571 |
var matches = this.matches; |
| 10572 |
var textDivs = this.textDivs; |
| 10573 |
var textContentItemsStr = this.textContentItemsStr; |
| 10574 |
var clearedUntilDivIdx = -1; |
| 10575 |
for (var i = 0, len = matches.length; i < len; i++) { |
| 10576 |
var match = matches[i]; |
| 10577 |
var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx); |
| 10578 |
for (var n = begin, end = match.end.divIdx; n <= end; n++) { |
| 10579 |
var div = textDivs[n]; |
| 10580 |
div.textContent = textContentItemsStr[n]; |
| 10581 |
div.className = ''; |
| 10582 |
} |
| 10583 |
clearedUntilDivIdx = match.end.divIdx + 1; |
| 10584 |
} |
| 10585 |
if (!this.findController || !this.findController.highlightMatches) { |
| 10586 |
return; |
| 10587 |
} |
| 10588 |
var pageMatches = void 0, |
| 10589 |
pageMatchesLength = void 0; |
| 10590 |
if (this.findController !== null) { |
| 10591 |
pageMatches = this.findController.pageMatches[this.pageIdx] || null; |
| 10592 |
pageMatchesLength = this.findController.pageMatchesLength ? this.findController.pageMatchesLength[this.pageIdx] || null : null; |
| 10593 |
} |
| 10594 |
this.matches = this.convertMatches(pageMatches, pageMatchesLength); |
| 10595 |
this.renderMatches(this.matches); |
| 10596 |
} |
| 10597 |
}, { |
| 10598 |
key: '_bindEvents', |
| 10599 |
value: function _bindEvents() { |
| 10600 |
var _this2 = this; |
| 10601 |
|
| 10602 |
var eventBus = this.eventBus, |
| 10603 |
_boundEvents = this._boundEvents; |
| 10604 |
|
| 10605 |
_boundEvents.pageCancelled = function (evt) { |
| 10606 |
if (evt.pageNumber !== _this2.pageNumber) { |
| 10607 |
return; |
| 10608 |
} |
| 10609 |
if (_this2.textLayerRenderTask) { |
| 10610 |
console.error('TextLayerBuilder._bindEvents: `this.cancel()` should ' + 'have been called when the page was reset, or rendering cancelled.'); |
| 10611 |
return; |
| 10612 |
} |
| 10613 |
for (var name in _boundEvents) { |
| 10614 |
eventBus.off(name.toLowerCase(), _boundEvents[name]); |
| 10615 |
delete _boundEvents[name]; |
| 10616 |
} |
| 10617 |
}; |
| 10618 |
_boundEvents.updateTextLayerMatches = function (evt) { |
| 10619 |
if (evt.pageIndex !== _this2.pageIdx && evt.pageIndex !== -1) { |
| 10620 |
return; |
| 10621 |
} |
| 10622 |
_this2.updateMatches(); |
| 10623 |
}; |
| 10624 |
eventBus.on('pagecancelled', _boundEvents.pageCancelled); |
| 10625 |
eventBus.on('updatetextlayermatches', _boundEvents.updateTextLayerMatches); |
| 10626 |
} |
| 10627 |
}, { |
| 10628 |
key: '_bindMouse', |
| 10629 |
value: function _bindMouse() { |
| 10630 |
var _this3 = this; |
| 10631 |
|
| 10632 |
var div = this.textLayerDiv; |
| 10633 |
var expandDivsTimer = null; |
| 10634 |
div.addEventListener('mousedown', function (evt) { |
| 10635 |
if (_this3.enhanceTextSelection && _this3.textLayerRenderTask) { |
| 10636 |
_this3.textLayerRenderTask.expandTextDivs(true); |
| 10637 |
if (expandDivsTimer) { |
| 10638 |
clearTimeout(expandDivsTimer); |
| 10639 |
expandDivsTimer = null; |
| 10640 |
} |
| 10641 |
return; |
| 10642 |
} |
| 10643 |
var end = div.querySelector('.endOfContent'); |
| 10644 |
if (!end) { |
| 10645 |
return; |
| 10646 |
} |
| 10647 |
var adjustTop = evt.target !== div; |
| 10648 |
adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none'; |
| 10649 |
if (adjustTop) { |
| 10650 |
var divBounds = div.getBoundingClientRect(); |
| 10651 |
var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height); |
| 10652 |
end.style.top = (r * 100).toFixed(2) + '%'; |
| 10653 |
} |
| 10654 |
end.classList.add('active'); |
| 10655 |
}); |
| 10656 |
div.addEventListener('mouseup', function () { |
| 10657 |
if (_this3.enhanceTextSelection && _this3.textLayerRenderTask) { |
| 10658 |
expandDivsTimer = setTimeout(function () { |
| 10659 |
if (_this3.textLayerRenderTask) { |
| 10660 |
_this3.textLayerRenderTask.expandTextDivs(false); |
| 10661 |
} |
| 10662 |
expandDivsTimer = null; |
| 10663 |
}, EXPAND_DIVS_TIMEOUT); |
| 10664 |
return; |
| 10665 |
} |
| 10666 |
var end = div.querySelector('.endOfContent'); |
| 10667 |
if (!end) { |
| 10668 |
return; |
| 10669 |
} |
| 10670 |
end.style.top = ''; |
| 10671 |
end.classList.remove('active'); |
| 10672 |
}); |
| 10673 |
} |
| 10674 |
}]); |
| 10675 |
|
| 10676 |
return TextLayerBuilder; |
| 10677 |
}(); |
| 10678 |
|
| 10679 |
var DefaultTextLayerFactory = function () { |
| 10680 |
function DefaultTextLayerFactory() { |
| 10681 |
_classCallCheck(this, DefaultTextLayerFactory); |
| 10682 |
} |
| 10683 |
|
| 10684 |
_createClass(DefaultTextLayerFactory, [{ |
| 10685 |
key: 'createTextLayerBuilder', |
| 10686 |
value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) { |
| 10687 |
var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; |
| 10688 |
|
| 10689 |
return new TextLayerBuilder({ |
| 10690 |
textLayerDiv: textLayerDiv, |
| 10691 |
pageIndex: pageIndex, |
| 10692 |
viewport: viewport, |
| 10693 |
enhanceTextSelection: enhanceTextSelection |
| 10694 |
}); |
| 10695 |
} |
| 10696 |
}]); |
| 10697 |
|
| 10698 |
return DefaultTextLayerFactory; |
| 10699 |
}(); |
| 10700 |
|
| 10701 |
exports.TextLayerBuilder = TextLayerBuilder; |
| 10702 |
exports.DefaultTextLayerFactory = DefaultTextLayerFactory; |
| 10703 |
|
| 10704 |
/***/ }), |
| 10705 |
/* 34 */ |
| 10706 |
/***/ (function(module, exports, __webpack_require__) { |
| 10707 |
|
| 10708 |
"use strict"; |
| 10709 |
|
| 10710 |
|
| 10711 |
Object.defineProperty(exports, "__esModule", { |
| 10712 |
value: true |
| 10713 |
}); |
| 10714 |
exports.SecondaryToolbar = undefined; |
| 10715 |
|
| 10716 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 10717 |
|
| 10718 |
var _base_viewer = __webpack_require__(30); |
| 10719 |
|
| 10720 |
var _pdf_cursor_tools = __webpack_require__(8); |
| 10721 |
|
| 10722 |
var _pdf_single_page_viewer = __webpack_require__(35); |
| 10723 |
|
| 10724 |
var _ui_utils = __webpack_require__(6); |
| 10725 |
|
| 10726 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 10727 |
|
| 10728 |
var SecondaryToolbar = function () { |
| 10729 |
function SecondaryToolbar(options, mainContainer, eventBus) { |
| 10730 |
var _this = this; |
| 10731 |
|
| 10732 |
_classCallCheck(this, SecondaryToolbar); |
| 10733 |
|
| 10734 |
this.toolbar = options.toolbar; |
| 10735 |
this.toggleButton = options.toggleButton; |
| 10736 |
this.toolbarButtonContainer = options.toolbarButtonContainer; |
| 10737 |
this.buttons = [{ |
| 10738 |
element: options.presentationModeButton, |
| 10739 |
eventName: 'presentationmode', |
| 10740 |
close: true |
| 10741 |
}, { |
| 10742 |
element: options.openFileButton, |
| 10743 |
eventName: 'openfile', |
| 10744 |
close: true |
| 10745 |
}, { |
| 10746 |
element: options.printButton, |
| 10747 |
eventName: 'print', |
| 10748 |
close: true |
| 10749 |
}, { |
| 10750 |
element: options.downloadButton, |
| 10751 |
eventName: 'download', |
| 10752 |
close: true |
| 10753 |
}, { |
| 10754 |
element: options.viewBookmarkButton, |
| 10755 |
eventName: null, |
| 10756 |
close: true |
| 10757 |
}, { |
| 10758 |
element: options.firstPageButton, |
| 10759 |
eventName: 'firstpage', |
| 10760 |
close: true |
| 10761 |
}, { |
| 10762 |
element: options.lastPageButton, |
| 10763 |
eventName: 'lastpage', |
| 10764 |
close: true |
| 10765 |
}, { |
| 10766 |
element: options.pageRotateCwButton, |
| 10767 |
eventName: 'rotatecw', |
| 10768 |
close: false |
| 10769 |
}, { |
| 10770 |
element: options.pageRotateCcwButton, |
| 10771 |
eventName: 'rotateccw', |
| 10772 |
close: false |
| 10773 |
}, { |
| 10774 |
element: options.cursorSelectToolButton, |
| 10775 |
eventName: 'switchcursortool', |
| 10776 |
eventDetails: { tool: _pdf_cursor_tools.CursorTool.SELECT }, |
| 10777 |
close: true |
| 10778 |
}, { |
| 10779 |
element: options.cursorHandToolButton, |
| 10780 |
eventName: 'switchcursortool', |
| 10781 |
eventDetails: { tool: _pdf_cursor_tools.CursorTool.HAND }, |
| 10782 |
close: true |
| 10783 |
}, { |
| 10784 |
element: options.scrollVerticalButton, |
| 10785 |
eventName: 'switchscrollmode', |
| 10786 |
eventDetails: { mode: _base_viewer.ScrollMode.VERTICAL }, |
| 10787 |
close: true |
| 10788 |
}, { |
| 10789 |
element: options.scrollHorizontalButton, |
| 10790 |
eventName: 'switchscrollmode', |
| 10791 |
eventDetails: { mode: _base_viewer.ScrollMode.HORIZONTAL }, |
| 10792 |
close: true |
| 10793 |
}, { |
| 10794 |
element: options.scrollWrappedButton, |
| 10795 |
eventName: 'switchscrollmode', |
| 10796 |
eventDetails: { mode: _base_viewer.ScrollMode.WRAPPED }, |
| 10797 |
close: true |
| 10798 |
}, { |
| 10799 |
element: options.spreadNoneButton, |
| 10800 |
eventName: 'switchspreadmode', |
| 10801 |
eventDetails: { mode: _base_viewer.SpreadMode.NONE }, |
| 10802 |
close: true |
| 10803 |
}, { |
| 10804 |
element: options.spreadOddButton, |
| 10805 |
eventName: 'switchspreadmode', |
| 10806 |
eventDetails: { mode: _base_viewer.SpreadMode.ODD }, |
| 10807 |
close: true |
| 10808 |
}, { |
| 10809 |
element: options.spreadEvenButton, |
| 10810 |
eventName: 'switchspreadmode', |
| 10811 |
eventDetails: { mode: _base_viewer.SpreadMode.EVEN }, |
| 10812 |
close: true |
| 10813 |
}, { |
| 10814 |
element: options.documentPropertiesButton, |
| 10815 |
eventName: 'documentproperties', |
| 10816 |
close: true |
| 10817 |
}]; |
| 10818 |
this.items = { |
| 10819 |
firstPage: options.firstPageButton, |
| 10820 |
lastPage: options.lastPageButton, |
| 10821 |
pageRotateCw: options.pageRotateCwButton, |
| 10822 |
pageRotateCcw: options.pageRotateCcwButton |
| 10823 |
}; |
| 10824 |
this.mainContainer = mainContainer; |
| 10825 |
this.eventBus = eventBus; |
| 10826 |
this.opened = false; |
| 10827 |
this.containerHeight = null; |
| 10828 |
this.previousContainerHeight = null; |
| 10829 |
this.reset(); |
| 10830 |
this._bindClickListeners(); |
| 10831 |
this._bindCursorToolsListener(options); |
| 10832 |
this._bindScrollModeListener(options); |
| 10833 |
this._bindSpreadModeListener(options); |
| 10834 |
this.eventBus.on('resize', this._setMaxHeight.bind(this)); |
| 10835 |
this.eventBus.on('baseviewerinit', function (evt) { |
| 10836 |
if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) { |
| 10837 |
_this.toolbarButtonContainer.classList.add('hiddenScrollModeButtons', 'hiddenSpreadModeButtons'); |
| 10838 |
} else { |
| 10839 |
_this.toolbarButtonContainer.classList.remove('hiddenScrollModeButtons', 'hiddenSpreadModeButtons'); |
| 10840 |
} |
| 10841 |
}); |
| 10842 |
} |
| 10843 |
|
| 10844 |
_createClass(SecondaryToolbar, [{ |
| 10845 |
key: 'setPageNumber', |
| 10846 |
value: function setPageNumber(pageNumber) { |
| 10847 |
this.pageNumber = pageNumber; |
| 10848 |
this._updateUIState(); |
| 10849 |
} |
| 10850 |
}, { |
| 10851 |
key: 'setPagesCount', |
| 10852 |
value: function setPagesCount(pagesCount) { |
| 10853 |
this.pagesCount = pagesCount; |
| 10854 |
this._updateUIState(); |
| 10855 |
} |
| 10856 |
}, { |
| 10857 |
key: 'reset', |
| 10858 |
value: function reset() { |
| 10859 |
this.pageNumber = 0; |
| 10860 |
this.pagesCount = 0; |
| 10861 |
this._updateUIState(); |
| 10862 |
this.eventBus.dispatch('secondarytoolbarreset', { source: this }); |
| 10863 |
} |
| 10864 |
}, { |
| 10865 |
key: '_updateUIState', |
| 10866 |
value: function _updateUIState() { |
| 10867 |
this.items.firstPage.disabled = this.pageNumber <= 1; |
| 10868 |
this.items.lastPage.disabled = this.pageNumber >= this.pagesCount; |
| 10869 |
this.items.pageRotateCw.disabled = this.pagesCount === 0; |
| 10870 |
this.items.pageRotateCcw.disabled = this.pagesCount === 0; |
| 10871 |
} |
| 10872 |
}, { |
| 10873 |
key: '_bindClickListeners', |
| 10874 |
value: function _bindClickListeners() { |
| 10875 |
var _this2 = this; |
| 10876 |
|
| 10877 |
this.toggleButton.addEventListener('click', this.toggle.bind(this)); |
| 10878 |
|
| 10879 |
var _loop = function _loop(button) { |
| 10880 |
var _buttons$button = _this2.buttons[button], |
| 10881 |
element = _buttons$button.element, |
| 10882 |
eventName = _buttons$button.eventName, |
| 10883 |
close = _buttons$button.close, |
| 10884 |
eventDetails = _buttons$button.eventDetails; |
| 10885 |
|
| 10886 |
element.addEventListener('click', function (evt) { |
| 10887 |
if (eventName !== null) { |
| 10888 |
var details = { source: _this2 }; |
| 10889 |
for (var property in eventDetails) { |
| 10890 |
details[property] = eventDetails[property]; |
| 10891 |
} |
| 10892 |
_this2.eventBus.dispatch(eventName, details); |
| 10893 |
} |
| 10894 |
if (close) { |
| 10895 |
_this2.close(); |
| 10896 |
} |
| 10897 |
}); |
| 10898 |
}; |
| 10899 |
|
| 10900 |
for (var button in this.buttons) { |
| 10901 |
_loop(button); |
| 10902 |
} |
| 10903 |
} |
| 10904 |
}, { |
| 10905 |
key: '_bindCursorToolsListener', |
| 10906 |
value: function _bindCursorToolsListener(buttons) { |
| 10907 |
this.eventBus.on('cursortoolchanged', function (evt) { |
| 10908 |
buttons.cursorSelectToolButton.classList.remove('toggled'); |
| 10909 |
buttons.cursorHandToolButton.classList.remove('toggled'); |
| 10910 |
switch (evt.tool) { |
| 10911 |
case _pdf_cursor_tools.CursorTool.SELECT: |
| 10912 |
buttons.cursorSelectToolButton.classList.add('toggled'); |
| 10913 |
break; |
| 10914 |
case _pdf_cursor_tools.CursorTool.HAND: |
| 10915 |
buttons.cursorHandToolButton.classList.add('toggled'); |
| 10916 |
break; |
| 10917 |
} |
| 10918 |
}); |
| 10919 |
} |
| 10920 |
}, { |
| 10921 |
key: '_bindScrollModeListener', |
| 10922 |
value: function _bindScrollModeListener(buttons) { |
| 10923 |
var _this3 = this; |
| 10924 |
|
| 10925 |
function scrollModeChanged(evt) { |
| 10926 |
buttons.scrollVerticalButton.classList.remove('toggled'); |
| 10927 |
buttons.scrollHorizontalButton.classList.remove('toggled'); |
| 10928 |
buttons.scrollWrappedButton.classList.remove('toggled'); |
| 10929 |
switch (evt.mode) { |
| 10930 |
case _base_viewer.ScrollMode.VERTICAL: |
| 10931 |
buttons.scrollVerticalButton.classList.add('toggled'); |
| 10932 |
break; |
| 10933 |
case _base_viewer.ScrollMode.HORIZONTAL: |
| 10934 |
buttons.scrollHorizontalButton.classList.add('toggled'); |
| 10935 |
break; |
| 10936 |
case _base_viewer.ScrollMode.WRAPPED: |
| 10937 |
buttons.scrollWrappedButton.classList.add('toggled'); |
| 10938 |
break; |
| 10939 |
} |
| 10940 |
var isScrollModeHorizontal = evt.mode === _base_viewer.ScrollMode.HORIZONTAL; |
| 10941 |
buttons.spreadNoneButton.disabled = isScrollModeHorizontal; |
| 10942 |
buttons.spreadOddButton.disabled = isScrollModeHorizontal; |
| 10943 |
buttons.spreadEvenButton.disabled = isScrollModeHorizontal; |
| 10944 |
} |
| 10945 |
this.eventBus.on('scrollmodechanged', scrollModeChanged); |
| 10946 |
this.eventBus.on('secondarytoolbarreset', function (evt) { |
| 10947 |
if (evt.source === _this3) { |
| 10948 |
scrollModeChanged({ mode: _base_viewer.ScrollMode.VERTICAL }); |
| 10949 |
} |
| 10950 |
}); |
| 10951 |
} |
| 10952 |
}, { |
| 10953 |
key: '_bindSpreadModeListener', |
| 10954 |
value: function _bindSpreadModeListener(buttons) { |
| 10955 |
var _this4 = this; |
| 10956 |
|
| 10957 |
function spreadModeChanged(evt) { |
| 10958 |
buttons.spreadNoneButton.classList.remove('toggled'); |
| 10959 |
buttons.spreadOddButton.classList.remove('toggled'); |
| 10960 |
buttons.spreadEvenButton.classList.remove('toggled'); |
| 10961 |
switch (evt.mode) { |
| 10962 |
case _base_viewer.SpreadMode.NONE: |
| 10963 |
buttons.spreadNoneButton.classList.add('toggled'); |
| 10964 |
break; |
| 10965 |
case _base_viewer.SpreadMode.ODD: |
| 10966 |
buttons.spreadOddButton.classList.add('toggled'); |
| 10967 |
break; |
| 10968 |
case _base_viewer.SpreadMode.EVEN: |
| 10969 |
buttons.spreadEvenButton.classList.add('toggled'); |
| 10970 |
break; |
| 10971 |
} |
| 10972 |
} |
| 10973 |
this.eventBus.on('spreadmodechanged', spreadModeChanged); |
| 10974 |
this.eventBus.on('secondarytoolbarreset', function (evt) { |
| 10975 |
if (evt.source === _this4) { |
| 10976 |
spreadModeChanged({ mode: _base_viewer.SpreadMode.NONE }); |
| 10977 |
} |
| 10978 |
}); |
| 10979 |
} |
| 10980 |
}, { |
| 10981 |
key: 'open', |
| 10982 |
value: function open() { |
| 10983 |
if (this.opened) { |
| 10984 |
return; |
| 10985 |
} |
| 10986 |
this.opened = true; |
| 10987 |
this._setMaxHeight(); |
| 10988 |
this.toggleButton.classList.add('toggled'); |
| 10989 |
this.toolbar.classList.remove('hidden'); |
| 10990 |
} |
| 10991 |
}, { |
| 10992 |
key: 'close', |
| 10993 |
value: function close() { |
| 10994 |
if (!this.opened) { |
| 10995 |
return; |
| 10996 |
} |
| 10997 |
this.opened = false; |
| 10998 |
this.toolbar.classList.add('hidden'); |
| 10999 |
this.toggleButton.classList.remove('toggled'); |
| 11000 |
} |
| 11001 |
}, { |
| 11002 |
key: 'toggle', |
| 11003 |
value: function toggle() { |
| 11004 |
if (this.opened) { |
| 11005 |
this.close(); |
| 11006 |
} else { |
| 11007 |
this.open(); |
| 11008 |
} |
| 11009 |
} |
| 11010 |
}, { |
| 11011 |
key: '_setMaxHeight', |
| 11012 |
value: function _setMaxHeight() { |
| 11013 |
if (!this.opened) { |
| 11014 |
return; |
| 11015 |
} |
| 11016 |
this.containerHeight = this.mainContainer.clientHeight; |
| 11017 |
if (this.containerHeight === this.previousContainerHeight) { |
| 11018 |
return; |
| 11019 |
} |
| 11020 |
this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this.containerHeight - _ui_utils.SCROLLBAR_PADDING) + 'px;'); |
| 11021 |
this.previousContainerHeight = this.containerHeight; |
| 11022 |
} |
| 11023 |
}, { |
| 11024 |
key: 'isOpen', |
| 11025 |
get: function get() { |
| 11026 |
return this.opened; |
| 11027 |
} |
| 11028 |
}]); |
| 11029 |
|
| 11030 |
return SecondaryToolbar; |
| 11031 |
}(); |
| 11032 |
|
| 11033 |
exports.SecondaryToolbar = SecondaryToolbar; |
| 11034 |
|
| 11035 |
/***/ }), |
| 11036 |
/* 35 */ |
| 11037 |
/***/ (function(module, exports, __webpack_require__) { |
| 11038 |
|
| 11039 |
"use strict"; |
| 11040 |
|
| 11041 |
|
| 11042 |
Object.defineProperty(exports, "__esModule", { |
| 11043 |
value: true |
| 11044 |
}); |
| 11045 |
exports.PDFSinglePageViewer = undefined; |
| 11046 |
|
| 11047 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 11048 |
|
| 11049 |
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; |
| 11050 |
|
| 11051 |
var _base_viewer = __webpack_require__(30); |
| 11052 |
|
| 11053 |
var _ui_utils = __webpack_require__(6); |
| 11054 |
|
| 11055 |
var _pdfjsLib = __webpack_require__(7); |
| 11056 |
|
| 11057 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 11058 |
|
| 11059 |
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } |
| 11060 |
|
| 11061 |
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
| 11062 |
|
| 11063 |
var PDFSinglePageViewer = function (_BaseViewer) { |
| 11064 |
_inherits(PDFSinglePageViewer, _BaseViewer); |
| 11065 |
|
| 11066 |
function PDFSinglePageViewer(options) { |
| 11067 |
_classCallCheck(this, PDFSinglePageViewer); |
| 11068 |
|
| 11069 |
var _this = _possibleConstructorReturn(this, (PDFSinglePageViewer.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer)).call(this, options)); |
| 11070 |
|
| 11071 |
_this.eventBus.on('pagesinit', function (evt) { |
| 11072 |
_this._ensurePageViewVisible(); |
| 11073 |
}); |
| 11074 |
return _this; |
| 11075 |
} |
| 11076 |
|
| 11077 |
_createClass(PDFSinglePageViewer, [{ |
| 11078 |
key: '_resetView', |
| 11079 |
value: function _resetView() { |
| 11080 |
_get(PDFSinglePageViewer.prototype.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer.prototype), '_resetView', this).call(this); |
| 11081 |
this._previousPageNumber = 1; |
| 11082 |
this._shadowViewer = document.createDocumentFragment(); |
| 11083 |
} |
| 11084 |
}, { |
| 11085 |
key: '_ensurePageViewVisible', |
| 11086 |
value: function _ensurePageViewVisible() { |
| 11087 |
var pageView = this._pages[this._currentPageNumber - 1]; |
| 11088 |
var previousPageView = this._pages[this._previousPageNumber - 1]; |
| 11089 |
var viewerNodes = this.viewer.childNodes; |
| 11090 |
switch (viewerNodes.length) { |
| 11091 |
case 0: |
| 11092 |
this.viewer.appendChild(pageView.div); |
| 11093 |
break; |
| 11094 |
case 1: |
| 11095 |
if (viewerNodes[0] !== previousPageView.div) { |
| 11096 |
throw new Error('_ensurePageViewVisible: Unexpected previously visible page.'); |
| 11097 |
} |
| 11098 |
if (pageView === previousPageView) { |
| 11099 |
break; |
| 11100 |
} |
| 11101 |
this._shadowViewer.appendChild(previousPageView.div); |
| 11102 |
this.viewer.appendChild(pageView.div); |
| 11103 |
this.container.scrollTop = 0; |
| 11104 |
break; |
| 11105 |
default: |
| 11106 |
throw new Error('_ensurePageViewVisible: Only one page should be visible at a time.'); |
| 11107 |
} |
| 11108 |
this._previousPageNumber = this._currentPageNumber; |
| 11109 |
} |
| 11110 |
}, { |
| 11111 |
key: '_scrollUpdate', |
| 11112 |
value: function _scrollUpdate() { |
| 11113 |
if (this._updateScrollDown) { |
| 11114 |
this._updateScrollDown(); |
| 11115 |
} |
| 11116 |
_get(PDFSinglePageViewer.prototype.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer.prototype), '_scrollUpdate', this).call(this); |
| 11117 |
} |
| 11118 |
}, { |
| 11119 |
key: '_scrollIntoView', |
| 11120 |
value: function _scrollIntoView(_ref) { |
| 11121 |
var _this2 = this; |
| 11122 |
|
| 11123 |
var pageDiv = _ref.pageDiv, |
| 11124 |
_ref$pageSpot = _ref.pageSpot, |
| 11125 |
pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot, |
| 11126 |
_ref$pageNumber = _ref.pageNumber, |
| 11127 |
pageNumber = _ref$pageNumber === undefined ? null : _ref$pageNumber; |
| 11128 |
|
| 11129 |
if (pageNumber) { |
| 11130 |
this._setCurrentPageNumber(pageNumber); |
| 11131 |
} |
| 11132 |
var scrolledDown = this._currentPageNumber >= this._previousPageNumber; |
| 11133 |
var previousLocation = this._location; |
| 11134 |
this._ensurePageViewVisible(); |
| 11135 |
(0, _ui_utils.scrollIntoView)(pageDiv, pageSpot); |
| 11136 |
this._updateScrollDown = function () { |
| 11137 |
_this2.scroll.down = scrolledDown; |
| 11138 |
delete _this2._updateScrollDown; |
| 11139 |
}; |
| 11140 |
setTimeout(function () { |
| 11141 |
if (_this2._location === previousLocation) { |
| 11142 |
if (_this2._updateScrollDown) { |
| 11143 |
_this2._updateScrollDown(); |
| 11144 |
} |
| 11145 |
_this2.update(); |
| 11146 |
} |
| 11147 |
}, 0); |
| 11148 |
} |
| 11149 |
}, { |
| 11150 |
key: '_getVisiblePages', |
| 11151 |
value: function _getVisiblePages() { |
| 11152 |
if (!this.pagesCount) { |
| 11153 |
return { views: [] }; |
| 11154 |
} |
| 11155 |
var pageView = this._pages[this._currentPageNumber - 1]; |
| 11156 |
var element = pageView.div; |
| 11157 |
var view = { |
| 11158 |
id: pageView.id, |
| 11159 |
x: element.offsetLeft + element.clientLeft, |
| 11160 |
y: element.offsetTop + element.clientTop, |
| 11161 |
view: pageView |
| 11162 |
}; |
| 11163 |
return { |
| 11164 |
first: view, |
| 11165 |
last: view, |
| 11166 |
views: [view] |
| 11167 |
}; |
| 11168 |
} |
| 11169 |
}, { |
| 11170 |
key: 'update', |
| 11171 |
value: function update() { |
| 11172 |
var visible = this._getVisiblePages(); |
| 11173 |
var visiblePages = visible.views, |
| 11174 |
numVisiblePages = visiblePages.length; |
| 11175 |
if (numVisiblePages === 0) { |
| 11176 |
return; |
| 11177 |
} |
| 11178 |
this._resizeBuffer(numVisiblePages); |
| 11179 |
this.renderingQueue.renderHighestPriority(visible); |
| 11180 |
this._updateLocation(visible.first); |
| 11181 |
this.eventBus.dispatch('updateviewarea', { |
| 11182 |
source: this, |
| 11183 |
location: this._location |
| 11184 |
}); |
| 11185 |
} |
| 11186 |
}, { |
| 11187 |
key: '_updateScrollMode', |
| 11188 |
value: function _updateScrollMode() {} |
| 11189 |
}, { |
| 11190 |
key: '_updateSpreadMode', |
| 11191 |
value: function _updateSpreadMode() {} |
| 11192 |
}, { |
| 11193 |
key: '_setDocumentViewerElement', |
| 11194 |
get: function get() { |
| 11195 |
return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this._shadowViewer); |
| 11196 |
} |
| 11197 |
}, { |
| 11198 |
key: '_isScrollModeHorizontal', |
| 11199 |
get: function get() { |
| 11200 |
return (0, _pdfjsLib.shadow)(this, '_isScrollModeHorizontal', false); |
| 11201 |
} |
| 11202 |
}]); |
| 11203 |
|
| 11204 |
return PDFSinglePageViewer; |
| 11205 |
}(_base_viewer.BaseViewer); |
| 11206 |
|
| 11207 |
exports.PDFSinglePageViewer = PDFSinglePageViewer; |
| 11208 |
|
| 11209 |
/***/ }), |
| 11210 |
/* 36 */ |
| 11211 |
/***/ (function(module, exports, __webpack_require__) { |
| 11212 |
|
| 11213 |
"use strict"; |
| 11214 |
|
| 11215 |
|
| 11216 |
Object.defineProperty(exports, "__esModule", { |
| 11217 |
value: true |
| 11218 |
}); |
| 11219 |
exports.Toolbar = undefined; |
| 11220 |
|
| 11221 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 11222 |
|
| 11223 |
var _ui_utils = __webpack_require__(6); |
| 11224 |
|
| 11225 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 11226 |
|
| 11227 |
var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading'; |
| 11228 |
var SCALE_SELECT_CONTAINER_PADDING = 8; |
| 11229 |
var SCALE_SELECT_PADDING = 22; |
| 11230 |
|
| 11231 |
var Toolbar = function () { |
| 11232 |
function Toolbar(options, eventBus) { |
| 11233 |
var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n; |
| 11234 |
|
| 11235 |
_classCallCheck(this, Toolbar); |
| 11236 |
|
| 11237 |
this.toolbar = options.container; |
| 11238 |
this.eventBus = eventBus; |
| 11239 |
this.l10n = l10n; |
| 11240 |
this.items = options; |
| 11241 |
this._wasLocalized = false; |
| 11242 |
this.reset(); |
| 11243 |
this._bindListeners(); |
| 11244 |
} |
| 11245 |
|
| 11246 |
_createClass(Toolbar, [{ |
| 11247 |
key: 'setPageNumber', |
| 11248 |
value: function setPageNumber(pageNumber, pageLabel) { |
| 11249 |
this.pageNumber = pageNumber; |
| 11250 |
this.pageLabel = pageLabel; |
| 11251 |
this._updateUIState(false); |
| 11252 |
} |
| 11253 |
}, { |
| 11254 |
key: 'setPagesCount', |
| 11255 |
value: function setPagesCount(pagesCount, hasPageLabels) { |
| 11256 |
this.pagesCount = pagesCount; |
| 11257 |
this.hasPageLabels = hasPageLabels; |
| 11258 |
this._updateUIState(true); |
| 11259 |
} |
| 11260 |
}, { |
| 11261 |
key: 'setPageScale', |
| 11262 |
value: function setPageScale(pageScaleValue, pageScale) { |
| 11263 |
this.pageScaleValue = (pageScaleValue || pageScale).toString(); |
| 11264 |
this.pageScale = pageScale; |
| 11265 |
this._updateUIState(false); |
| 11266 |
} |
| 11267 |
}, { |
| 11268 |
key: 'reset', |
| 11269 |
value: function reset() { |
| 11270 |
this.pageNumber = 0; |
| 11271 |
this.pageLabel = null; |
| 11272 |
this.hasPageLabels = false; |
| 11273 |
this.pagesCount = 0; |
| 11274 |
this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE; |
| 11275 |
this.pageScale = _ui_utils.DEFAULT_SCALE; |
| 11276 |
this._updateUIState(true); |
| 11277 |
} |
| 11278 |
}, { |
| 11279 |
key: '_bindListeners', |
| 11280 |
value: function _bindListeners() { |
| 11281 |
var _this = this; |
| 11282 |
|
| 11283 |
var eventBus = this.eventBus, |
| 11284 |
items = this.items; |
| 11285 |
|
| 11286 |
var self = this; |
| 11287 |
items.previous.addEventListener('click', function () { |
| 11288 |
eventBus.dispatch('previouspage', { source: self }); |
| 11289 |
}); |
| 11290 |
items.next.addEventListener('click', function () { |
| 11291 |
eventBus.dispatch('nextpage', { source: self }); |
| 11292 |
}); |
| 11293 |
items.zoomIn.addEventListener('click', function () { |
| 11294 |
eventBus.dispatch('zoomin', { source: self }); |
| 11295 |
}); |
| 11296 |
items.zoomOut.addEventListener('click', function () { |
| 11297 |
eventBus.dispatch('zoomout', { source: self }); |
| 11298 |
}); |
| 11299 |
items.pageNumber.addEventListener('click', function () { |
| 11300 |
this.select(); |
| 11301 |
}); |
| 11302 |
items.pageNumber.addEventListener('change', function () { |
| 11303 |
eventBus.dispatch('pagenumberchanged', { |
| 11304 |
source: self, |
| 11305 |
value: this.value |
| 11306 |
}); |
| 11307 |
}); |
| 11308 |
items.scaleSelect.addEventListener('change', function () { |
| 11309 |
if (this.value === 'custom') { |
| 11310 |
return; |
| 11311 |
} |
| 11312 |
eventBus.dispatch('scalechanged', { |
| 11313 |
source: self, |
| 11314 |
value: this.value |
| 11315 |
}); |
| 11316 |
}); |
| 11317 |
items.presentationModeButton.addEventListener('click', function () { |
| 11318 |
eventBus.dispatch('presentationmode', { source: self }); |
| 11319 |
}); |
| 11320 |
items.openFile.addEventListener('click', function () { |
| 11321 |
eventBus.dispatch('openfile', { source: self }); |
| 11322 |
}); |
| 11323 |
items.print.addEventListener('click', function () { |
| 11324 |
eventBus.dispatch('print', { source: self }); |
| 11325 |
}); |
| 11326 |
items.download.addEventListener('click', function () { |
| 11327 |
eventBus.dispatch('download', { source: self }); |
| 11328 |
}); |
| 11329 |
items.scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler; |
| 11330 |
eventBus.on('localized', function () { |
| 11331 |
_this._localized(); |
| 11332 |
}); |
| 11333 |
} |
| 11334 |
}, { |
| 11335 |
key: '_localized', |
| 11336 |
value: function _localized() { |
| 11337 |
this._wasLocalized = true; |
| 11338 |
this._adjustScaleWidth(); |
| 11339 |
this._updateUIState(true); |
| 11340 |
} |
| 11341 |
}, { |
| 11342 |
key: '_updateUIState', |
| 11343 |
value: function _updateUIState() { |
| 11344 |
var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
| 11345 |
|
| 11346 |
if (!this._wasLocalized) { |
| 11347 |
return; |
| 11348 |
} |
| 11349 |
var pageNumber = this.pageNumber, |
| 11350 |
pagesCount = this.pagesCount, |
| 11351 |
pageScaleValue = this.pageScaleValue, |
| 11352 |
pageScale = this.pageScale, |
| 11353 |
items = this.items; |
| 11354 |
|
| 11355 |
if (resetNumPages) { |
| 11356 |
if (this.hasPageLabels) { |
| 11357 |
items.pageNumber.type = 'text'; |
| 11358 |
} else { |
| 11359 |
items.pageNumber.type = 'number'; |
| 11360 |
this.l10n.get('of_pages', { pagesCount: pagesCount }, 'of {{pagesCount}}').then(function (msg) { |
| 11361 |
items.numPages.textContent = msg; |
| 11362 |
}); |
| 11363 |
} |
| 11364 |
items.pageNumber.max = pagesCount; |
| 11365 |
} |
| 11366 |
if (this.hasPageLabels) { |
| 11367 |
items.pageNumber.value = this.pageLabel; |
| 11368 |
this.l10n.get('page_of_pages', { |
| 11369 |
pageNumber: pageNumber, |
| 11370 |
pagesCount: pagesCount |
| 11371 |
}, '({{pageNumber}} of {{pagesCount}})').then(function (msg) { |
| 11372 |
items.numPages.textContent = msg; |
| 11373 |
}); |
| 11374 |
} else { |
| 11375 |
items.pageNumber.value = pageNumber; |
| 11376 |
} |
| 11377 |
items.previous.disabled = pageNumber <= 1; |
| 11378 |
items.next.disabled = pageNumber >= pagesCount; |
| 11379 |
items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE; |
| 11380 |
items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE; |
| 11381 |
var customScale = Math.round(pageScale * 10000) / 100; |
| 11382 |
this.l10n.get('page_scale_percent', { scale: customScale }, '{{scale}}%').then(function (msg) { |
| 11383 |
var options = items.scaleSelect.options; |
| 11384 |
var predefinedValueFound = false; |
| 11385 |
for (var i = 0, ii = options.length; i < ii; i++) { |
| 11386 |
var option = options[i]; |
| 11387 |
if (option.value !== pageScaleValue) { |
| 11388 |
option.selected = false; |
| 11389 |
continue; |
| 11390 |
} |
| 11391 |
option.selected = true; |
| 11392 |
predefinedValueFound = true; |
| 11393 |
} |
| 11394 |
if (!predefinedValueFound) { |
| 11395 |
items.customScaleOption.textContent = msg; |
| 11396 |
items.customScaleOption.selected = true; |
| 11397 |
} |
| 11398 |
}); |
| 11399 |
} |
| 11400 |
}, { |
| 11401 |
key: 'updateLoadingIndicatorState', |
| 11402 |
value: function updateLoadingIndicatorState() { |
| 11403 |
var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
| 11404 |
|
| 11405 |
var pageNumberInput = this.items.pageNumber; |
| 11406 |
pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading); |
| 11407 |
} |
| 11408 |
}, { |
| 11409 |
key: '_adjustScaleWidth', |
| 11410 |
value: function _adjustScaleWidth() { |
| 11411 |
var container = this.items.scaleSelectContainer; |
| 11412 |
var select = this.items.scaleSelect; |
| 11413 |
_ui_utils.animationStarted.then(function () { |
| 11414 |
if (container.clientWidth === 0) { |
| 11415 |
container.setAttribute('style', 'display: inherit;'); |
| 11416 |
} |
| 11417 |
if (container.clientWidth > 0) { |
| 11418 |
select.setAttribute('style', 'min-width: inherit;'); |
| 11419 |
var width = select.clientWidth + SCALE_SELECT_CONTAINER_PADDING; |
| 11420 |
select.setAttribute('style', 'min-width: ' + (width + SCALE_SELECT_PADDING) + 'px;'); |
| 11421 |
container.setAttribute('style', 'min-width: ' + width + 'px; ' + 'max-width: ' + width + 'px;'); |
| 11422 |
} |
| 11423 |
}); |
| 11424 |
} |
| 11425 |
}]); |
| 11426 |
|
| 11427 |
return Toolbar; |
| 11428 |
}(); |
| 11429 |
|
| 11430 |
exports.Toolbar = Toolbar; |
| 11431 |
|
| 11432 |
/***/ }), |
| 11433 |
/* 37 */ |
| 11434 |
/***/ (function(module, exports, __webpack_require__) { |
| 11435 |
|
| 11436 |
"use strict"; |
| 11437 |
|
| 11438 |
|
| 11439 |
Object.defineProperty(exports, "__esModule", { |
| 11440 |
value: true |
| 11441 |
}); |
| 11442 |
exports.ViewHistory = undefined; |
| 11443 |
|
| 11444 |
var _regenerator = __webpack_require__(2); |
| 11445 |
|
| 11446 |
var _regenerator2 = _interopRequireDefault(_regenerator); |
| 11447 |
|
| 11448 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 11449 |
|
| 11450 |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
| 11451 |
|
| 11452 |
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } |
| 11453 |
|
| 11454 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 11455 |
|
| 11456 |
var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20; |
| 11457 |
|
| 11458 |
var ViewHistory = function () { |
| 11459 |
function ViewHistory(fingerprint) { |
| 11460 |
var _this = this; |
| 11461 |
|
| 11462 |
var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE; |
| 11463 |
|
| 11464 |
_classCallCheck(this, ViewHistory); |
| 11465 |
|
| 11466 |
this.fingerprint = fingerprint; |
| 11467 |
this.cacheSize = cacheSize; |
| 11468 |
this._initializedPromise = this._readFromStorage().then(function (databaseStr) { |
| 11469 |
var database = JSON.parse(databaseStr || '{}'); |
| 11470 |
if (!('files' in database)) { |
| 11471 |
database.files = []; |
| 11472 |
} else { |
| 11473 |
while (database.files.length >= _this.cacheSize) { |
| 11474 |
database.files.shift(); |
| 11475 |
} |
| 11476 |
} |
| 11477 |
var index = -1; |
| 11478 |
for (var i = 0, length = database.files.length; i < length; i++) { |
| 11479 |
var branch = database.files[i]; |
| 11480 |
if (branch.fingerprint === _this.fingerprint) { |
| 11481 |
index = i; |
| 11482 |
break; |
| 11483 |
} |
| 11484 |
} |
| 11485 |
if (index === -1) { |
| 11486 |
index = database.files.push({ fingerprint: _this.fingerprint }) - 1; |
| 11487 |
} |
| 11488 |
_this.file = database.files[index]; |
| 11489 |
_this.database = database; |
| 11490 |
}); |
| 11491 |
} |
| 11492 |
|
| 11493 |
_createClass(ViewHistory, [{ |
| 11494 |
key: '_writeToStorage', |
| 11495 |
value: function () { |
| 11496 |
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() { |
| 11497 |
var databaseStr; |
| 11498 |
return _regenerator2.default.wrap(function _callee$(_context) { |
| 11499 |
while (1) { |
| 11500 |
switch (_context.prev = _context.next) { |
| 11501 |
case 0: |
| 11502 |
databaseStr = JSON.stringify(this.database); |
| 11503 |
|
| 11504 |
localStorage.setItem('pdfjs.history', databaseStr); |
| 11505 |
|
| 11506 |
case 2: |
| 11507 |
case 'end': |
| 11508 |
return _context.stop(); |
| 11509 |
} |
| 11510 |
} |
| 11511 |
}, _callee, this); |
| 11512 |
})); |
| 11513 |
|
| 11514 |
function _writeToStorage() { |
| 11515 |
return _ref.apply(this, arguments); |
| 11516 |
} |
| 11517 |
|
| 11518 |
return _writeToStorage; |
| 11519 |
}() |
| 11520 |
}, { |
| 11521 |
key: '_readFromStorage', |
| 11522 |
value: function () { |
| 11523 |
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() { |
| 11524 |
return _regenerator2.default.wrap(function _callee2$(_context2) { |
| 11525 |
while (1) { |
| 11526 |
switch (_context2.prev = _context2.next) { |
| 11527 |
case 0: |
| 11528 |
return _context2.abrupt('return', localStorage.getItem('pdfjs.history')); |
| 11529 |
|
| 11530 |
case 1: |
| 11531 |
case 'end': |
| 11532 |
return _context2.stop(); |
| 11533 |
} |
| 11534 |
} |
| 11535 |
}, _callee2, this); |
| 11536 |
})); |
| 11537 |
|
| 11538 |
function _readFromStorage() { |
| 11539 |
return _ref2.apply(this, arguments); |
| 11540 |
} |
| 11541 |
|
| 11542 |
return _readFromStorage; |
| 11543 |
}() |
| 11544 |
}, { |
| 11545 |
key: 'set', |
| 11546 |
value: function () { |
| 11547 |
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3(name, val) { |
| 11548 |
return _regenerator2.default.wrap(function _callee3$(_context3) { |
| 11549 |
while (1) { |
| 11550 |
switch (_context3.prev = _context3.next) { |
| 11551 |
case 0: |
| 11552 |
_context3.next = 2; |
| 11553 |
return this._initializedPromise; |
| 11554 |
|
| 11555 |
case 2: |
| 11556 |
this.file[name] = val; |
| 11557 |
return _context3.abrupt('return', this._writeToStorage()); |
| 11558 |
|
| 11559 |
case 4: |
| 11560 |
case 'end': |
| 11561 |
return _context3.stop(); |
| 11562 |
} |
| 11563 |
} |
| 11564 |
}, _callee3, this); |
| 11565 |
})); |
| 11566 |
|
| 11567 |
function set(_x2, _x3) { |
| 11568 |
return _ref3.apply(this, arguments); |
| 11569 |
} |
| 11570 |
|
| 11571 |
return set; |
| 11572 |
}() |
| 11573 |
}, { |
| 11574 |
key: 'setMultiple', |
| 11575 |
value: function () { |
| 11576 |
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4(properties) { |
| 11577 |
var name; |
| 11578 |
return _regenerator2.default.wrap(function _callee4$(_context4) { |
| 11579 |
while (1) { |
| 11580 |
switch (_context4.prev = _context4.next) { |
| 11581 |
case 0: |
| 11582 |
_context4.next = 2; |
| 11583 |
return this._initializedPromise; |
| 11584 |
|
| 11585 |
case 2: |
| 11586 |
for (name in properties) { |
| 11587 |
this.file[name] = properties[name]; |
| 11588 |
} |
| 11589 |
return _context4.abrupt('return', this._writeToStorage()); |
| 11590 |
|
| 11591 |
case 4: |
| 11592 |
case 'end': |
| 11593 |
return _context4.stop(); |
| 11594 |
} |
| 11595 |
} |
| 11596 |
}, _callee4, this); |
| 11597 |
})); |
| 11598 |
|
| 11599 |
function setMultiple(_x4) { |
| 11600 |
return _ref4.apply(this, arguments); |
| 11601 |
} |
| 11602 |
|
| 11603 |
return setMultiple; |
| 11604 |
}() |
| 11605 |
}, { |
| 11606 |
key: 'get', |
| 11607 |
value: function () { |
| 11608 |
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee5(name, defaultValue) { |
| 11609 |
var val; |
| 11610 |
return _regenerator2.default.wrap(function _callee5$(_context5) { |
| 11611 |
while (1) { |
| 11612 |
switch (_context5.prev = _context5.next) { |
| 11613 |
case 0: |
| 11614 |
_context5.next = 2; |
| 11615 |
return this._initializedPromise; |
| 11616 |
|
| 11617 |
case 2: |
| 11618 |
val = this.file[name]; |
| 11619 |
return _context5.abrupt('return', val !== undefined ? val : defaultValue); |
| 11620 |
|
| 11621 |
case 4: |
| 11622 |
case 'end': |
| 11623 |
return _context5.stop(); |
| 11624 |
} |
| 11625 |
} |
| 11626 |
}, _callee5, this); |
| 11627 |
})); |
| 11628 |
|
| 11629 |
function get(_x5, _x6) { |
| 11630 |
return _ref5.apply(this, arguments); |
| 11631 |
} |
| 11632 |
|
| 11633 |
return get; |
| 11634 |
}() |
| 11635 |
}, { |
| 11636 |
key: 'getMultiple', |
| 11637 |
value: function () { |
| 11638 |
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee6(properties) { |
| 11639 |
var values, name, val; |
| 11640 |
return _regenerator2.default.wrap(function _callee6$(_context6) { |
| 11641 |
while (1) { |
| 11642 |
switch (_context6.prev = _context6.next) { |
| 11643 |
case 0: |
| 11644 |
_context6.next = 2; |
| 11645 |
return this._initializedPromise; |
| 11646 |
|
| 11647 |
case 2: |
| 11648 |
values = Object.create(null); |
| 11649 |
|
| 11650 |
for (name in properties) { |
| 11651 |
val = this.file[name]; |
| 11652 |
|
| 11653 |
values[name] = val !== undefined ? val : properties[name]; |
| 11654 |
} |
| 11655 |
return _context6.abrupt('return', values); |
| 11656 |
|
| 11657 |
case 5: |
| 11658 |
case 'end': |
| 11659 |
return _context6.stop(); |
| 11660 |
} |
| 11661 |
} |
| 11662 |
}, _callee6, this); |
| 11663 |
})); |
| 11664 |
|
| 11665 |
function getMultiple(_x7) { |
| 11666 |
return _ref6.apply(this, arguments); |
| 11667 |
} |
| 11668 |
|
| 11669 |
return getMultiple; |
| 11670 |
}() |
| 11671 |
}]); |
| 11672 |
|
| 11673 |
return ViewHistory; |
| 11674 |
}(); |
| 11675 |
|
| 11676 |
exports.ViewHistory = ViewHistory; |
| 11677 |
|
| 11678 |
/***/ }), |
| 11679 |
/* 38 */ |
| 11680 |
/***/ (function(module, exports, __webpack_require__) { |
| 11681 |
|
| 11682 |
"use strict"; |
| 11683 |
|
| 11684 |
|
| 11685 |
Object.defineProperty(exports, "__esModule", { |
| 11686 |
value: true |
| 11687 |
}); |
| 11688 |
exports.GenericCom = undefined; |
| 11689 |
|
| 11690 |
var _regenerator = __webpack_require__(2); |
| 11691 |
|
| 11692 |
var _regenerator2 = _interopRequireDefault(_regenerator); |
| 11693 |
|
| 11694 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 11695 |
|
| 11696 |
var _app = __webpack_require__(1); |
| 11697 |
|
| 11698 |
var _preferences = __webpack_require__(39); |
| 11699 |
|
| 11700 |
var _download_manager = __webpack_require__(40); |
| 11701 |
|
| 11702 |
var _genericl10n = __webpack_require__(41); |
| 11703 |
|
| 11704 |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
| 11705 |
|
| 11706 |
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } |
| 11707 |
|
| 11708 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 11709 |
|
| 11710 |
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } |
| 11711 |
|
| 11712 |
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
| 11713 |
|
| 11714 |
; |
| 11715 |
var GenericCom = {}; |
| 11716 |
|
| 11717 |
var GenericPreferences = function (_BasePreferences) { |
| 11718 |
_inherits(GenericPreferences, _BasePreferences); |
| 11719 |
|
| 11720 |
function GenericPreferences() { |
| 11721 |
_classCallCheck(this, GenericPreferences); |
| 11722 |
|
| 11723 |
return _possibleConstructorReturn(this, (GenericPreferences.__proto__ || Object.getPrototypeOf(GenericPreferences)).apply(this, arguments)); |
| 11724 |
} |
| 11725 |
|
| 11726 |
_createClass(GenericPreferences, [{ |
| 11727 |
key: '_writeToStorage', |
| 11728 |
value: function () { |
| 11729 |
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(prefObj) { |
| 11730 |
return _regenerator2.default.wrap(function _callee$(_context) { |
| 11731 |
while (1) { |
| 11732 |
switch (_context.prev = _context.next) { |
| 11733 |
case 0: |
| 11734 |
localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj)); |
| 11735 |
|
| 11736 |
case 1: |
| 11737 |
case 'end': |
| 11738 |
return _context.stop(); |
| 11739 |
} |
| 11740 |
} |
| 11741 |
}, _callee, this); |
| 11742 |
})); |
| 11743 |
|
| 11744 |
function _writeToStorage(_x) { |
| 11745 |
return _ref.apply(this, arguments); |
| 11746 |
} |
| 11747 |
|
| 11748 |
return _writeToStorage; |
| 11749 |
}() |
| 11750 |
}, { |
| 11751 |
key: '_readFromStorage', |
| 11752 |
value: function () { |
| 11753 |
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2(prefObj) { |
| 11754 |
return _regenerator2.default.wrap(function _callee2$(_context2) { |
| 11755 |
while (1) { |
| 11756 |
switch (_context2.prev = _context2.next) { |
| 11757 |
case 0: |
| 11758 |
return _context2.abrupt('return', JSON.parse(localStorage.getItem('pdfjs.preferences'))); |
| 11759 |
|
| 11760 |
case 1: |
| 11761 |
case 'end': |
| 11762 |
return _context2.stop(); |
| 11763 |
} |
| 11764 |
} |
| 11765 |
}, _callee2, this); |
| 11766 |
})); |
| 11767 |
|
| 11768 |
function _readFromStorage(_x2) { |
| 11769 |
return _ref2.apply(this, arguments); |
| 11770 |
} |
| 11771 |
|
| 11772 |
return _readFromStorage; |
| 11773 |
}() |
| 11774 |
}]); |
| 11775 |
|
| 11776 |
return GenericPreferences; |
| 11777 |
}(_preferences.BasePreferences); |
| 11778 |
|
| 11779 |
var GenericExternalServices = Object.create(_app.DefaultExternalServices); |
| 11780 |
GenericExternalServices.createDownloadManager = function (options) { |
| 11781 |
return new _download_manager.DownloadManager(options); |
| 11782 |
}; |
| 11783 |
GenericExternalServices.createPreferences = function () { |
| 11784 |
return new GenericPreferences(); |
| 11785 |
}; |
| 11786 |
GenericExternalServices.createL10n = function (_ref3) { |
| 11787 |
var _ref3$locale = _ref3.locale, |
| 11788 |
locale = _ref3$locale === undefined ? 'en-US' : _ref3$locale; |
| 11789 |
|
| 11790 |
return new _genericl10n.GenericL10n(locale); |
| 11791 |
}; |
| 11792 |
_app.PDFViewerApplication.externalServices = GenericExternalServices; |
| 11793 |
exports.GenericCom = GenericCom; |
| 11794 |
|
| 11795 |
/***/ }), |
| 11796 |
/* 39 */ |
| 11797 |
/***/ (function(module, exports, __webpack_require__) { |
| 11798 |
|
| 11799 |
"use strict"; |
| 11800 |
|
| 11801 |
|
| 11802 |
Object.defineProperty(exports, "__esModule", { |
| 11803 |
value: true |
| 11804 |
}); |
| 11805 |
exports.BasePreferences = undefined; |
| 11806 |
|
| 11807 |
var _regenerator = __webpack_require__(2); |
| 11808 |
|
| 11809 |
var _regenerator2 = _interopRequireDefault(_regenerator); |
| 11810 |
|
| 11811 |
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; |
| 11812 |
|
| 11813 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 11814 |
|
| 11815 |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
| 11816 |
|
| 11817 |
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } |
| 11818 |
|
| 11819 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 11820 |
|
| 11821 |
var defaultPreferences = null; |
| 11822 |
function getDefaultPreferences() { |
| 11823 |
if (!defaultPreferences) { |
| 11824 |
defaultPreferences = Promise.resolve({ |
| 11825 |
"showPreviousViewOnLoad": true, |
| 11826 |
"defaultZoomValue": "", |
| 11827 |
"sidebarViewOnLoad": 0, |
| 11828 |
"cursorToolOnLoad": 0, |
| 11829 |
"enableWebGL": false, |
| 11830 |
"eventBusDispatchToDOM": false, |
| 11831 |
"pdfBugEnabled": false, |
| 11832 |
"disableRange": false, |
| 11833 |
"disableStream": false, |
| 11834 |
"disableAutoFetch": false, |
| 11835 |
"disableFontFace": false, |
| 11836 |
"textLayerMode": 1, |
| 11837 |
"useOnlyCssZoom": false, |
| 11838 |
"externalLinkTarget": 0, |
| 11839 |
"renderer": "canvas", |
| 11840 |
"renderInteractiveForms": false, |
| 11841 |
"enablePrintAutoRotate": false, |
| 11842 |
"disablePageMode": false, |
| 11843 |
"disablePageLabels": false, |
| 11844 |
"scrollModeOnLoad": 0, |
| 11845 |
"spreadModeOnLoad": 0 |
| 11846 |
}); |
| 11847 |
} |
| 11848 |
return defaultPreferences; |
| 11849 |
} |
| 11850 |
|
| 11851 |
var BasePreferences = function () { |
| 11852 |
function BasePreferences() { |
| 11853 |
var _this = this; |
| 11854 |
|
| 11855 |
_classCallCheck(this, BasePreferences); |
| 11856 |
|
| 11857 |
if (this.constructor === BasePreferences) { |
| 11858 |
throw new Error('Cannot initialize BasePreferences.'); |
| 11859 |
} |
| 11860 |
this.prefs = null; |
| 11861 |
this._initializedPromise = getDefaultPreferences().then(function (defaults) { |
| 11862 |
Object.defineProperty(_this, 'defaults', { |
| 11863 |
value: Object.freeze(defaults), |
| 11864 |
writable: false, |
| 11865 |
enumerable: true, |
| 11866 |
configurable: false |
| 11867 |
}); |
| 11868 |
_this.prefs = Object.assign(Object.create(null), defaults); |
| 11869 |
return _this._readFromStorage(defaults); |
| 11870 |
}).then(function (prefs) { |
| 11871 |
if (!prefs) { |
| 11872 |
return; |
| 11873 |
} |
| 11874 |
for (var name in prefs) { |
| 11875 |
var defaultValue = _this.defaults[name], |
| 11876 |
prefValue = prefs[name]; |
| 11877 |
if (defaultValue === undefined || (typeof prefValue === "undefined" ? "undefined" : _typeof(prefValue)) !== (typeof defaultValue === "undefined" ? "undefined" : _typeof(defaultValue))) { |
| 11878 |
continue; |
| 11879 |
} |
| 11880 |
_this.prefs[name] = prefValue; |
| 11881 |
} |
| 11882 |
}); |
| 11883 |
} |
| 11884 |
|
| 11885 |
_createClass(BasePreferences, [{ |
| 11886 |
key: "_writeToStorage", |
| 11887 |
value: function () { |
| 11888 |
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(prefObj) { |
| 11889 |
return _regenerator2.default.wrap(function _callee$(_context) { |
| 11890 |
while (1) { |
| 11891 |
switch (_context.prev = _context.next) { |
| 11892 |
case 0: |
| 11893 |
throw new Error('Not implemented: _writeToStorage'); |
| 11894 |
|
| 11895 |
case 1: |
| 11896 |
case "end": |
| 11897 |
return _context.stop(); |
| 11898 |
} |
| 11899 |
} |
| 11900 |
}, _callee, this); |
| 11901 |
})); |
| 11902 |
|
| 11903 |
function _writeToStorage(_x) { |
| 11904 |
return _ref.apply(this, arguments); |
| 11905 |
} |
| 11906 |
|
| 11907 |
return _writeToStorage; |
| 11908 |
}() |
| 11909 |
}, { |
| 11910 |
key: "_readFromStorage", |
| 11911 |
value: function () { |
| 11912 |
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2(prefObj) { |
| 11913 |
return _regenerator2.default.wrap(function _callee2$(_context2) { |
| 11914 |
while (1) { |
| 11915 |
switch (_context2.prev = _context2.next) { |
| 11916 |
case 0: |
| 11917 |
throw new Error('Not implemented: _readFromStorage'); |
| 11918 |
|
| 11919 |
case 1: |
| 11920 |
case "end": |
| 11921 |
return _context2.stop(); |
| 11922 |
} |
| 11923 |
} |
| 11924 |
}, _callee2, this); |
| 11925 |
})); |
| 11926 |
|
| 11927 |
function _readFromStorage(_x2) { |
| 11928 |
return _ref2.apply(this, arguments); |
| 11929 |
} |
| 11930 |
|
| 11931 |
return _readFromStorage; |
| 11932 |
}() |
| 11933 |
}, { |
| 11934 |
key: "reset", |
| 11935 |
value: function () { |
| 11936 |
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3() { |
| 11937 |
return _regenerator2.default.wrap(function _callee3$(_context3) { |
| 11938 |
while (1) { |
| 11939 |
switch (_context3.prev = _context3.next) { |
| 11940 |
case 0: |
| 11941 |
_context3.next = 2; |
| 11942 |
return this._initializedPromise; |
| 11943 |
|
| 11944 |
case 2: |
| 11945 |
this.prefs = Object.assign(Object.create(null), this.defaults); |
| 11946 |
return _context3.abrupt("return", this._writeToStorage(this.defaults)); |
| 11947 |
|
| 11948 |
case 4: |
| 11949 |
case "end": |
| 11950 |
return _context3.stop(); |
| 11951 |
} |
| 11952 |
} |
| 11953 |
}, _callee3, this); |
| 11954 |
})); |
| 11955 |
|
| 11956 |
function reset() { |
| 11957 |
return _ref3.apply(this, arguments); |
| 11958 |
} |
| 11959 |
|
| 11960 |
return reset; |
| 11961 |
}() |
| 11962 |
}, { |
| 11963 |
key: "set", |
| 11964 |
value: function () { |
| 11965 |
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4(name, value) { |
| 11966 |
var defaultValue, valueType, defaultType; |
| 11967 |
return _regenerator2.default.wrap(function _callee4$(_context4) { |
| 11968 |
while (1) { |
| 11969 |
switch (_context4.prev = _context4.next) { |
| 11970 |
case 0: |
| 11971 |
_context4.next = 2; |
| 11972 |
return this._initializedPromise; |
| 11973 |
|
| 11974 |
case 2: |
| 11975 |
defaultValue = this.defaults[name]; |
| 11976 |
|
| 11977 |
if (!(defaultValue === undefined)) { |
| 11978 |
_context4.next = 7; |
| 11979 |
break; |
| 11980 |
} |
| 11981 |
|
| 11982 |
throw new Error("Set preference: \"" + name + "\" is undefined."); |
| 11983 |
|
| 11984 |
case 7: |
| 11985 |
if (!(value === undefined)) { |
| 11986 |
_context4.next = 9; |
| 11987 |
break; |
| 11988 |
} |
| 11989 |
|
| 11990 |
throw new Error('Set preference: no value is specified.'); |
| 11991 |
|
| 11992 |
case 9: |
| 11993 |
valueType = typeof value === "undefined" ? "undefined" : _typeof(value); |
| 11994 |
defaultType = typeof defaultValue === "undefined" ? "undefined" : _typeof(defaultValue); |
| 11995 |
|
| 11996 |
if (!(valueType !== defaultType)) { |
| 11997 |
_context4.next = 19; |
| 11998 |
break; |
| 11999 |
} |
| 12000 |
|
| 12001 |
if (!(valueType === 'number' && defaultType === 'string')) { |
| 12002 |
_context4.next = 16; |
| 12003 |
break; |
| 12004 |
} |
| 12005 |
|
| 12006 |
value = value.toString(); |
| 12007 |
_context4.next = 17; |
| 12008 |
break; |
| 12009 |
|
| 12010 |
case 16: |
| 12011 |
throw new Error("Set preference: \"" + value + "\" is a " + valueType + ", " + ("expected a " + defaultType + ".")); |
| 12012 |
|
| 12013 |
case 17: |
| 12014 |
_context4.next = 21; |
| 12015 |
break; |
| 12016 |
|
| 12017 |
case 19: |
| 12018 |
if (!(valueType === 'number' && !Number.isInteger(value))) { |
| 12019 |
_context4.next = 21; |
| 12020 |
break; |
| 12021 |
} |
| 12022 |
|
| 12023 |
throw new Error("Set preference: \"" + value + "\" must be an integer."); |
| 12024 |
|
| 12025 |
case 21: |
| 12026 |
this.prefs[name] = value; |
| 12027 |
return _context4.abrupt("return", this._writeToStorage(this.prefs)); |
| 12028 |
|
| 12029 |
case 23: |
| 12030 |
case "end": |
| 12031 |
return _context4.stop(); |
| 12032 |
} |
| 12033 |
} |
| 12034 |
}, _callee4, this); |
| 12035 |
})); |
| 12036 |
|
| 12037 |
function set(_x3, _x4) { |
| 12038 |
return _ref4.apply(this, arguments); |
| 12039 |
} |
| 12040 |
|
| 12041 |
return set; |
| 12042 |
}() |
| 12043 |
}, { |
| 12044 |
key: "get", |
| 12045 |
value: function () { |
| 12046 |
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee5(name) { |
| 12047 |
var defaultValue, prefValue; |
| 12048 |
return _regenerator2.default.wrap(function _callee5$(_context5) { |
| 12049 |
while (1) { |
| 12050 |
switch (_context5.prev = _context5.next) { |
| 12051 |
case 0: |
| 12052 |
_context5.next = 2; |
| 12053 |
return this._initializedPromise; |
| 12054 |
|
| 12055 |
case 2: |
| 12056 |
defaultValue = this.defaults[name]; |
| 12057 |
|
| 12058 |
if (!(defaultValue === undefined)) { |
| 12059 |
_context5.next = 7; |
| 12060 |
break; |
| 12061 |
} |
| 12062 |
|
| 12063 |
throw new Error("Get preference: \"" + name + "\" is undefined."); |
| 12064 |
|
| 12065 |
case 7: |
| 12066 |
prefValue = this.prefs[name]; |
| 12067 |
|
| 12068 |
if (!(prefValue !== undefined)) { |
| 12069 |
_context5.next = 10; |
| 12070 |
break; |
| 12071 |
} |
| 12072 |
|
| 12073 |
return _context5.abrupt("return", prefValue); |
| 12074 |
|
| 12075 |
case 10: |
| 12076 |
return _context5.abrupt("return", defaultValue); |
| 12077 |
|
| 12078 |
case 11: |
| 12079 |
case "end": |
| 12080 |
return _context5.stop(); |
| 12081 |
} |
| 12082 |
} |
| 12083 |
}, _callee5, this); |
| 12084 |
})); |
| 12085 |
|
| 12086 |
function get(_x5) { |
| 12087 |
return _ref5.apply(this, arguments); |
| 12088 |
} |
| 12089 |
|
| 12090 |
return get; |
| 12091 |
}() |
| 12092 |
}, { |
| 12093 |
key: "getAll", |
| 12094 |
value: function () { |
| 12095 |
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee6() { |
| 12096 |
return _regenerator2.default.wrap(function _callee6$(_context6) { |
| 12097 |
while (1) { |
| 12098 |
switch (_context6.prev = _context6.next) { |
| 12099 |
case 0: |
| 12100 |
_context6.next = 2; |
| 12101 |
return this._initializedPromise; |
| 12102 |
|
| 12103 |
case 2: |
| 12104 |
return _context6.abrupt("return", Object.assign(Object.create(null), this.defaults, this.prefs)); |
| 12105 |
|
| 12106 |
case 3: |
| 12107 |
case "end": |
| 12108 |
return _context6.stop(); |
| 12109 |
} |
| 12110 |
} |
| 12111 |
}, _callee6, this); |
| 12112 |
})); |
| 12113 |
|
| 12114 |
function getAll() { |
| 12115 |
return _ref6.apply(this, arguments); |
| 12116 |
} |
| 12117 |
|
| 12118 |
return getAll; |
| 12119 |
}() |
| 12120 |
}]); |
| 12121 |
|
| 12122 |
return BasePreferences; |
| 12123 |
}(); |
| 12124 |
|
| 12125 |
exports.BasePreferences = BasePreferences; |
| 12126 |
|
| 12127 |
/***/ }), |
| 12128 |
/* 40 */ |
| 12129 |
/***/ (function(module, exports, __webpack_require__) { |
| 12130 |
|
| 12131 |
"use strict"; |
| 12132 |
|
| 12133 |
|
| 12134 |
Object.defineProperty(exports, "__esModule", { |
| 12135 |
value: true |
| 12136 |
}); |
| 12137 |
exports.DownloadManager = undefined; |
| 12138 |
|
| 12139 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 12140 |
|
| 12141 |
var _pdfjsLib = __webpack_require__(7); |
| 12142 |
|
| 12143 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 12144 |
|
| 12145 |
; |
| 12146 |
var DISABLE_CREATE_OBJECT_URL = _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL || false; |
| 12147 |
function _download(blobUrl, filename) { |
| 12148 |
var a = document.createElement('a'); |
| 12149 |
if (!a.click) { |
| 12150 |
throw new Error('DownloadManager: "a.click()" is not supported.'); |
| 12151 |
} |
| 12152 |
a.href = blobUrl; |
| 12153 |
a.target = '_parent'; |
| 12154 |
if ('download' in a) { |
| 12155 |
a.download = filename; |
| 12156 |
} |
| 12157 |
(document.body || document.documentElement).appendChild(a); |
| 12158 |
a.click(); |
| 12159 |
a.remove(); |
| 12160 |
} |
| 12161 |
|
| 12162 |
var DownloadManager = function () { |
| 12163 |
function DownloadManager(_ref) { |
| 12164 |
var _ref$disableCreateObj = _ref.disableCreateObjectURL, |
| 12165 |
disableCreateObjectURL = _ref$disableCreateObj === undefined ? DISABLE_CREATE_OBJECT_URL : _ref$disableCreateObj; |
| 12166 |
|
| 12167 |
_classCallCheck(this, DownloadManager); |
| 12168 |
|
| 12169 |
this.disableCreateObjectURL = disableCreateObjectURL; |
| 12170 |
} |
| 12171 |
|
| 12172 |
_createClass(DownloadManager, [{ |
| 12173 |
key: 'downloadUrl', |
| 12174 |
value: function downloadUrl(url, filename) { |
| 12175 |
if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) { |
| 12176 |
return; |
| 12177 |
} |
| 12178 |
_download(url + '#pdfjs.action=download', filename); |
| 12179 |
} |
| 12180 |
}, { |
| 12181 |
key: 'downloadData', |
| 12182 |
value: function downloadData(data, filename, contentType) { |
| 12183 |
if (navigator.msSaveBlob) { |
| 12184 |
return navigator.msSaveBlob(new Blob([data], { type: contentType }), filename); |
| 12185 |
} |
| 12186 |
var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, this.disableCreateObjectURL); |
| 12187 |
_download(blobUrl, filename); |
| 12188 |
} |
| 12189 |
}, { |
| 12190 |
key: 'download', |
| 12191 |
value: function download(blob, url, filename) { |
| 12192 |
if (navigator.msSaveBlob) { |
| 12193 |
if (!navigator.msSaveBlob(blob, filename)) { |
| 12194 |
this.downloadUrl(url, filename); |
| 12195 |
} |
| 12196 |
return; |
| 12197 |
} |
| 12198 |
if (this.disableCreateObjectURL) { |
| 12199 |
this.downloadUrl(url, filename); |
| 12200 |
return; |
| 12201 |
} |
| 12202 |
var blobUrl = _pdfjsLib.URL.createObjectURL(blob); |
| 12203 |
_download(blobUrl, filename); |
| 12204 |
} |
| 12205 |
}]); |
| 12206 |
|
| 12207 |
return DownloadManager; |
| 12208 |
}(); |
| 12209 |
|
| 12210 |
exports.DownloadManager = DownloadManager; |
| 12211 |
|
| 12212 |
/***/ }), |
| 12213 |
/* 41 */ |
| 12214 |
/***/ (function(module, exports, __webpack_require__) { |
| 12215 |
|
| 12216 |
"use strict"; |
| 12217 |
|
| 12218 |
|
| 12219 |
Object.defineProperty(exports, "__esModule", { |
| 12220 |
value: true |
| 12221 |
}); |
| 12222 |
exports.GenericL10n = undefined; |
| 12223 |
|
| 12224 |
var _regenerator = __webpack_require__(2); |
| 12225 |
|
| 12226 |
var _regenerator2 = _interopRequireDefault(_regenerator); |
| 12227 |
|
| 12228 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
| 12229 |
|
| 12230 |
__webpack_require__(42); |
| 12231 |
|
| 12232 |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
| 12233 |
|
| 12234 |
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } |
| 12235 |
|
| 12236 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 12237 |
|
| 12238 |
var webL10n = document.webL10n; |
| 12239 |
|
| 12240 |
var GenericL10n = function () { |
| 12241 |
function GenericL10n(lang) { |
| 12242 |
_classCallCheck(this, GenericL10n); |
| 12243 |
|
| 12244 |
this._lang = lang; |
| 12245 |
this._ready = new Promise(function (resolve, reject) { |
| 12246 |
webL10n.setLanguage(lang, function () { |
| 12247 |
resolve(webL10n); |
| 12248 |
}); |
| 12249 |
}); |
| 12250 |
} |
| 12251 |
|
| 12252 |
_createClass(GenericL10n, [{ |
| 12253 |
key: 'getLanguage', |
| 12254 |
value: function () { |
| 12255 |
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() { |
| 12256 |
var l10n; |
| 12257 |
return _regenerator2.default.wrap(function _callee$(_context) { |
| 12258 |
while (1) { |
| 12259 |
switch (_context.prev = _context.next) { |
| 12260 |
case 0: |
| 12261 |
_context.next = 2; |
| 12262 |
return this._ready; |
| 12263 |
|
| 12264 |
case 2: |
| 12265 |
l10n = _context.sent; |
| 12266 |
return _context.abrupt('return', l10n.getLanguage()); |
| 12267 |
|
| 12268 |
case 4: |
| 12269 |
case 'end': |
| 12270 |
return _context.stop(); |
| 12271 |
} |
| 12272 |
} |
| 12273 |
}, _callee, this); |
| 12274 |
})); |
| 12275 |
|
| 12276 |
function getLanguage() { |
| 12277 |
return _ref.apply(this, arguments); |
| 12278 |
} |
| 12279 |
|
| 12280 |
return getLanguage; |
| 12281 |
}() |
| 12282 |
}, { |
| 12283 |
key: 'getDirection', |
| 12284 |
value: function () { |
| 12285 |
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() { |
| 12286 |
var l10n; |
| 12287 |
return _regenerator2.default.wrap(function _callee2$(_context2) { |
| 12288 |
while (1) { |
| 12289 |
switch (_context2.prev = _context2.next) { |
| 12290 |
case 0: |
| 12291 |
_context2.next = 2; |
| 12292 |
return this._ready; |
| 12293 |
|
| 12294 |
case 2: |
| 12295 |
l10n = _context2.sent; |
| 12296 |
return _context2.abrupt('return', l10n.getDirection()); |
| 12297 |
|
| 12298 |
case 4: |
| 12299 |
case 'end': |
| 12300 |
return _context2.stop(); |
| 12301 |
} |
| 12302 |
} |
| 12303 |
}, _callee2, this); |
| 12304 |
})); |
| 12305 |
|
| 12306 |
function getDirection() { |
| 12307 |
return _ref2.apply(this, arguments); |
| 12308 |
} |
| 12309 |
|
| 12310 |
return getDirection; |
| 12311 |
}() |
| 12312 |
}, { |
| 12313 |
key: 'get', |
| 12314 |
value: function () { |
| 12315 |
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3(property, args, fallback) { |
| 12316 |
var l10n; |
| 12317 |
return _regenerator2.default.wrap(function _callee3$(_context3) { |
| 12318 |
while (1) { |
| 12319 |
switch (_context3.prev = _context3.next) { |
| 12320 |
case 0: |
| 12321 |
_context3.next = 2; |
| 12322 |
return this._ready; |
| 12323 |
|
| 12324 |
case 2: |
| 12325 |
l10n = _context3.sent; |
| 12326 |
return _context3.abrupt('return', l10n.get(property, args, fallback)); |
| 12327 |
|
| 12328 |
case 4: |
| 12329 |
case 'end': |
| 12330 |
return _context3.stop(); |
| 12331 |
} |
| 12332 |
} |
| 12333 |
}, _callee3, this); |
| 12334 |
})); |
| 12335 |
|
| 12336 |
function get(_x, _x2, _x3) { |
| 12337 |
return _ref3.apply(this, arguments); |
| 12338 |
} |
| 12339 |
|
| 12340 |
return get; |
| 12341 |
}() |
| 12342 |
}, { |
| 12343 |
key: 'translate', |
| 12344 |
value: function () { |
| 12345 |
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4(element) { |
| 12346 |
var l10n; |
| 12347 |
return _regenerator2.default.wrap(function _callee4$(_context4) { |
| 12348 |
while (1) { |
| 12349 |
switch (_context4.prev = _context4.next) { |
| 12350 |
case 0: |
| 12351 |
_context4.next = 2; |
| 12352 |
return this._ready; |
| 12353 |
|
| 12354 |
case 2: |
| 12355 |
l10n = _context4.sent; |
| 12356 |
return _context4.abrupt('return', l10n.translate(element)); |
| 12357 |
|
| 12358 |
case 4: |
| 12359 |
case 'end': |
| 12360 |
return _context4.stop(); |
| 12361 |
} |
| 12362 |
} |
| 12363 |
}, _callee4, this); |
| 12364 |
})); |
| 12365 |
|
| 12366 |
function translate(_x4) { |
| 12367 |
return _ref4.apply(this, arguments); |
| 12368 |
} |
| 12369 |
|
| 12370 |
return translate; |
| 12371 |
}() |
| 12372 |
}]); |
| 12373 |
|
| 12374 |
return GenericL10n; |
| 12375 |
}(); |
| 12376 |
|
| 12377 |
exports.GenericL10n = GenericL10n; |
| 12378 |
|
| 12379 |
/***/ }), |
| 12380 |
/* 42 */ |
| 12381 |
/***/ (function(module, exports, __webpack_require__) { |
| 12382 |
|
| 12383 |
"use strict"; |
| 12384 |
|
| 12385 |
|
| 12386 |
document.webL10n = function (window, document, undefined) { |
| 12387 |
var gL10nData = {}; |
| 12388 |
var gTextData = ''; |
| 12389 |
var gTextProp = 'textContent'; |
| 12390 |
var gLanguage = ''; |
| 12391 |
var gMacros = {}; |
| 12392 |
var gReadyState = 'loading'; |
| 12393 |
var gAsyncResourceLoading = true; |
| 12394 |
function getL10nResourceLinks() { |
| 12395 |
return document.querySelectorAll('link[type="application/l10n"]'); |
| 12396 |
} |
| 12397 |
function getL10nDictionary() { |
| 12398 |
var script = document.querySelector('script[type="application/l10n"]'); |
| 12399 |
return script ? JSON.parse(script.innerHTML) : null; |
| 12400 |
} |
| 12401 |
function getTranslatableChildren(element) { |
| 12402 |
return element ? element.querySelectorAll('*[data-l10n-id]') : []; |
| 12403 |
} |
| 12404 |
function getL10nAttributes(element) { |
| 12405 |
if (!element) return {}; |
| 12406 |
var l10nId = element.getAttribute('data-l10n-id'); |
| 12407 |
var l10nArgs = element.getAttribute('data-l10n-args'); |
| 12408 |
var args = {}; |
| 12409 |
if (l10nArgs) { |
| 12410 |
try { |
| 12411 |
args = JSON.parse(l10nArgs); |
| 12412 |
} catch (e) { |
| 12413 |
console.warn('could not parse arguments for #' + l10nId); |
| 12414 |
} |
| 12415 |
} |
| 12416 |
return { |
| 12417 |
id: l10nId, |
| 12418 |
args: args |
| 12419 |
}; |
| 12420 |
} |
| 12421 |
function fireL10nReadyEvent(lang) { |
| 12422 |
var evtObject = document.createEvent('Event'); |
| 12423 |
evtObject.initEvent('localized', true, false); |
| 12424 |
evtObject.language = lang; |
| 12425 |
document.dispatchEvent(evtObject); |
| 12426 |
} |
| 12427 |
function xhrLoadText(url, onSuccess, onFailure) { |
| 12428 |
onSuccess = onSuccess || function _onSuccess(data) {}; |
| 12429 |
onFailure = onFailure || function _onFailure() {}; |
| 12430 |
var xhr = new XMLHttpRequest(); |
| 12431 |
xhr.open('GET', url, gAsyncResourceLoading); |
| 12432 |
if (xhr.overrideMimeType) { |
| 12433 |
xhr.overrideMimeType('text/plain; charset=utf-8'); |
| 12434 |
} |
| 12435 |
xhr.onreadystatechange = function () { |
| 12436 |
if (xhr.readyState == 4) { |
| 12437 |
if (xhr.status == 200 || xhr.status === 0) { |
| 12438 |
onSuccess(xhr.responseText); |
| 12439 |
} else { |
| 12440 |
onFailure(); |
| 12441 |
} |
| 12442 |
} |
| 12443 |
}; |
| 12444 |
xhr.onerror = onFailure; |
| 12445 |
xhr.ontimeout = onFailure; |
| 12446 |
try { |
| 12447 |
xhr.send(null); |
| 12448 |
} catch (e) { |
| 12449 |
onFailure(); |
| 12450 |
} |
| 12451 |
} |
| 12452 |
function parseResource(href, lang, successCallback, failureCallback) { |
| 12453 |
var baseURL = href.replace(/[^\/]*$/, '') || './'; |
| 12454 |
function evalString(text) { |
| 12455 |
if (text.lastIndexOf('\\') < 0) return text; |
| 12456 |
return text.replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\t/g, '\t').replace(/\\b/g, '\b').replace(/\\f/g, '\f').replace(/\\{/g, '{').replace(/\\}/g, '}').replace(/\\"/g, '"').replace(/\\'/g, "'"); |
| 12457 |
} |
| 12458 |
function parseProperties(text, parsedPropertiesCallback) { |
| 12459 |
var dictionary = {}; |
| 12460 |
var reBlank = /^\s*|\s*$/; |
| 12461 |
var reComment = /^\s*#|^\s*$/; |
| 12462 |
var reSection = /^\s*\[(.*)\]\s*$/; |
| 12463 |
var reImport = /^\s*@import\s+url\((.*)\)\s*$/i; |
| 12464 |
var reSplit = /^([^=\s]*)\s*=\s*(.+)$/; |
| 12465 |
function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) { |
| 12466 |
var entries = rawText.replace(reBlank, '').split(/[\r\n]+/); |
| 12467 |
var currentLang = '*'; |
| 12468 |
var genericLang = lang.split('-', 1)[0]; |
| 12469 |
var skipLang = false; |
| 12470 |
var match = ''; |
| 12471 |
function nextEntry() { |
| 12472 |
while (true) { |
| 12473 |
if (!entries.length) { |
| 12474 |
parsedRawLinesCallback(); |
| 12475 |
return; |
| 12476 |
} |
| 12477 |
var line = entries.shift(); |
| 12478 |
if (reComment.test(line)) continue; |
| 12479 |
if (extendedSyntax) { |
| 12480 |
match = reSection.exec(line); |
| 12481 |
if (match) { |
| 12482 |
currentLang = match[1].toLowerCase(); |
| 12483 |
skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang; |
| 12484 |
continue; |
| 12485 |
} else if (skipLang) { |
| 12486 |
continue; |
| 12487 |
} |
| 12488 |
match = reImport.exec(line); |
| 12489 |
if (match) { |
| 12490 |
loadImport(baseURL + match[1], nextEntry); |
| 12491 |
return; |
| 12492 |
} |
| 12493 |
} |
| 12494 |
var tmp = line.match(reSplit); |
| 12495 |
if (tmp && tmp.length == 3) { |
| 12496 |
dictionary[tmp[1]] = evalString(tmp[2]); |
| 12497 |
} |
| 12498 |
} |
| 12499 |
} |
| 12500 |
nextEntry(); |
| 12501 |
} |
| 12502 |
function loadImport(url, callback) { |
| 12503 |
xhrLoadText(url, function (content) { |
| 12504 |
parseRawLines(content, false, callback); |
| 12505 |
}, function () { |
| 12506 |
console.warn(url + ' not found.'); |
| 12507 |
callback(); |
| 12508 |
}); |
| 12509 |
} |
| 12510 |
parseRawLines(text, true, function () { |
| 12511 |
parsedPropertiesCallback(dictionary); |
| 12512 |
}); |
| 12513 |
} |
| 12514 |
xhrLoadText(href, function (response) { |
| 12515 |
gTextData += response; |
| 12516 |
parseProperties(response, function (data) { |
| 12517 |
for (var key in data) { |
| 12518 |
var id, |
| 12519 |
prop, |
| 12520 |
index = key.lastIndexOf('.'); |
| 12521 |
if (index > 0) { |
| 12522 |
id = key.substring(0, index); |
| 12523 |
prop = key.substring(index + 1); |
| 12524 |
} else { |
| 12525 |
id = key; |
| 12526 |
prop = gTextProp; |
| 12527 |
} |
| 12528 |
if (!gL10nData[id]) { |
| 12529 |
gL10nData[id] = {}; |
| 12530 |
} |
| 12531 |
gL10nData[id][prop] = data[key]; |
| 12532 |
} |
| 12533 |
if (successCallback) { |
| 12534 |
successCallback(); |
| 12535 |
} |
| 12536 |
}); |
| 12537 |
}, failureCallback); |
| 12538 |
} |
| 12539 |
function loadLocale(lang, callback) { |
| 12540 |
if (lang) { |
| 12541 |
lang = lang.toLowerCase(); |
| 12542 |
} |
| 12543 |
callback = callback || function _callback() {}; |
| 12544 |
clear(); |
| 12545 |
gLanguage = lang; |
| 12546 |
var langLinks = getL10nResourceLinks(); |
| 12547 |
var langCount = langLinks.length; |
| 12548 |
if (langCount === 0) { |
| 12549 |
var dict = getL10nDictionary(); |
| 12550 |
if (dict && dict.locales && dict.default_locale) { |
| 12551 |
console.log('using the embedded JSON directory, early way out'); |
| 12552 |
gL10nData = dict.locales[lang]; |
| 12553 |
if (!gL10nData) { |
| 12554 |
var defaultLocale = dict.default_locale.toLowerCase(); |
| 12555 |
for (var anyCaseLang in dict.locales) { |
| 12556 |
anyCaseLang = anyCaseLang.toLowerCase(); |
| 12557 |
if (anyCaseLang === lang) { |
| 12558 |
gL10nData = dict.locales[lang]; |
| 12559 |
break; |
| 12560 |
} else if (anyCaseLang === defaultLocale) { |
| 12561 |
gL10nData = dict.locales[defaultLocale]; |
| 12562 |
} |
| 12563 |
} |
| 12564 |
} |
| 12565 |
callback(); |
| 12566 |
} else { |
| 12567 |
console.log('no resource to load, early way out'); |
| 12568 |
} |
| 12569 |
fireL10nReadyEvent(lang); |
| 12570 |
gReadyState = 'complete'; |
| 12571 |
return; |
| 12572 |
} |
| 12573 |
var onResourceLoaded = null; |
| 12574 |
var gResourceCount = 0; |
| 12575 |
onResourceLoaded = function onResourceLoaded() { |
| 12576 |
gResourceCount++; |
| 12577 |
if (gResourceCount >= langCount) { |
| 12578 |
callback(); |
| 12579 |
fireL10nReadyEvent(lang); |
| 12580 |
gReadyState = 'complete'; |
| 12581 |
} |
| 12582 |
}; |
| 12583 |
function L10nResourceLink(link) { |
| 12584 |
var href = link.href; |
| 12585 |
this.load = function (lang, callback) { |
| 12586 |
parseResource(href, lang, callback, function () { |
| 12587 |
console.warn(href + ' not found.'); |
| 12588 |
console.warn('"' + lang + '" resource not found'); |
| 12589 |
gLanguage = ''; |
| 12590 |
callback(); |
| 12591 |
}); |
| 12592 |
}; |
| 12593 |
} |
| 12594 |
for (var i = 0; i < langCount; i++) { |
| 12595 |
var resource = new L10nResourceLink(langLinks[i]); |
| 12596 |
resource.load(lang, onResourceLoaded); |
| 12597 |
} |
| 12598 |
} |
| 12599 |
function clear() { |
| 12600 |
gL10nData = {}; |
| 12601 |
gTextData = ''; |
| 12602 |
gLanguage = ''; |
| 12603 |
} |
| 12604 |
function getPluralRules(lang) { |
| 12605 |
var locales2rules = { |
| 12606 |
'af': 3, |
| 12607 |
'ak': 4, |
| 12608 |
'am': 4, |
| 12609 |
'ar': 1, |
| 12610 |
'asa': 3, |
| 12611 |
'az': 0, |
| 12612 |
'be': 11, |
| 12613 |
'bem': 3, |
| 12614 |
'bez': 3, |
| 12615 |
'bg': 3, |
| 12616 |
'bh': 4, |
| 12617 |
'bm': 0, |
| 12618 |
'bn': 3, |
| 12619 |
'bo': 0, |
| 12620 |
'br': 20, |
| 12621 |
'brx': 3, |
| 12622 |
'bs': 11, |
| 12623 |
'ca': 3, |
| 12624 |
'cgg': 3, |
| 12625 |
'chr': 3, |
| 12626 |
'cs': 12, |
| 12627 |
'cy': 17, |
| 12628 |
'da': 3, |
| 12629 |
'de': 3, |
| 12630 |
'dv': 3, |
| 12631 |
'dz': 0, |
| 12632 |
'ee': 3, |
| 12633 |
'el': 3, |
| 12634 |
'en': 3, |
| 12635 |
'eo': 3, |
| 12636 |
'es': 3, |
| 12637 |
'et': 3, |
| 12638 |
'eu': 3, |
| 12639 |
'fa': 0, |
| 12640 |
'ff': 5, |
| 12641 |
'fi': 3, |
| 12642 |
'fil': 4, |
| 12643 |
'fo': 3, |
| 12644 |
'fr': 5, |
| 12645 |
'fur': 3, |
| 12646 |
'fy': 3, |
| 12647 |
'ga': 8, |
| 12648 |
'gd': 24, |
| 12649 |
'gl': 3, |
| 12650 |
'gsw': 3, |
| 12651 |
'gu': 3, |
| 12652 |
'guw': 4, |
| 12653 |
'gv': 23, |
| 12654 |
'ha': 3, |
| 12655 |
'haw': 3, |
| 12656 |
'he': 2, |
| 12657 |
'hi': 4, |
| 12658 |
'hr': 11, |
| 12659 |
'hu': 0, |
| 12660 |
'id': 0, |
| 12661 |
'ig': 0, |
| 12662 |
'ii': 0, |
| 12663 |
'is': 3, |
| 12664 |
'it': 3, |
| 12665 |
'iu': 7, |
| 12666 |
'ja': 0, |
| 12667 |
'jmc': 3, |
| 12668 |
'jv': 0, |
| 12669 |
'ka': 0, |
| 12670 |
'kab': 5, |
| 12671 |
'kaj': 3, |
| 12672 |
'kcg': 3, |
| 12673 |
'kde': 0, |
| 12674 |
'kea': 0, |
| 12675 |
'kk': 3, |
| 12676 |
'kl': 3, |
| 12677 |
'km': 0, |
| 12678 |
'kn': 0, |
| 12679 |
'ko': 0, |
| 12680 |
'ksb': 3, |
| 12681 |
'ksh': 21, |
| 12682 |
'ku': 3, |
| 12683 |
'kw': 7, |
| 12684 |
'lag': 18, |
| 12685 |
'lb': 3, |
| 12686 |
'lg': 3, |
| 12687 |
'ln': 4, |
| 12688 |
'lo': 0, |
| 12689 |
'lt': 10, |
| 12690 |
'lv': 6, |
| 12691 |
'mas': 3, |
| 12692 |
'mg': 4, |
| 12693 |
'mk': 16, |
| 12694 |
'ml': 3, |
| 12695 |
'mn': 3, |
| 12696 |
'mo': 9, |
| 12697 |
'mr': 3, |
| 12698 |
'ms': 0, |
| 12699 |
'mt': 15, |
| 12700 |
'my': 0, |
| 12701 |
'nah': 3, |
| 12702 |
'naq': 7, |
| 12703 |
'nb': 3, |
| 12704 |
'nd': 3, |
| 12705 |
'ne': 3, |
| 12706 |
'nl': 3, |
| 12707 |
'nn': 3, |
| 12708 |
'no': 3, |
| 12709 |
'nr': 3, |
| 12710 |
'nso': 4, |
| 12711 |
'ny': 3, |
| 12712 |
'nyn': 3, |
| 12713 |
'om': 3, |
| 12714 |
'or': 3, |
| 12715 |
'pa': 3, |
| 12716 |
'pap': 3, |
| 12717 |
'pl': 13, |
| 12718 |
'ps': 3, |
| 12719 |
'pt': 3, |
| 12720 |
'rm': 3, |
| 12721 |
'ro': 9, |
| 12722 |
'rof': 3, |
| 12723 |
'ru': 11, |
| 12724 |
'rwk': 3, |
| 12725 |
'sah': 0, |
| 12726 |
'saq': 3, |
| 12727 |
'se': 7, |
| 12728 |
'seh': 3, |
| 12729 |
'ses': 0, |
| 12730 |
'sg': 0, |
| 12731 |
'sh': 11, |
| 12732 |
'shi': 19, |
| 12733 |
'sk': 12, |
| 12734 |
'sl': 14, |
| 12735 |
'sma': 7, |
| 12736 |
'smi': 7, |
| 12737 |
'smj': 7, |
| 12738 |
'smn': 7, |
| 12739 |
'sms': 7, |
| 12740 |
'sn': 3, |
| 12741 |
'so': 3, |
| 12742 |
'sq': 3, |
| 12743 |
'sr': 11, |
| 12744 |
'ss': 3, |
| 12745 |
'ssy': 3, |
| 12746 |
'st': 3, |
| 12747 |
'sv': 3, |
| 12748 |
'sw': 3, |
| 12749 |
'syr': 3, |
| 12750 |
'ta': 3, |
| 12751 |
'te': 3, |
| 12752 |
'teo': 3, |
| 12753 |
'th': 0, |
| 12754 |
'ti': 4, |
| 12755 |
'tig': 3, |
| 12756 |
'tk': 3, |
| 12757 |
'tl': 4, |
| 12758 |
'tn': 3, |
| 12759 |
'to': 0, |
| 12760 |
'tr': 0, |
| 12761 |
'ts': 3, |
| 12762 |
'tzm': 22, |
| 12763 |
'uk': 11, |
| 12764 |
'ur': 3, |
| 12765 |
've': 3, |
| 12766 |
'vi': 0, |
| 12767 |
'vun': 3, |
| 12768 |
'wa': 4, |
| 12769 |
'wae': 3, |
| 12770 |
'wo': 0, |
| 12771 |
'xh': 3, |
| 12772 |
'xog': 3, |
| 12773 |
'yo': 0, |
| 12774 |
'zh': 0, |
| 12775 |
'zu': 3 |
| 12776 |
}; |
| 12777 |
function isIn(n, list) { |
| 12778 |
return list.indexOf(n) !== -1; |
| 12779 |
} |
| 12780 |
function isBetween(n, start, end) { |
| 12781 |
return start <= n && n <= end; |
| 12782 |
} |
| 12783 |
var pluralRules = { |
| 12784 |
'0': function _(n) { |
| 12785 |
return 'other'; |
| 12786 |
}, |
| 12787 |
'1': function _(n) { |
| 12788 |
if (isBetween(n % 100, 3, 10)) return 'few'; |
| 12789 |
if (n === 0) return 'zero'; |
| 12790 |
if (isBetween(n % 100, 11, 99)) return 'many'; |
| 12791 |
if (n == 2) return 'two'; |
| 12792 |
if (n == 1) return 'one'; |
| 12793 |
return 'other'; |
| 12794 |
}, |
| 12795 |
'2': function _(n) { |
| 12796 |
if (n !== 0 && n % 10 === 0) return 'many'; |
| 12797 |
if (n == 2) return 'two'; |
| 12798 |
if (n == 1) return 'one'; |
| 12799 |
return 'other'; |
| 12800 |
}, |
| 12801 |
'3': function _(n) { |
| 12802 |
if (n == 1) return 'one'; |
| 12803 |
return 'other'; |
| 12804 |
}, |
| 12805 |
'4': function _(n) { |
| 12806 |
if (isBetween(n, 0, 1)) return 'one'; |
| 12807 |
return 'other'; |
| 12808 |
}, |
| 12809 |
'5': function _(n) { |
| 12810 |
if (isBetween(n, 0, 2) && n != 2) return 'one'; |
| 12811 |
return 'other'; |
| 12812 |
}, |
| 12813 |
'6': function _(n) { |
| 12814 |
if (n === 0) return 'zero'; |
| 12815 |
if (n % 10 == 1 && n % 100 != 11) return 'one'; |
| 12816 |
return 'other'; |
| 12817 |
}, |
| 12818 |
'7': function _(n) { |
| 12819 |
if (n == 2) return 'two'; |
| 12820 |
if (n == 1) return 'one'; |
| 12821 |
return 'other'; |
| 12822 |
}, |
| 12823 |
'8': function _(n) { |
| 12824 |
if (isBetween(n, 3, 6)) return 'few'; |
| 12825 |
if (isBetween(n, 7, 10)) return 'many'; |
| 12826 |
if (n == 2) return 'two'; |
| 12827 |
if (n == 1) return 'one'; |
| 12828 |
return 'other'; |
| 12829 |
}, |
| 12830 |
'9': function _(n) { |
| 12831 |
if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few'; |
| 12832 |
if (n == 1) return 'one'; |
| 12833 |
return 'other'; |
| 12834 |
}, |
| 12835 |
'10': function _(n) { |
| 12836 |
if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few'; |
| 12837 |
if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one'; |
| 12838 |
return 'other'; |
| 12839 |
}, |
| 12840 |
'11': function _(n) { |
| 12841 |
if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few'; |
| 12842 |
if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many'; |
| 12843 |
if (n % 10 == 1 && n % 100 != 11) return 'one'; |
| 12844 |
return 'other'; |
| 12845 |
}, |
| 12846 |
'12': function _(n) { |
| 12847 |
if (isBetween(n, 2, 4)) return 'few'; |
| 12848 |
if (n == 1) return 'one'; |
| 12849 |
return 'other'; |
| 12850 |
}, |
| 12851 |
'13': function _(n) { |
| 12852 |
if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few'; |
| 12853 |
if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many'; |
| 12854 |
if (n == 1) return 'one'; |
| 12855 |
return 'other'; |
| 12856 |
}, |
| 12857 |
'14': function _(n) { |
| 12858 |
if (isBetween(n % 100, 3, 4)) return 'few'; |
| 12859 |
if (n % 100 == 2) return 'two'; |
| 12860 |
if (n % 100 == 1) return 'one'; |
| 12861 |
return 'other'; |
| 12862 |
}, |
| 12863 |
'15': function _(n) { |
| 12864 |
if (n === 0 || isBetween(n % 100, 2, 10)) return 'few'; |
| 12865 |
if (isBetween(n % 100, 11, 19)) return 'many'; |
| 12866 |
if (n == 1) return 'one'; |
| 12867 |
return 'other'; |
| 12868 |
}, |
| 12869 |
'16': function _(n) { |
| 12870 |
if (n % 10 == 1 && n != 11) return 'one'; |
| 12871 |
return 'other'; |
| 12872 |
}, |
| 12873 |
'17': function _(n) { |
| 12874 |
if (n == 3) return 'few'; |
| 12875 |
if (n === 0) return 'zero'; |
| 12876 |
if (n == 6) return 'many'; |
| 12877 |
if (n == 2) return 'two'; |
| 12878 |
if (n == 1) return 'one'; |
| 12879 |
return 'other'; |
| 12880 |
}, |
| 12881 |
'18': function _(n) { |
| 12882 |
if (n === 0) return 'zero'; |
| 12883 |
if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one'; |
| 12884 |
return 'other'; |
| 12885 |
}, |
| 12886 |
'19': function _(n) { |
| 12887 |
if (isBetween(n, 2, 10)) return 'few'; |
| 12888 |
if (isBetween(n, 0, 1)) return 'one'; |
| 12889 |
return 'other'; |
| 12890 |
}, |
| 12891 |
'20': function _(n) { |
| 12892 |
if ((isBetween(n % 10, 3, 4) || n % 10 == 9) && !(isBetween(n % 100, 10, 19) || isBetween(n % 100, 70, 79) || isBetween(n % 100, 90, 99))) return 'few'; |
| 12893 |
if (n % 1000000 === 0 && n !== 0) return 'many'; |
| 12894 |
if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two'; |
| 12895 |
if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one'; |
| 12896 |
return 'other'; |
| 12897 |
}, |
| 12898 |
'21': function _(n) { |
| 12899 |
if (n === 0) return 'zero'; |
| 12900 |
if (n == 1) return 'one'; |
| 12901 |
return 'other'; |
| 12902 |
}, |
| 12903 |
'22': function _(n) { |
| 12904 |
if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one'; |
| 12905 |
return 'other'; |
| 12906 |
}, |
| 12907 |
'23': function _(n) { |
| 12908 |
if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one'; |
| 12909 |
return 'other'; |
| 12910 |
}, |
| 12911 |
'24': function _(n) { |
| 12912 |
if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few'; |
| 12913 |
if (isIn(n, [2, 12])) return 'two'; |
| 12914 |
if (isIn(n, [1, 11])) return 'one'; |
| 12915 |
return 'other'; |
| 12916 |
} |
| 12917 |
}; |
| 12918 |
var index = locales2rules[lang.replace(/-.*$/, '')]; |
| 12919 |
if (!(index in pluralRules)) { |
| 12920 |
console.warn('plural form unknown for [' + lang + ']'); |
| 12921 |
return function () { |
| 12922 |
return 'other'; |
| 12923 |
}; |
| 12924 |
} |
| 12925 |
return pluralRules[index]; |
| 12926 |
} |
| 12927 |
gMacros.plural = function (str, param, key, prop) { |
| 12928 |
var n = parseFloat(param); |
| 12929 |
if (isNaN(n)) return str; |
| 12930 |
if (prop != gTextProp) return str; |
| 12931 |
if (!gMacros._pluralRules) { |
| 12932 |
gMacros._pluralRules = getPluralRules(gLanguage); |
| 12933 |
} |
| 12934 |
var index = '[' + gMacros._pluralRules(n) + ']'; |
| 12935 |
if (n === 0 && key + '[zero]' in gL10nData) { |
| 12936 |
str = gL10nData[key + '[zero]'][prop]; |
| 12937 |
} else if (n == 1 && key + '[one]' in gL10nData) { |
| 12938 |
str = gL10nData[key + '[one]'][prop]; |
| 12939 |
} else if (n == 2 && key + '[two]' in gL10nData) { |
| 12940 |
str = gL10nData[key + '[two]'][prop]; |
| 12941 |
} else if (key + index in gL10nData) { |
| 12942 |
str = gL10nData[key + index][prop]; |
| 12943 |
} else if (key + '[other]' in gL10nData) { |
| 12944 |
str = gL10nData[key + '[other]'][prop]; |
| 12945 |
} |
| 12946 |
return str; |
| 12947 |
}; |
| 12948 |
function getL10nData(key, args, fallback) { |
| 12949 |
var data = gL10nData[key]; |
| 12950 |
if (!data) { |
| 12951 |
console.warn('#' + key + ' is undefined.'); |
| 12952 |
if (!fallback) { |
| 12953 |
return null; |
| 12954 |
} |
| 12955 |
data = fallback; |
| 12956 |
} |
| 12957 |
var rv = {}; |
| 12958 |
for (var prop in data) { |
| 12959 |
var str = data[prop]; |
| 12960 |
str = substIndexes(str, args, key, prop); |
| 12961 |
str = substArguments(str, args, key); |
| 12962 |
rv[prop] = str; |
| 12963 |
} |
| 12964 |
return rv; |
| 12965 |
} |
| 12966 |
function substIndexes(str, args, key, prop) { |
| 12967 |
var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/; |
| 12968 |
var reMatch = reIndex.exec(str); |
| 12969 |
if (!reMatch || !reMatch.length) return str; |
| 12970 |
var macroName = reMatch[1]; |
| 12971 |
var paramName = reMatch[2]; |
| 12972 |
var param; |
| 12973 |
if (args && paramName in args) { |
| 12974 |
param = args[paramName]; |
| 12975 |
} else if (paramName in gL10nData) { |
| 12976 |
param = gL10nData[paramName]; |
| 12977 |
} |
| 12978 |
if (macroName in gMacros) { |
| 12979 |
var macro = gMacros[macroName]; |
| 12980 |
str = macro(str, param, key, prop); |
| 12981 |
} |
| 12982 |
return str; |
| 12983 |
} |
| 12984 |
function substArguments(str, args, key) { |
| 12985 |
var reArgs = /\{\{\s*(.+?)\s*\}\}/g; |
| 12986 |
return str.replace(reArgs, function (matched_text, arg) { |
| 12987 |
if (args && arg in args) { |
| 12988 |
return args[arg]; |
| 12989 |
} |
| 12990 |
if (arg in gL10nData) { |
| 12991 |
return gL10nData[arg]; |
| 12992 |
} |
| 12993 |
console.log('argument {{' + arg + '}} for #' + key + ' is undefined.'); |
| 12994 |
return matched_text; |
| 12995 |
}); |
| 12996 |
} |
| 12997 |
function translateElement(element) { |
| 12998 |
var l10n = getL10nAttributes(element); |
| 12999 |
if (!l10n.id) return; |
| 13000 |
var data = getL10nData(l10n.id, l10n.args); |
| 13001 |
if (!data) { |
| 13002 |
console.warn('#' + l10n.id + ' is undefined.'); |
| 13003 |
return; |
| 13004 |
} |
| 13005 |
if (data[gTextProp]) { |
| 13006 |
if (getChildElementCount(element) === 0) { |
| 13007 |
element[gTextProp] = data[gTextProp]; |
| 13008 |
} else { |
| 13009 |
var children = element.childNodes; |
| 13010 |
var found = false; |
| 13011 |
for (var i = 0, l = children.length; i < l; i++) { |
| 13012 |
if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) { |
| 13013 |
if (found) { |
| 13014 |
children[i].nodeValue = ''; |
| 13015 |
} else { |
| 13016 |
children[i].nodeValue = data[gTextProp]; |
| 13017 |
found = true; |
| 13018 |
} |
| 13019 |
} |
| 13020 |
} |
| 13021 |
if (!found) { |
| 13022 |
var textNode = document.createTextNode(data[gTextProp]); |
| 13023 |
element.insertBefore(textNode, element.firstChild); |
| 13024 |
} |
| 13025 |
} |
| 13026 |
delete data[gTextProp]; |
| 13027 |
} |
| 13028 |
for (var k in data) { |
| 13029 |
element[k] = data[k]; |
| 13030 |
} |
| 13031 |
} |
| 13032 |
function getChildElementCount(element) { |
| 13033 |
if (element.children) { |
| 13034 |
return element.children.length; |
| 13035 |
} |
| 13036 |
if (typeof element.childElementCount !== 'undefined') { |
| 13037 |
return element.childElementCount; |
| 13038 |
} |
| 13039 |
var count = 0; |
| 13040 |
for (var i = 0; i < element.childNodes.length; i++) { |
| 13041 |
count += element.nodeType === 1 ? 1 : 0; |
| 13042 |
} |
| 13043 |
return count; |
| 13044 |
} |
| 13045 |
function translateFragment(element) { |
| 13046 |
element = element || document.documentElement; |
| 13047 |
var children = getTranslatableChildren(element); |
| 13048 |
var elementCount = children.length; |
| 13049 |
for (var i = 0; i < elementCount; i++) { |
| 13050 |
translateElement(children[i]); |
| 13051 |
} |
| 13052 |
translateElement(element); |
| 13053 |
} |
| 13054 |
return { |
| 13055 |
get: function get(key, args, fallbackString) { |
| 13056 |
var index = key.lastIndexOf('.'); |
| 13057 |
var prop = gTextProp; |
| 13058 |
if (index > 0) { |
| 13059 |
prop = key.substring(index + 1); |
| 13060 |
key = key.substring(0, index); |
| 13061 |
} |
| 13062 |
var fallback; |
| 13063 |
if (fallbackString) { |
| 13064 |
fallback = {}; |
| 13065 |
fallback[prop] = fallbackString; |
| 13066 |
} |
| 13067 |
var data = getL10nData(key, args, fallback); |
| 13068 |
if (data && prop in data) { |
| 13069 |
return data[prop]; |
| 13070 |
} |
| 13071 |
return '{{' + key + '}}'; |
| 13072 |
}, |
| 13073 |
getData: function getData() { |
| 13074 |
return gL10nData; |
| 13075 |
}, |
| 13076 |
getText: function getText() { |
| 13077 |
return gTextData; |
| 13078 |
}, |
| 13079 |
getLanguage: function getLanguage() { |
| 13080 |
return gLanguage; |
| 13081 |
}, |
| 13082 |
setLanguage: function setLanguage(lang, callback) { |
| 13083 |
loadLocale(lang, function () { |
| 13084 |
if (callback) callback(); |
| 13085 |
}); |
| 13086 |
}, |
| 13087 |
getDirection: function getDirection() { |
| 13088 |
var rtlList = ['ar', 'he', 'fa', 'ps', 'ur']; |
| 13089 |
var shortCode = gLanguage.split('-', 1)[0]; |
| 13090 |
return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr'; |
| 13091 |
}, |
| 13092 |
translate: translateFragment, |
| 13093 |
getReadyState: function getReadyState() { |
| 13094 |
return gReadyState; |
| 13095 |
}, |
| 13096 |
ready: function ready(callback) { |
| 13097 |
if (!callback) { |
| 13098 |
return; |
| 13099 |
} else if (gReadyState == 'complete' || gReadyState == 'interactive') { |
| 13100 |
window.setTimeout(function () { |
| 13101 |
callback(); |
| 13102 |
}); |
| 13103 |
} else if (document.addEventListener) { |
| 13104 |
document.addEventListener('localized', function once() { |
| 13105 |
document.removeEventListener('localized', once); |
| 13106 |
callback(); |
| 13107 |
}); |
| 13108 |
} |
| 13109 |
} |
| 13110 |
}; |
| 13111 |
}(window, document); |
| 13112 |
|
| 13113 |
/***/ }), |
| 13114 |
/* 43 */ |
| 13115 |
/***/ (function(module, exports, __webpack_require__) { |
| 13116 |
|
| 13117 |
"use strict"; |
| 13118 |
|
| 13119 |
|
| 13120 |
Object.defineProperty(exports, "__esModule", { |
| 13121 |
value: true |
| 13122 |
}); |
| 13123 |
exports.PDFPrintService = undefined; |
| 13124 |
|
| 13125 |
var _ui_utils = __webpack_require__(6); |
| 13126 |
|
| 13127 |
var _app = __webpack_require__(1); |
| 13128 |
|
| 13129 |
var _pdfjsLib = __webpack_require__(7); |
| 13130 |
|
| 13131 |
var activeService = null; |
| 13132 |
var overlayManager = null; |
| 13133 |
function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) { |
| 13134 |
var scratchCanvas = activeService.scratchCanvas; |
| 13135 |
var PRINT_RESOLUTION = 150; |
| 13136 |
var PRINT_UNITS = PRINT_RESOLUTION / 72.0; |
| 13137 |
scratchCanvas.width = Math.floor(size.width * PRINT_UNITS); |
| 13138 |
scratchCanvas.height = Math.floor(size.height * PRINT_UNITS); |
| 13139 |
var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + 'px'; |
| 13140 |
var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + 'px'; |
| 13141 |
var ctx = scratchCanvas.getContext('2d'); |
| 13142 |
ctx.save(); |
| 13143 |
ctx.fillStyle = 'rgb(255, 255, 255)'; |
| 13144 |
ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height); |
| 13145 |
ctx.restore(); |
| 13146 |
return pdfDocument.getPage(pageNumber).then(function (pdfPage) { |
| 13147 |
var renderContext = { |
| 13148 |
canvasContext: ctx, |
| 13149 |
transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0], |
| 13150 |
viewport: pdfPage.getViewport(1, size.rotation), |
| 13151 |
intent: 'print' |
| 13152 |
}; |
| 13153 |
return pdfPage.render(renderContext).promise; |
| 13154 |
}).then(function () { |
| 13155 |
return { |
| 13156 |
width: width, |
| 13157 |
height: height |
| 13158 |
}; |
| 13159 |
}); |
| 13160 |
} |
| 13161 |
function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) { |
| 13162 |
this.pdfDocument = pdfDocument; |
| 13163 |
this.pagesOverview = pagesOverview; |
| 13164 |
this.printContainer = printContainer; |
| 13165 |
this.l10n = l10n || _ui_utils.NullL10n; |
| 13166 |
this.disableCreateObjectURL = pdfDocument.loadingParams['disableCreateObjectURL']; |
| 13167 |
this.currentPage = -1; |
| 13168 |
this.scratchCanvas = document.createElement('canvas'); |
| 13169 |
} |
| 13170 |
PDFPrintService.prototype = { |
| 13171 |
layout: function layout() { |
| 13172 |
this.throwIfInactive(); |
| 13173 |
var body = document.querySelector('body'); |
| 13174 |
body.setAttribute('data-pdfjsprinting', true); |
| 13175 |
var hasEqualPageSizes = this.pagesOverview.every(function (size) { |
| 13176 |
return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height; |
| 13177 |
}, this); |
| 13178 |
if (!hasEqualPageSizes) { |
| 13179 |
console.warn('Not all pages have the same size. The printed ' + 'result may be incorrect!'); |
| 13180 |
} |
| 13181 |
this.pageStyleSheet = document.createElement('style'); |
| 13182 |
var pageSize = this.pagesOverview[0]; |
| 13183 |
this.pageStyleSheet.textContent = '@supports ((size:A4) and (size:1pt 1pt)) {' + '@page { size: ' + pageSize.width + 'pt ' + pageSize.height + 'pt;}' + '}'; |
| 13184 |
body.appendChild(this.pageStyleSheet); |
| 13185 |
}, |
| 13186 |
destroy: function destroy() { |
| 13187 |
if (activeService !== this) { |
| 13188 |
return; |
| 13189 |
} |
| 13190 |
this.printContainer.textContent = ''; |
| 13191 |
if (this.pageStyleSheet) { |
| 13192 |
this.pageStyleSheet.remove(); |
| 13193 |
this.pageStyleSheet = null; |
| 13194 |
} |
| 13195 |
this.scratchCanvas.width = this.scratchCanvas.height = 0; |
| 13196 |
this.scratchCanvas = null; |
| 13197 |
activeService = null; |
| 13198 |
ensureOverlay().then(function () { |
| 13199 |
if (overlayManager.active !== 'printServiceOverlay') { |
| 13200 |
return; |
| 13201 |
} |
| 13202 |
overlayManager.close('printServiceOverlay'); |
| 13203 |
}); |
| 13204 |
}, |
| 13205 |
renderPages: function renderPages() { |
| 13206 |
var _this = this; |
| 13207 |
|
| 13208 |
var pageCount = this.pagesOverview.length; |
| 13209 |
var renderNextPage = function renderNextPage(resolve, reject) { |
| 13210 |
_this.throwIfInactive(); |
| 13211 |
if (++_this.currentPage >= pageCount) { |
| 13212 |
renderProgress(pageCount, pageCount, _this.l10n); |
| 13213 |
resolve(); |
| 13214 |
return; |
| 13215 |
} |
| 13216 |
var index = _this.currentPage; |
| 13217 |
renderProgress(index, pageCount, _this.l10n); |
| 13218 |
renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index]).then(_this.useRenderedPage.bind(_this)).then(function () { |
| 13219 |
renderNextPage(resolve, reject); |
| 13220 |
}, reject); |
| 13221 |
}; |
| 13222 |
return new Promise(renderNextPage); |
| 13223 |
}, |
| 13224 |
useRenderedPage: function useRenderedPage(printItem) { |
| 13225 |
this.throwIfInactive(); |
| 13226 |
var img = document.createElement('img'); |
| 13227 |
img.style.width = printItem.width; |
| 13228 |
img.style.height = printItem.height; |
| 13229 |
var scratchCanvas = this.scratchCanvas; |
| 13230 |
if ('toBlob' in scratchCanvas && !this.disableCreateObjectURL) { |
| 13231 |
scratchCanvas.toBlob(function (blob) { |
| 13232 |
img.src = _pdfjsLib.URL.createObjectURL(blob); |
| 13233 |
}); |
| 13234 |
} else { |
| 13235 |
img.src = scratchCanvas.toDataURL(); |
| 13236 |
} |
| 13237 |
var wrapper = document.createElement('div'); |
| 13238 |
wrapper.appendChild(img); |
| 13239 |
this.printContainer.appendChild(wrapper); |
| 13240 |
return new Promise(function (resolve, reject) { |
| 13241 |
img.onload = resolve; |
| 13242 |
img.onerror = reject; |
| 13243 |
}); |
| 13244 |
}, |
| 13245 |
performPrint: function performPrint() { |
| 13246 |
var _this2 = this; |
| 13247 |
|
| 13248 |
this.throwIfInactive(); |
| 13249 |
return new Promise(function (resolve) { |
| 13250 |
setTimeout(function () { |
| 13251 |
if (!_this2.active) { |
| 13252 |
resolve(); |
| 13253 |
return; |
| 13254 |
} |
| 13255 |
print.call(window); |
| 13256 |
setTimeout(resolve, 20); |
| 13257 |
}, 0); |
| 13258 |
}); |
| 13259 |
}, |
| 13260 |
|
| 13261 |
get active() { |
| 13262 |
return this === activeService; |
| 13263 |
}, |
| 13264 |
throwIfInactive: function throwIfInactive() { |
| 13265 |
if (!this.active) { |
| 13266 |
throw new Error('This print request was cancelled or completed.'); |
| 13267 |
} |
| 13268 |
} |
| 13269 |
}; |
| 13270 |
var print = window.print; |
| 13271 |
window.print = function print() { |
| 13272 |
if (activeService) { |
| 13273 |
console.warn('Ignored window.print() because of a pending print job.'); |
| 13274 |
return; |
| 13275 |
} |
| 13276 |
ensureOverlay().then(function () { |
| 13277 |
if (activeService) { |
| 13278 |
overlayManager.open('printServiceOverlay'); |
| 13279 |
} |
| 13280 |
}); |
| 13281 |
try { |
| 13282 |
dispatchEvent('beforeprint'); |
| 13283 |
} finally { |
| 13284 |
if (!activeService) { |
| 13285 |
console.error('Expected print service to be initialized.'); |
| 13286 |
ensureOverlay().then(function () { |
| 13287 |
if (overlayManager.active === 'printServiceOverlay') { |
| 13288 |
overlayManager.close('printServiceOverlay'); |
| 13289 |
} |
| 13290 |
}); |
| 13291 |
return; |
| 13292 |
} |
| 13293 |
var activeServiceOnEntry = activeService; |
| 13294 |
activeService.renderPages().then(function () { |
| 13295 |
return activeServiceOnEntry.performPrint(); |
| 13296 |
}).catch(function () {}).then(function () { |
| 13297 |
if (activeServiceOnEntry.active) { |
| 13298 |
abort(); |
| 13299 |
} |
| 13300 |
}); |
| 13301 |
} |
| 13302 |
}; |
| 13303 |
function dispatchEvent(eventType) { |
| 13304 |
var event = document.createEvent('CustomEvent'); |
| 13305 |
event.initCustomEvent(eventType, false, false, 'custom'); |
| 13306 |
window.dispatchEvent(event); |
| 13307 |
} |
| 13308 |
function abort() { |
| 13309 |
if (activeService) { |
| 13310 |
activeService.destroy(); |
| 13311 |
dispatchEvent('afterprint'); |
| 13312 |
} |
| 13313 |
} |
| 13314 |
function renderProgress(index, total, l10n) { |
| 13315 |
var progressContainer = document.getElementById('printServiceOverlay'); |
| 13316 |
var progress = Math.round(100 * index / total); |
| 13317 |
var progressBar = progressContainer.querySelector('progress'); |
| 13318 |
var progressPerc = progressContainer.querySelector('.relative-progress'); |
| 13319 |
progressBar.value = progress; |
| 13320 |
l10n.get('print_progress_percent', { progress: progress }, progress + '%').then(function (msg) { |
| 13321 |
progressPerc.textContent = msg; |
| 13322 |
}); |
| 13323 |
} |
| 13324 |
var hasAttachEvent = !!document.attachEvent; |
| 13325 |
window.addEventListener('keydown', function (event) { |
| 13326 |
if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) { |
| 13327 |
window.print(); |
| 13328 |
if (hasAttachEvent) { |
| 13329 |
return; |
| 13330 |
} |
| 13331 |
event.preventDefault(); |
| 13332 |
if (event.stopImmediatePropagation) { |
| 13333 |
event.stopImmediatePropagation(); |
| 13334 |
} else { |
| 13335 |
event.stopPropagation(); |
| 13336 |
} |
| 13337 |
return; |
| 13338 |
} |
| 13339 |
}, true); |
| 13340 |
if (hasAttachEvent) { |
| 13341 |
document.attachEvent('onkeydown', function (event) { |
| 13342 |
event = event || window.event; |
| 13343 |
if (event.keyCode === 80 && event.ctrlKey) { |
| 13344 |
event.keyCode = 0; |
| 13345 |
return false; |
| 13346 |
} |
| 13347 |
}); |
| 13348 |
} |
| 13349 |
if ('onbeforeprint' in window) { |
| 13350 |
var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) { |
| 13351 |
if (event.detail !== 'custom' && event.stopImmediatePropagation) { |
| 13352 |
event.stopImmediatePropagation(); |
| 13353 |
} |
| 13354 |
}; |
| 13355 |
window.addEventListener('beforeprint', stopPropagationIfNeeded); |
| 13356 |
window.addEventListener('afterprint', stopPropagationIfNeeded); |
| 13357 |
} |
| 13358 |
var overlayPromise = void 0; |
| 13359 |
function ensureOverlay() { |
| 13360 |
if (!overlayPromise) { |
| 13361 |
overlayManager = _app.PDFViewerApplication.overlayManager; |
| 13362 |
if (!overlayManager) { |
| 13363 |
throw new Error('The overlay manager has not yet been initialized.'); |
| 13364 |
} |
| 13365 |
overlayPromise = overlayManager.register('printServiceOverlay', document.getElementById('printServiceOverlay'), abort, true); |
| 13366 |
document.getElementById('printCancel').onclick = abort; |
| 13367 |
} |
| 13368 |
return overlayPromise; |
| 13369 |
} |
| 13370 |
_app.PDFPrintServiceFactory.instance = { |
| 13371 |
supportsPrinting: true, |
| 13372 |
createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, l10n) { |
| 13373 |
if (activeService) { |
| 13374 |
throw new Error('The print service is created and active.'); |
| 13375 |
} |
| 13376 |
activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n); |
| 13377 |
return activeService; |
| 13378 |
} |
| 13379 |
}; |
| 13380 |
exports.PDFPrintService = PDFPrintService; |
| 13381 |
|
| 13382 |
/***/ }) |
| 13383 |
/******/ ]); |
| 13384 |
//# sourceMappingURL=viewer.js.map |