1/******/ (function() { // webpackBootstrap 2/******/ var __webpack_modules__ = ({ 3 4/***/ 745: 5/***/ (function() { 6 7//region TWEEN.js required for animation 8/** 9 * Tween.js - Licensed under the MIT license 10 * https://github.com/tweenjs/tween.js 11 */ 12(function TweenJs() { 13 var TWEEN = TWEEN || function () { 14 var _tweens = []; 15 return { 16 getAll: function getAll() { 17 return _tweens; 18 }, 19 removeAll: function removeAll() { 20 _tweens = []; 21 }, 22 add: function add(tween) { 23 _tweens.push(tween); 24 }, 25 remove: function remove(tween) { 26 var i = _tweens.indexOf(tween); 27 if (i !== -1) { 28 _tweens.splice(i, 1); 29 } 30 }, 31 update: function update(time) { 32 if (_tweens.length === 0) { 33 return false; 34 } 35 var i = 0; 36 37 //noinspection JSUnresolvedVariable 38 time = time != null ? time : window.performance.now(); 39 while (i < _tweens.length) { 40 if (_tweens[i].update(time)) { 41 i++; 42 } else { 43 _tweens.splice(i, 1); 44 } 45 } 46 return true; 47 } 48 }; 49 }(); 50 TWEEN.Tween = function (object) { 51 var _object = object; 52 var _valuesStart = {}; 53 var _valuesEnd = {}; 54 var _valuesStartRepeat = {}; 55 var _duration = 1000; 56 var _repeat = 0; 57 var _yoyo = false; 58 var _isPlaying = false; 59 var _reversed = false; 60 var _delayTime = 0; 61 var _startTime = null; 62 var _easingFunction = TWEEN.Easing.Linear.None; 63 var _interpolationFunction = TWEEN.Interpolation.Linear; 64 var _chainedTweens = []; 65 var _onStartCallback = null; 66 var _onStartCallbackFired = false; 67 var _onUpdateCallback = null; 68 var _onCompleteCallback = null; 69 var _onStopCallback = null; 70 71 // Set all starting values present on the target object 72 for (var field in object) { 73 //noinspection JSUnfilteredForInLoop 74 _valuesStart[field] = parseFloat(object[field], 10); 75 } 76 this.to = function (properties, duration) { 77 if (duration != null) { 78 _duration = duration; 79 } 80 _valuesEnd = properties; 81 return this; 82 }; 83 this.start = function (time) { 84 TWEEN.add(this); 85 _isPlaying = true; 86 _onStartCallbackFired = false; 87 _startTime = time != null ? time : window.performance.now(); 88 _startTime += _delayTime; 89 for (var property in _valuesEnd) { 90 // Check if an Array was provided as property value 91 if (_valuesEnd[property] instanceof Array) { 92 if (_valuesEnd[property].length === 0) { 93 continue; 94 } 95 96 // Create a local copy of the Array with the start value at the front 97 _valuesEnd[property] = [_object[property]].concat(_valuesEnd[property]); 98 } 99 100 // If `to()` specifies a property that doesn't exist in the source object, 101 // we should not set that property in the object 102 if (_valuesStart[property] == null) { 103 continue; 104 } 105 _valuesStart[property] = _object[property]; 106 if (_valuesStart[property] instanceof Array === false) { 107 _valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings 108 } 109 110 _valuesStartRepeat[property] = _valuesStart[property] || 0; 111 } 112 return this; 113 }; 114 this.stop = function () { 115 if (!_isPlaying) { 116 return this; 117 } 118 TWEEN.remove(this); 119 _isPlaying = false; 120 if (_onStopCallback != null) { 121 _onStopCallback.call(_object); 122 } 123 this.stopChainedTweens(); 124 return this; 125 }; 126 this.stopChainedTweens = function () { 127 for (var i = 0, numChainedTweens = _chainedTweens.length; i < numChainedTweens; i++) { 128 _chainedTweens[i].stop(); 129 } 130 }; 131 this.complete = function () { 132 if (!_isPlaying) { 133 return this; 134 } 135 TWEEN.remove(this); 136 _isPlaying = false; 137 if (_onCompleteCallback != null) { 138 _onCompleteCallback.call(_object); 139 } 140 this.completeChainedTweens(); 141 return this; 142 }; 143 this.completeChainedTweens = function () { 144 for (var i = 0, numChainedTweens = _chainedTweens.length; i < numChainedTweens; i++) { 145 _chainedTweens[i].complete(); 146 } 147 }; 148 this.delay = function (amount) { 149 _delayTime = amount; 150 return this; 151 }; 152 this.repeat = function (times) { 153 _repeat = times; 154 return this; 155 }; 156 157 //noinspection JSUnusedGlobalSymbols 158 this.yoyo = function (yoyo) { 159 _yoyo = yoyo; 160 return this; 161 }; 162 this.easing = function (easing) { 163 _easingFunction = easing == null ? _easingFunction : easing; 164 return this; 165 }; 166 this.interpolation = function (interpolation) { 167 _interpolationFunction = interpolation; 168 return this; 169 }; 170 171 //noinspection JSUnusedGlobalSymbols 172 this.chain = function () { 173 _chainedTweens = arguments; 174 return this; 175 }; 176 this.onStart = function (callback) { 177 _onStartCallback = callback; 178 return this; 179 }; 180 this.onUpdate = function (callback) { 181 _onUpdateCallback = callback; 182 return this; 183 }; 184 this.onComplete = function (callback) { 185 _onCompleteCallback = callback; 186 return this; 187 }; 188 189 //noinspection JSUnusedGlobalSymbols 190 this.onStop = function (callback) { 191 _onStopCallback = callback; 192 return this; 193 }; 194 this.update = function (time) { 195 var property; 196 var elapsed; 197 var value; 198 if (time < _startTime) { 199 return true; 200 } 201 if (_onStartCallbackFired === false) { 202 if (_onStartCallback != null) { 203 _onStartCallback.call(_object); 204 } 205 _onStartCallbackFired = true; 206 }
207 elapsed = (time - _startTime) / _duration; 208 elapsed = elapsed > 1 ? 1 : elapsed; 209 value = _easingFunction(elapsed); 210 for (property in _valuesEnd) { 211 // Don't update properties that do not exist in the source object 212 if (_valuesStart[property] == null) { 213 continue; 214 } 215 var start = _valuesStart[property] || 0; 216 var end = _valuesEnd[property]; 217 if (end instanceof Array) { 218 _object[property] = _interpolationFunction(end, value); 219 } else { 220 // Parses relative end values with start as base (e.g.: +10, -3) 221 if (typeof end === 'string') { 222 if (end.startsWith('+') || end.startsWith('-')) { 223 end = start + parseFloat(end, 10); 224 } else { 225 end = parseFloat(end, 10); 226 } 227 } 228 229 // Protect against non-numeric properties. 230 if (typeof end === 'number') { 231 _object[property] = start + (end - start) * value; 232 } 233 } 234 } 235 if (_onUpdateCallback != null) { 236 _onUpdateCallback.call(_object, value); 237 } 238 if (elapsed === 1) { 239 if (_repeat > 0) { 240 if (isFinite(_repeat)) { 241 _repeat--; 242 } 243 244 // Reassign starting values, restart by making startTime = now 245 for (property in _valuesStartRepeat) { 246 if (typeof _valuesEnd[property] === 'string') { 247 _valuesStartRepeat[property] = _valuesStartRepeat[property] + parseFloat(_valuesEnd[property], 10); 248 } 249 if (_yoyo) { 250 var tmp = _valuesStartRepeat[property]; 251 _valuesStartRepeat[property] = _valuesEnd[property]; 252 _valuesEnd[property] = tmp; 253 } 254 _valuesStart[property] = _valuesStartRepeat[property]; 255 } 256 if (_yoyo) { 257 _reversed = !_reversed; 258 } 259 _startTime = time + _delayTime; 260 return true; 261 } else { 262 if (_onCompleteCallback != null) { 263 _onCompleteCallback.call(_object); 264 } 265 for (var i = 0, numChainedTweens = _chainedTweens.length; i < numChainedTweens; i++) { 266 // Make the chained tweens start exactly at the time they should, 267 // even if the `update()` method was called way past the duration of the tween 268 _chainedTweens[i].start(_startTime + _duration); 269 } 270 return false; 271 } 272 } 273 return true; 274 }; 275 }; 276 TWEEN.Easing = { 277 Linear: { 278 None: function None(k) { 279 return k; 280 } 281 }, 282 Quadratic: { 283 In: function In(k) { 284 return k * k; 285 }, 286 Out: function Out(k) { 287 return k * (2 - k); 288 }, 289 InOut: function InOut(k) { 290 if ((k *= 2) < 1) { 291 return 0.5 * k * k; 292 } 293 return -0.5 * (--k * (k - 2) - 1); 294 } 295 }, 296 Quartic: { 297 In: function In(k) { 298 return k * k * k * k; 299 }, 300 Out: function Out(k) { 301 return 1 - --k * k * k * k; 302 }, 303 InOut: function InOut(k) { 304 if ((k *= 2) < 1) { 305 return 0.5 * k * k * k * k; 306 } 307 return -0.5 * ((k -= 2) * k * k * k - 2); 308 } 309 }, 310 Sinusoidal: { 311 In: function In(k) { 312 return 1 - Math.cos(k * Math.PI / 2); 313 }, 314 Out: function Out(k) { 315 return Math.sin(k * Math.PI / 2); 316 }, 317 InOut: function InOut(k) { 318 return 0.5 * (1 - Math.cos(Math.PI * k)); 319 } 320 }, 321 Cubic: { 322 In: function In(k) { 323 return k * k * k; 324 }, 325 Out: function Out(k) { 326 return --k * k * k + 1; 327 }, 328 InOut: function InOut(k) { 329 if ((k *= 2) < 1) { 330 return 0.5 * k * k * k; 331 } 332 return 0.5 * ((k -= 2) * k * k + 2); 333 } 334 } 335 }; 336 337 //noinspection JSUnusedGlobalSymbols 338 TWEEN.Interpolation = { 339 Linear: function Linear(v, k) { 340 var m = v.length - 1; 341 var f = m * k; 342 var i = Math.floor(f); 343 var fn = TWEEN.Interpolation.Utils.Linear; 344 if (k < 0) { 345 return fn(v[0], v[1], f); 346 } 347 if (k > 1) { 348 return fn(v[m], v[m - 1], m - f); 349 } 350 return fn(v[i], v[i + 1 > m ? m : i + 1], f - i); 351 }, 352 Bezier: function Bezier(v, k) { 353 var b = 0; 354 var n = v.length - 1; 355 var pw = Math.pow; 356 var bn = TWEEN.Interpolation.Utils.Bernstein; 357 for (var i = 0; i <= n; i++) { 358 b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i); 359 } 360 return b; 361 }, 362 Utils: { 363 Linear: function Linear(p0, p1, t) { 364 return (p1 - p0) * t + p0; 365 }, 366 Bernstein: function Bernstein(n, i) { 367 var fc = TWEEN.Interpolation.Utils.Factorial; 368 return fc(n) / fc(i) / fc(n - i); 369 }, 370 Factorial: function () { 371 var a = [1]; 372 return function (n) { 373 var s = 1; 374 if (a[n]) { 375 return a[n]; 376 } 377 for (var i = n; i > 1; i--) { 378 s *= i; 379 } 380 a[n] = s; 381 return s; 382 }; 383 }(), 384 CatmullRom: function CatmullRom(p0, p1, p2, p3, t) { 385 var v0 = (p2 - p0) * 0.5; 386 var v1 = (p3 - p1) * 0.5; 387 var t2 = t * t; 388 var t3 = t * t2; 389 return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; 390 } 391 } 392 }; 393 window.TWEEN = TWEEN; 394})(); 395 396/***/ }) 397 398/******/ }); 399/************************************************************************/ 400/******/ // The module cache 401/******/ var __webpack_module_cache__ = {}; 402/******/ 403/******/ // The require function 404/******/ function __webpack_require__(moduleId) { 405/******/ // Check if module is in cache 406/******/ var cachedModule = __webpack_module_cache__[moduleId]; 407/******/ if (cachedModule !== undefined) { 408/******/ return cachedModule.exports; 409/******/ } 410/******/ // Create a new module (and put it into the cache) 411/******/ var module = __webpack_module_cache__[moduleId] = { 412/******/ // no module.id needed 413/******/ // no module.loaded needed 414/******/ exports: {} 415/******/ }; 416/******/ 417/******/ // Execute the module function 418/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); 419/******/ 420/******/ // Return the exports of the module 421/******/ return module.exports; 422/******/ } 423/******/ 424/************************************************************************/ 425/******/ /* webpack/runtime/amd options */ 426/******/ !function() { 427/******/ __webpack_require__.amdO = {}; 428/******/ }(); 429/******/ 430/************************************************************************/ 431var __webpack_exports__ = {}; 432// This entry need to be wrapped in an IIFE because it need to be in strict mode. 433!function() { 434"use strict"; 435 436// UNUSED EXPORTS: default 437 438;// CONCATENATED MODULE: ./src/js/dearviewer/defaults.js 439/* globals jQuery */ 440var defaults_DEARVIEWER = { 441 jQuery: jQuery, 442 version: '2.1.188', 443 autoDetectLocation: true, 444 slug: undefined, 445 //this has to be defined by respective Viewer/Plugin, used in analytics 446 locationVar: "dearViewerLocation", 447 //this has to be defined by respective Viewer/Plugin 448 locationFile: undefined, 449 //this has to be defined by respective Viewer/Plugin , used to detect locationVar 450 MOUSE_CLICK_ACTIONS: { 451 NONE: "none", 452 NAV: "nav" 453 }, 454 ARROW_KEYS_ACTIONS: { 455 NONE: "none", 456 NAV: "nav" 457 }, 458 MOUSE_DBL_CLICK_ACTIONS: { 459 NONE: "none", 460 ZOOM: "zoom" 461 }, 462 MOUSE_SCROLL_ACTIONS: { 463 NONE: "none", 464 ZOOM: "zoom", 465 NAV: "nav" 466 }, 467 PAGE_SCALE: { 468 PAGE_FIT: "fit", 469 PAGE_WIDTH: 'width', 470 AUTO: "auto", 471 //page_width to a maximum of 125% zoom 472 ACTUAL: 'actual', 473 //100% 474 MANUAL: 'manual' 475 }, 476 READ_DIRECTION: { 477 LTR: 'ltr', 478 RTL: 'rtl' 479 }, 480 TURN_DIRECTION: { 481 LEFT: 'left', 482 RIGHT: 'right', 483 NONE: 'none' 484 }, 485 INFO_TYPE: { 486 INFO: "info", 487 ERROR: "error" 488 }, 489 FLIPBOOK_PAGE_MODE: { 490 SINGLE: "single", 491 DOUBLE: "double", 492 AUTO: "auto" 493 }, 494 FLIPBOOK_SINGLE_PAGE_MODE: { 495 ZOOM: "zoom", 496 BOOKLET: "booklet", 497 AUTO: "auto" 498 }, 499 FLIPBOOK_PAGE_SIZE: { 500 AUTO: "auto", 501 SINGLE: "single", 502 DOUBLE_INTERNAL: "dbl_int", 503 // |1|, |2-3|, |4-5|, |6-7|, |8| -- booklet modes , can be auto detected 504 DOUBLE: "dbl", 505 // |1-2|, |3-4|, |5-6|, |7-8| -- used from unorganized images , cannot be autodetected 506 DOUBLE_COVER_BACK: "dbl_cover_back" // |8-1|, |2-3|, |4-5|, |6-7| -- used in printing , cannot be autodetected 507 }, 508 509 LINK_TARGET: { 510 NONE: 0, 511 SELF: 1, 512 BLANK: 2, 513 PARENT: 3, 514 TOP: 4 515 }, 516 //as per PDF.js standard 517 CONTROLS_POSITION: { 518 HIDDEN: 'hidden', 519 TOP: 'top', 520 BOTTOM: 'bottom' 521 }, 522 //internals 523 TURN_CORNER: { 524 TL: "tl", 525 TR: "tr", 526 BL: "bl", 527 BR: "br", 528 L: "l", 529 R: "r", 530 NONE: "none" 531 }, 532 REQUEST_STATUS: { 533 OFF: "none",
534 ON: "pending", 535 COUNT: "counting" 536 }, 537 TEXTURE_TARGET: { 538 THUMB: 0, 539 VIEWER: 1, 540 ZOOM: 2 541 }, 542 FLIPBOOK_CENTER_SHIFT: { 543 RIGHT: 1, 544 LEFT: -1, 545 NONE: 0 546 }, 547 FLIPBOOK_COVER_TYPE: { 548 NONE: "none", 549 PLAIN: "plain", 550 BASIC: "basic", 551 RIDGE: "ridge" 552 } 553}; 554 555//_defaults that can be referenced but should not be changed 556defaults_DEARVIEWER._defaults = { 557 // When viewer is set to flipbook 558 // use 3D flipbook(true) or normal CSS flipbook(false) 559 is3D: true, 560 // When viewer is set to flipbook, and 3D is on. 561 // if you want to turn off shadow in 3d set it to false 562 has3DShadow: true, 563 color3DCover: "#aaaaaa", 564 color3DSheets: "#fff", 565 //we use white if needed in future 566 cover3DType: defaults_DEARVIEWER.FLIPBOOK_COVER_TYPE.NONE, 567 flexibility: 0.9, 568 // height of the container 569 // value(eg: 320) or percentage (eg: '50%') 570 // calculation limit: minimum 320, max window height 571 height: 'auto', 572 // set to true to show outline on open (true|false) 573 autoOpenOutline: false, 574 // set to true to show thumbnail on open (true|false) 575 autoOpenThumbnail: false, 576 // enableDownload of PDF files (true|false) 577 showDownloadControl: true, 578 showSearchControl: true, 579 showPrintControl: true, 580 // if enable sound at start (true|false) 581 enableSound: true, 582 // duration of page turn in milliseconds 583 duration: 800, 584 pageRotation: 0, 585 flipbook3DTiltAngleUp: 0, 586 flipbook3DTiltAngleLeft: 0, 587 readDirection: defaults_DEARVIEWER.READ_DIRECTION.LTR, 588 pageMode: defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.AUTO, 589 singlePageMode: defaults_DEARVIEWER.FLIPBOOK_SINGLE_PAGE_MODE.AUTO, 590 //resizes the underlying pages to suit the top cover page after flip 591 flipbookFitPages: false, 592 //can be hard set to false 593 594 //color value in hexadecimal 595 backgroundColor: "transparent", 596 flipbookHardPages: "none", 597 //possible values are "all", "none", "cover" 598 599 openPage: 1, 600 //the page number where the book should open 601 602 annotationClass: "", 603 // texture settings 604 maxTextureSize: 3200, 605 //max page size to be rendered. for pdf files only 606 minTextureSize: 256, 607 //min page size to be rendered. for pdf files only 608 rangeChunkSize: 524288, 609 //pdf related options 610 disableAutoFetch: true, 611 disableStream: true, 612 disableFontFace: false, 613 // icons for the buttons 614 icons: { 615 'altnext': 'df-icon-arrow-right1', 616 'altprev': 'df-icon-arrow-left1', 617 'next': 'df-icon-arrow-right1', 618 'prev': 'df-icon-arrow-left1', 619 'end': 'df-icon-last-page', 620 'start': 'df-icon-first-page', 621 'share': 'df-icon-share', 622 'outline-open': 'df-icon-arrow-right', 623 'outline-close': 'df-icon-arrow-down', 624 'help': 'df-icon-help', 625 'more': 'df-icon-more', 626 'download': 'df-icon-download', 627 'zoomin': 'df-icon-add-circle', 628 'zoomout': 'df-icon-minus-circle', 629 'resetzoom': 'df-icon-minus-circle', 630 'fullscreen': 'df-icon-fullscreen',
631 'fullscreen-off': 'df-icon-fit-screen', 632 'fitscreen': 'df-icon-fit-screen', 633 'thumbnail': 'df-icon-grid-view', 634 'outline': 'df-icon-list', 635 'close': 'df-icon-close', 636 'doublepage': 'df-icon-double-page', 637 'singlepage': 'df-icon-file', 638 'print': 'df-icon-print', 639 'play': 'df-icon-play', 640 'pause': 'df-icon-pause', 641 'search': 'df-icon-search', 642 'sound': 'df-icon-volume', 643 'sound-off': 'df-icon-volume', 644 'facebook': 'df-icon-facebook', 645 'google': 'df-icon-google', 646 'twitter': 'df-icon-twitter', 647 'whatsapp': 'df-icon-whatsapp', 648 'linkedin': 'df-icon-linkedin', 649 'pinterest': 'df-icon-pinterest', 650 'mail': 'df-icon-mail' 651 }, 652 // TRANSLATION text to be displayed 653 text: { 654 toggleSound: "Turn on/off Sound", 655 toggleThumbnails: "Toggle Thumbnails", 656 toggleOutline: "Toggle Outline/Bookmark", 657 previousPage: "Previous Page", 658 nextPage: "Next Page", 659 toggleFullscreen: "Toggle Fullscreen", 660 zoomIn: "Zoom In", 661 zoomOut: "Zoom Out", 662 resetZoom: "Reset Zoom", 663 pageFit: 'Fit Page', 664 widthFit: 'Fit Width', 665 toggleHelp: "Toggle Help", 666 search: "Search in PDF", 667 singlePageMode: "Single Page Mode", 668 doublePageMode: "Double Page Mode", 669 downloadPDFFile: "Download PDF File", 670 gotoFirstPage: "Goto First Page", 671 gotoLastPage: "Goto Last Page", 672 print: "Print", 673 play: "Start AutoPlay", 674 pause: "Pause AutoPlay", 675 share: "Share", 676 close: "Close", 677 mailSubject: "Check out this FlipBook", 678 mailBody: "Check out this site {{url}}", 679 loading: "Loading", 680 analyticsEventCategory: "DearPDF", 681 analyticsViewerReady: "Document Ready", 682 analyticsViewerOpen: "Document Opened", 683 analyticsViewerClose: "Document Closed", 684 analyticsFirstPageChange: "First Page Changed" 685 }, 686 share: { 687 'facebook': 'https://www.facebook.com/sharer/sharer.php?u={{url}}&t={{mailsubject}}', 688 'twitter': 'https://twitter.com/share?url={{url}}&text={{mailsubject}}', 689 'mail': undefined, 690 // calculated based on translate text.mailSubject and text.mailBody or can be directly overridden 691 'whatsapp': 'https://api.whatsapp.com/send/?text={{mailsubject}}+{{url}}&type=custom_url&app_absent=0', 692 'linkedin': 'https://www.linkedin.com/shareArticle?url={{url}}&title={{mailsubject}}', 693 'pinterest': 'https://www.pinterest.com/pin/create/button/?url={{url}}&media=&description={{mailsubject}}' 694 }, 695 //valid control-names: 696 //altPrev,pageNumber,altNext,outline,thumbnail,zoomIn,zoomOut,fullScreen,share 697 //more,download,pageMode,startPage,endPage,sound 698 allControls: "altPrev,pageNumber,altNext,play,outline,thumbnail,zoomIn,zoomOut,zoom,fullScreen,share,download,search,pageMode,startPage,endPage,sound,search,print,more", 699 moreControls: "download,pageMode,pageFit,startPage,endPage,sound", 700 leftControls: "outline,thumbnail", 701 rightControls: "fullScreen,share,download,more", 702 hideControls: "", 703 hideShareControls: "", 704 controlsPosition: defaults_DEARVIEWER.CONTROLS_POSITION.BOTTOM, 705 paddingTop: 20, 706 paddingLeft: 15, 707 paddingRight: 15, 708 paddingBottom: 20, 709 enableAnalytics: false, 710 //todo Analytics https://github.com/deepak-ghimire/dearviewer/issues/328 711 712 zoomRatio: 2, 713 pageScale: defaults_DEARVIEWER.PAGE_SCALE.PAGE_FIT, 714 controlsFloating: true, 715 sideMenuOverlay: true, 716 enableAnnotation: true, 717 enableAutoLinks: true, 718 //ACTIONS 719 arrowKeysAction: defaults_DEARVIEWER.ARROW_KEYS_ACTIONS.NAV, 720 clickAction: defaults_DEARVIEWER.MOUSE_CLICK_ACTIONS.NAV, 721 dblClickAction: defaults_DEARVIEWER.MOUSE_DBL_CLICK_ACTIONS.NONE, 722 mouseScrollAction: defaults_DEARVIEWER.MOUSE_SCROLL_ACTIONS.NONE, 723 linkTarget: defaults_DEARVIEWER.LINK_TARGET.BLANK, 724 //Resources settings 725 soundFile: "sound/turn2.mp3", 726 imagesLocation: "images", 727 imageResourcesPath: "images/pdfjs/", 728 popupThumbPlaceholder: 'data:image/svg+xml,' + escape('<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 210 297"><rect width="210" height="297" style="fill:#f1f2f2"/><circle cx="143" cy="95" r="12" style="fill:#e3e8ed"/><polygon points="131 138 120 149 95 124 34 184 176 185 131 138" style="fill:#e3e8ed"/></svg>'), 729 cMapUrl: "js/libs/cmaps/", 730 logo: "", 731 logoUrl: "", 732 sharePrefix: '', 733 pageSize: defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.AUTO, 734 // link to the images file that you want as background. 735 // supported files are jpgs,png. smaller files are preffered for performance 736 backgroundImage: "", 737 //"images/textures/el.jpg", 738 pixelRatio: window.devicePixelRatio || 1, 739 /*3D settings*/ 740 spotLightIntensity: 0.22, 741 ambientLightColor: "#fff", 742 ambientLightIntensity: 0.8, 743 shadowOpacity: 0.1, 744 slug: undefined, 745 headerElementSelector: undefined, 746 //callbacks 747 onReady: function onReady(app) { 748 // after document and viewer is loaded 749 }, 750 onPageChanged: function onPageChanged(app) { 751 // when page change is detected 752 }, 753 beforePageChanged: function beforePageChanged(app) { 754 // when page change validated but before pages are changed 755 }, 756 onCreate: function onCreate(app) { 757 // after app is created and initialized, viewer and document loading is not included 758 }, 759 onCreateUI: function onCreateUI(app) { 760 // after UI is created 761 }, 762 onFlip: function onFlip(app) { 763 // after flip event is fired 764 }, 765 beforeFlip: function beforeFlip(app) { 766 // before flip event is fired 767 }, 768 autoPDFLinktoViewer: false, 769 autoLightBoxFullscreen: false, 770 thumbLayout: 'book-title-hover', 771 cleanupAfterRender: true, 772 //creates issue in pdf.js version above 2.5.207 773 canvasWillReadFrequently: true, 774 providerType: 'pdf', 775 loadMoreCount: -1, 776 //0 and -1 will display all items
777 autoPlay: false, 778 autoPlayDuration: 1000, 779 autoPlayStart: false, 780 popupBackGroundColor: "#eee" 781}; 782 783//options that can be changed by users 784//Needed for: When user changed text or icons and just changed one, it impacted all others. 785defaults_DEARVIEWER.defaults = {}; 786defaults_DEARVIEWER.jQuery.extend(true, defaults_DEARVIEWER.defaults, defaults_DEARVIEWER._defaults); 787defaults_DEARVIEWER.viewers = {}; 788defaults_DEARVIEWER.providers = {}; 789defaults_DEARVIEWER.openFileOptions = {}; 790defaults_DEARVIEWER.executeCallback = function () {}; 791 792;// CONCATENATED MODULE: ./src/js/dearviewer/utils/utils.js 793function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } 794/* globals requirejs, jQuery*/ 795 796var DV = defaults_DEARVIEWER; 797var utils_jQuery = defaults_DEARVIEWER.jQuery; 798/*VARIABLES*/ 799var has3d = 'WebKitCSSMatrix' in window || document.body && 'MozPerspective' in document.body.style, 800 hasMouse = ('onmousedown' in window); 801var utils = DV.utils = { 802 mouseEvents: hasMouse ? { 803 type: "mouse", 804 start: "mousedown", 805 move: "mousemove", 806 end: "mouseup" 807 } : { 808 type: "touch", 809 start: "touchstart", 810 move: "touchmove", 811 end: "touchend" 812 }, 813 html: { 814 div: "<div></div>", 815 a: "<a>", 816 input: "<input type='text'/>", 817 select: "<select></select>" 818 }, 819 //functions or so 820 getSharePrefix: function getSharePrefix() { 821 //-dearpdf is used for backward compatibility and safety 822 var prefixes = utils.getSharePrefixes(); 823 return prefixes[0]; 824 }, 825 /** 826 * 827 * @returns {array} 828 */ 829 getSharePrefixes: function getSharePrefixes() { 830 return (DV.defaults.sharePrefix + ',dflip-,flipbook-,dearflip-,dearpdf-').split(",").map(function (e) { 831 return e.trim(); 832 }); 833 }, 834 toRad: function toRad(deg) { 835 return deg * Math.PI / 180; 836 }, 837 toDeg: function toDeg(rad) { 838 return rad * 180 / Math.PI; 839 }, 840 /** 841 * Object Fallback when empty 842 * @param {Object} checkVal Object to check if it's empty 843 * @param {Object} ifEmpty Object to use if checkVal is empty 844 * @returns {*} 845 */ 846 ifdef: function ifdef(checkVal) { 847 var ifEmpty = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 848 if (checkVal === null || checkVal === void 0) { 849 return ifEmpty; 850 } 851 return checkVal; 852 }, 853 createBtn: function createBtn(name, icon, text) { 854 // icon = options.icons[icon]; 855 // text = options.text[text]; 856 857 // noinspection CheckTagEmptyBody 858 var btn = utils_jQuery(utils.html.div, { 859 "class": "df-ui-btn df-ui-" + name, 860 title: text, 861 html: text !== void 0 ? '<span>' + text + '</span>' : '' 862 }); 863 if (icon !== void 0 && icon.indexOf('<svg') > -1) { 864 btn.html(icon.replace('<svg', '<svg xmlns="http://www.w3.org/2000/svg" ')); 865 } else { 866 btn.addClass(icon); 867 } 868 return btn; 869 }, 870 transition: function transition(hasTransition, duration) { 871 return hasTransition ? duration / 1000 + "s ease-out" : "0s none"; 872 }, 873 display: function display(hasDisplay) { 874 return hasDisplay ? "block" : "none"; 875 }, 876 resetTranslate: function resetTranslate() { 877 return utils.translateStr(0, 0); 878 }, 879 bgImage: function bgImage(src) { 880 return src == null || src === "blank" ? '' : ' url("' + src + '")'; 881 }, 882 translateStr: function translateStr(x, y) { 883 return has3d ? ' translate3d(' + x + 'px,' + y + 'px, 0px) ' : ' translate(' + x + 'px, ' + y + 'px) '; 884 }, 885 httpsCorrection: function httpsCorrection(url) { 886 if (url === null || url === void 0) return null; 887 if (typeof url !== "string") return url; 888 var location = window.location; 889 if (location.href.split(".")[0] === url.split(".")[0]) return url; 890 if (url.indexOf(location.hostname.replace("www.", "")) > -1) { 891 if (location.href.indexOf("https://") > -1) { 892 url = url.replace("http://", "https://"); 893 } else if (location.href.indexOf("http://") > -1) { 894 url = url.replace("https://", "http://"); 895 } 896 897 //correct www and non www 898 //match to www 899 if (location.href.indexOf("://www.") > -1 && url.indexOf("://www.") === -1) { 900 url = url.replace("://", "://www."); 901 } 902 //match to non www 903 if (location.href.indexOf("://www.") === -1 && url.indexOf("://www.") > -1) { 904 url = url.replace("://www.", "://"); 905 } 906 } 907 return url; 908 }, 909 rotateStr: function rotateStr(deg) { 910 return ' rotateZ(' + deg + 'deg) '; 911 }, 912 lowerPowerOfTwo: function lowerPowerOfTwo(value) { 913 return Math.pow(2, Math.floor(Math.log(value) / Math.LN2)); 914 }, 915 nearestPowerOfTwo: function nearestPowerOfTwo(value, max) { 916 return Math.min(max || 2048, Math.pow(2, Math.ceil(Math.log(value) / Math.LN2))); 917 }, 918 getFullscreenElement: function getFullscreenElement() { 919 //noinspection JSUnresolvedVariable 920 return document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement; 921 }, 922 hasFullscreenEnabled: function hasFullscreenEnabled() { 923 //noinspection JSUnresolvedVariable 924 return document.fullscreenEnabled || document.mozFullScreenEnabled || document.webkitFullscreenEnabled || document.msFullscreenEnabled; 925 },
926 fixMouseEvent: function fixMouseEvent(event) { 927 if (event) { 928 var originalEvent = event.originalEvent || event; 929 930 //noinspection JSUnresolvedVariable 931 if (originalEvent.changedTouches && originalEvent.changedTouches.length > 0) { 932 var _event = utils_jQuery.event.fix(event); 933 //noinspection JSUnresolvedVariable 934 var touch = originalEvent.changedTouches[0]; 935 _event.clientX = touch.clientX; 936 _event.clientY = touch.clientY; 937 _event.pageX = touch.pageX; 938 _event.touches = originalEvent.touches; 939 _event.pageY = touch.pageY; 940 _event.movementX = touch.movementX; 941 _event.movementY = touch.movementY; 942 return _event; 943 } else { 944 return event; 945 } 946 } else { 947 return event; 948 } 949 }, 950 limitAt: function limitAt(x, min, max) { 951 return x < min ? min : x > max ? max : x; 952 }, 953 distOrigin: function distOrigin(x, y) { 954 return utils.distPoints(0, 0, x, y); 955 }, 956 distPoints: function distPoints(x1, y1, x2, y2) { 957 return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)); 958 }, 959 angleByDistance: function angleByDistance(distance, fullWidth) { 960 var h = fullWidth / 2; 961 var d = utils.limitAt(distance, 0, fullWidth); 962 return d < h ? utils.toDeg(Math.asin(d / h)) : 90 + utils.toDeg(Math.asin((d - h) / h)); 963 }, 964 calculateScale: function calculateScale(startTouches, endTouches) { 965 var startDistance = utils.distPoints(startTouches[0].x, startTouches[0].y, startTouches[1].x, startTouches[1].y), 966 endDistance = utils.distPoints(endTouches[0].x, endTouches[0].y, endTouches[1].x, endTouches[1].y); 967 return endDistance / startDistance; 968 }, 969 /** 970 * Calculates the average of multiple vectors (x, y values) 971 */ 972 getVectorAvg: function getVectorAvg(vectors) { 973 return { 974 x: vectors.map(function (v) { 975 return v.x; 976 }).reduce(utils.sum) / vectors.length, 977 y: vectors.map(function (v) { 978 return v.y; 979 }).reduce(utils.sum) / vectors.length 980 }; 981 }, 982 sum: function sum(a, b) { 983 return a + b; 984 }, 985 /** 986 * Returns the touches of an event relative to the container offset 987 * @param event 988 * @param position 989 * @return array touches 990 */ 991 getTouches: function getTouches(event, position) { 992 position = position || { 993 left: 0, 994 top: 0 995 }; 996 return Array.prototype.slice.call(event.touches).map(function (touch) { 997 return { 998 x: touch.pageX - position.left, 999 y: touch.pageY - position.top 1000 }; 1001 }); 1002 }, 1003 getScriptCallbacks: [], 1004 getScript: function getScript(source, callback, errorCallback) { 1005 var _callbacks = utils.getScriptCallbacks[source], 1006 script; 1007 function clean() { 1008 script.removeEventListener("load", load, false); 1009 script.removeEventListener("readystatechange", load, false); 1010 script.removeEventListener("complete", load, false); 1011 script.removeEventListener("error", onError, false); 1012 script.onload = script.onreadystatechange = null; 1013 script = null; 1014 script = null; 1015 } 1016 function load(_, isAbort) { 1017 if (script != null) { 1018 //IE 10 doesn't regard 1019 if (isAbort || !script.readyState || /loaded|complete/.test(script.readyState)) { 1020 //console.log("aborted loading :" + source); 1021 if (!isAbort) { 1022 for (var i = 0; i < _callbacks.length; i++) { 1023 if (_callbacks[i]) _callbacks[i](); 1024 _callbacks[i] = null; 1025 } 1026 errorCallback = null; 1027 } 1028 clean(); 1029 } 1030 } 1031 } 1032 function onError() { 1033 errorCallback(); 1034 clean(); 1035 errorCallback = null; 1036 } 1037 if (utils_jQuery("script[src='" + source + "']").length === 0) { 1038 _callbacks = utils.getScriptCallbacks[source] = []; 1039 _callbacks.push(callback); 1040 script = document.createElement('script'); 1041 var prior = document.body.getElementsByTagName('script')[0]; 1042 script.async = true; 1043 script.setAttribute("data-cfasync", "false"); 1044 if (prior != null) { 1045 prior.parentNode.insertBefore(script, prior); 1046 prior = null; 1047 } else { 1048 //sometimes if script are loaded in head and no scripts are present in body 1049 document.body.appendChild(script); 1050 } 1051 script.addEventListener("load", load, false); 1052 script.addEventListener("readystatechange", load, false); 1053 script.addEventListener("complete", load, false); 1054 if (errorCallback) { 1055 script.addEventListener("error", onError, false); 1056 } 1057 //Todo check if removing random(1) to random() has any effect 1058 script.src = source + (utils.prefix.dom === "MS" ? "?" + Math.random() : ""); 1059 } else { 1060 _callbacks.push(callback); 1061 } 1062 }, 1063 detectScriptLocation: function detectScriptLocation() { 1064 //Auto-detection if the folder structure is copied properly 1065 if (typeof window[defaults_DEARVIEWER.locationVar] == 'undefined') { 1066 utils_jQuery("script").each(function () { 1067 var src = utils_jQuery(this)[0].src; 1068 // noinspection HttpUrlsUsage 1069 if ((src.indexOf("/" + defaults_DEARVIEWER.locationFile + ".js") > -1 || src.indexOf("/" + defaults_DEARVIEWER.locationFile + ".min.js") > -1 || src.indexOf("js/" + defaults_DEARVIEWER.locationFile + ".") > -1) && (src.indexOf("https://") > -1 || src.indexOf("http://") > -1)) { 1070 var splits = src.split("/"); 1071 window[defaults_DEARVIEWER.locationVar] = splits.slice(0, -2).join("/"); 1072 } 1073 }); 1074 } 1075 //if locationVar is relative, change it to absolute 1076 else if (window[defaults_DEARVIEWER.locationVar].indexOf(":") == -1) { 1077 var a = document.createElement("a"); 1078 a.href = window[defaults_DEARVIEWER.locationVar]; 1079 window[defaults_DEARVIEWER.locationVar] = a.href; 1080 a = null; 1081 } 1082 if (typeof window[defaults_DEARVIEWER.locationVar] !== 'undefined') { 1083 //add ending forward slash trail for safety 1084 if (window[defaults_DEARVIEWER.locationVar].length > 2 && window[defaults_DEARVIEWER.locationVar].slice(-1) !== "/") { 1085 window.window[defaults_DEARVIEWER.locationVar] += "/"; 1086 } 1087 } 1088 }, 1089 disposeObject: function disposeObject(object) { 1090 if (object && object.dispose) { 1091 object.dispose(); 1092 } 1093 object = null; 1094 return object; 1095 }, 1096 log: function log() { 1097 var _console; 1098 if (DV.defaults.enableDebugLog === true && window.console) (_console = console).log.a
1098pply(_console, arguments); 1099 }, 1100 color: { 1101 getBrightness: function getBrightness(hex) { 1102 var rgb = hex.replace("#", "").match(/.{1,2}/g).map(function (e) { 1103 return parseInt(e, 16); 1104 }); 1105 return rgb[0] * .299 + rgb[1] * .587 + rgb[2] * .114; 1106 }, 1107 isLight: function isLight(hex) { 1108 return !utils.color.isDark(hex); 1109 }, 1110 isDark: function isDark(hex) { 1111 return utils.color.getBrightness(hex) < 128; 1112 } 1113 }, 1114 isMobile: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), 1115 isIOS: /(iPad|iPhone|iPod)/g.test(navigator.userAgent), 1116 isIPad: function () { 1117 return navigator.maxTouchPoints && navigator.maxTouchPoints > 2 && /Mac/.test(navigator.platform); 1118 }(), 1119 isSafari: function () { 1120 // noinspection JSCheckFunctionSignatures 1121 return /constructor/i.test(window.HTMLElement) || function (p) { 1122 return p.toString() === "[object SafariRemoteNotification]"; 1123 }(!window['safari'] || window['safari']['pushNotification']); 1124 }(), 1125 isIEUnsupported: navigator.userAgent.match(/(MSIE|Trident)/), 1126 isSafariWindows: function isSafariWindows() { 1127 return !utils.isIOS && utils.isSafari; 1128 }, 1129 //self Execution 1130 hasWebgl: function () { 1131 try { 1132 var canvas = document.createElement('canvas'); 1133 //noinspection JSUnresolvedVariable 1134 return !!(window.WebGLRenderingContext && (canvas.getContext('webgl') || canvas.getContext('experimental-webgl'))); 1135 } catch (e) { 1136 return false; 1137 } 1138 }(), 1139 canSupport3D: function canSupport3D() { 1140 var canSupport = true; 1141 try { 1142 if (utils.hasWebgl == false) { 1143 canSupport = false; 1144 console.log("Proper Support for Canvas webgl 3D not detected!"); 1145 } else if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) { 1146 canSupport = false; 1147 console.log("Proper Support for 3D not detected for IE!"); 1148 } else if (utils.isSafari && !utils.isIOS) { 1149 canSupport = false; 1150 console.log("Proper Support for 3D not detected for IOS!"); 1151 } else { 1152 var android = navigator.userAgent.toString().toLowerCase().match(/android\s([0-9\.]*)/i); 1153 android = android ? android[1] : undefined; 1154 if (android) { 1155 android = parseInt(android, 10); 1156 if (!isNaN(android) && android < 9) { 1157 canSupport = false; 1158 console.log("Proper Support for 3D not detected for Android below 9.0!"); 1159 } 1160 } 1161 } 1162 } catch (error) {} 1163 return canSupport; 1164 }, 1165 prefix: function () { 1166 var styles = window.getComputedStyle(document.documentElement, ''), 1167 pre = Array.prototype.slice.call(styles).join('').match(/-(moz|webkit|ms)-/)[1], 1168 dom = 'WebKit|Moz|MS'.match(new RegExp('(' + pre + ')', 'i'))[1]; 1169 return { 1170 dom: dom, 1171 lowercase: pre, 1172 css: '-' + pre + '-', 1173 js: pre[0].toUpperCase() + pre.substr(1) 1174 }; 1175 }(), 1176 scrollIntoView: function scrollIntoView(element, reference, align) { 1177 reference = reference || element.parentNode; 1178 reference.scrollTop = element.offsetTop + (align === false ? element.offsetHeight - reference.offsetHeight : 0); 1179 reference.scrollLeft = element.offsetLeft - reference.offsetLeft; 1180 }, 1181 getVisibleElements: function getVisibleElements(options) { 1182 var container = options.container; 1183 var elements = options.elements; 1184 var visible = options.visible || []; 1185 var top = container.scrollTop, 1186 bottom = top + container.clientHeight; 1187 if (bottom == 0) return visible; 1188 var minIndex = 0, 1189 maxIndex = elements.length - 1; 1190 var element = elements[minIndex]; 1191 var elementBottom = element.offsetTop + element.clientTop + element.clientHeight; 1192 if (elementBottom < top) { 1193 //check first page 1194 while (minIndex < maxIndex) { 1195 var currentIndex = minIndex + maxIndex >> 1; 1196 element = elements[currentIndex]; 1197 elementBottom = element.offsetTop + element.clientTop + element.clientHeight; 1198 if (elementBottom > top) { 1199 maxIndex = currentIndex; 1200 } else { 1201 minIndex = currentIndex + 1; 1202 } 1203 } 1204 } 1205 for (var i = minIndex; i < elements.length; i++) { 1206 element = elements[i]; 1207 var elementTop = element.offsetTop + element.clientTop; 1208 if (elementTop <= bottom) { 1209 visible.push(i + 1); 1210 } else { 1211 break; 1212 } 1213 } 1214 return visible; 1215 }, 1216 getMouseDelta: function getMouseDelta(event) { 1217 var delta = 0; 1218 if (event['wheelDelta'] != null) { 1219 // WebKit / Opera / Explorer 9 1220 1221 delta = event['wheelDelta']; 1222 } else if (event.detail != null) { 1223 // Firefox 1224 1225 delta = -event.detail; 1226 } 1227 return delta; 1228 }, 1229 pan: function pan(viewer, point) { 1230 var reset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1231 var origin = viewer.startPoint; 1232 var scale = viewer.app.zoomValue; 1233 var left = viewer.left + (reset === true ? 0 : point.raw.x - origin.raw.x), 1234 top = viewer.top + (reset === true ? 0 : point.raw.y - origin.raw.y); 1235 1236 //round removes blur due to decimal value in transform. 1237 viewer.left = Math.ceil(utils.limitAt(left, -viewer.shiftWidth, viewer.shiftWidth)); 1238 viewer.top = Math.ceil(utils.limitAt(top, -viewer.shiftHeight, viewer.shiftHeight)); 1239 if (scale === 1) { 1240 viewer.left = 0; 1241 viewer.top = 0; 1242 } 1243 if (reset === false) { 1244 viewer.startPoint = point; 1245 } 1246 1247 //requires updatePan to update in DOM 1248 } 1249}; 1250 1251utils.isChromeExtension = function () { 1252 return window.location.href.indexOf("chrome-extension://") === 0; 1253}; 1254var NullCharactersRegExp = /\x00+/g; 1255var InvisibleCharactersRegExp = /[\x01-\x1F]/g; 1256utils.removeNullCharacters = function (str) { 1257 var replaceInvisible = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 1258 if (typeof str !== "string") { 1259 warn("The argument for removeNullCharacters must be a string."); 1260 return str; 1261 } 1262 if (replaceInvisible) { 1263 str = str.replace(InvisibleCharactersRegExp, " "); 1264 } 1265 return str.replace(NullCharactersRegExp, ""); 1266}; 1267defaults_DEARVIEWER.hashFocusBookFound = false; 1268utils.detectHash = function () { 1269 defaults_DEARVIEWER.preParseHash = window.location.hash; 1270 //parse hash and check if any exists 1271 1272 /** 1273 * @type {boolean} - Introduced due to a user case where the same hash was detected twice and clicked twice. 1274 */ 1275 1276 var prefixes = utils.getSharePrefixes(); 1277 if (prefixes.indexOf("") == 0) prefixes.push(""); 1278 Array.prototype.every.call(utils.getSharePrefixes(), function (prefix) { 1279 var hash = defaults_DEARVIEWER.preParseHash; 1280 if (hash && hash.indexOf(prefix) >= 0 && defaults_DEARVIEWER.hashFocusBookFound === false) { 1281 if (prefix.length > 0) { 1282 hash = hash.split(prefix)[1]; 1283 } 1284 var id = hash.split('/')[0].replace("#", ""); 1285 var page = hash.split('/')[1]; 1286 if (page != null) { 1287 page = page.split('/')[0]; 1288 } 1289 var book; 1290 //first check for slug pattern 1291 book = utils_jQuery("[data-slug=" + id + "]"); 1292 //then id pattern 1293 if (book.length === 0) book = utils_jQuery('#df-' + id + ",#" + id); 1294 //then _slug pattern 1295 if (book.length === 0) book = utils_jQuery("[data-_slug=" + id + "]"); 1296 if (book.length > 0 && book.is("._df_thumb,._df_button,._df_custom,._df_link,._df_book,.df-element,.dp-element")) { 1297 book = utils_jQuery(book[0]); 1298 defaults_DEARVIEWER.hashFocusBookFound = true; 1299 page = parseInt(page, 10); 1300 1301 //case : flipbook is already created, thus link moves the page 1302 var app = defaults_DEARVIEWER.activeLightBox && defaults_DEARVIEWER.activeLightBox.app || book.data("df-app"); 1303 if (app != null) { 1304 app.gotoPage(page); 1305 app.hashNavigationEnabled = true; 1306 utils.focusHash(app.element); 1307 return false; 1308 } else if (page != null) { 1309 book.attr("data-hash-page", page); //data-has-page shall be removed after it is used 1310 //data added attribues cannot be searched or fetched using selectors annd attr() 1311 //when shortcode specifies page 1, but url says page 5, page 1 is added using attr data-page 1312 } 1313 1314 book.addClass("df-hash-focused", true); 1315 if (book.data('lightbox') != null) { 1316 book.trigger("click"); 1317 } else if (book.attr("href") != null && book.attr("href").indexOf(".pdf") > -1) { 1318 book.trigger("click"); 1319 } 1320 return false; 1321 } 1322 } 1323 }); 1324}; 1325utils.focusHash = function (element) { 1326 var _element$0$scrollInto, _element$; 1327 (_element$0$scrollInto = (_element$ = element[0]).scrollIntoView) === null || _element$0$scrollInto === void 0 || _element$0$scrollInto.call(_element$, { 1328 behavior: "smooth", 1329 block: "end", 1330 inline: "nearest" 1331 }); 1332}; 1333 1334/** 1335 * Conserve aspect ratio of the original region. Useful when shrinking/enlarging 1336 * images to fit into a certain area. 1337 * 1338 * @param {Number} srcWidth width of source image 1339 * @param {Number} srcHeight height of source image 1340 * @param {Number} maxWidth maximum available width 1341 * @param {Number} maxHeight maximum available height 1342 * @return {Object} { width, height } 1343 */ 1344utils.contain = function (srcWidth, srcHeight, maxWidth, maxHeight) { 1345 var ratio = Math.min(maxWidth / srcWidth, maxHeight / srcHeight); 1346 return { 1347 width: srcWidth * ratio, 1348 height: srcHeight * ratio 1349 }; 1350}; 1351utils.containUnStretched = function (srcWidth, srcHeight, maxWidth, maxHeight) { 1352 var ratio = Math.min(1, maxWidth / srcWidth, maxHeight / srcHeight); 1353 return { 1354 width: srcWidth * ratio, 1355 height: srcHeight * ratio 1356 }; 1357}; 1358utils.fallbackOptions = function (options) { 1359 //todo this could work without fallback 1360 if (options.share['mail'] === undefined) { 1361 options.share['mail'] = 'mailto:?subject=' + options.text.mailSubject + '&body=' + options.text.mailBody; 1362 } 1363 if (options.openPage) { 1364 options.openPage = parseInt(options.openPage, 10); 1365 } 1366 return options; 1367}; 1368var getAttributes = function getAttributes(element) { 1369 var attrOptions = {}; 1370 var attrKeys = { 1371 'id': '', 1372 'thumb': '',
1373 'openPage': 'data-hash-page,data-page,page', 1374 'target': '', 1375 'height': '', 1376 'source': 'pdf-source', 1377 'is3D': 'webgl,is3d', 1378 'viewerType': 'viewertype,viewer-type', 1379 'pagemode': '' 1380 }; 1381 for (var key in attrKeys) { 1382 var aliases = (key + "," + attrKeys[key]).split(","); 1383 for (var i = 0; i < aliases.length; i++) { 1384 var alias = aliases[i]; 1385 if (alias !== '') { 1386 var val = element.data(alias); 1387 if (val !== null && val != "" && val != void 0) { 1388 attrOptions[key] = val; 1389 break; 1390 } 1391 val = element.attr(alias); 1392 if (val !== null && val != "" && val != void 0) { 1393 attrOptions[key] = val; 1394 break; 1395 } 1396 } 1397 } 1398 } 1399 1400 //clear temporary attributes 1401 element.removeAttr('data-hash-page'); 1402 return attrOptions; 1403}; 1404 1405//getOptions of a specific book in DOM and merge with respective variable 1406utils.getOptions = function (element) { 1407 element = utils_jQuery(element); 1408 if (element.data("option") == void 0) { 1409 element.data("option", "option_" + element.attr("id")); 1410 } 1411 if (element.attr("source") !== void 0) { 1412 element.data("source", element.attr("source")); 1413 } 1414 1415 //GetOption Variable 1416 var optionVar = element.data("option"); 1417 var options = void 0; 1418 if (_typeof(optionVar) === "object") { 1419 options = optionVar; 1420 } else { 1421 options = optionVar == null || optionVar === "" || window[optionVar] == null ? {} : window[optionVar]; 1422 } 1423 //get all options defined in attributes 1424 var attrOptions = getAttributes(element); 1425 1426 //merge options, attribute options override variable options 1427 options = utils_jQuery.extend(true, {}, options, attrOptions); 1428 return options; 1429}; 1430utils.isTrue = function (val) { 1431 return val === "true" || val === true; 1432}; 1433utils.parseInt = function (option) { 1434 return parseInt(option, 10); 1435}; 1436utils.parseFloat = function (option) { 1437 return parseFloat(option); 1438}; 1439utils.parseIntIfExists = function (option) { 1440 if (option !== void 0) { 1441 option = parseInt(option, 10); 1442 } 1443 return option; 1444}; 1445utils.parseFloatIfExists = function (option) { 1446 if (option !== void 0) { 1447 option = parseFloat(option); 1448 } 1449 return option; 1450}; 1451utils.parseBoolIfExists = function (option) { 1452 if (option !== void 0) { 1453 option = utils.isTrue(option); 1454 } 1455 return option; 1456}; 1457utils.sanitizeOptions = function (options) { 1458 options.showDownloadControl = utils.parseBoolIfExists(options.showDownloadControl); 1459 options.showSearchControl = utils.parseBoolIfExists(options.showSearchControl); 1460 options.showPrintControl = utils.parseBoolIfExists(options.showPrintControl); 1461 options.flipbook3DTiltAngleLeft = utils.parseIntIfExists(options.flipbook3DTiltAngleLeft); 1462 options.flipbook3DTiltAngleUp = utils.parseIntIfExists(options.flipbook3DTiltAngleUp); 1463 options.paddingLeft = utils.parseIntIfExists(options.paddingLeft); 1464 options.paddingRight = utils.parseIntIfExists(options.paddingRight); 1465 options.paddingTop = utils.parseIntIfExists(options.paddingTop); 1466 options.paddingBottom = utils.parseIntIfExists(options.paddingBottom); 1467 options.duration = utils.parseIntIfExists(options.duration); 1468 options.rangeChunkSize = utils.parseIntIfExists(options.rangeChunkSize); 1469 options.maxTextureSize = utils.parseIntIfExists(options.maxTextureSize); 1470 options.linkTarget = utils.parseIntIfExists(options.linkTarget); 1471 options.zoomRatio = utils.parseFloatIfExists(options.zoomRatio); 1472 options.enableAnalytics = utils.parseBoolIfExists(options.enableAnalytics); 1473 options.autoPlay = utils.parseBoolIfExists(options.autoPlay); 1474 options.autoPlayStart = utils.parseBoolIfExists(options.autoPlayStart); 1475 options.autoPlayDuration = utils.parseIntIfExists(options.autoPlayDuration); 1476 if (options.loadMoreCount !== void 0) { 1477 options.loadMoreCount = utils.parseInt(options.loadMoreCount); 1478 if (isNaN(options.loadMoreCount) || options.loadMoreCount === 0) options.loadMoreCount = -1; 1479 } 1480 if (options.source != null && (Array === options.source.constructor || Array.isArray(options.source) || options.source instanceof Array)) { 1481 for (var _correct = 0; _correct < options.source.length; _correct++) { 1482 options.source[_correct] = utils.httpsCorrection(options.source[_correct]); 1483 } 1484 } else { 1485 options.source = utils.httpsCorrection(options.source); 1486 } 1487 return options; 1488}; 1489utils.finalizeOptions = function (options) { 1490 return options; 1491}; 1492//Possible improvements: https://www.npmjs.com/package/linkifyjs 1493utils.urlify = function (text) { 1494 var myRegexp = /[a-z0-9][^\s,]{3,}\.[^\s,]+[a-z0-9]/gi; 1495 var result, 1496 hits = []; 1497 while (result = myRegexp.exec(text)) { 1498 var url = result[0]; 1499 if (url.indexOf("@") > -1) { 1500 if (url.match(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/gi)) { 1501 hits.push({ 1502 index: result.index, 1503 length: url.length, 1504 text: url 1505 }); 1506 } 1507 } else if (url.match(/[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b[-a-zA-Z0-9@:%_\+.~#?&//=]*/g)) { 1508 if (url.indexOf('http:') === 0 || url.indexOf('https:') === 0 || url.indexOf('www.') === 0) { 1509 hits.push({ 1510 index: result.index, 1511 length: url.length, 1512 text: url 1513 }); 1514 } 1515 } 1516 } 1517 return hits; 1518 //can have multiple match in a text 1519 return text.replace(myRegexp, function (url, a, b) { 1520 if (url.indexOf("@") > -1) { 1521 //this is a mail just verify if valid 1522 if (url.match(/^((?!\.)[\w_.-]*[^.])(@\w+)(\.\w+(\.\w+)?[^.\W])$/gi)) { 1523 var url2 = url.toLowerCase(); 1524 if (url.indexOf("mailto:" === -1)) url2 = "mailto:" + url; 1525 utils.log("AutoLink: " + url2 + " for " + url); 1526 return '<a href="' + url2 + '" ' + 'class="df-autolink" target="_blank">' + url + '</a>'; 1527 } 1528 } else { 1529 //this is a domain like just verify if valid 1530 if (url.match(/[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b[-a-zA-Z0-9@:%_\+.~#?&//=]*/g)) { 1531 var url2 = url; 1532 if (url.indexOf('www.') === 0) { 1533 url2 = 'http://' + url; 1534 } else if (url2.indexOf('http:') === -1 && url2.indexOf('https:') === -1) { 1535 return url; 1536 } 1537 utils.log("AutoLink: " + url2 + " for " + url); 1538 return '<a href="' + url2 + '" class="df-autolink" target="_blank">' + url + '</a>'; 1539 } 1540 } 1541 return url; 1542 }); 1543}; 1544utils.oldurlify = function (text) { 1545 //https://regex101.com/r/cX0pJ8/1 1546 var urlRegex = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;
1546:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[.\!\/\\w]*))?)/g; 1547 // urlRegex = /(((https?:\/\/)|(www\.))[^\s]+)/g; 1548 // noinspection HttpUrlsUsage 1549 return text.replace(urlRegex, function (url, b, c, d, e) { 1550 url = url.toLowerCase(); 1551 var url2 = url; 1552 if (url.indexOf(':') > 0 && url.indexOf('http:') === -1 && url.indexOf('https:') === -1) { 1553 utils.log("AutoLink Rejected: " + url2 + " for " + url); 1554 return url; 1555 } else if (url.indexOf('www.') === 0) { 1556 url2 = 'http://' + url; 1557 } else if (url.indexOf('http://') === 0 || url.indexOf('https://') === 0) {} else if (url.indexOf('mailto:') === 0) {} else if (url.indexOf('@') > 0) { 1558 url2 = 'mailto:' + url; 1559 var mailformat = /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/; 1560 if (url.match(mailformat) === null) { 1561 utils.log("AutoLink Rejected: " + url2 + " for " + url); 1562 return url; 1563 } 1564 } 1565 utils.log("AutoLink: " + url2 + " for " + url); 1566 return '<a href="' + url2 + '" class="df-autolink" target="_blank">' + url + '</a>'; 1567 }); 1568}; 1569 1570// Test via a getter in the options object to see if the passive property is accessed 1571utils.supportsPassive = false; 1572try { 1573 var opts = Object.defineProperty({}, 'passive', { 1574 get: function get() { 1575 utils.supportsPassive = true; 1576 } 1577 }); 1578 window.addEventListener("testPassive", null, opts); 1579 window.removeEventListener("testPassive", null, opts); 1580} catch (e) {} 1581function getDataFromClass(el) { 1582 var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "dvcss_e_"; 1583 var classList = el.classList, 1584 className; 1585 for (var i = 0; i < classList.length; i++) { 1586 className = classList[i]; 1587 if (className.indexOf(prefix) === 0) return className; 1588 } 1589 return null; 1590} 1591defaults_DEARVIEWER.parseCSSElements = function () { 1592 utils_jQuery(".dvcss").each(function () { 1593 var el = utils_jQuery(this); 1594 var cssData = getDataFromClass(el[0]); 1595 el.removeClass(cssData).removeClass("dvcss"); 1596 cssData = cssData.replace("dvcss_e_", ""); 1597 var data; 1598 try { 1599 data = JSON.parse(atob(cssData)); 1600 } catch (e) {} 1601 if (data) { 1602 var option_id = "df_option_" + data.id; 1603 window[option_id] = utils_jQuery.extend(true, {}, window[option_id], data); 1604 el.addClass("df-element"); 1605 if (data.lightbox !== "none") { 1606 el.attr("data-lightbox", data.lightbox === void 0 ? "custom" : data.lightbox); 1607 if (data.lightbox == "thumb") el.attr("data-thumb", data.pdfThumb); 1608 if (data.thumbLayout) el.attr("data-thumb-layout", data.thumbLayout); 1609 if (data.apl) el.attr("apl", data.apl); 1610 } 1611 el.data("option", option_id); 1612 //attr is required, data("slug") cannot be used in selector 1613 el.attr("data-slug", data.slug); 1614 el.attr("id", "df_" + data.id); 1615 } 1616 }); 1617}; 1618defaults_DEARVIEWER.parseThumbs = function (args) { 1619 args.element.html(""); 1620 if (args.thumbURL == null || args.thumbURL.toString().trim() == '') { 1621 args.element.addClass("df-thumb-not-found"); 1622 args.thumbURL = defaults_DEARVIEWER.defaults.popupThumbPlaceholder; 1623 } 1624 var titleElement = utils_jQuery("<span class='df-book-title'>").html(args.title); 1625 var wrapperElement = utils_jQuery("<div class='df-book-wrapper'>").appendTo(args.element); 1626 wrapperElement.append(utils_jQuery("<div class='df-book-page1'>")); 1627 wrapperElement.append(utils_jQuery("<div class='df-book-page2'>")); 1628 var coverElement = utils_jQuery("<div class='df-book-cover'>").append(titleElement).appendTo(wrapperElement); 1629 var image = utils_jQuery('<img width="210px" height="297px" class="df-lazy" alt="' + args.title + '"/>'); 1630 image.attr('data-src', args.thumbURL); 1631 image.attr('src', defaults_DEARVIEWER.defaults.popupThumbPlaceholder);
1632 coverElement.prepend(image); 1633 defaults_DEARVIEWER.addLazyElement(image[0]); 1634 if (defaults_DEARVIEWER.defaults.displayLightboxPlayIcon === true) coverElement.addClass("df-icon-play-popup"); 1635 if (args.thumbLayout === "book-title-bottom" || args.thumbLayout === "cover-title") { 1636 if (args.hasShelf) { 1637 args.thumbLayout = "book-title-fixed"; 1638 } else { 1639 titleElement.appendTo(args.element); 1640 } 1641 if (defaults_DEARVIEWER.defaults.displayLightboxPlayIcon === true) { 1642 args.element.removeClass("df-icon-play-popup"); 1643 wrapperElement.addClass("df-icon-play-popup"); 1644 } 1645 } 1646 args.element.addClass("df-tl-" + args.thumbLayout); 1647 args.element.attr("title", args.title); 1648}; 1649defaults_DEARVIEWER.initId = 10; 1650defaults_DEARVIEWER.embeds = []; 1651defaults_DEARVIEWER.removeEmbeds = []; 1652defaults_DEARVIEWER.removeEmbedsLimit = utils.isMobile ? 1 : 2; 1653defaults_DEARVIEWER.parseNormalElements = function () { 1654 utils_jQuery('.df-posts').each(function () { 1655 if (defaults_DEARVIEWER.defaults.loadMoreCount === false || defaults_DEARVIEWER.defaults.loadMoreCount === -1) return; 1656 var postsWrapper = utils_jQuery(this); 1657 var parsed = postsWrapper.data("parsed"); 1658 1659 //skip if already parsed or failed 1660 if (parsed !== "true") { 1661 postsWrapper.data("parsed", "true"); 1662 postsWrapper.attr("df-parsed", "true"); //backward-compatibility - issue #374 https://github.com/deepak-ghimire/dearviewer/issues/374 1663 1664 var count = 0; 1665 var books = postsWrapper.find('.df-element'); 1666 var totalBooks = books.length; 1667 books.each(function () { 1668 //skip first n books 1669 count++; 1670 if (count > defaults_DEARVIEWER.defaults.loadMoreCount) utils_jQuery(this).attr("skip-parse", "true"); 1671 }); 1672 if (totalBooks > defaults_DEARVIEWER.defaults.loadMoreCount) { 1673 postsWrapper.append("<div class='df-load-more-button-wrapper'><div class='df-load-more-button'>Load More..</div></div>"); 1674 } 1675 } 1676 }); 1677 defaults_DEARVIEWER.triggerId = 10; 1678 utils_jQuery('.df-element').each(function () { 1679 var element = utils_jQuery(this); 1680 if (element.attr("skip-parse") === "true") return; 1681 var isParsed = element.data("parsed"); 1682 if (isParsed !== "true") { 1683 element.data("parsed", "true"); 1684 element.attr("df-parsed", "true"); //backward-compatibility 1685 1686 var lightboxType = element.data("lightbox"); 1687 if (lightboxType === void 0) { 1688 element.addClass("df-lazy-embed"); 1689 defaults_DEARVIEWER.addLazyElement(element[0]); 1690 //element.dearviewer(); 1691 } else { 1692 element.addClass("df-popup-" + lightboxType); 1693 if (lightboxType === "thumb") { 1694 var thumbLayout = element.data("thumb-layout") || defaults_DEARVIEWER.defaults.thumbLayout; 1695 var thumbURL = utils.httpsCorrection(element.data("thumb")); 1696 element.removeAttr("data-thumb").removeAttr("data-thumb-layout"); 1697 var innerText = element.html().trim(); 1698 if (innerText === undefined || innerText === "") { 1699 innerText = "Click to Open"; 1700 } 1701 var hasShelf = element.parent().hasClass('df-has-shelf'); 1702 defaults_DEARVIEWER.parseThumbs({ 1703 element: element, 1704 thumbURL: thumbURL, 1705 title: innerText, 1706 thumbLayout: thumbLayout, 1707 hasShelf: hasShelf 1708 }); 1709 if (hasShelf) element.after(utils_jQuery("<df-post-shelf>")); 1710 } else if (lightboxType === "button") { 1711 if (defaults_DEARVIEWER.defaults.buttonClass) { 1712 element.addClass(defaults_DEARVIEWER.defaults.buttonClass); 1713 } 1714 } 1715 } 1716 var triggers = element.attr("data-trigger"); 1717 if (triggers != null && triggers.length > 1) { 1718 triggers = triggers.split(","); 1719 defaults_DEARVIEWER.triggerId++; 1720 triggers.forEach(function (trigger) { 1721 element.attr("df-trigger-id", defaults_DEARVIEWER.triggerId); 1722 utils_jQuery("#" + trigger).addClass("df-trigger").attr("df-trigger", defaults_DEARVIEWER.triggerId); 1723 }); 1724 } 1725 1726 //edit-link if available 1727 if (element.data("editlink")) { 1728 element.append('<a class="df-edit-link" href="' + element.data("editlink") + '" >Edit Book</a>'); 1729 } 1730 } 1731 }); 1732 defaults_DEARVIEWER.handleLazy = function () { 1733 //remove removeembeds 1734 var appId; 1735 if (defaults_DEARVIEWER.removeEmbeds.length > defaults_DEARVIEWER.removeEmbedsLimit) { 1736 appId = defaults_DEARVIEWER.removeEmbeds.shift(); 1737 if (appId) { 1738 var element = utils_jQuery("[initID='" + appId + "']"); 1739 if (element.length > 0) { 1740 var app = element.data("df-app"); 1741 if (app) { 1742 element.attr("data-page", app.currentPageNumber); 1743 utils.log("Removed app id " + appId); 1744 app.dispose(); 1745 app = null; 1746 } 1747 } 1748 } 1749 } 1750 //add embeds 1751 appId = defaults_DEARVIEWER.embeds.shift(); 1752 if (appId) { 1753 var _element = utils_jQuery("[initID='" + appId + "']"); 1754 if (_element.length > 0) { 1755 if (_element.is("img")) { 1756 if (_element.hasClass("df-lazy")) { 1757 _element.attr("src", _element.attr("data-src")); 1758 _element.removeAttr("data-src"); 1759 _element.removeClass("df-lazy"); 1760 defaults_DEARVIEWER.lazyObserver.unobserve(_element[0]); 1761 defaults_DEARVIEWER.handleLazy(); 1762 } else { 1763 utils.log("Prevent this"); 1764 defaults_DEARVIEWER.handleLazy(); 1765 } 1766 } else { 1767 var _app = _element.data("df-app"); 1768 if (_app == null) { 1769 _element.dearviewer(); 1770 } else { 1771 _app.softInit(); 1772 } 1773 utils.log("Created app id " + appId); 1774 } 1775 } 1776 } 1777 if (defaults_DEARVIEWER.removeEmbeds.length <= defaults_DEARVIEWER.removeEmbedsLimit && defaults_DEARVIEWER.embeds.length == 0) { 1778 defaults_DEARVIEWER.checkRequestQueue = null; 1779 } 1780 }; 1781}; 1782 1783/** Then we set up an intersection observer watching over those images and whenever any of those becomes visible on the view then replace the placeholder image with actual one, remove the non-loaded class and then unobserve for that element **/ 1784defaults_DEARVIEWER.lazyObserver = { 1785 observe: function observe(element) { 1786 element = utils_jQuery(element); 1787 if (element.is("img")) { 1788 if (element.hasClass("df-lazy")) { 1789 element.attr("src", element.attr("data-src")); 1790 element.removeAttr("data-src"); 1791 element.removeClass("df-lazy"); 1792 } 1793 } else { 1794 element.dearviewer(); 1795 } 1796 } 1797}; 1798if (typeof IntersectionObserver === 'function') { 1799 defaults_DEARVIEWER.lazyObserver = new IntersectionObserver(function (entries, observer) {
1800 entries.forEach(function (entry) { 1801 var lazyImage = utils_jQuery(entry.target); 1802 var initId = lazyImage.attr("initID"), 1803 index; 1804 if (entry.isIntersecting) { 1805 if (!lazyImage.attr("initID")) { 1806 lazyImage.attr("initID", defaults_DEARVIEWER.initId); 1807 initId = defaults_DEARVIEWER.initId.toString(); 1808 defaults_DEARVIEWER.initId++; 1809 } 1810 index = defaults_DEARVIEWER.removeEmbeds.indexOf(initId); 1811 if (index > -1) { 1812 // only splice array when item is found 1813 defaults_DEARVIEWER.removeEmbeds.splice(index, 1); // 2nd parameter means remove one item only 1814 utils.log("Removed id " + initId + "from Removal list"); 1815 } else { 1816 index = defaults_DEARVIEWER.embeds.indexOf(initId); 1817 if (index == -1) { 1818 defaults_DEARVIEWER.embeds.push(initId); 1819 utils.log("Added id " + initId + "to Add list"); 1820 } 1821 } 1822 } else { 1823 if (initId) { 1824 index = defaults_DEARVIEWER.embeds.indexOf(initId); 1825 if (index > -1) { 1826 // only splice array when item is found 1827 defaults_DEARVIEWER.embeds.splice(index, 1); // 2nd parameter means remove one item only 1828 utils.log("Removed id " + initId + " from Add list"); 1829 } else { 1830 index = defaults_DEARVIEWER.removeEmbeds.indexOf(initId); 1831 if (index == -1) { 1832 defaults_DEARVIEWER.removeEmbeds.push(initId); 1833 utils.log("Added id " + initId + " to Removal list"); 1834 } 1835 } 1836 } 1837 } 1838 requestCount = 0; 1839 if ((defaults_DEARVIEWER.removeEmbeds.length > defaults_DEARVIEWER.removeEmbedsLimit || defaults_DEARVIEWER.embeds.length > 0) && defaults_DEARVIEWER.checkRequestQueue == null) { 1840 //start the requestQueue 1841 defaults_DEARVIEWER.checkRequestQueue = function () { 1842 requestCount++; 1843 if (defaults_DEARVIEWER.checkRequestQueue) { 1844 requestAnimationFrame(function () { 1845 if (defaults_DEARVIEWER && defaults_DEARVIEWER.checkRequestQueue) defaults_DEARVIEWER.checkRequestQueue(); 1846 }); 1847 } 1848 if (requestCount > 20) { 1849 requestCount = 0; 1850 defaults_DEARVIEWER.handleLazy(); 1851 } 1852 }; 1853 defaults_DEARVIEWER.checkRequestQueue(); 1854 } 1855 }); 1856 }); 1857} 1858var requestCount = 0; 1859defaults_DEARVIEWER.addLazyElement = function (element) { 1860 defaults_DEARVIEWER.lazyObserver.observe(element); 1861}; 1862 1863//scan the whole document for un-parsed PDFs and convert them to viewer and flipbooks 1864defaults_DEARVIEWER.parseElements = utils.parseElements = function () { 1865 defaults_DEARVIEWER.parseCSSElements(); 1866 defaults_DEARVIEWER.parseNormalElements(); 1867}; 1868//jQuery events 1869defaults_DEARVIEWER.initUtils = function () { 1870 utils.detectScriptLocation(); 1871 var body = utils_jQuery('body'); 1872 1873 //assign webkit so that thumbs and other functions can be optimized 1874 if (utils.isSafari || utils.isIOS) { 1875 body.addClass("df-ios"); 1876 } 1877 body.on('click', function () {}); 1878 body.on('click', '.df-posts .df-load-more-button', function () { 1879 var postsWrapper = utils_jQuery(this).closest(".df-posts"); 1880 if (postsWrapper.length > 0) { 1881 var count = 0; 1882 var posts = postsWrapper.find('.df-element'); 1883 posts.each(function () { 1884 var post = utils_jQuery(this); 1885 if (post.attr("skip-parse") === "true") { 1886 //skip first 10 1887 if (count < defaults_DEARVIEWER.defaults.loadMoreCount) post.removeAttr("skip-parse"); 1888 count++; 1889 } 1890 }); 1891 defaults_DEARVIEWER.parseNormalElements(); 1892 } 1893 }); 1894 if (defaults_DEARVIEWER.defaults.shelfImage && defaults_DEARVIEWER.defaults.shelfImage != '') { 1895 body.append("<style>.df-has-shelf df-post-shelf:before, .df-has-shelf df-post-shelf:after{background-image: url('" + defaults_DEARVIEWER.defaults.shelfImage + "');}</style>"); 1896 } 1897}; 1898 1899;// CONCATENATED MODULE: ./src/js/dearviewer/viewers/base-viewer.js 1900function base_viewer_typeof(o) { "@babel/helpers - typeof"; return base_viewer_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, base_viewer_typeof(o); } 1901function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1902function _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, _toPropertyKey(descriptor.key), descriptor); } } 1903function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 1904function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string");
1904 return base_viewer_typeof(key) === "symbol" ? key : String(key); } 1905function _toPrimitive(input, hint) { if (base_viewer_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (base_viewer_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } 1906 1907var base_viewer_DV = defaults_DEARVIEWER; 1908var base_viewer_utils = defaults_DEARVIEWER.utils; 1909var BaseViewer = /*#__PURE__*/function () { 1910 function BaseViewer(options, appContext) { 1911 _classCallCheck(this, BaseViewer); 1912 this.pages = []; 1913 this.app = appContext; 1914 this.parentElement = this.app.viewerContainer; 1915 var viewerClass = "df-viewer " + (options.viewerClass || ""); 1916 this.element = jQuery('<div>', { 1917 "class": viewerClass 1918 }); 1919 this.parentElement.append(this.element); 1920 this.wrapper = jQuery('<div>', { 1921 "class": 'df-viewer-wrapper' 1922 }); 1923 this.element.append(this.wrapper); 1924 this.oldBasePageNumber = 0; 1925 this.pages = []; 1926 this.minZoom = 1; 1927 this.maxZoom = 4; 1928 this.swipeThreshold = 20; 1929 this.stageDOM = null; 1930 this.events = {}; 1931 this.arrowKeysAction = options.arrowKeysAction; 1932 this.clickAction = options.clickAction; 1933 this.scrollAction = options.scrollAction; 1934 this.dblClickAction = options.dblClickAction; 1935 this.pageBuffer = []; 1936 this.pageBufferSize = 10; 1937 } 1938 _createClass(BaseViewer, [{ 1939 key: "init", 1940 value: function init() {} 1941 }, { 1942 key: "softDispose", 1943 value: function softDispose() {} 1944 }, { 1945 key: "updateBuffer", 1946 value: function updateBuffer(page) {} 1947 }, { 1948 key: "pageResetCallback", 1949 value: function pageResetCallback(page) {} 1950 }, { 1951 key: "initCustomControls", 1952 value: function initCustomControls() {} 1953 }, { 1954 key: "_getInnerWidth", 1955 value: function _getInnerWidth() { 1956 return this.app.dimensions.containerWidth - this.app.dimensions.padding.width - this.app.dimensions.offset.width; 1957 } 1958 }, { 1959 key: "_getInnerHeight", 1960 value: function _getInnerHeight() { 1961 //individual viewers don't calculate on maxHeight 1962 return this.app.dimensions.maxHeight - this.app.dimensions.padding.height; 1963 } 1964 }, { 1965 key: "_getOuterHeight", 1966 value: function _getOuterHeight(height) { 1967 return height; 1968 } 1969 }, { 1970 key: "dispose", 1971 value: function dispose() { 1972 if (this.stageDOM) { 1973 this.stageDOM.removeEventListener("mousemove", this.events.mousemove, false); 1974 this.stageDOM.removeEventListener("mousedown", this.events.mousedown, false); 1975 this.stageDOM.removeEventListener("mouseup", this.events.mouseup, false); 1976 this.stageDOM.removeEventListener("touchmove", this.events.mousemove, false); 1977 this.stageDOM.removeEventListener("touchstart", this.events.mousedown, false); 1978 this.stageDOM.removeEventListener("touchend", this.events.mouseup, false); 1979 this.stageDOM.removeEventListener("dblclick", this.events.dblclick, false); 1980 this.stageDOM.removeEventListener("scroll", this.events.scroll, false); 1981 this.stageDOM.removeEventListener("mousewheel", this.events.mousewheel, false); 1982 this.stageDOM.removeEventListener("DOMMouseScroll", this.events.mousewheel, false); 1983 } 1984 this.events = null; 1985 this.stageDOM = null; 1986 this.element.remove(); 1987 } 1988 1989 /** 1990 * Verify page size differences in the document 1991 */ 1992 }, { 1993 key: "checkDocumentPageSizes", 1994 value: function checkDocumentPageSizes() {} 1995 1996 /** 1997 * Determines which page to jump in viewer when a PDF link is clicked. Pagenumber passed from PDF provider. 1998 * Clicked link provides absolute number but a number relatiev to viewer is required. 1999 * @param pageNumber 2000 * @returns {number} 2001 */ 2002 }, { 2003 key: "getViewerPageNumber", 2004 value: function getViewerPageNumber(pageNumber) { 2005 return pageNumber; 2006 } 2007 2008 /** 2009 * Determines which page to render from PDF document. Pagenumber passed from viewer. 2010 * PDF document page and viewer page numbers are different in some cases. 2011 * @param pageNumber 2012 * @returns {number} 2013 */ 2014 }, { 2015 key: "getDocumentPageNumber", 2016 value: function getDocumentPageNumber(pageNumber) { 2017 return pageNumber; 2018 } 2019 }, { 2020 key: "getRenderContext", 2021 value: function getRenderContext(pdfPage, param) { 2022 var app = this.app, 2023 provider = app.provider, 2024 pageNumber = param.pageNumber, 2025 textureTarget = base_viewer_utils.ifdef(param.textureTarget, defaults_DEARVIEWER.TEXTURE_TARGET.VIEWER); 2026 var pageFit = app.dimensions.pageFit; 2027 var pageViewport = provider.viewPorts[pageNumber]; 2028 var dimen = app.viewer.getTextureSize(param); 2029 var textureCacheIndex = null; 2030 if (textureTarget === defaults_DEARVIEWER.TEXTURE_TARGET.THUMB) { 2031 textureCacheIndex = app.thumbSize; 2032 } else { 2033 textureCacheIndex = Math.floor(dimen.height); 2034 } 2035 if (provider.getCache(pageNumber, textureCacheIndex) !== undefined) { 2036 return; 2037 } 2038 var scale = dimen.height / pageViewport.height; 2039 var canvas = document.createElement('canvas'),
2040 viewport = this.filterViewPort(pdfPage.getViewport({ 2041 scale: scale, 2042 rotation: pdfPage._pageInfo.rotate + app.options.pageRotation 2043 }), pageNumber); 2044 if (textureTarget === defaults_DEARVIEWER.TEXTURE_TARGET.THUMB) { 2045 // in-case the thumb size is wider 2046 if (viewport.width / viewport.height > 180 / app.thumbSize) { 2047 scale = scale * 180 / viewport.width; 2048 } else { 2049 scale = scale * app.thumbSize / viewport.height; 2050 } 2051 viewport = this.filterViewPort(pdfPage.getViewport({ 2052 scale: scale, 2053 rotation: pdfPage._pageInfo.rotate + app.options.pageRotation 2054 }), pageNumber); 2055 } 2056 canvas.height = Math.floor(viewport.height); 2057 canvas.width = Math.floor(viewport.width); 2058 2059 // if (app.pageScaling === DEARVIEWER.PAGE_SCALE.PAGE_FIT) { 2060 var error = Math.abs(canvas.width - dimen.width) / dimen.width * 100; 2061 if (error > 0.001 && error < 2) { 2062 //1px error in upto 5000px is detected 2063 canvas.width = Math.floor(dimen.width); 2064 canvas.height = Math.floor(dimen.height); 2065 } 2066 // } 2067 app.viewer.filterViewPortCanvas(viewport, canvas, pageNumber); 2068 return { 2069 canvas: canvas, 2070 canvasContext: canvas.getContext('2d', { 2071 willReadFrequently: defaults_DEARVIEWER.defaults.canvasWillReadFrequently === true 2072 }), 2073 viewport: viewport 2074 }; 2075 } 2076 }, { 2077 key: "filterViewPort", 2078 value: function filterViewPort(viewport, pageNumber) { 2079 return viewport; 2080 } 2081 }, { 2082 key: "getViewPort", 2083 value: function getViewPort(pageNumber) { 2084 var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 2085 var viewPort = this.app.provider.viewPorts[pageNumber]; 2086 if (fallback) return viewPort !== null && viewPort !== void 0 ? viewPort : this.app.provider.defaultPage.viewPort; 2087 return viewPort; 2088 } 2089 }, { 2090 key: "pagesReady", 2091 value: function pagesReady() {} 2092 }, { 2093 key: "onReady", 2094 value: function onReady() {} 2095 }, { 2096 key: "filterViewPortCanvas", 2097 value: function filterViewPortCanvas(viewport) {} 2098 }, { 2099 key: "finalizeAnnotations", 2100 value: function finalizeAnnotations() {} 2101 }, { 2102 key: "finalizeTextContent", 2103 value: function finalizeTextContent() {} 2104 }, { 2105 key: "updateTextContent", 2106 value: function updateTextContent(pageNumber) { 2107 if (pageNumber == void 0) { 2108 pageNumber = this.getBasePage(pageNumber); 2109 } 2110 this.app.provider.processTextContent(pageNumber, this.getTextElement(pageNumber, true)); 2111 } 2112 }, { 2113 key: "isActivePage", 2114 value: function isActivePage(pageNumber) { 2115 return pageNumber === this.app.currentPageNumber; 2116 } 2117 }, { 2118 key: "initEvents", 2119 value: function initEvents() { 2120 var viewer = this; 2121 var stageDOM = viewer.stageDOM = base_viewer_utils.ifdef(viewer.stageDOM, viewer.parentElement[0]); 2122 if (stageDOM) { 2123 // Use our detect's results. passive applied if supported, capture will be false either way. 2124 // let opts = utils.supportsPassive ? {passive: true} : false; //passive is not possible. like it's in https://www.google.com/maps/ 2125 var opts = false; 2126 stageDOM.addEventListener("mousemove", viewer.events.mousemove = viewer.mouseMove.bind(viewer), false); 2127 stageDOM.addEventListener("mousedown", viewer.events.mousedown = viewer.mouseDown.bind(viewer), false); 2128 stageDOM.addEventListener("mouseup", viewer.events.mouseup = viewer.mouseUp.bind(viewer), false); 2129 stageDOM.addEventListener("touchmove", viewer.events.mousemove = viewer.mouseMove.bind(viewer), opts); 2130 stageDOM.addEventListener("touchstart", viewer.events.mousedown = viewer.mouseDown.bind(viewer), opts); 2131 stageDOM.addEventListener("touchend", viewer.events.mouseup = viewer.mouseUp.bind(viewer), false); 2132 stageDOM.addEventListener("dblclick", viewer.events.dblclick = viewer.dblclick.bind(viewer), false); 2133 stageDOM.addEventListener("scroll", viewer.events.scroll = viewer.onScroll.bind(viewer), false); 2134 stageDOM.addEventListener("mousewheel", viewer.events.mousewheel = viewer.mouseWheel.bind(viewer), opts); 2135 stageDOM.addEventListener('DOMMouseScroll', viewer.events.mousewheel = viewer.mouseWheel.bind(viewer), false); 2136 } 2137 this.startTouches = null; 2138 this.lastScale = null; 2139 this.startPoint = null; 2140 } 2141 }, { 2142 key: "refresh", 2143 value: function refresh() {} 2144 }, { 2145 key: "reset", 2146 value: function reset() {} 2147 }, { 2148 key: "eventToPoint", 2149 value: function eventToPoint(event) { 2150 var point = { 2151 x: event.clientX, 2152 y: event.clientY 2153 }; 2154 point.x = point.x - this.app.viewerContainer[0].getBoundingClientRect().left; 2155 point.y = point.y - this.app.viewerContainer[0].getBoundingClientRect().top; 2156 return { 2157 raw: point 2158 }; 2159 } 2160 }, { 2161 key: "mouseMove", 2162 value: function mouseMove(event) { 2163 event = base_viewer_utils.fixMouseEvent(event); 2164 this.pinchMove(event); 2165 if (this.pinchZoomDirty === true) { 2166 event.preventDefault(); 2167 } 2168 if (this.startPoint && this.pinchZoomDirty != true) { 2169 this.pan(this.eventToPoint(event)); 2170 event.preventDefault(); 2171 } 2172 } 2173 }, { 2174 key: "mouseDown", 2175 value: function mouseDown(event) { 2176 event = base_viewer_utils.fixMouseEvent(event); 2177 this.pinchDown(event); 2178 this.startPoint = this.eventToPoint(event); 2179 } 2180 }, { 2181 key: "mouseUp", 2182 value: function mouseUp(event) { 2183 event = base_viewer_utils.fixMouseEvent(event); 2184 var viewer = this; 2185 if (viewer.pinchZoomDirty === true) { 2186 event.preventDefault(); 2187 } 2188 var point = viewer.eventToPoint(event); 2189 var element = event.target || event.originalTarget; //check to see if the clicked element is a link, if so skip turn
2190 var isClick = viewer.startPoint && point.x === viewer.startPoint.x && point.y === viewer.startPoint.y && element.nodeName !== "A"; 2191 if (event.ctrlKey === true && isClick) { 2192 this.zoomOnPoint(point); 2193 } 2194 this.pinchUp(event); 2195 this.startPoint = null; 2196 } 2197 }, { 2198 key: "pinchDown", 2199 value: function pinchDown(event) { 2200 //extened in pro 2201 } 2202 }, { 2203 key: "pinchUp", 2204 value: function pinchUp(event) { 2205 //extened in pro 2206 } 2207 }, { 2208 key: "pinchMove", 2209 value: function pinchMove(event) { 2210 //extened in pro 2211 } 2212 }, { 2213 key: "updateTemporaryScale", 2214 value: function updateTemporaryScale() { 2215 var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 2216 // return; 2217 if (reset === true) { 2218 this.parentElement[0].style.transform = "none"; 2219 } else if (this.app.viewer.zoomCenter) { 2220 var scale = this.app.viewer.pinchZoomUpdateScale; 2221 this.parentElement[0].style.transformOrigin = this.app.viewer.zoomCenter.x + "px " + this.app.viewer.zoomCenter.y + "px"; 2222 this.parentElement[0].style.transform = "scale3d(" + scale + "," + scale + ",1)"; 2223 } 2224 } 2225 }, { 2226 key: "pan", 2227 value: function pan(point) { 2228 var reset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 2229 this.panRequestStatus = defaults_DEARVIEWER.REQUEST_STATUS.ON; 2230 base_viewer_utils.pan(this, point, reset); 2231 } 2232 }, { 2233 key: "updatePan", 2234 value: function updatePan() { 2235 this.element.css({ 2236 transform: "translate3d(" + this.left + "px," + this.top + "px,0)" 2237 }); 2238 } 2239 }, { 2240 key: "dblclick", 2241 value: function dblclick(event) {} 2242 }, { 2243 key: "onScroll", 2244 value: function onScroll(event) {} 2245 }, { 2246 key: "mouseWheel", 2247 value: function mouseWheel(event) { 2248 var viewer = this, 2249 app = this.app, 2250 delta = base_viewer_utils.getMouseDelta(event); 2251 2252 //detect trackpad or CTRL + mouse scroll zoom, both use CTRL + scroll method 2253 var isValidZoomKey = event.ctrlKey === true; 2254 var isValidZoomOption = app.options.mouseScrollAction === defaults_DEARVIEWER.MOUSE_SCROLL_ACTIONS.ZOOM && (app.options.isLightBox === true || app.isFullscreen === true); 2255 2256 //if it CTRL mousewheel. it is zoom. 2257 if (isValidZoomKey || isValidZoomOption) { 2258 if (delta > 0 || delta < 0) { 2259 event.preventDefault(); 2260 app.viewer.zoomCenter = this.eventToPoint(event).raw; 2261 app.zoom(delta); 2262 app.ui.update(); 2263 } 2264 } else if (app.options.mouseScrollAction === defaults_DEARVIEWER.MOUSE_SCROLL_ACTIONS.NAV) { 2265 if (delta > 0) { 2266 app.next(); 2267 } else if (delta < 0) { 2268 app.prev(); 2269 } 2270 } 2271 } 2272 }, { 2273 key: "zoomOnPoint", 2274 value: function zoomOnPoint(point) { 2275 this.app.viewer.zoomCenter = point.raw; 2276 this.app.zoom(1); 2277 } 2278 }, { 2279 key: "getVisiblePages", 2280 value: function getVisiblePages() { 2281 this.visiblePagesCache = []; 2282 return { 2283 main: this.visiblePagesCache, 2284 buffer: [] 2285 }; 2286 } 2287 }, { 2288 key: "getBasePage", 2289 value: function getBasePage() { 2290 return this.app.currentPageNumber; 2291 } 2292 }, { 2293 key: "isFirstPage", 2294 value: function isFirstPage(pageNumber) { 2295 if (pageNumber === void 0) pageNumber = this.app.currentPageNumber; 2296 return pageNumber === 1; 2297 } 2298 }, { 2299 key: "isLastPage", 2300 value: function isLastPage(pageNumber) { 2301 if (pageNumber === void 0) pageNumber = this.app.currentPageNumber; 2302 return pageNumber === this.app.pageCount; 2303 } 2304 }, { 2305 key: "isEdgePage", 2306 value: function isEdgePage(pageNumber) { 2307 if (pageNumber === void 0) pageNumber = this.app.currentPageNumber; 2308 return pageNumber === 1 || pageNumber === this.app.pageCount; 2309 } 2310 }, { 2311 key: "checkRequestQueue", 2312 value: function checkRequestQueue() { 2313 var REQUEST_STATUS = defaults_DEARVIEWER.REQUEST_STATUS; 2314 if (this.panRequestStatus === REQUEST_STATUS.ON) { 2315 this.updatePan(); 2316 this.panRequestStatus = REQUEST_STATUS.OFF; 2317 } 2318 if (this.app.viewer.pinchZoomRequestStatus === REQUEST_STATUS.ON) { 2319 this.app.viewer.updateTemporaryScale(); 2320 this.app.viewer.pinchZoomRequestStatus = REQUEST_STATUS.OFF; 2321 } 2322 } 2323 }, { 2324 key: "isAnimating", 2325 value: function isAnimating() { 2326 return false;
2327 } 2328 }, { 2329 key: "updatePendingStatusClass", 2330 value: function updatePendingStatusClass(status) { 2331 if (status === void 0) status = this.isAnimating(); 2332 this.app.container.toggleClass("df-pending", status); 2333 } 2334 }, { 2335 key: "initPages", 2336 value: function initPages() {} 2337 }, { 2338 key: "resize", 2339 value: function resize() {} 2340 }, { 2341 key: "determinePageMode", 2342 value: function determinePageMode() {} 2343 }, { 2344 key: "zoom", 2345 value: function zoom() {} 2346 }, { 2347 key: "gotoPageCallBack", 2348 value: function gotoPageCallBack() { 2349 this.requestRefresh(); 2350 } 2351 }, { 2352 key: "requestRefresh", 2353 value: function requestRefresh() { 2354 var status = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; 2355 this.app.refreshRequestStatus = status === true ? base_viewer_DV.REQUEST_STATUS.ON : base_viewer_DV.REQUEST_STATUS.OFF; 2356 } 2357 }, { 2358 key: "getPageByNumber", 2359 value: function getPageByNumber(pageNumber) { 2360 var pages = this.pages, 2361 page = undefined; 2362 if (this.app.isValidPage(pageNumber)) { 2363 for (var count = 0; count < pages.length; count++) { 2364 if (pageNumber === pages[count].pageNumber) { 2365 page = pages[count]; 2366 break; 2367 } 2368 } 2369 } 2370 return page; 2371 } 2372 }, { 2373 key: "changeAnnotation", 2374 value: function changeAnnotation() { 2375 return false; 2376 } 2377 }, { 2378 key: "getAnnotationElement", 2379 value: function getAnnotationElement(pageNumber) { 2380 var clean = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 2381 var page = this.getPageByNumber(pageNumber); 2382 if (page === undefined) return undefined; 2383 if (page.annotationElement === undefined) { 2384 page.annotationElement = jQuery("<div class='df-link-content'>"); 2385 page.contentLayer.append(page.annotationElement); 2386 } 2387 if (clean === true) { 2388 page.annotationElement.html(""); 2389 } 2390 return page.annotationElement[0]; 2391 } 2392 }, { 2393 key: "getTextElement", 2394 value: function getTextElement(pageNumber) { 2395 var clean = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 2396 var page = this.getPageByNumber(pageNumber); 2397 if (page === undefined) return undefined; 2398 if (page.textElement === undefined) { 2399 page.textElement = jQuery("<div class='df-text-content'>"); 2400 page.contentLayer.append(page.textElement); 2401 } 2402 if (clean === true) { 2403 //if clean is not done early, old annotations are displayed until the page is loaded + until new annotation is displayed 2404 page.textElement.html(""); 2405 page.textElement.siblings(".df-auto-link-content").html(""); 2406 } 2407 return page.textElement[0]; 2408 } 2409 }, { 2410 key: "render", 2411 value: function render() {} 2412 }, { 2413 key: "textureLoadedCallback", 2414 value: function textureLoadedCallback(param) {} 2415 }, { 2416 key: "handleZoom", 2417 value: function handleZoom() {} 2418 }, { 2419 key: "getTextureSize", 2420 value: function getTextureSize(param) { 2421 console.error("Texture calculation missing!"); 2422 } 2423 }, { 2424 key: "textureHeightLimit", 2425 value: function textureHeightLimit(height) { 2426 return base_viewer_utils.limitAt(height, 1, this.app.dimensions.maxTextureHeight); 2427 } 2428 }, { 2429 key: "textureWidthLimit", 2430 value: function textureWidthLimit(width) { 2431 return base_viewer_utils.limitAt(width, 1, this.app.dimensions.maxTextureWidth); 2432 } 2433 }, { 2434 key: "setPage", 2435 value: function setPage(param) { 2436 base_viewer_utils.log("Set Page detected", param.pageNumber); 2437 var page = this.getPageByNumber(param.pageNumber); 2438 if (page) { 2439 // page.texturePageNumber = param.pageNumber; 2440 param.callback = this.textureLoadedCallback.bind(this); 2441 page.loadTexture(param); 2442 this.updateBuffer(page); 2443 return true; 2444 } 2445 return false; 2446 } 2447 }, { 2448 key: "cleanPage", 2449 value: function cleanPage(pageNumber) { 2450 return true; 2451 } 2452 2453 /** 2454 * Check if the Page change request really makes a page change if not returns false 2455 * @param pageNumber 2456 * @returns {boolean} 2457 */ 2458 }, { 2459 key: "validatePageChange", 2460 value: function validatePageChange(pageNumber) { 2461 //Fixes issue #40 - validates only if the pageNumber has changed 2462 return pageNumber !== this.app.currentPageNumber; 2463 } 2464 }, { 2465 key: "afterControlUpdate", 2466 value: function afterControlUpdate() {} 2467 }, { 2468 key: "searchPage", 2469 value: function searchPage(pageNumber) { 2470 return { 2471 include: true, 2472 label: this.app.provider.getLabelforPage(pageNumber) 2473 }; 2474 } 2475 }]); 2476 return BaseViewer; 2477}(); 2478 2479;// CONCATENATED MODULE: ./src/js/dearviewer/viewers/page.js 2480function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { c
vendor: 4,261 bytes, lines 2480-2519
2480onstructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } 2481function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 2482function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 2483function _possibleConstructorReturn(self, call) { if (call && (page_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } 2484function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 2485function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } 2486function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 2487function page_typeof(o) { "@babel/helpers - typeof"; return page_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, page_typeof(o); } 2488function page_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 2489function page_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, page_toPropertyKey(descriptor.key), descriptor); } } 2490function page_createClass(Constructor, protoProps, staticProps) { if (protoProps) page_defineProperties(Constructor.prototype, protoProps); if (staticProps) page_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 2491function page_toPropertyKey(arg) { var key = page_toPrimitive(arg, "string"); return page_typeof(key) === "symbol" ? key : String(key); } 2492function page_toPrimitive(input, hint) { if (page_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (page_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } 2493/* globals jQuery, pdfjsLib,THREE */ 2494 2495var page_DV = (/* unused pure expression or super */ null && (DEARVIEWER)); 2496var page_utils = defaults_DEARVIEWER.utils; 2497var Page = /*#__PURE__*/function () { 2498 function Page() { 2499 page_classCallCheck(this, Page); 2500 this.textureLoadFallback = "blank"; 2501 this.textureStamp = "-1"; 2502 this.textureLoaded = false; 2503 this.texture = "blank"; 2504 this.textureSrc = "blank"; 2505 this.pageNumber = undefined; 2506 this.contentLayer = jQuery('<div>', { 2507 "class": "df-page-content" 2508 }); 2509 } 2510 page_createClass(Page, [{ 2511 key: "reset", 2512 value: function reset() { 2513 this.resetTexture(); 2514 this.resetContent(); 2515 } 2516 }, { 2517 key: "resetTexture", 2518 value: function resetTexture() { 2519 this.textureLoaded = false;
2520 this.textureStamp = "-1"; 2521 this.loadTexture({ 2522 texture: this.textureLoadFallback 2523 }); 2524 this.contentLayer.removeClass("df-content-loaded"); 2525 } 2526 }, { 2527 key: "clearTexture", 2528 value: function clearTexture() { 2529 this.loadTexture({ 2530 texture: this.textureLoadFallback 2531 }); 2532 } 2533 }, { 2534 key: "resetContent", 2535 value: function resetContent() {} 2536 }, { 2537 key: "loadTexture", 2538 value: function loadTexture(param) {} 2539 }, { 2540 key: "getTexture", 2541 value: function getTexture() { 2542 var clone = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 2543 var texture = this.textureSrc; 2544 if (clone === true && texture && texture.cloneNode) { 2545 texture = texture.cloneNode(); 2546 if (texture.getContext) texture.getContext('2d').drawImage(this.textureSrc, 0, 0); 2547 } 2548 return texture; 2549 } 2550 }, { 2551 key: "setLoading", 2552 value: function setLoading() {} 2553 }, { 2554 key: "updateTextureLoadStatus", 2555 value: function updateTextureLoadStatus(textureLoaded) { 2556 this.textureLoaded = textureLoaded === true; 2557 page_utils.log((this.textureLoaded === true ? "Loaded " : "Loading ") + this.textureStamp + " for " + this.pageNumber); 2558 this.contentLayer.toggleClass("df-content-loaded", textureLoaded === true); 2559 this.setLoading(); 2560 } 2561 2562 /** 2563 * 2564 * @param pageNumber 2565 * @param textureSize 2566 * @returns {boolean} true if new stamp is set 2567 */ 2568 }, { 2569 key: "changeTexture", 2570 value: function changeTexture(pageNumber, textureSize) { 2571 var page = this; 2572 var reqStamp = pageNumber + "|" + textureSize; 2573 if (page.textureStamp !== reqStamp) { 2574 page_utils.log("Page " + pageNumber + " : texture changed from - " + page.textureStamp + " to " + reqStamp); 2575 page.textureLoaded = false; 2576 // page.element.attr("stamp", reqStamp); 2577 page.textureStamp = reqStamp; 2578 page.updateTextureLoadStatus(false); 2579 return true; 2580 } 2581 return false; 2582 } 2583 }]); 2584 return Page; 2585}(); 2586var Page2D = /*#__PURE__*/function (_Page) { 2587 _inherits(Page2D, _Page); 2588 var _super = _createSuper(Page2D); 2589 function Page2D(options) { 2590 var _this; 2591 page_classCallCheck(this, Page2D); 2592 _this = _super.call(this); 2593 _this.canvasMode = null; 2594 if (options && options.parentElement) _this.parentElement = options.parentElement; 2595 _this.init(); 2596 return _this; 2597 } 2598 page_createClass(Page2D, [{ 2599 key: "init", 2600 value: function init() { 2601 var element = this.element = jQuery('<div>', { 2602 "class": 'df-page' 2603 }); 2604 element[0].appendChild(this.contentLayer[0]); 2605 this.texture = new Image(); 2606 if (this.parentElement) this.parentElement[0].append(element[0]); 2607 } 2608 }, { 2609 key: "resetContent", 2610 value: function resetContent() { 2611 if (this.annotationElement !== undefined) this.annotationElement.html(""); 2612 if (this.textElement !== undefined) this.textElement.html(""); 2613 } 2614 }, { 2615 key: "setLoading", 2616 value: function setLoading() { 2617 this.element.toggleClass("df-loading", this.textureLoaded !== true); 2618 } 2619 }, { 2620 key: "loadTexture", 2621 value: function loadTexture(param) { 2622 var page = this, 2623 texture = param.texture, 2624 callback = param.callback; 2625 function completed() { 2626 page.textureSrc = texture; 2627 page.element.css({ 2628 backgroundImage: page_utils.bgImage(texture) 2629 }); 2630 page.updateTextureLoadStatus(true); 2631 if (typeof callback == 'function') callback(param); 2632 } 2633 if (page.canvasMode === null && texture && texture.nodeName === "CANVAS") page.canvasMode = true; 2634 if (page.canvasMode === true) { 2635 page.element.find(">canvas").remove(); 2636 if (texture !== page.textureLoadFallback) { 2637 page.textureSrc = texture; 2638 page.element.append(jQuery(texture)); 2639 // page.element.width(texture.width).height(texture.height); 2640 } 2641 2642 page.updateTextureLoadStatus(true); 2643 if (typeof callback == 'function') callback(param); 2644 } else { 2645 if (texture === page.textureLoadFallback) { 2646 completed(); 2647 } else { 2648 page.texture.onload = completed; 2649 page.texture.src = texture; 2650 } 2651 } 2652 } 2653 }, { 2654 key: "updateCSS", 2655 value: function updateCSS(css) { 2656 var page = this; 2657 page.element.css(css); 2658 } 2659 }, { 2660 key: "resetCSS", 2661 value: function resetCSS() { 2662 var page = this; 2663 page.element.css({ 2664 transform: '', 2665 boxShadow: '', 2666 display: "block" 2667 }); 2668 } 2669 }]); 2670 return Page2D; 2671}(Page); 2672 2673;// CONCATENATED MODULE: ./src/js/dearviewer/viewers/reader.js 2674function reader_typeof(o) { "@babel/helpers - typeof"; return reader_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, reader_typeof(o); } 2675function reader_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 2676function reader_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, reader_toPropertyKey(descriptor.key), descriptor); } } 2677function reader_createClass(Constructor, protoProps, staticProps) { if (protoProps) reader_defineProperties(Constructor.prototype, protoProps); if (staticProps) reader_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 2678function reader_toPropertyKey(arg) { var key = reader_toPrimitive(arg, "string");
2678 return reader_typeof(key) === "symbol" ? key : String(key); } 2679function reader_toPrimitive(input, hint) { if (reader_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (reader_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } 2680function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); } 2681function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = reader_getPrototypeOf(object); if (object === null) break; } return object; } 2682function reader_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) reader_setPrototypeOf(subClass, superClass); } 2683function reader_setPrototypeOf(o, p) { reader_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return reader_setPrototypeOf(o, p); } 2684function reader_createSuper(Derived) { var hasNativeReflectConstruct = reader_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = reader_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = reader_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return reader_possibleConstructorReturn(this, result); }; } 2685function reader_possibleConstructorReturn(self, call) { if (call && (reader_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return reader_assertThisInitialized(self); } 2686function reader_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 2687function reader_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } 2688function reader_getPrototypeOf(o) { reader_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return reader_getPrototypeOf(o); } 2689 2690 2691 2692var reader_utils = defaults_DEARVIEWER.utils; 2693var Reader = /*#__PURE__*/function (_BaseViewer) { 2694 reader_inherits(Reader, _BaseViewer); 2695 var _super = reader_createSuper(Reader); 2696 function Reader(options, appContext) { 2697 var _this; 2698 reader_classCallCheck(this, Reader); 2699 options.viewerClass = "df-reader"; 2700 appContext.options.mouseScrollAction = defaults_DEARVIEWER.MOUSE_SCROLL_ACTIONS.NONE; 2701 _this = _super.call(this, options, appContext); 2702 _this.app.jumpStep = 1; 2703 _this.minZoom = 0.25; 2704 _this.stackCount = _this.app.pageCount; 2705 _this.app.options.paddingLeft = 0; 2706 _this.app.options.paddingRight = 0; 2707 _this.app.options.paddingTop = 10; 2708 _this.app.options.paddingBottom = _this.app.options.controlsFloating === true ? 20 : 10; 2709 _this.app.pageScaling = _this.app.options.pageScale; 2710 _this.acceptAppMouseEvents = true; //fixes #236 doublemouse events were passed 2711 2712 _this.scrollStatus = defaults_DEARVIEWER.REQUEST_STATUS.OFF; 2713 _this.deltaPanX = 0; 2714 _this.deltaPanY = 0; 2715 // this.app.options.pageSize = DEARVIEWER.PAGE_ 2716 // this.app.options.hideControls = "zoomIn,zoomOut"; 2717 appContext._viewerPrepared(); 2718 _this.zoomViewer = reader_assertThisInitialized(_this); //todo zoomviewer is a bad idea at base 2719 return _this; 2720 } 2721 reader_createClass(Reader, [{ 2722 key: "init",
2723 value: function init() { 2724 _get(reader_getPrototypeOf(Reader.prototype), "init", this).call(this); 2725 this.initEvents(); 2726 this.initPages(); 2727 this.initScrollBar(); 2728 } 2729 }, { 2730 key: "initEvents", 2731 value: function initEvents() { 2732 this.stageDOM = this.element[0]; 2733 _get(reader_getPrototypeOf(Reader.prototype), "initEvents", this).call(this); 2734 } 2735 }, { 2736 key: "initPages", 2737 value: function initPages() { 2738 this.stackCount = this.app.pageCount; 2739 for (var count = 0; count < this.stackCount; count++) { 2740 var page = new Page2D({ 2741 parentElement: this.wrapper 2742 }); 2743 page.index = count; //just reference for debugging 2744 page.viewer = this; 2745 this.pages.push(page); 2746 } 2747 } 2748 }, { 2749 key: "initScrollBar", 2750 value: function initScrollBar() { 2751 this.scrollBar = jQuery("<div class='df-reader-scrollbar'>"); 2752 //adding scrollbar to viewer.wrapper doesn't fit properly with mobile momentum scroll, shaky movement is detected 2753 this.scrollBar.appendTo(this.app.container); 2754 //solved #237 2755 this.scrollPageNumber = jQuery("<div class='df-reader-scroll-page-number'>").appendTo(this.app.container); 2756 } 2757 }, { 2758 key: "afterControlUpdate", 2759 value: function afterControlUpdate() { 2760 if (this.scrollBar === void 0) return; 2761 this.scrollBar[0].innerHTML = this.app.getCurrentLabel(); 2762 if (this.app.provider.pageLabels) { 2763 this.scrollPageNumber[0].innerHTML = this.app.getCurrentLabel() + "<div>(" + this.app.currentPageNumber + " of " + this.app.pageCount + ")</div>"; 2764 } else { 2765 this.scrollPageNumber[0].innerHTML = this.app.getCurrentLabel() + "<div>of " + this.app.pageCount + "</div>"; 2766 } 2767 } 2768 }, { 2769 key: "updateBuffer", 2770 value: function updateBuffer(page) { 2771 if (page.textureStamp === "-1" || page.pageNumber === void 0) return; 2772 var index = page.pageNumber, 2773 farthest = page.pageNumber, 2774 farthestIndex = 0; 2775 for (var count = 0; count < this.pageBuffer.length; count++) { 2776 var _pageNumber = this.pageBuffer[count].pageNumber; 2777 if (index === _pageNumber) { 2778 reader_utils.log("Page " + index + " already in buffer, skipping"); 2779 return; 2780 } 2781 if (Math.abs(this.app.currentPageNumber - _pageNumber) > Math.abs(this.app.currentPageNumber - farthest)) { 2782 farthest = _pageNumber; 2783 farthestIndex = count; 2784 } 2785 } 2786 this.pageBuffer.push(page); 2787 if (this.pageBuffer.length > this.pageBufferSize) { 2788 reader_utils.log("Farthest buffer: " + farthest); 2789 this.pageBuffer[farthestIndex].reset(); 2790 this.pageBuffer.splice(farthestIndex, 1); 2791 } 2792 } 2793 }, { 2794 key: "initCustomControls", 2795 value: function initCustomControls() { 2796 var ui = this.app.ui; 2797 var controls = ui.controls; 2798 controls.openRight.hide(); 2799 controls.openLeft.hide(); 2800 } 2801 }, { 2802 key: "dispose", 2803 value: function dispose() { 2804 _get(reader_getPrototypeOf(Reader.prototype), "dispose", this).call(this); 2805 if (this.scrollBar) this.scrollBar.remove(); 2806 if (this.scrollPageNumber) this.scrollPageNumber.remove(); 2807 this.element.remove(); 2808 } 2809 }, { 2810 key: "_getInnerHeight", 2811 value: function _getInnerHeight() { 2812 var height = _get(reader_getPrototypeOf(Reader.prototype), "_getInnerHeight", this).call(this), 2813 appHeight = this.app.dimensions.maxHeight - this.app.dimensions.padding.height; 2814 var viewPort = this.app.dimensions.defaultPage.viewPort; 2815 var maxWidth = this.app.dimensions.containerWidth - 20 - this.app.dimensions.padding.width; 2816 if (this.app.pageScaling === defaults_DEARVIEWER.PAGE_SCALE.ACTUAL) maxWidth = this.app.provider.defaultPage.viewPort.width * 1; 2817 2818 //if it's page fit it's from the available height 2819 var maxHeight = appHeight; 2820 if (this.app.pageScaling === defaults_DEARVIEWER.PAGE_SCALE.PAGE_WIDTH) maxHeight = viewPort.height * 100;else if (this.app.pageScaling === defaults_DEARVIEWER.PAGE_SCALE.AUTO) maxHeight = viewPort.height * 1.5;else if (this.app.pageScaling === defaults_DEARVIEWER.PAGE_SCALE.ACTUAL) maxHeight = viewPort.height * 1; 2821 maxHeight = maxHeight - 2; 2822 this._containCover = reader_utils.contain(viewPort.width, viewPort.height, maxWidth, maxHeight); 2823 maxHeight = Math.min(appHeight, this._containCover.height + 2); 2824 this.app.pageScaleValue = this._containCover.height / viewPort.height; 2825 return this.app.dimensions.isFixedHeight ? appHeight : maxHeight; 2826 } 2827 }, { 2828 key: "handleZoom", 2829 value: function handleZoom() { 2830 var app = this.app; 2831 var maxZoom = this.maxZoom = 4, 2832 //app.dimensions.maxTextureHeight / this._containCover.height, 2833 // todo find a solution than can land properly in zoom value 1. 2834 zoomValue = app.zoomValue; 2835 if (app.pendingZoom === true && app.zoomDelta != null) { 2836 var delta = app.zoomDelta; 2837 zoomValue = delta >
2837 0 ? zoomValue * app.options.zoomRatio : zoomValue / app.options.zoomRatio; 2838 } else if (this.lastScale != null) { 2839 zoomValue *= this.lastScale; 2840 this.lastScale = null; 2841 } 2842 zoomValue = reader_utils.limitAt(zoomValue, this.minZoom, maxZoom); 2843 app.zoomValueChange = zoomValue / app.zoomValue; 2844 app.zoomChanged = app.zoomValue !== zoomValue; 2845 app.zoomValue = zoomValue; 2846 } 2847 }, { 2848 key: "resize", 2849 value: function resize() { 2850 var viewer = this; 2851 var app = viewer.app; 2852 var dimensions = app.dimensions, 2853 padding = app.dimensions.padding; 2854 var shiftHeight = this.shiftHeight = 0, 2855 shiftWidth = 0; 2856 this.element.css({ 2857 top: -shiftHeight, 2858 bottom: -shiftHeight, 2859 right: -shiftWidth, 2860 //+ (isRTL ? sideShift : 0), 2861 left: -shiftWidth, 2862 //(isRTL ? 0 : sideShift), 2863 paddingTop: padding.top, 2864 paddingRight: padding.right, 2865 paddingBottom: padding.bottom, 2866 paddingLeft: padding.left 2867 }); 2868 var topVisiblePage = viewer.getVisiblePages().main[0] - 1; 2869 topVisiblePage = viewer.pages[topVisiblePage].element[0]; 2870 var rect = topVisiblePage.getBoundingClientRect(); 2871 var rectParent = this.parentElement[0].getBoundingClientRect(); 2872 for (var count = 0; count < viewer.pages.length; count++) { 2873 var page = viewer.pages[count]; 2874 var viewPort = viewer.getViewPort(count + 1, true); 2875 2876 // page.element 2877 var els = page.element[0].style; 2878 els.height = Math.floor(viewPort.height * app.pageScaleValue * app.zoomValue) + "px"; 2879 els.width = Math.floor(viewPort.width * app.pageScaleValue * app.zoomValue) + "px"; 2880 } 2881 if (viewer.oldScrollHeight != viewer.element[0].scrollHeight && viewer.oldScrollHeight !== void 0) { 2882 var _this$zoomCenter; 2883 var delta = viewer.element[0].scrollHeight / viewer.oldScrollHeight; 2884 viewer.skipScrollCheck = true; 2885 var top = topVisiblePage.offsetTop + topVisiblePage.clientTop - (rect.top - rectParent.top + topVisiblePage.clientTop) * delta, 2886 left = topVisiblePage.offsetLeft + topVisiblePage.clientLeft - (rect.left - rectParent.left + topVisiblePage.clientLeft) * delta; 2887 2888 //10 is margin that zooms too and reset to 10 2889 top += (delta - 1) * 10 / 2; 2890 left += (delta - 1) * 10 / 2; 2891 this.zoomCenter = (_this$zoomCenter = this.zoomCenter) !== null && _this$zoomCenter !== void 0 ? _this$zoomCenter : { 2892 x: 0, 2893 //(viewer.element[0].offsetWidth) / 2, 2894 y: 0 //(viewer.element[0].offsetHeight) / 2 2895 }; 2896 2897 //if pinch zoom , then move to center 2898 top += (delta - 1) * this.zoomCenter.y; 2899 left += (delta - 1) * this.zoomCenter.x; 2900 this.zoomCenter = null; 2901 viewer.element[0].scrollTop = top; 2902 viewer.element[0].scrollLeft = left; 2903 viewer.skipScrollCheck = false; 2904 } 2905 viewer.oldScrollHeight = viewer.element[0].scrollHeight; 2906 2907 // this.updatePendingStatusClass(); 2908 this.scrollBar[0].style.transform = "none"; 2909 this.updateScrollBar(); 2910 } 2911 }, { 2912 key: "onReady", 2913 value: function onReady() { 2914 this.gotoPageCallBack(); 2915 this.oldScrollHeight = this.element[0].scrollHeight; 2916 } 2917 }, { 2918 key: "refresh", 2919 value: function refresh() { 2920 var viewer = this; 2921 var app = this.app; 2922 var visible = viewer.getVisiblePages().main; 2923 for (var _pageCount = 0; _pageCount < visible.length; _pageCount++) { 2924 var page = void 0, 2925 _pageNumber = visible[_pageCount]; 2926 page = viewer.pages[_pageNumber - 1]; 2927 var pageChanged = _pageNumber !== page.pageNumber; 2928 2929 //Determine Page Situation 2930 if (pageChanged) { 2931 //texture reset 2932 page.resetTexture(); 2933 this.app.textureRequestStatus = defaults_DEARVIEWER.REQUEST_STATUS.ON; 2934 } 2935 page.element.attr("number", _pageNumber); 2936 page.pageNumber = _pageNumber; 2937 // page.name = _pageNumber.toString(); 2938 } 2939 2940 viewer.requestRefresh(false); 2941 app.textureRequestStatus = defaults_DEARVIEWER.REQUEST_STATUS.ON; 2942 // viewer.element.toggleClass("df-noscroll", !(viewer.element[0].scrollHeight > viewer.element[0].offsetHeight)); 2943 } 2944 }, { 2945 key: "isAnimating", 2946 value: function isAnimating() { 2947 // if (this.scrollStatus === DEARVIEWER.REQUEST_STATUS.ON) console.log("animating"); 2948 return this.scrollStatus === defaults_DEARVIEWER.REQUEST_STATUS.ON || this.scrollStatus === defaults_DEARVIEWER.REQUEST_STATUS.COUNT; 2949 } 2950 }, { 2951 key: "checkRequestQueue", 2952 value: function checkRequestQueue() { 2953 _get(reader_getPrototypeOf(Reader.prototype), "checkRequestQueue", this).call(this); 2954 if (this.scrollStatus === defaults_DEARVIEWER.REQUEST_STATUS.ON) { 2955 this.scrollStatus = defaults_DEARVIEWER.REQUEST_STATUS.OFF; 2956 } 2957 if (this.scrollStatus === defaults_DEARVIEWER.REQUEST_STATUS.COUNT) { 2958 //skip one beat 2959 this.scrollStatus = defaults_DEARVIEWER.REQUEST_STATUS.ON; 2960 } 2961 } 2962 }, { 2963 key: "isActivePage", 2964 value: function isActivePage(pageNumber) { 2965 return this.visiblePagesCache !== void 0 && this.visiblePagesCache.includes(pageNumber); 2966 } 2967 }, { 2968 key: "getVisiblePages", 2969 value: function getVisiblePages() { 2970 var visiblePages = reader_utils.getVisibleElements({ 2971 container: this.element[0], 2972 elements: this.wrapper[0].children 2973 }); 2974 if (visiblePages.length === 0) { 2975 visiblePages = [this.app.currentPageNumber]; 2976 } else { 2977 visiblePages = visiblePages.splice(0, this.pageBufferSize); 2978 } 2979 this.visiblePagesCache = visiblePages; 2980 return { 2981 main: visiblePages, 2982 buffer: [] 2983 }; 2984 } 2985 }, { 2986 key: "getPageByNumber", 2987 value: function getPageByNumber(pageNumber) { 2988 var page = this.pages[pageNumber - 1]; 2989 if (page === undefined) { 2990 reader_utils.log("Page Not found for: " + pageNumber); 2991 } 2992 return page; 2993 } 2994 }, { 2995 key: "onScroll", 2996 value: function onScroll(event) { 2997 var viewer = this; 2998 var center = viewer.element[0].scrollTop + viewer.app.dimensions.containerHeight / 2; // Triggers reflow 2999 3000 var visible = viewer.getVisiblePages().main; 3001 var pageIndex = visible[0]; 3002 for (var i = 0; i < visible.length; i++) { 3003 pageIndex = visible[i]; 3004 var element = viewer.pages[pageIndex - 1].element[0]; 3005 var top = element.offsetTop + element.clientTop; 3006 if (top <= center && element.clientHeight + top >= center) { 3007 //page starts before center and ends after center 3008 break; 3009 } else if (i > 0 && top > center && element.clientHeight + top >= center) { 3010 //page has crossed center 3011 pageIndex = visible[i - 1]; 3012 break; 3013 } 3014 } 3015 viewer.skipScrollIntoView = true; 3016 viewer.app.gotoPage(pageIndex); 3017 viewer.skipScrollIntoView = false;
3018 viewer.updateScrollBar(); 3019 event.preventDefault && event.preventDefault(); 3020 event.stopPropagation(); 3021 viewer.requestRefresh(); 3022 this.scrollStatus = defaults_DEARVIEWER.REQUEST_STATUS.COUNT; 3023 defaults_DEARVIEWER.handlePopup(viewer.element, false); 3024 } 3025 }, { 3026 key: "updateScrollBar", 3027 value: function updateScrollBar() { 3028 var el = this.element[0], 3029 container = this.app.container[0], 3030 top = 60, 3031 bottom = 60, 3032 height = 40; 3033 // this.scrollBar[0].style.top = (el.scrollTop + ((el.offsetHeight - height) * el.scrollTop / (el.scrollHeight - el.offsetHeight))) + "px"; 3034 // this.scrollBar[0].style.top = (el.scrollTop + top + ((el.offsetHeight - height - top - bottom) * el.scrollTop / (el.scrollHeight - el.offsetHeight))) + "px"; 3035 // this.scrollBar[0].style.right = -el.scrollLeft + "px"; 3036 var x = el.scrollLeft, 3037 y = top + (el.offsetHeight - height - top - bottom) * el.scrollTop / (el.scrollHeight - el.offsetHeight); 3038 if (isNaN(y)) { 3039 y = top; 3040 } 3041 this.scrollBar.lastY = y; 3042 this.scrollBar[0].style.transform = 'translateY(' + y + 'px)'; 3043 } 3044 }, { 3045 key: "validatePageChange", 3046 value: function validatePageChange(pageNumber) { 3047 true; 3048 } 3049 }, { 3050 key: "gotoPageCallBack", 3051 value: function gotoPageCallBack() { 3052 var viewer = this; 3053 if (viewer.skipScrollIntoView !== true) { 3054 var page = viewer.getPageByNumber(viewer.app.currentPageNumber); 3055 if (page != null) reader_utils.scrollIntoView(page.element[0], viewer.element[0]); 3056 } 3057 viewer.skipScrollIntoView = false; 3058 viewer.requestRefresh(); 3059 } 3060 }, { 3061 key: "getTextureSize", 3062 value: function getTextureSize(param) { 3063 var viewPort = this.app.provider.viewPorts[1]; 3064 if (this.app.provider.viewPorts[param.pageNumber]) { 3065 viewPort = this.app.provider.viewPorts[param.pageNumber]; 3066 } 3067 return { 3068 height: viewPort.height * this.app.zoomValue * this.app.pageScaleValue * window.devicePixelRatio, 3069 width: viewPort.width * this.app.zoomValue * this.app.pageScaleValue * window.devicePixelRatio 3070 }; 3071 } 3072 }, { 3073 key: "textureLoadedCallback", 3074 value: function textureLoadedCallback(param) { 3075 var page = this.getPageByNumber(param.pageNumber), 3076 app = this.app; 3077 var viewPort = this.getViewPort(param.pageNumber, true); 3078 page.element.height(Math.floor(viewPort.height * app.pageScaleValue * app.zoomValue)).width(Math.floor(viewPort.width * app.pageScaleValue * app.zoomValue)); 3079 } 3080 }, { 3081 key: "pan", 3082 value: function pan(point) { 3083 var reset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 3084 var viewer = this; 3085 var origin = viewer.startPoint; 3086 var deltay = point.raw.y - origin.raw.y, 3087 deltax = point.raw.x - origin.raw.x; 3088 viewer.deltaPanY += deltay; 3089 viewer.deltaPanX += deltax; 3090 viewer.panRequestStatus = defaults_DEARVIEWER.REQUEST_STATUS.ON; 3091 if (reset === false) { 3092 viewer.startPoint = point; 3093 } 3094 } 3095 }, { 3096 key: "updatePan", 3097 value: function updatePan() { 3098 this.element[0].scrollTop = this.element[0].scrollTop - this.deltaPanY; 3099 this.element[0].scrollLeft = this.element[0].scrollLeft - this.deltaPanX; 3100 this.deltaPanY = 0; 3101 this.deltaPanX = 0; 3102 } 3103 }, { 3104 key: "mouseMove", 3105 value: function mouseMove(event) { 3106 // check if scroll bar is moved. 3107 if (this.startPoint && this.isScrollBarPressed) { 3108 var _event = reader_utils.fixMouseEvent(event); 3109 var point = this.eventToPoint(_event); 3110 var el = this.element[0], 3111 top = 60, 3112 bottom = 60, 3113 height = 40, 3114 estY = this.scrollBar.lastY - (this.startPoint.raw.y - point.raw.y); 3115 this.scrollBar.lastY = estY; 3116 el.scrollTop = (estY - top) * (el.scrollHeight - el.offsetHeight) / (el.offsetHeight - height - top - bottom); 3117 this.startPoint = point; 3118 event.preventDefault(); 3119 return; 3120 } 3121 3122 //if it's swipe scroll we need to leave goign further and use system swipe-scroll 3123 if (event.touches && event.touches.length < 2) return; 3124 _get(reader_getPrototypeOf(Reader.prototype), "mouseMove", this).call(this, event); 3125 } 3126 }, { 3127 key: "mouseDown", 3128 value: function mouseDown(event) { 3129 _get(reader_getPrototypeOf(Reader.prototype), "mouseDown", this).call(this, event); 3130 if (event.srcElement === this.scrollBar[0]) { 3131 this.isScrollBarPressed = true; 3132 this.scrollBar.addClass("df-active"); 3133 this.scrollPageNumber.addClass("df-active"); 3134 } 3135 } 3136 }, { 3137 key: "mouseUp", 3138 value: function mouseUp(event) { 3139 _get(reader_getPrototypeOf(Reader.prototype), "mouseUp", this).call(this, event); 3140 if (this.isScrollBarPressed = true && this.scrollBar) { 3141 this.isScrollBarPressed = false;
vendor: 4,604 bytes, lines 3142-3164
3142 this.scrollBar.removeClass("df-active"); 3143 this.scrollPageNumber.removeClass("df-active"); 3144 } 3145 } 3146 }]); 3147 return Reader; 3148}(BaseViewer); 3149 3150;// CONCATENATED MODULE: ./src/js/dearviewer/viewers/flipbook.js 3151function flipbook_typeof(o) { "@babel/helpers - typeof"; return flipbook_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, flipbook_typeof(o); } 3152function flipbook_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 3153function flipbook_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, flipbook_toPropertyKey(descriptor.key), descriptor); } } 3154function flipbook_createClass(Constructor, protoProps, staticProps) { if (protoProps) flipbook_defineProperties(Constructor.prototype, protoProps); if (staticProps) flipbook_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 3155function flipbook_toPropertyKey(arg) { var key = flipbook_toPrimitive(arg, "string"); return flipbook_typeof(key) === "symbol" ? key : String(key); } 3156function flipbook_toPrimitive(input, hint) { if (flipbook_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (flipbook_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } 3157function flipbook_get() { if (typeof Reflect !== "undefined" && Reflect.get) { flipbook_get = Reflect.get.bind(); } else { flipbook_get = function _get(target, property, receiver) { var base = flipbook_superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return flipbook_get.apply(this, arguments); } 3158function flipbook_superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = flipbook_getPrototypeOf(object); if (object === null) break; } return object; } 3159function flipbook_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) flipbook_setPrototypeOf(subClass, superClass); } 3160function flipbook_setPrototypeOf(o, p) { flipbook_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return flipbook_setPrototypeOf(o, p); } 3161function flipbook_createSuper(Derived) { var hasNativeReflectConstruct = flipbook_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = flipbook_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = flipbook_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return flipbook_possibleConstructorReturn(this, result); }; } 3162function flipbook_possibleConstructorReturn(self, call) { if (call && (flipbook_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return flipbook_assertThisInitialized(self); } 3163function flipbook_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 3164function flipbook_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
3165function flipbook_getPrototypeOf(o) { flipbook_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return flipbook_getPrototypeOf(o); } 3166 3167 3168 3169var flipbook_utils = defaults_DEARVIEWER.utils; 3170var BaseFlipBookViewer = /*#__PURE__*/function (_BaseViewer) { 3171 flipbook_inherits(BaseFlipBookViewer, _BaseViewer); 3172 var _super = flipbook_createSuper(BaseFlipBookViewer); 3173 function BaseFlipBookViewer(options, appContext) { 3174 var _options$stackCount; 3175 var _this; 3176 flipbook_classCallCheck(this, BaseFlipBookViewer); 3177 options.viewerClass = "df-flipbook " + (options.viewerClass || ""); 3178 _this = _super.call(this, options, appContext); 3179 _this.isFlipBook = true; 3180 _this.sheets = []; 3181 _this.isRTL = _this.app.isRTL; 3182 _this.foldSense = 50; 3183 _this.isOneSided = false; 3184 _this.stackCount = (_options$stackCount = options.stackCount) !== null && _options$stackCount !== void 0 ? _options$stackCount : 6; 3185 _this.annotedPage = null; 3186 _this.pendingAnnotations = []; 3187 _this.seamPosition = 0; 3188 _this.dragSheet = null; 3189 _this.drag = null; 3190 _this.soundOn = options.enableSound === true; 3191 _this.soundFile = null; 3192 _this.minZoom = 1; 3193 _this.maxZoom = 4; 3194 if (_this.app.options.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.AUTO || _this.app.options.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE_INTERNAL) { 3195 _this.app.checkSecondPage = true; 3196 } 3197 3198 // if (this.app.options.pageScale === null) { 3199 _this.app.pageScaling = defaults_DEARVIEWER.PAGE_SCALE.PAGE_FIT; 3200 // } 3201 options.viewerClass = ""; 3202 _this.zoomViewer = new ZoomViewer(options, appContext); 3203 return _this; 3204 } 3205 flipbook_createClass(BaseFlipBookViewer, [{ 3206 key: "init", 3207 value: function init() { 3208 flipbook_get(flipbook_getPrototypeOf(BaseFlipBookViewer.prototype), "init", this).call(this); 3209 this.initSound(); 3210 var app = this.app; 3211 this.pageMode = app.options.pageMode === defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.AUTO ? flipbook_utils.isMobile || app.pageCount <= 2 ? defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE : defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.DOUBLE : app.options.pageMode; 3212 this.singlePageMode = app.options.singlePageMode || (flipbook_utils.isMobile ? defaults_DEARVIEWER.FLIPBOOK_SINGLE_PAGE_MODE.BOOKLET : defaults_DEARVIEWER.FLIPBOOK_SINGLE_PAGE_MODE.ZOOM); 3213 this.updatePageMode(); 3214 this.rightSheetHeight = this.leftSheetHeight = this._defaultPageSize.height; 3215 this.leftSheetWidth = this.rightSheetWidth = this._defaultPageSize.width; 3216 this.leftSheetTop = this.rightSheetTop = (this.availablePageHeight() - this._defaultPageSize.height) / 2; 3217 this.zoomViewer.rightSheetHeight = this.zoomViewer.leftSheetHeight = this._defaultPageSize.height; 3218 this.zoomViewer.leftSheetWidth = this.zoomViewer.rightSheetWidth = this._defaultPageSize.width; 3219 } 3220 }, { 3221 key: "determineHeight", 3222 value: function determineHeight() {} 3223 }, { 3224 key: "initCustomControls", 3225 value: function initCustomControls() { 3226 flipbook_get(flipbook_getPrototypeOf(BaseFlipBookViewer.prototype), "initCustomControls", this).call(this); 3227 var viewer = this; 3228 var app = this.app; 3229 var ui = app.ui; 3230 var controls = ui.controls; 3231 var text = app.options.text, 3232 icons = app.options.icons; 3233 //region Sound Button 3234 controls.sound = flipbook_utils.createBtn('sound', icons['sound'], text.toggleSound).on("click", function () { 3235 viewer.soundOn = !viewer.soundOn; 3236 ui.updateSound(); 3237 }); 3238 3239 //Updates sound on click of sound button 3240 ui.updateSound = function () { 3241 if (viewer.soundOn === false) controls.sound.addClass("disabled");else controls.sound.removeClass("disabled"); 3242 }; 3243 3244 //immediate check 3245 ui.updateSound(); 3246 } 3247 }, { 3248 key: "dispose", 3249 value: function dispose() { 3250 flipbook_get(flipbook_getPrototypeOf(BaseFlipBookViewer.prototype), "dispose", this).call(this); 3251 for (var count = 0; count < this.sheets.length; count++) { 3252 var sheet = this.sheets[count]; 3253 if (sheet && sheet.currentTween) { 3254 sheet.currentTween.stop(); 3255 sheet.currentTween = null; 3256 } 3257 } 3258 this.zoomViewer.dispose(); 3259 this.soundFile = null; 3260 } 3261 }, { 3262 key: "determinePageMode", 3263 value: function determinePageMode() { 3264 var app = this.app; 3265 var oldPageMode = this.pageMode; 3266 if (this.app.pageCount < 3) { 3267 this.pageMode = defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE; 3268 } else if (this.app.options.pageMode === defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.AUTO && this.pageModeChangedManually != true) { 3269 if (flipbook_utils.isMobile === true) { 3270 // using this only in phone so that orientation change can be supported 3271 if (this.app.dimensions.isAutoHeight && this.app.dimensions.isFixedHeight == false) { 3272 //when the flipbook is autoheight but the fullscreen mode is fixed height 3273 var singlePageModeHeight = this._calculateInnerHeight(true); 3274 var compareWidth = app.dimensions.stage.innerWidth + (app.options.sideMenuOverlay != true && app.isSideMenuOpen ? 220 : 0); 3275 this.pageMode = singlePageModeHeight > compareWidth * 1.1 && compareWidth < 768 ? defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE : defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.DOUBLE; 3276 //calculating innerheight affects other calculations, like this._defaultPageSize, so if the end result is not single page mode, calculate normally. 3277 this._calculateInnerHeight(); 3278 } else { 3279 var _compareWidth = app.dimensions.stage.innerWidth + (app.options.sideMenuOverlay != true && app.isSideMenuOpen ? 220 : 0);
3280 this.pageMode = app.dimensions.stage.innerHeight > _compareWidth * 1.1 && _compareWidth < 768 ? defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE : defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.DOUBLE; 3281 } 3282 } 3283 if (this.pageMode != oldPageMode) { 3284 this.setPageMode({ 3285 isSingle: this.pageMode == defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE 3286 }); 3287 } 3288 } 3289 } 3290 }, { 3291 key: "initSound", 3292 value: function initSound() { 3293 this.soundFile = document.createElement("audio"); 3294 this.soundFile.setAttribute("src", this.app.options.soundFile + "?ver=" + defaults_DEARVIEWER.version); 3295 this.soundFile.setAttribute("type", "audio/mpeg"); 3296 } 3297 }, { 3298 key: "playSound", 3299 value: function playSound() { 3300 var viewer = this; 3301 try { 3302 if (viewer.app.userHasInteracted === true && viewer.soundOn === true) { 3303 viewer.soundFile.currentTime = 0; 3304 viewer.soundFile.play(); 3305 } 3306 } catch (error) {} 3307 } 3308 }, { 3309 key: "checkDocumentPageSizes", 3310 value: function checkDocumentPageSizes() { 3311 var provider = this.app.provider; 3312 if (provider.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.AUTO) { 3313 if (provider._page2Ratio && provider._page2Ratio > provider.defaultPage.pageRatio * 1.5) { 3314 provider.pageSize = defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE_INTERNAL; 3315 } else { 3316 provider.pageSize = defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.SINGLE; 3317 } 3318 } 3319 if (provider.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE_INTERNAL) { 3320 provider.pageCount = provider.numPages === 1 ? 1 : provider.numPages * 2 - 2; 3321 } 3322 if (provider.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE_COVER_BACK || provider.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE) { 3323 provider.pageCount = provider.numPages * 2; 3324 } 3325 } 3326 }, { 3327 key: "getViewerPageNumber", 3328 value: function getViewerPageNumber(pageNumber) { 3329 //case double internal 3330 if (this.app.provider.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE_INTERNAL && pageNumber > 2) { 3331 pageNumber = pageNumber * 2 - 1; 3332 } 3333 if (this.app.provider.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE_COVER_BACK && pageNumber > 2) { 3334 pageNumber = pageNumber * 2 - 1; //todo not sure, we don't have a document yet with links. Since this layout is only intended with printing 3335 } 3336 3337 return pageNumber; 3338 } 3339 }, { 3340 key: "getDocumentPageNumber", 3341 value: function getDocumentPageNumber(pageNumber) { 3342 //case double internal 3343 if (this.app.provider.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE_INTERNAL && pageNumber > 2) return Math.ceil((pageNumber - 1) / 2) + 1; 3344 3345 //case double page 3346 if (this.app.provider.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE_COVER_BACK && pageNumber > 1) { 3347 //case double page last page, it's on page 1 3348 if (pageNumber === this.app.pageCount) return 1; 3349 3350 //case double page 3351 return Math.ceil((pageNumber - 1) / 2) + 1; 3352 } 3353 return pageNumber; 3354 } 3355 }, { 3356 key: "getViewPort", 3357 value: function getViewPort(pageNumber) { 3358 var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 3359 var filter = arguments.length > 2 ? arguments[2] : undefined; 3360 return this.filterViewPort(flipbook_get(flipbook_getPrototypeOf(BaseFlipBookViewer.prototype), "getViewPort", this).call(this, pageNumber, fallback), pageNumber, filter); 3361 } 3362 }, { 3363 key: "isDoubleInternal", 3364 value: function isDoubleInternal() { 3365 return this.app.provider.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE_INTERNAL; 3366 } 3367 }, { 3368 key: "isDoubleCoverBack", 3369 value: function isDoubleCoverBack() { 3370 return this.app.provider.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE_COVER_BACK; 3371 } 3372 }, { 3373 key: "isDoubleInternalPage", 3374 value: function isDoubleInternalPage(pageNumber) { 3375 return this.isDoubleInternal() && pageNumber >
3375 1 && pageNumber < this.app.provider.pageCount; 3376 } 3377 }, { 3378 key: "getDoublePageWidthFix", 3379 value: function getDoublePageWidthFix(pageNumber) { 3380 return this.isDoubleInternalPage(pageNumber) || this.isDoubleCoverBack() ? 2 : 1; 3381 } 3382 }, { 3383 key: "isDoublePageFix", 3384 value: function isDoublePageFix(pageNumber) { 3385 var fix = false; 3386 if (this.isDoubleCoverBack() || this.isDoubleInternalPage(pageNumber)) { 3387 if (this.app.isRTL) { 3388 if (pageNumber % 2 === 0) { 3389 fix = true; 3390 } 3391 } else { 3392 // canvas.width = canvas.width / doublePageWidthFix; 3393 if (pageNumber % 2 === 1) { 3394 fix = true; 3395 } 3396 } 3397 } 3398 return fix; 3399 } 3400 }, { 3401 key: "finalizeAnnotations", 3402 value: function finalizeAnnotations(element, pageNumber) { 3403 // element.parentNode.classList.toggle('df-double-internal', this.isDoubleInternalPage(pageNumber)); 3404 // element.parentNode.classList.toggle('df-double-internal-fix', this.isDoublePageFix(pageNumber)); 3405 } 3406 }, { 3407 key: "finalizeTextContent", 3408 value: function finalizeTextContent(element, pageNumber) { 3409 // element.parentNode.classList.toggle('df-double-internal', this.isDoubleInternalPage(pageNumber)); 3410 // element.parentNode.classList.toggle('df-double-internal-fix', this.isDoublePageFix(pageNumber)); 3411 } 3412 }, { 3413 key: "isActivePage", 3414 value: function isActivePage(pageNumber) { 3415 return this.visiblePagesCache !== void 0 && this.visiblePagesCache.includes(pageNumber); 3416 } 3417 }, { 3418 key: "isSheetCover", 3419 value: function isSheetCover(sheetNumber) { 3420 var isBooklet = this.isBooklet; 3421 return sheetNumber === 0 || isBooklet && sheetNumber === 1 //front cover is 0 3422 || sheetNumber === Math.ceil(this.app.pageCount / (isBooklet ? 1 : 2)) - (isBooklet ? 0 : 1); //start with 0 so 1 minus 3423 } 3424 }, { 3425 key: "isSheetHard", 3426 value: function isSheetHard(sheetNumber) { 3427 var config = this.app.options.flipbookHardPages, 3428 isBooklet = this.isBooklet; 3429 if (config === "cover") { 3430 return this.isSheetCover(sheetNumber); 3431 } else if (config === "all") { 3432 return true; 3433 } else { 3434 var baseTest = ("," + config + ",").indexOf("," + (sheetNumber * 2 + 1) + ",") > -1; 3435 var nextTest = ("," + config + ",").indexOf("," + (sheetNumber * 2 + 2) + ",") > -1; 3436 return baseTest || nextTest; 3437 } 3438 } 3439 }, { 3440 key: "sheetsIndexShift", 3441 value: function sheetsIndexShift(oldBasePageNumber, basePageNumber, stackCount) { 3442 if (oldBasePageNumber > basePageNumber) { 3443 this.sheets[stackCount - 1].skipFlip = true; 3444 this.sheets.unshift(this.sheets.pop()); 3445 } else if (oldBasePageNumber < basePageNumber) { 3446 this.sheets[0].skipFlip = true; 3447 this.sheets.push(this.sheets.shift()); 3448 } 3449 } 3450 }, { 3451 key: "checkSwipe", 3452 value: function checkSwipe(point, event) { 3453 var viewer = this; 3454 if (viewer.pinchZoomDirty === true) return; 3455 if (viewer.app.zoomValue === 1 && viewer.canSwipe === true) { 3456 //todo only if touch is available 3457 var swipe_dist = viewer.orientation == 'vertical' ? point.y - viewer.lastPosY : point.x - viewer.lastPosX; 3458 if (Math.abs(swipe_dist) > viewer.swipeThreshold) { 3459 //swipe has triggered 3460 if (swipe_dist < 0) { 3461 viewer.app.openRight(); 3462 } else { 3463 viewer.app.openLeft(); 3464 } 3465 viewer.canSwipe = false; 3466 event.preventDefault(); 3467 } 3468 viewer.lastPosX = point.x; 3469 viewer.lastPosY = point.y; 3470 } 3471 } 3472 }, { 3473 key: "checkCenter", 3474 value: function checkCenter() { 3475 var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 3476 var viewer = this, 3477 app = this.app, 3478 SHIFT = defaults_DEARVIEWER.FLIPBOOK_CENTER_SHIFT; 3479 var centerShift, 3480 isEven = app.currentPageNumber % 2 === 0, 3481 basePage = viewer.getBasePage(), 3482 isRTL = viewer.isRTL, 3483 isSingle = viewer.isSingle; 3484 if (basePage === 0 || viewer.isBooklet) { 3485 centerShift = viewer.isRTL ? SHIFT.RIGHT : SHIFT.LEFT; 3486 } else if (basePage === app.pageCount) { 3487 centerShift = isRTL ? SHIFT.LEFT : SHIFT.RIGHT; 3488 } else { 3489 centerShift = isSingle ? isRTL ? isEven ? SHIFT.LEFT : SHIFT.RIGHT : isEven ? SHIFT.RIGHT : SHIFT.LEFT : SHIFT.NONE; 3490 } 3491 if (viewer.centerNeedsUpdate !== true) { 3492 //in-case centerNeedsUpdate needs to be forced 3493 viewer.centerNeedsUpdate = viewer.centerShift !== centerShift; 3494 } 3495 if (viewer.centerNeedsUpdate) { 3496 viewer.centerShift = centerShift; 3497 viewer.updateCenter(flag); 3498 viewer.centerNeedsUpdate = false;
3499 } 3500 } 3501 }, { 3502 key: "updateCenter", 3503 value: function updateCenter() { 3504 console.log("UpdateCenter: missing implementation."); 3505 } 3506 }, { 3507 key: "reset", 3508 value: function reset() { 3509 var sheet; 3510 for (var count = 0; count < this.sheets.length; count++) { 3511 sheet = this.sheets[count]; 3512 sheet.reset(); 3513 sheet.pageNumber = -1; 3514 if (sheet.frontPage) sheet.frontPage.pageNumber = -1; 3515 if (sheet.backPage) sheet.backPage.pageNumber = -1; 3516 sheet.resetTexture(); 3517 } 3518 this.annotedPage = null; 3519 this.oldBasePageNumber = -1; 3520 this.centerShift = null; 3521 this.refresh(); 3522 } 3523 }, { 3524 key: "handleZoom", 3525 value: function handleZoom() { 3526 var app = this.app, 3527 dimensions = app.dimensions; 3528 3529 //these dimension require raw values not the ones rouded up or newreast power of two, using isAnnnotation returns raw value. 3530 var leftDimen = this.getLeftPageTextureSize({ 3531 zoom: false, 3532 isAnnotation: true 3533 }), 3534 rightDimen = this.getRightPageTextureSize({ 3535 zoom: false, 3536 isAnnotation: true 3537 }); 3538 var wasMaxZoomed = this.maxZoom === app.zoomValue; 3539 var maxZoom = this.maxZoom = app.dimensions.maxTextureSize / Math.max(leftDimen.height, leftDimen.width, rightDimen.height, rightDimen.width), 3540 zoomValue = app.zoomValue, 3541 zoomChanged = false, 3542 exitZoom = false, 3543 enterZoom = false;
3544 if (maxZoom < this.minZoom) { 3545 //this happens when the texture height is smaller than window height 3546 maxZoom = this.maxZoom = this.minZoom; 3547 } 3548 if (app.pendingZoom === true && app.zoomDelta != null) { 3549 var delta = app.zoomDelta; 3550 zoomValue = delta > 0 ? zoomValue * app.options.zoomRatio : zoomValue / app.options.zoomRatio; 3551 } else if (this.lastScale != null) { 3552 zoomValue *= this.lastScale; 3553 this.lastScale = null; 3554 } 3555 // else if (wasMaxZoomed === true) { 3556 // zoomValue = app.zoomValue = maxZoom; 3557 // console.log("Zoom value4: " + app.zoomValue); 3558 // } 3559 // While using maxZoomed, If the flipbook maxTexture is smaller than fullscreen page size. MaxZoomed is auto triggered and zoomValue is auto set to maxZoom value instead of original zoomValue 1 3560 3561 zoomValue = flipbook_utils.limitAt(zoomValue, this.minZoom, maxZoom); 3562 app.zoomValueChange = zoomValue / app.zoomValue; 3563 zoomChanged = app.zoomChanged = app.zoomValue !== zoomValue; 3564 if (zoomChanged && (zoomValue === 1 || app.zoomValue === 1)) { 3565 exitZoom = zoomValue === 1; 3566 enterZoom = app.zoomValue === 1; 3567 } 3568 app.zoomValue = zoomValue; 3569 if (enterZoom || exitZoom) { 3570 app.container.toggleClass("df-zoom-active", zoomValue !== 1); 3571 enterZoom && this.enterZoom(); 3572 exitZoom && this.exitZoom(); 3573 } 3574 } 3575 }, { 3576 key: "refresh", 3577 value: function refresh() { 3578 var viewer = this, 3579 app = this.app; 3580 var stackCount = viewer.stackCount, 3581 isRTL = viewer.isRTL, 3582 isBooklet = viewer.isBooklet; 3583 var basePageNumber = viewer.getBasePage(), 3584 pageDivisor = isBooklet ? 1 : 2; 3585 if (isRTL) basePageNumber = app.pageCount - basePageNumber; 3586 var oldBasePageNumber = viewer.oldBasePageNumber, 3587 totalSheets = Math.ceil(app.pageCount / pageDivisor), 3588 _sheetCount, 3589 midPoint = Math.floor(stackCount / 2); 3590 if (basePageNumber !== viewer.oldBasePageNumber) { 3591 viewer.pageNumberChanged = true; 3592 this.updatePendingStatusClass(true); 3593 viewer.zoomViewer.reset(); 3594 } 3595 3596 //Pages index shifting 3597 viewer.sheetsIndexShift(oldBasePageNumber, basePageNumber, stackCount); 3598 var baseSheetNumber = Math.ceil(basePageNumber / pageDivisor); 3599 for (_sheetCount = 0; _sheetCount < stackCount; _sheetCount++) { 3600 var _sheet = void 0, 3601 sheetNumber = baseSheetNumber - midPoint + _sheetCount; 3602 if (isRTL) sheetNumber = totalSheets - sheetNumber - 1; 3603 _sheet = viewer.sheets[_sheetCount]; 3604 if (_sheet == null) continue; 3605 _sheet.targetSide = _sheetCount < midPoint ? defaults_DEARVIEWER.TURN_DIRECTION.LEFT : defaults_DEARVIEWER.TURN_DIRECTION.RIGHT; 3606 var sideChanged = _sheet.side !== _sheet.targetSide, 3607 pageChanged = sheetNumber !== _sheet.pageNumber, 3608 needsFlip = sideChanged && _sheet.skipFlip === false && app.zoomValue === 1; 3609 if (!sideChanged && pageChanged && _sheet.isFlipping && _sheet.currentTween) { 3610 _sheet.currentTween.stop(); 3611 } 3612 _sheet.isHard = viewer.isSheetHard(sheetNumber); 3613 _sheet.isCover = viewer.isSheetCover(sheetNumber); 3614 3615 //Determine Page Situation 3616 if (pageChanged) { 3617 //texture reset 3618 _sheet.resetTexture(); 3619 var firstPage = this.app.isRTL ? _sheet.backPage : _sheet.frontPage; 3620 firstPage.pageNumber = this.isBooklet ? sheetNumber : sheetNumber * 2 + 1; 3621 var secondPage = this.app.isRTL ? _sheet.frontPage : _sheet.backPage; 3622 secondPage.pageNumber = this.isBooklet ? -1 : sheetNumber * 2 + 2; 3623 app.textureRequestStatus = defaults_DEARVIEWER.REQUEST_STATUS.ON; 3624 } 3625 _sheet.pageNumber = sheetNumber; 3626 viewer.refreshSheet({ 3627 sheet: _sheet, 3628 sheetNumber: sheetNumber, 3629 totalSheets: totalSheets, 3630 zIndex: this.stackCount + (_sheetCount < midPoint ? _sheetCount - midPoint : midPoint - _sheetCount), 3631 visible: isBooklet ? isRTL ? _sheetCount < midPoint || _sheet.isFlipping || needsFlip : _sheetCount >= midPoint || _sheet.isFlipping || needsFlip : sheetNumber >= 0 && sheetNumber < totalSheets || isBooklet && sheetNumber === totalSheets, 3632 index: _sheetCount, 3633 needsFlip: needsFlip, 3634 midPoint: midPoint 3635 }); 3636 } 3637 viewer.requestRefresh(false); 3638 app.textureRequestStatus = defaults_DEARVIEWER.REQUEST_STATUS.ON; 3639 viewer.oldBasePageNumber = basePageNumber; 3640 this.checkCenter(); 3641 this.zoomViewer.refresh(); 3642 viewer.pageNumberChanged = false;
3643 } 3644 }, { 3645 key: "validatePageChange", 3646 value: function validatePageChange(pageNumber) { 3647 if (pageNumber === this.app.currentPageNumber) return false; 3648 var app = this.app, 3649 valid = !this.isFlipping() || app.oldPageNumber === undefined; 3650 3651 //for continuos same direction flip, even when flipping is not completed 3652 valid = valid || app.currentPageNumber < pageNumber && app.oldPageNumber < app.currentPageNumber; 3653 valid = valid || app.currentPageNumber > pageNumber && app.oldPageNumber > app.currentPageNumber; 3654 return valid; 3655 } 3656 }, { 3657 key: "getVisiblePages", 3658 value: function getVisiblePages() { 3659 var viewer = this, 3660 visible = []; 3661 var page = viewer.getBasePage(); 3662 var count = viewer.app.zoomValue > 1 ? 1 : viewer.isBooklet && flipbook_utils.isMobile ? Math.min(viewer.stackCount / 2, 2) : viewer.stackCount / 2; 3663 for (var _count = 0; _count < count; _count++) { 3664 visible.push(page - _count); 3665 visible.push(page + _count + 1); 3666 } 3667 this.visiblePagesCache = visible; 3668 return { 3669 main: visible, 3670 buffer: [] 3671 }; 3672 } 3673 }, { 3674 key: "getBasePage", 3675 value: function getBasePage(pageNumber) { 3676 if (pageNumber === void 0) pageNumber = this.app.currentPageNumber; 3677 if (this.isBooklet) return pageNumber;else return Math.floor(pageNumber / 2) * 2; 3678 } 3679 }, { 3680 key: "getRightPageNumber", 3681 value: function getRightPageNumber() { 3682 return this.getBasePage() + (this.isBooklet ? 0 : this.isRTL ? 0 : 1); 3683 } 3684 }, { 3685 key: "getLeftPageNumber", 3686 value: function getLeftPageNumber() { 3687 return this.getBasePage() + (this.isBooklet ? 0 : this.isRTL ? 1 : 0); 3688 } 3689 }, { 3690 key: "afterFlip", 3691 value: function afterFlip() { 3692 var skip = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 3693 if (this.isAnimating() !== true) { 3694 this.pagesReady(); 3695 this.updatePendingStatusClass(); 3696 } 3697 } 3698 }, { 3699 key: "isFlipping", 3700 value: function isFlipping() { 3701 var isFlipping = false; 3702 this.sheets.forEach(function (sheet) { 3703 if (sheet.isFlipping === true) isFlipping = true; 3704 }); 3705 return isFlipping; 3706 } 3707 }, { 3708 key: "isAnimating", 3709 value: function isAnimating() { 3710 return this.isFlipping(); 3711 } 3712 }, { 3713 key: "mouseWheel", 3714 value: function mouseWheel(event) { 3715 if (this.app.options.mouseScrollAction === defaults_DEARVIEWER.MOUSE_SCROLL_ACTIONS.ZOOM) { 3716 this.zoomViewer.mouseWheel(event); 3717 } else { 3718 flipbook_get(flipbook_getPrototypeOf(BaseFlipBookViewer.prototype), "mouseWheel", this).call(this, event); 3719 } 3720 } 3721 }, { 3722 key: "checkRequestQueue", 3723 value: function checkRequestQueue() { 3724 if (this.app.zoomValue > 1) this.zoomViewer.checkRequestQueue();else flipbook_get(flipbook_getPrototypeOf(BaseFlipBookViewer.prototype), "checkRequestQueue", this).call(this); 3725 } 3726 }, { 3727 key: "updatePan", 3728 value: function updatePan() {} 3729 }, { 3730 key: "resetPageTween", 3731 value: function resetPageTween() {} 3732 }, { 3733 key: "gotoPageCallBack", 3734 value: function gotoPageCallBack() { 3735 this.resetPageTween(); 3736 3737 // this.app.options.resetZoomBeforeFlip = true; 3738 if (this.app.zoomValue !== 1 && this.app.options.resetZoomBeforeFlip === true) { 3739 this.app.resetZoom(); 3740 } 3741 this.beforeFlip(); 3742 this.requestRefresh(); 3743 } 3744 }, { 3745 key: "beforeFlip", 3746 value: function beforeFlip() { 3747 var viewer = this; 3748 3749 //callback for before flip 3750 viewer.app.executeCallback('beforeFlip'); 3751 if (viewer.app.zoomValue === 1) viewer.playSound(); 3752 } 3753 }, { 3754 key: "onFlip", 3755 value: function onFlip() { 3756 var viewer = this; 3757 //callback for after flip 3758 viewer.app.executeCallback('onFlip'); 3759 } 3760 3761 //todo should be handled properly by zoomviewer directly 3762 }, { 3763 key: "getAnnotationElement", 3764 value: function getAnnotationElement(pageNumber) { 3765 var clean = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 3766 var annotationEl = undefined; 3767 if (this.app.zoomValue > 1) annotationEl = this.zoomViewer.getAnnotationElement(pageNumber,
3767clean);else annotationEl = flipbook_get(flipbook_getPrototypeOf(BaseFlipBookViewer.prototype), "getAnnotationElement", this).call(this, pageNumber, clean); 3768 if (annotationEl) { 3769 annotationEl.parentNode.classList.toggle('df-double-internal', this.isDoubleInternalPage(pageNumber)); 3770 annotationEl.parentNode.classList.toggle('df-double-internal-fix', this.isDoublePageFix(pageNumber)); 3771 } 3772 return annotationEl; 3773 } 3774 }, { 3775 key: "getTextElement", 3776 value: function getTextElement(pageNumber) { 3777 var clean = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 3778 if (this.app.zoomValue > 1) return this.zoomViewer.getTextElement(pageNumber, clean);else return flipbook_get(flipbook_getPrototypeOf(BaseFlipBookViewer.prototype), "getTextElement", this).call(this, pageNumber, clean); 3779 } 3780 }, { 3781 key: "enterZoom", 3782 value: function enterZoom() { 3783 this.exchangeTexture(this, this.zoomViewer); 3784 } 3785 }, { 3786 key: "exitZoom", 3787 value: function exitZoom() { 3788 this.exchangeTexture(this.zoomViewer, this); 3789 } 3790 }, { 3791 key: "exchangeTexture", 3792 value: function exchangeTexture(from, to) { 3793 var basePage = this.getBasePage(); 3794 var fromPage = from.getPageByNumber(basePage); 3795 var toPage = to.getPageByNumber(basePage); 3796 if (toPage && toPage.textureStamp === "-1") { 3797 toPage.textureStamp = fromPage.textureStamp; 3798 toPage.loadTexture({ 3799 texture: fromPage.getTexture(true) 3800 }); 3801 flipbook_utils.log("Texture Exchanging at " + basePage); 3802 } else { 3803 flipbook_utils.log("Texture Exchanging Bypassed at " + basePage); 3804 } 3805 if (!this.isBooklet) { 3806 var _fromPage = from.getPageByNumber(basePage + 1); 3807 var _toPage = to.getPageByNumber(basePage + 1); 3808 if (_toPage && _toPage.textureStamp === "-1") { 3809 _toPage.textureStamp = _fromPage.textureStamp; 3810 _toPage.loadTexture({ 3811 texture: _fromPage.getTexture(true) 3812 }); 3813 flipbook_utils.log("Texture Exchanging at " + (basePage + 1)); 3814 } else { 3815 flipbook_utils.log("Texture Exchanging Bypassed at " + (basePage + 1)); 3816 } 3817 } 3818 to.pagesReady(); 3819 } 3820 }, { 3821 key: "setPageMode", 3822 value: function setPageMode(args) { 3823 var app = this.app; 3824 var isSingle = args.isSingle === true; 3825 this.pageMode = isSingle ? defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE : defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.DOUBLE; 3826 this.updatePageMode(); 3827 app.resizeRequestStart(); 3828 // this.requestRefresh(); 3829 3830 if (app.viewer.pageMode === defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.DOUBLE && app.ui.controls.pageMode) { 3831 app.ui.controls.pageMode.removeClass(app.options.icons['doublepage']).addClass(app.options.icons['singlepage']).attr('title', app.options.text.singlePageMode).html('<span>' + app.options.text.singlePageMode + '</span>'); 3832 } else { 3833 app.ui.controls.pageMode.addClass(app.options.icons['doublepage']).removeClass(app.options.icons['singlepage']).attr('title', app.options.text.doublePageMode).html('<span>' + app.options.text.doublePageMode + '</span>'); 3834 } 3835 } 3836 }, { 3837 key: "updatePageMode", 3838 value: function updatePageMode() { 3839 if (this.app.pageCount < 3) this.pageMode = defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE; 3840 this.isSingle = this.pageMode === defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE; 3841 this.isBooklet = this.isSingle && this.singlePageMode === defaults_DEARVIEWER.FLIPBOOK_SINGLE_PAGE_MODE.BOOKLET; 3842 this.app.jumpStep = this.isSingle ? 1 : 2; 3843 this.totalSheets = Math.ceil(this.app.pageCount / (this.isBooklet ? 1 : 2)); 3844 if (this.sheets.length > 0) this.reset(); 3845 } 3846 }, { 3847 key: "setPage", 3848 value: function setPage(param) { 3849 if (param.textureTarget === defaults_DEARVIEWER.TEXTURE_TARGET.ZOOM) { 3850 return this.zoomViewer.setPage(param); 3851 } else { 3852 return flipbook_get(flipbook_getPrototypeOf(BaseFlipBookViewer.prototype), "setPage", this).call(this, param); 3853 } 3854 } 3855 }, { 3856 key: "_calculateInnerHeight", 3857 value: function _calculateInnerHeight() { 3858 var singleMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : void 0; 3859 if (singleMode === void 0) { 3860 singleMode = this.pageMode === defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE; 3861 } 3862 var viewPort = this.app.dimensions.defaultPage.viewPort; 3863 var appWidth = this.availablePageWidth(false, true, singleMode), 3864 appHeightMax = this.app.dimensions.maxHeight - this.app.dimensions.padding.height; 3865 if (this.orientation == 'vertical' && singleMode == false) { 3866 appHeightMax /= 2; 3867 } 3868 this._defaultPageSize = flipbook_utils.contain(viewPort.width, viewPort.height, appWidth, appHeightMax); 3869 this._pageFitArea = { 3870 width: appWidth, 3871 height: appHeightMax 3872 }; //do not use this value as reference, it's a midvalue 3873 //_pageFitArea is not the size of flipbook. It the size of possible viewport inside a browser when auto height. In short, it's the restricted area iside which flipbook lies 3874 /// ------------ 3875 /// | | | 3876 /// -------------- this is flibpok size 3877 /// ______________ this is pagefit area, flipbook cannot go beyond the pagefit area 3878 3879 var innerHeight = this.app.dimensions.isFixedHeight ? appHeightMax : this._pageFitArea.height; 3880 if (this.app.dimensions.isAutoHeight && this.app.dimensions.isFixedHeight == false) { 3881 //when the flipbook is autoheight but the fullscreen mode is fixed height 3882 innerHeight = Math.floor(this._defaultPageSize.height); 3883 }
3884 return innerHeight; 3885 } 3886 }, { 3887 key: "_getInnerHeight", 3888 value: function _getInnerHeight() { 3889 var innerHeight = this._calculateInnerHeight(); 3890 this.app.dimensions.stage.width = this.app.dimensions.stage.innerWidth + this.app.dimensions.padding.width; 3891 this.app.dimensions.stage.height = innerHeight + this.app.dimensions.padding.height; 3892 return innerHeight; 3893 } 3894 }, { 3895 key: "availablePageWidth", 3896 value: function availablePageWidth() { 3897 var zoom = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; 3898 var ignoreSidemenuOverlay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 3899 var singleMode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : void 0; 3900 if (singleMode === void 0) { 3901 singleMode = this.pageMode === defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE; 3902 } 3903 var extraWidth = ignoreSidemenuOverlay === true ? this.app.dimensions.offset.width : 0; 3904 var pageWidth = this.app.dimensions.stage.innerWidth + extraWidth; 3905 pageWidth /= singleMode === true || this.orientation == 'vertical' ? 1 : 2; 3906 return Math.floor(pageWidth * (zoom ? this.app.zoomValue : 1)); 3907 } 3908 }, { 3909 key: "availablePageHeight", 3910 value: function availablePageHeight() { 3911 var zoom = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; 3912 var singleMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : void 0; 3913 if (singleMode === void 0) { 3914 singleMode = this.pageMode === defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE; 3915 } 3916 var pageHeight = this.app.dimensions.stage.innerHeight; 3917 if (singleMode === false && this.orientation == 'vertical') { 3918 pageHeight /= 2; 3919 } 3920 return Math.floor(pageHeight * (zoom ? this.app.zoomValue : 1)); 3921 } 3922 }, { 3923 key: "getTextureSize", 3924 value: function getTextureSize(param) { 3925 var _param$pixelRatio; 3926 var viewport = this.getViewPort(param.pageNumber, true); 3927 var pixelRatio = (_param$pixelRatio = param.pixelRatio) !== null && _param$pixelRatio !== void 0 ? _param$pixelRatio : window.devicePixelRatio; 3928 var dimen = flipbook_utils.contain(viewport.width, viewport.height, pixelRatio * this.availablePageWidth(param.zoom), pixelRatio * this.availablePageHeight(param.zoom)); 3929 dimen = flipbook_utils.containUnStretched(dimen.width, dimen.height, this.app.options.maxTextureSize, this.app.options.maxTextureSize); 3930 return { 3931 height: dimen.height, 3932 width: dimen.width 3933 }; 3934 } 3935 }, { 3936 key: "getLeftPageTextureSize", 3937 value: function getLeftPageTextureSize() { 3938 var param = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 3939 param.pageNumber = this.getLeftPageNumber(); 3940 return this.getTextureSize(param); 3941 } 3942 }, { 3943 key: "getRightPageTextureSize", 3944 value: function getRightPageTextureSize() { 3945 var param = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 3946 param.pageNumber = this.getRightPageNumber(); 3947 return this.getTextureSize(param); 3948 } 3949 }, { 3950 key: "filterViewPort", 3951 value: function filterViewPort(viewport, pageNumber) { 3952 var filter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; 3953 if (viewport === undefined) return undefined; 3954 if (filter != true) return viewport; 3955 var _viewport = viewport.clone(); 3956 _viewport.width = _viewport.width / this.getDoublePageWidthFix(pageNumber); 3957 return _viewport; 3958 } 3959 }, { 3960 key: "filterViewPortCanvas", 3961 value: function filterViewPortCanvas(viewport, canvas, pageNumber) { 3962 if (this.isDoublePageFix(pageNumber)) { 3963 viewport.transform[4] = viewport.transform[4] - Math.floor(Math.min(canvas.width, viewport.width * 2 - canvas.width)); 3964 } 3965 viewport.widthFix = this.isDoubleInternalPage(pageNumber) ? 2 : 1; 3966 } 3967 }, { 3968 key: "isClosedPage", 3969 value: function isClosedPage(pageNumber) { 3970 if (pageNumber === void 0) pageNumber = this.app.currentPageNumber; 3971 return pageNumber === 1 || pageNumber === this.app.jumpStep * Math.ceil(this.app.pageCount / this.app.jumpStep) && !this.isBooklet; 3972 //Booklets never close on the end 3973 } 3974 }, { 3975 key: "isLeftPage", 3976 value: function isLeftPage(pageNumber) { 3977 if (pageNumber === void 0) pageNumber = this.app.currentPageNumber; 3978 if (this.isBooklet) { 3979 return this.isRTL; 3980 } else { 3981 return pageNumber % 2 === (this.isRTL ? 1 : 0); 3982 } 3983 } 3984 }, { 3985 key: "cleanPage", 3986 value: function cleanPage(pageNumber) { 3987 if (this.isDoubleInternalPage(pageNumber)) { 3988 var otherPage = pageNumber + (pageNumber % 2 === 1 ? -1 : 1); 3989 return this.app.provider.requestedPages[pageNumber] === false && this.app.provider.requestedPages[otherPage] === false; 3990 } else { 3991 return flipbook_get(flipbook_getPrototypeOf(BaseFlipBookViewer.prototype), "cleanPage", this).call(this, pageNumber); 3992 } 3993 } 3994 }, { 3995 key: "onReady", 3996 value: function onReady() { 3997 flipbook_get(flipbook_getPrototypeOf(BaseFlipBookViewer.prototype), "onReady", this).call(this); 3998 } 3999 }, { 4000 key: "searchPage", 4001 value: function searchPage(pageNumber) { 4002 return { 4003 include: !this.isDoublePageFix(pageNumber), 4004 label: this.app.provider.getLabelforPage(pageNumber) + (this.isDoubleInternalPage(pageNumber) ? "-" + this.app.provider.getLabelforPage(pageNumber + 1) : "") 4005 }; 4006 } 4007 }]); 4008 return BaseFlipBookViewer; 4009}(BaseViewer); 4010var ZoomViewer = /*#__PURE__*/function (_BaseViewer2) { 4011 flipbook_inherits(ZoomViewer, _BaseViewer2); 4012 var _super2 = flipbook_createSuper(ZoomViewer); 4013 function ZoomViewer(options, appContext) { 4014 var _this2; 4015 flipbook_classCallCheck(this, ZoomViewer); 4016 options.viewerClass = "df-zoomview " + (options.viewerClass || ""); 4017 _this2 = _super2.call(this, options, appContext);
4018 _this2.viewer = _this2.app.viewer; 4019 _this2.events = {}; 4020 _this2.init(); 4021 _this2.initEvents(); 4022 _this2.left = 0; 4023 _this2.top = 0; 4024 return _this2; 4025 } 4026 flipbook_createClass(ZoomViewer, [{ 4027 key: "init", 4028 value: function init() { 4029 this.leftPage = new Page2D(); 4030 this.rightPage = new Page2D(); 4031 this.pages.push(this.leftPage); 4032 this.pages.push(this.rightPage); 4033 this.leftPage.element.addClass('df-page-back'); 4034 this.rightPage.element.addClass('df-page-front'); 4035 this.wrapper.append(this.leftPage.element); 4036 this.wrapper.append(this.rightPage.element); 4037 this.bookShadow = jQuery('<div>', { 4038 "class": 'df-book-shadow' 4039 }); 4040 this.wrapper.append(this.bookShadow); 4041 this.wrapper.addClass("df-sheet"); 4042 } 4043 }, { 4044 key: "initEvents", 4045 value: function initEvents() { 4046 this.stageDOM = this.element[0]; 4047 flipbook_get(flipbook_getPrototypeOf(ZoomViewer.prototype), "initEvents", this).call(this); 4048 } 4049 }, { 4050 key: "dispose", 4051 value: function dispose() { 4052 this.element.remove(); 4053 } 4054 }, { 4055 key: "resize", 4056 value: function resize() { 4057 var viewer = this; 4058 var dimensions = viewer.app.dimensions; 4059 var padding = dimensions.padding; 4060 var zoomHeight = this.app.viewer.availablePageHeight(), 4061 zoomWidth = this.app.viewer.availablePageWidth(), 4062 zoomFullWidth = viewer.fullWidth = zoomWidth * (this.app.viewer.pageMode === defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE ? 1 : 2), 4063 stageWidth = dimensions.stage.innerWidth, 4064 stageHeight = dimensions.stage.innerHeight; 4065 var shiftHeight = viewer.shiftHeight = Math.ceil(flipbook_utils.limitAt((zoomHeight - stageHeight) / 2, 0, zoomHeight)), 4066 shiftWidth = viewer.shiftWidth = Math.ceil(flipbook_utils.limitAt((zoomFullWidth - stageWidth) / 2, 0, zoomFullWidth)); 4067 if (viewer.app.zoomValue === 1) { 4068 viewer.left = 0; 4069 viewer.top = 0; 4070 } 4071 viewer.element.css({ 4072 top: -shiftHeight, 4073 bottom: -shiftHeight, 4074 right: -shiftWidth, 4075 left: -shiftWidth, 4076 paddingTop: padding.top, 4077 paddingRight: padding.right, 4078 paddingBottom: padding.bottom, 4079 paddingLeft: padding.left, 4080 transform: "translate3d(" + viewer.left + "px," + viewer.top + "px,0)" 4081 }); 4082 viewer.wrapper.css({ 4083 width: zoomFullWidth, 4084 height: zoomHeight, 4085 //marginTop when the flipbook is smaller than the ViewArea it has to center align vertically 4086 marginTop: dimensions.height - zoomHeight - padding.height > 0 ? (dimensions.height - padding.height - zoomHeight) / 2 : 0 4087 }); 4088 this.wrapper.height(zoomHeight).width(zoomFullWidth - zoomFullWidth % 2); 4089 if (viewer.app.pendingZoom === true) { 4090 viewer.zoom(); 4091 } 4092 this.app.viewer.annotedPage = null; 4093 this.pagesReady(); 4094 } 4095 }, { 4096 key: "zoom", 4097 value: function zoom() { 4098 var viewer = this, 4099 app = this.app; 4100 if (app.zoomChanged) { 4101 var origin = app.dimensions.origin, 4102 dz = app.zoomValueChange; 4103 4104 //fix zoom to previous center 4105 if (app.zoomValue === 1) { 4106 viewer.left = 0; 4107 viewer.top = 0; 4108 } else { 4109 viewer.left *= dz; 4110 viewer.top *= dz; 4111 if (!app.viewer.zoomCenter) { 4112 app.viewer.zoomCenter = { 4113 x: origin.x, 4114 y: origin.y 4115 }; 4116 } 4117 var pointOld = { 4118 raw: app.viewer.zoomCenter 4119 }, 4120 pointNew = { 4121 raw: {} 4122 }; 4123 // pointOld.raw.x -= app.dimensions.offset.left / 2; 4124 4125 //fix zoom to previous pointer 4126 var dx = (pointOld.raw.x - origin.x) * dz, 4127 dy = (pointOld.raw.y - origin.y) * dz; 4128 pointNew.raw.x = origin.x + dx; 4129 pointNew.raw.y = origin.y + dy; 4130 viewer.startPoint = pointNew; 4131 viewer.pan(pointOld); 4132 viewer.startPoint = null; 4133 } 4134 } 4135 app.viewer.zoomCenter = null; 4136 } 4137 }, { 4138 key: "reset", 4139 value: function reset() { 4140 this.leftPage.resetTexture(); 4141 this.rightPage.resetTexture(); 4142 } 4143 }, { 4144 key: "refresh", 4145 value: function refresh() { 4146 var app = this.app, 4147 viewer = app.viewer; 4148 var basePageNumber = viewer.getBasePage(), 4149 isLeftBase = viewer.isBooklet ? !app.isRTL : app.isRTL, 4150 basePage = isLeftBase ? this.rightPage : this.leftPage, 4151 nextPage = isLeftBase ? this.leftPage : this.rightPage; 4152 basePage.pageNumber = basePageNumber; 4153 nextPage.pageNumber = basePageNumber + 1; 4154 basePage.updateCSS({ 4155 display: basePageNumber === 0 ? "none" : "block" 4156 }); 4157 nextPage.updateCSS({ 4158 display: nextPage.pageNumber > app.pageCount || viewer.isBooklet ? "none" : "block" 4159 }); 4160 } 4161 }, { 4162 key: "updateCenter", 4163 value: function updateCenter() { 4164 var viewer = this; 4165 if (viewer === null || viewer.app.viewer === null) return; 4166 var centerShift = viewer.app.viewer.centerShift, 4167 isRTL = viewer.app.viewer.isRTL, 4168 width = !isRTL && viewer.app.currentPageNumber > 1 || isRTL && viewer.app.currentPageNumber < viewer.app.pageCount ? viewer.leftSheetWidth : viewer.rightSheetWidth; 4169 var end = centerShift * width / 2; 4170 viewer.wrapper[0].style.left = end + "px"; 4171 } 4172 }, { 4173 key: "isDoubleInternalPage", 4174 value: function isDoubleInternalPage(pageNumber) { 4175 return this.app.viewer.isDoubleInternalPage(pageNumber); 4176 } 4177 }, { 4178 key: "pagesReady", 4179 value: function pagesReady() { 4180 if (this.app.viewer.isFlipping()) return; 4181 if (this.app.zoomValue !== 1) this.app.viewer.updatePendingStatusClass(false); 4182 if (this.app.options.flipbookFitPages === false) { 4183 var basePage = this.app.viewer.getBasePage();
4184 var leftViewPort = this.leftViewport = this.app.viewer.getViewPort(basePage + (this.app.viewer.isBooklet ? 0 : this.app.viewer.isRTL ? 1 : 0)), 4185 rightViewPort = this.rightViewPort = this.app.viewer.getViewPort(basePage + (this.app.viewer.isBooklet ? 0 : this.app.viewer.isRTL ? 0 : 1)); 4186 if (leftViewPort) { 4187 var leftDimen = flipbook_utils.contain(leftViewPort.width, leftViewPort.height, this.app.viewer.availablePageWidth(), this.app.viewer.availablePageHeight()); 4188 this.leftSheetWidth = Math.floor(leftDimen.width); 4189 this.leftSheetHeight = Math.floor(leftDimen.height); 4190 this.leftSheetTop = (this.app.viewer.availablePageHeight() - this.leftSheetHeight) / 2; 4191 } 4192 if (rightViewPort) { 4193 var rightDimen = flipbook_utils.contain(rightViewPort.width, rightViewPort.height, this.app.viewer.availablePageWidth(), this.app.viewer.availablePageHeight()); 4194 this.rightSheetWidth = Math.floor(rightDimen.width); 4195 this.rightSheetHeight = Math.floor(rightDimen.height); 4196 this.rightSheetTop = (this.app.viewer.availablePageHeight() - this.rightSheetHeight) / 2; 4197 } 4198 if (leftViewPort != void 0 || rightViewPort != void 0) { 4199 this.totalSheetsWidth = this.leftSheetWidth + this.rightSheetWidth; 4200 this.leftPage.element.height(Math.floor(this.leftSheetHeight)).width(Math.floor(this.leftSheetWidth)).css({ 4201 transform: 'translateY(' + Math.floor(this.leftSheetTop) + 'px)' 4202 }); 4203 this.rightPage.element.height(Math.floor(this.rightSheetHeight)).width(Math.floor(this.rightSheetWidth)).css({ 4204 transform: 'translateY(' + Math.floor(this.rightSheetTop) + 'px)' 4205 }); 4206 } 4207 } 4208 } 4209 }, { 4210 key: "textureLoadedCallback", 4211 value: function textureLoadedCallback(param) { 4212 var page = this.getPageByNumber(param.pageNumber); 4213 //page.element.toggleClass("df-odd", param.oddPage === true); 4214 this.pagesReady(); 4215 } 4216 }]); 4217 return ZoomViewer; 4218}(BaseViewer); 4219var BookSheet = /*#__PURE__*/function () { 4220 function BookSheet(options) { 4221 flipbook_classCallCheck(this, BookSheet); 4222 this.parentElement = options.parentElement; 4223 this.isFlipping = false; 4224 this.isOneSided = false; 4225 this.viewer = options.viewer; 4226 this.frontPage = null; 4227 this.backPage = null; 4228 this.pageNumber = void 0; 4229 this.animateToReset = null; 4230 } 4231 flipbook_createClass(BookSheet, [{ 4232 key: "init", 4233 value: function init() {} 4234 }, { 4235 key: "flip", 4236 value: function flip() {} 4237 }, { 4238 key: "frontImage", 4239 value: function frontImage(param) { 4240 this.frontPage.loadTexture({ 4241 texture: param.texture, 4242 callback: param.callback 4243 }); 4244 } 4245 }, { 4246 key: "backImage", 4247 value: function backImage(param) { 4248 this.backPage.loadTexture({ 4249 texture: param.texture, 4250 callback: param.callback 4251 }); 4252 } 4253 }, { 4254 key: "resetTexture", 4255 value: function resetTexture() { 4256 this.frontPage.resetTexture(); 4257 this.backPage.resetTexture(); 4258 } 4259 }, { 4260 key: "reset", 4261 value: function reset() { 4262 var sheet = this; 4263 sheet.animateToReset = null; 4264 sheet.isFlipping = false; 4265 // page.element[0].style.opacity = 1; 4266 sheet.currentTween = null; 4267 sheet.pendingPoint = null; 4268 sheet.magnetic = false; 4269 sheet.skipFlip = true; 4270 sheet.animateToReset = null; 4271 sheet.viewer.dragPage = null; 4272 sheet.viewer.flipPage = null; 4273 sheet.viewer.corner = defaults_DEARVIEWER.TURN_CORNER.NONE; 4274 } 4275 }]); 4276 return BookSheet; 4277}(); 4278 4279;// CONCATENATED MODULE: ./src/js/dearviewer/viewers/flipbook-2d.js 4280function flipbook_2d_typeof(o) { "@babel/helpers - typeof"; return flipbook_2d_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, flipbook_2d_typeof(o); } 4281function flipbook_2d_get() { if (typeof Reflect !== "undefined" && Reflect.get) { flipbook_2d_get = Reflect.get.bind(); } else { flipbook_2d_get = function _get(target, property, receiver) { var base = flipbook_2d_superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return flipbook_2d_get.apply(this, arguments); } 4282function flipbook_2d_superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = flipbook_2d_getPrototypeOf(object); if (object === null) break; } return object; } 4283function flipbook_2d_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 4284function flipbook_2d_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, flipbook_2d_toPropertyKey(descriptor.key), descriptor); } } 4285function flipbook_2d_createClass(Constructor, protoProps, staticProps) { if (protoProps) flipbook_2d_defineProperties(Constructor.prototype, protoProps); if (staticProps) flipbook_2d_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 4286function flipbook_2d_toPropertyKey(arg) { var key = flipbook_2d_toPrimitive(arg, "string");
4286 return flipbook_2d_typeof(key) === "symbol" ? key : String(key); } 4287function flipbook_2d_toPrimitive(input, hint) { if (flipbook_2d_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (flipbook_2d_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } 4288function flipbook_2d_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) flipbook_2d_setPrototypeOf(subClass, superClass); } 4289function flipbook_2d_setPrototypeOf(o, p) { flipbook_2d_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return flipbook_2d_setPrototypeOf(o, p); } 4290function flipbook_2d_createSuper(Derived) { var hasNativeReflectConstruct = flipbook_2d_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = flipbook_2d_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = flipbook_2d_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return flipbook_2d_possibleConstructorReturn(this, result); }; } 4291function flipbook_2d_possibleConstructorReturn(self, call) { if (call && (flipbook_2d_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return flipbook_2d_assertThisInitialized(self); } 4292function flipbook_2d_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 4293function flipbook_2d_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } 4294function flipbook_2d_getPrototypeOf(o) { flipbook_2d_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return flipbook_2d_getPrototypeOf(o); } 4295/*Stage collects events and passed to respective implementation*/ 4296 4297 4298 4299var flipbook_2d_DV = defaults_DEARVIEWER; 4300var flipbook_2d_utils = flipbook_2d_DV.utils; 4301var BookSheet2D = /*#__PURE__*/function (_BookSheet) { 4302 flipbook_2d_inherits(BookSheet2D, _BookSheet); 4303 var _super = flipbook_2d_createSuper(BookSheet2D); 4304 function BookSheet2D(options) { 4305 var _this; 4306 flipbook_2d_classCallCheck(this, BookSheet2D); 4307 _this = _super.call(this, options); 4308 _this.init(); 4309 return _this; 4310 } 4311 flipbook_2d_createClass(BookSheet2D, [{ 4312 key: "init", 4313 value: function init() { 4314 var sheet = this, 4315 div = '<div>'; 4316 var element = sheet.element = jQuery(div, { 4317 "class": 'df-sheet' 4318 }); 4319 var frontPage = sheet.frontPage = new Page2D(); 4320 frontPage.element.addClass('df-page-front'); 4321 var backPage = sheet.backPage = new Page2D(); 4322 backPage.element.addClass('df-page-back'); 4323 var wrapper = sheet.wrapper = jQuery(div, { 4324 "class": "df-sheet-wrapper" 4325 }); 4326 var foldInnerShadow = sheet.foldInnerShadow = jQuery(div, { 4327 "class": "df-sheet-fold-inner-shadow" 4328 }); 4329 var foldOuterShadow = sheet.foldOuterShadow = jQuery(div, { 4330 "class": "df-sheet-fold-outer-shadow" 4331 }); 4332 this.parentElement.append(element); 4333 element.append(wrapper); 4334 element.append(foldOuterShadow); 4335 wrapper.append(frontPage.element); 4336 wrapper.append(backPage.element); 4337 wrapper.append(foldInnerShadow); 4338 } 4339 }, { 4340 key: "updateCSS", 4341 value: function updateCSS(css) { 4342 var page = this; 4343 page.element.css(css); 4344 } 4345 }, { 4346 key: "resetCSS", 4347 value: function resetCSS() { 4348 var sheet = this; 4349 sheet.wrapper.css({ 4350 transform: '' 4351 }); 4352 sheet.frontPage.resetCSS(); 4353 sheet.backPage.resetCSS(); 4354 } 4355 }, { 4356 key: "updateSize", 4357 value: function updateSize(width, height, top) { 4358 width = Math.floor(width); 4359 height = Math.floor(height); 4360 top = Math.floor(top); 4361 this.wrapper[0].style.height = this.wrapper[0].style.width = Math.ceil(flipbook_2d_utils.distOrigin(width, height) * this.viewer.app.zoomValue) + "px"; 4362 this.element[0].style.height = this.frontPage.element[0].style.height = this.backPage.element[0].style.height = this.foldInnerShadow[0].style.height = height + "px"; 4363 this.element[0].style.width = this.frontPage.element[0].style.width = this.backPage.element[0].style.width = this.foldInnerShadow[0].style.width = width + "px"; 4364 this.element[0].style.transform = 'translateY(' + top + 'px)'; 4365 } 4366 }, { 4367 key: "flip", 4368 value: function flip(point) { 4369 var sheet = this; 4370 4371 //point is usually null if the flip was made by next or previous without folding 4372 point = point || sheet.pendingPoint; 4373 if (sheet == null || sheet.viewer == null) return; 4374 sheet.isFlipping = true; 4375 sheet.viewer.flipPage = sheet; 4376 var isBooklet = sheet.viewer.isBooklet, 4377 isRight = sheet.side === defaults_DEARVIEWER.TURN_DIRECTION.RIGHT, 4378 isRTL = sheet.viewer.isRTL, 4379 isBottom = sheet.viewer.corner === defaults_DEARVIEWER.TURN_CORNER.BL || sheet.viewer.corner === defaults_DEARVIEWER.TURN_CORNER.BR; 4380 var travelY = isBottom ? sheet.element.height() : 0; 4381 var fullWidth = sheet.viewer.leftSheetWidth + sheet.viewer.rightSheetWidth; 4382 var init, 4383 angle = 0, 4384 end; //stages of flip or fold cancel 4385 4386 end = sheet.end = sheet && sheet.animateToReset === true ? { 4387 x: isRight ? fullWidth : 0, 4388 y: travelY 4389 } : { 4390 x: isRight ? 0 : fullWidth, 4391 y: travelY 4392 }; 4393 sheet.flipEasing = sheet.isHard ? TWEEN.Easing.Quadratic.InOut : TWEEN.Easing.Linear.None; 4394 var flipDuration = sheet.viewer.app.options.duration; //duration that should take based on distance(calculated below) 4395 4396 if (sheet.isHard === true) { 4397 if (point != null) { 4398 angle = flipbook_2d_utils.angleByDistance(point.distance, point.fullWidth); 4399 } 4400 init = sheet.init = { 4401 angle: angle * (isRight ? -1 : 1) 4402 }; 4403 end = sheet.end = sheet && sheet.animateToReset === true ? { 4404 angle: isRight ? 0 : -0 4405 } : { 4406 angle: isRight ? -180 : 180 4407 }; 4408 } else { 4409 if (point == null) { 4410 init = sheet.init = sheet && sheet.animateToReset === true ? { 4411 x: isRight ? 0 : fullWidth, 4412 y: 0 4413 } : { 4414 x: isRight ? fullWidth : 0, 4415 y: 0 4416 }; 4417 } else { 4418 init = sheet.init = { 4419 x: point.x, 4420 y: point.y, 4421 opacity: 1 4422 }; 4423 flipDuration = sheet.viewer.app.options.duration * flipbook_2d_utils.distPoints(init.x, init.y, end.x, end.y) / sheet.viewer.fullWidth; 4424 flipDuration = flipbook_2d_utils.limitAt(flipDuration, sheet.viewer.app.options.duration / 3, sheet.viewer.duration); 4425 } 4426 } 4427 init.index = 0; 4428 end.index = 1; 4429 sheet.isFlipping = true; 4430 if (isBooklet && (!isRight && !isRTL || isRight && isRTL)) sheet.element[0].style.opacity = 0; 4431 if (sheet.isHard === true) { 4432 sheet.currentTween = new TWEEN.Tween(init).delay(0).to(end, sheet.viewer.app.options.duration).onUp
4432date(function () { 4433 sheet.updateTween(this); 4434 }).easing(sheet.flipEasing).onComplete(sheet.completeTween.bind(sheet)).start(); 4435 } else { 4436 if (point == null) { 4437 sheet.currentTween = new TWEEN.Tween(init).delay(0).to(end, sheet.viewer.app.options.duration).onUpdate(function () { 4438 sheet.updateTween(this); 4439 }).easing(TWEEN.Easing.Sinusoidal.Out).onComplete(sheet.completeTween.bind(sheet)).start(); 4440 } else { 4441 sheet.currentTween = new TWEEN.Tween(init).delay(0).to(end, flipDuration).onUpdate(function () { 4442 sheet.updateTween(this); 4443 }).easing(TWEEN.Easing.Sinusoidal.Out).onComplete(sheet.completeTween.bind(sheet)).start(); 4444 } 4445 } 4446 //page.currentTween.viewer= page; 4447 } 4448 }, { 4449 key: "updatePoint", 4450 value: function updatePoint(point) { 4451 var sheet = this; 4452 if (point == null) return; 4453 4454 //detect the current page 4455 // let page = page.viewer.dragPage != null ? page.viewer.dragPage 4456 // : point.page != null ? point.page : this; 4457 4458 //get the pageWidth and pageHeight 4459 var pageWidth = sheet.element.width(), 4460 pageHeight = sheet.element.height(); 4461 4462 //the corner where the drag started 4463 var corner = sheet.viewer.corner !== defaults_DEARVIEWER.TURN_CORNER.NONE ? sheet.viewer.corner : point.corner, 4464 corners = defaults_DEARVIEWER.TURN_CORNER; 4465 var isRight = sheet.side === defaults_DEARVIEWER.TURN_DIRECTION.RIGHT, 4466 isBottom = corner === corners.BL || corner === corners.BR; 4467 point.rx = isRight === true ? sheet.viewer.leftSheetWidth + pageWidth - point.x : point.x; 4468 point.ry = isBottom === true ? pageHeight - point.y : point.y; 4469 var radAngle = Math.atan2(point.ry, point.rx); 4470 radAngle = Math.PI / 2 - flipbook_2d_utils.limitAt(radAngle, 0, flipbook_2d_utils.toRad(90)); 4471 var correctionX = pageWidth - point.rx / 2, 4472 correctionY = point.ry / 2, 4473 refLength = Math.max(0, Math.sin(radAngle - Math.atan2(correctionY, correctionX)) * flipbook_2d_utils.distOrigin(correctionX, correctionY)), 4474 //the distance from where the fold starts 4475 foldLength = 0.5 * flipbook_2d_utils.distOrigin(point.rx, point.ry); 4476 var x = Math.ceil(pageWidth - refLength * Math.sin(radAngle)), 4477 y = Math.ceil(refLength * Math.cos(radAngle)), 4478 angle = flipbook_2d_utils.toDeg(radAngle); 4479 var angle1 = isBottom ? isRight ? 180 + (90 - angle) : 180 + angle : isRight ? angle : 90 - angle; 4480 var angle2 = isBottom ? isRight ? 180 + (90 - angle) : angle : isRight ? angle + 180 : angle1, 4481 angleS = isBottom ? isRight ? 90 - angle : angle + 90 : isRight ? angle1 - 90 : angle1 + 180, 4482 x1 = isRight ? pageWidth - x : x, 4483 y1 = isBottom ? pageHeight + y : -y, 4484 x2 = isRight ? -x : x - pageWidth, 4485 y2 = isBottom ? -pageHeight - y : y; 4486 var opacity = flipbook_2d_utils.limitAt(point.distance * 0.5 / pageWidth, 0, 0.5); 4487 var foldOpacity = flipbook_2d_utils.limitAt((sheet.viewer.leftSheetWidth + pageWidth - point.rx) * 0.5 / pageWidth, 0.05, 0.3); 4488 sheet.element.addClass("df-folding"); 4489 var front = isRight ? sheet.backPage.element : sheet.frontPage.element; 4490 var back = isRight ? sheet.frontPage.element : sheet.backPage.element; 4491 var outerShadow = sheet.foldOuterShadow; 4492 var innerShadow = sheet.foldInnerShadow; 4493 sheet.wrapper.css({ 4494 transform: flipbook_2d_utils.translateStr(x1, y1) + flipbook_2d_utils.rotateStr(angle1) 4495 }); 4496 back.css({ 4497 transform: flipbook_2d_utils.rotateStr(-angle1) + flipbook_2d_utils.translateStr(-x1, -y1) 4498 }); 4499 front.css({ 4500 transform: flipbook_2d_utils.rotateStr(angle2) + flipbook_2d_utils.translateStr(x2, y2), 4501 boxShadow: "rgba(0, 0, 0, " + opacity + ") 0px 0px 20px" 4502 }); 4503 innerShadow.css({ 4504 transform: flipbook_2d_utils.rotateStr(angle2) + flipbook_2d_utils.translateStr(x2, y2), 4505 opacity: foldOpacity / 2, 4506 backgroundImage: flipbook_2d_utils.prefix.css + "linear-gradient( " + angleS + "deg, rgba(0, 0, 0, 0.25) , rgb(0, 0, 0) " + foldLength * 0.7 + "px, rgb(255, 255, 255) " + foldLength + "px)" 4507 }); 4508 outerShadow.css({ 4509 opacity: foldOpacity / 2, 4510 left: isRight ? "auto" : 0, 4511 right: isRight ? 0 : "auto", 4512 backgroundImage: flipbook_2d_utils.prefix.css + "linear-gradient( " + (-angleS + 180) + "deg, rgba(0, 0, 0,0) " + foldLength / 3 + "px, rgb(0, 0, 0) " + foldLength + "px)" 4513 }); 4514 } 4515 }, { 4516 key: "updateAngle", 4517 value: function updateAngle(angle, isRight) { 4518 var sheet = this; 4519 var width = sheet.element.width() * 5; 4520 sheet.wrapper.css({ 4521 perspective: width, 4522 perspectiveOrigin: isRight === true ? "0% 50%" : "100% 50%" 4523 }); 4524 sheet.element.addClass("df-folding"); 4525 sheet.backPage.updateCSS({ 4526 display: isRight === true ? angle <= -90 ? 'block' : 'none' : angle < 90 ? 'block' : 'none', 4527 transform: (flipbook_2d_utils.prefix.dom !== 'MfS' ? "" : "perspective(" + width + "px) ") + (isRight === true ? "translateX(-100%) " : "") + "rotateY(" + ((isRight === true ? 180 : 0) + angle) + "deg)" 4528 }); 4529 sheet.frontPage.updateCSS({ 4530 display: isRight === true ? angle > -90 ? 'block' : 'none' : angle >= 90 ? 'block' : 'none', 4531 transform: (flipbook_2d_utils.prefix.dom !== 'MSd' ? "" : "perspective(" + width + "px) ") + (isRight === false ? "translateX(100%) " : "") + "rotateY(" + ((isRight === false ? -180 : 0) + angle) + "deg)" 4532 }); 4533 } 4534 }, { 4535 key: "updateTween", 4536 value: function updateTween(tween) { 4537 var sheet = this; 4538 var isBooklet = sheet.viewer.isBooklet, 4539 isRight = sheet.side === defaults_DEARVIEWER.TURN_DIRECTION.RIGHT, 4540 isRTL = sheet.viewer.isRTL; 4541 var isReset = sheet.animateToReset === true; 4542 if (sheet.isHard === true) { 4543 sheet.updateAngle(tween.angle, isRight); 4544 sheet.angle = tween.angle; 4545 } else { 4546 sheet.updatePoint({ 4547 x: tween.x, 4548 y: tween.y 4549 });
4550 sheet.x = tween.x; 4551 sheet.y = tween.y; 4552 } 4553 if (isBooklet && !isReset) sheet.element[0].style.opacity = isRight && !isRTL || !isRight && isRTL ? tween.index > 0.5 ? 2 * (1 - tween.index) : 1 : tween.index < 0.5 ? 2 * tween.index : 1; 4554 } 4555 }, { 4556 key: "completeTween", 4557 value: function completeTween() { 4558 var sheet = this; 4559 if (sheet.isHard === true) { 4560 sheet.updateAngle(sheet.end.angle); 4561 sheet.backPage.element.css({ 4562 display: "block" 4563 }); 4564 sheet.frontPage.element.css({ 4565 display: "block" 4566 }); 4567 } else { 4568 sheet.updatePoint({ 4569 x: sheet.end.x, 4570 y: sheet.end.y 4571 }); 4572 } 4573 sheet.element[0].style.opacity = 1; 4574 if (sheet.animateToReset !== true) { 4575 sheet.side = sheet.targetSide; 4576 } 4577 sheet.reset(); 4578 sheet.viewer.onFlip(); 4579 sheet.viewer.afterFlip(); 4580 sheet.viewer.requestRefresh(); 4581 } 4582 }]); 4583 return BookSheet2D; 4584}(BookSheet); 4585var FlipBook2D = /*#__PURE__*/function (_BaseFlipBookViewer) { 4586 flipbook_2d_inherits(FlipBook2D, _BaseFlipBookViewer); 4587 var _super2 = flipbook_2d_createSuper(FlipBook2D); 4588 function FlipBook2D(options, appContext) { 4589 var _options$viewerClass; 4590 var _this2; 4591 flipbook_2d_classCallCheck(this, FlipBook2D); 4592 options.viewerClass = (_options$viewerClass = options.viewerClass) !== null && _options$viewerClass !== void 0 ? _options$viewerClass : "df-flipbook-2d"; 4593 options.skipViewerLoaded = true; 4594 _this2 = _super2.call(this, options, appContext); 4595 _this2.bookShadow = jQuery('<div>', { 4596 "class": 'df-book-shadow' 4597 }); 4598 _this2.wrapper.append(_this2.bookShadow); 4599 _this2.corner = defaults_DEARVIEWER.TURN_CORNER.NONE; 4600 appContext._viewerPrepared(); 4601 return _this2; 4602 } 4603 flipbook_2d_createClass(FlipBook2D, [{ 4604 key: "init", 4605 value: function init() { 4606 flipbook_2d_get(flipbook_2d_getPrototypeOf(FlipBook2D.prototype), "init", this).call(this); 4607 this.initEvents(); 4608 this.initPages(); 4609 } 4610 }, { 4611 key: "initEvents", 4612 value: function initEvents() { 4613 this.stageDOM = this.element[0]; 4614 flipbook_2d_get(flipbook_2d_getPrototypeOf(FlipBook2D.prototype), "initEvents", this).call(this); 4615 } 4616 }, { 4617 key: "dispose", 4618 value: function dispose() { 4619 flipbook_2d_get(flipbook_2d_getPrototypeOf(FlipBook2D.prototype), "dispose", this).call(this); 4620 this.element.remove(); 4621 } 4622 }, { 4623 key: "initPages", 4624 value: function initPages() { 4625 for (var count = 0; count < this.stackCount; count++) { 4626 var sheet = new BookSheet2D({ 4627 parentElement: this.wrapper 4628 }); 4629 sheet.index = count; //just reference for debugging 4630 sheet.viewer = this; 4631 this.sheets.push(sheet); 4632 this.pages.push(sheet.frontPage); 4633 this.pages.push(sheet.backPage); 4634 } 4635 } 4636 }, { 4637 key: "resize", 4638 value: function resize() { 4639 flipbook_2d_get(flipbook_2d_getPrototypeOf(FlipBook2D.prototype), "resize", this).call(this); 4640 var viewer = this; 4641 var dimensions = viewer.app.dimensions; 4642 var padding = dimensions.padding; 4643 var zoomHeight = this.availablePageHeight(), 4644 zoomWidth = this.availablePageWidth(), 4645 zoomFullWidth = viewer.fullWidth = zoomWidth * 2, 4646 stageWidth = dimensions.width, 4647 stageHeight = dimensions.height; 4648 var shiftHeight = viewer.shiftHeight = Math.ceil(flipbook_2d_utils.limitAt((zoomHeight - stageHeight + padding.height) / 2, 0, zoomHeight)), 4649 shiftWidth = viewer.shiftWidth = Math.ceil(flipbook_2d_utils.limitAt((zoomFullWidth - stageWidth + padding.width) / 2, 0, zoomFullWidth)); 4650 if (viewer.app.zoomValue === 1) { 4651 //todo add this line 4652 viewer.left = 0; 4653 viewer.top = 0; 4654 } 4655 viewer.element.css({ 4656 top: -shiftHeight, 4657 bottom: -shiftHeight, 4658 right: -shiftWidth, 4659 left: -shiftWidth, 4660 paddingTop: padding.top, 4661 paddingRight: padding.right, 4662 paddingBottom: padding.bottom, 4663 paddingLeft: padding.left, 4664 transform: "translate3d(" + viewer.left + "px," + viewer.top + "px,0)" 4665 }); 4666 viewer.wrapper.css({ 4667 //marginTop when the flipbook is smaller than the ViewArea it has to center align vertically 4668 marginTop: Math.max(dimensions.height - zoomHeight - padding.height) / 2, 4669 height: zoomHeight, 4670 width: zoomFullWidth - zoomFullWidth % 2 4671 }); 4672 viewer.zoomViewer.resize(); 4673 viewer.centerNeedsUpdate = true; 4674 viewer.checkCenter(true); 4675 viewer.pagesReady(); 4676 } 4677 }, { 4678 key: "updateCenter", 4679 value: function updateCenter() { 4680 var skipTransition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
4681 var viewer = this; 4682 var centerShift = viewer.centerShift, 4683 isRTL = viewer.isRTL, 4684 width = this.isLeftPage() ? this.leftSheetWidth : this.rightSheetWidth; 4685 var end = centerShift * width / 2; 4686 viewer.seamPosition = (-viewer.app.dimensions.offset.width + viewer.app.dimensions.containerWidth) / 2 + end; 4687 viewer.wrapperShift = (viewer.isSingle ? -viewer.app.dimensions.stage.innerWidth / 2 : 0) + end; 4688 viewer.wrapper[0].style.left = viewer.wrapperShift + "px"; 4689 viewer.wrapper[0].style.transition = skipTransition ? "none" : ""; 4690 this.zoomViewer.updateCenter(); 4691 } 4692 }, { 4693 key: "refreshSheet", 4694 value: function refreshSheet(options) { 4695 var _sheet = options.sheet, 4696 sheetPageNumber = options.sheetNumber; 4697 4698 //Render Pages & flip 4699 if (_sheet.isFlipping === false) { 4700 if (options.needsFlip) { 4701 //this.beforeFlip(); 4702 4703 _sheet.element.addClass("df-flipping"); 4704 _sheet.flip(); 4705 } else { 4706 // page.depth = depth; 4707 _sheet.skipFlip = false; 4708 _sheet.element.removeClass("df-flipping df-quick-turn df-folding df-left-side df-right-side"); 4709 _sheet.element.addClass(_sheet.targetSide === flipbook_2d_DV.TURN_DIRECTION.LEFT ? "df-left-side" : "df-right-side"); 4710 _sheet.side = _sheet.targetSide; 4711 _sheet.targetSide === flipbook_2d_DV.TURN_DIRECTION.LEFT ? _sheet.updateSize(this.leftSheetWidth, this.leftSheetHeight, this.leftSheetTop) : _sheet.updateSize(this.rightSheetWidth, this.rightSheetHeight, this.rightSheetTop); 4712 } 4713 } 4714 _sheet.visible = options.visible; 4715 if (_sheet.isHard) { 4716 _sheet.element.addClass("df-hard-sheet"); 4717 } else { 4718 _sheet.element.removeClass("df-hard-sheet"); 4719 _sheet.frontPage.updateCSS({ 4720 display: "block" 4721 }); 4722 _sheet.backPage.updateCSS({ 4723 display: "block" 4724 }); 4725 } 4726 _sheet.updateCSS({ 4727 display: _sheet.visible === true ? "block" : "none", 4728 zIndex: options.zIndex 4729 // transform: '' 4730 }); 4731 4732 if (_sheet.pendingPoint == null && _sheet.isFlipping === false) { 4733 _sheet.resetCSS(); 4734 } 4735 if (sheetPageNumber !== _sheet.pageNumber) { 4736 _sheet.element.attr("number", sheetPageNumber); 4737 _sheet.backPage.element.attr("pagenumber", _sheet.backPage.pageNumber); 4738 _sheet.frontPage.element.attr("pagenumber", _sheet.frontPage.pageNumber); 4739 } 4740 } 4741 }, { 4742 key: "eventToPoint", 4743 value: function eventToPoint(event) { 4744 var viewer = this; 4745 event = flipbook_2d_utils.fixMouseEvent(event); 4746 4747 // if(event.type==="mouseup"){ 4748 // let a = "mouseup"; 4749 // } 4750 var wrapper = viewer.wrapper, 4751 bRect = wrapper[0].getBoundingClientRect(), 4752 webgl = viewer.is3D, 4753 sheets = viewer.sheets, 4754 dimen = viewer.app.dimensions, 4755 pageWidth, 4756 fullWidth, 4757 pageHeight, 4758 point = { 4759 x: event.clientX, 4760 y: event.clientY 4761 }, 4762 left, 4763 top, 4764 distance, 4765 sheet, 4766 sheetDrag, 4767 isRight; 4768 4769 //calculate x and y relative to container 4770 var pRect = viewer.parentElement[0].getBoundingClientRect(); 4771 point.x = point.x - pRect.left; 4772 point.y = point.y - pRect.top; 4773 if (viewer.dragSheet) isRight = viewer.dragSheet.side === flipbook_2d_DV.TURN_DIRECTION.RIGHT;else { 4774 isRight = point.x > viewer.seamPosition; 4775 } 4776 pageWidth = isRight ? viewer.rightSheetWidth : viewer.leftSheetWidth; 4777 pageHeight = isRight ? viewer.rightSheetHeight : viewer.leftSheetHeight; 4778 fullWidth = viewer.rightSheetWidth + viewer.leftSheetWidth; 4779 top = isRight ? viewer.rightSheetTop : viewer.leftSheetTop; 4780 4781 //region old 4782 //calculate x and y relative to wrapper 4783 left = point.x - (viewer.seamPosition - viewer.leftSheetWidth); 4784 top = point.y - (bRect.top - pRect.top) - top; 4785 distance = viewer.drag === flipbook_2d_DV.TURN_DIRECTION.NONE ? left < pageWidth ? left : fullWidth - left : viewer.drag === flipbook_2d_DV.TURN_DIRECTION.LEFT ? left : fullWidth - left; 4786 sheet = isRight ? sheets[viewer.stackCount / 2] : sheets[viewer.stackCount / 2 - 1]; 4787 sheetDrag = left < viewer.foldSense ? flipbook_2d_DV.TURN_DIRECTION.LEFT : left > fullWidth - viewer.foldSense ? flipbook_2d_DV.TURN_DIRECTION.RIGHT : flipbook_2d_DV.TURN_DIRECTION.NONE; 4788 var x = left, 4789 y = top, 4790 h = pageHeight, 4791 w = fullWidth, 4792 delta = viewer.foldSense, 4793 corner; 4794 //determine the corner 4795 if (x >= 0 && x < delta) { 4796 if (y >= 0 && y <= delta) corner = flipbook_2d_DV.TURN_CORNER.TL;else if (y >= h - delta && y <= h) corner = flipbook_2d_DV.TURN_CORNER.BL;else if (y > delta && y < h - delta) corner = flipbook_2d_DV.TURN_CORNER.L;else corner = flipbook_2d_DV.TURN_CORNER.NONE; 4797 } else if (x >= w - delta && x <= w) { 4798 if (y >= 0 && y <= delta) corner = flipbook_2d_DV.TURN_CORNER.TR;else if (y >= h - delta && y <= h) corner = flipbook_2d_DV.TURN_CORNER.BR;else if (y > delta && y < h - delta) corner = flipbook_2d_DV.TURN_CORNER.R;else corner = flipbook_2d_DV.TURN_CORNER.NONE; 4799 } else corner = flipbook_2d_DV.TURN_CORNER.NONE; 4800 var returnPoint = { 4801 isInsideSheet: x >= 0 && x <= w && y >= 0 && y <= h, 4802 isInsideCorner: corner !== flipbook_2d_DV.TURN_CORNER.NONE && corner !== flipbook_2d_DV.TURN_CORNER.L && corner !== flipbook_2d_DV.TURN_CORNER.R, 4803 x: webgl ? point.x : left, 4804 y: webgl ? point.y : top, 4805 fullWidth: fullWidth, 4806 sheetWidth: pageWidth, 4807 sheetHeight: pageHeight, 4808 rawDistance: fullWidth - left, 4809 distance: distance, 4810 sheet: sheet, 4811 drag: sheetDrag, 4812 foldSense: viewer.foldSense, 4813 event: event, 4814 raw: point, 4815 corner: corner 4816 }; 4817 return returnPoint; 4818 } 4819 }, { 4820 key: "pan", 4821 value: function pan(point) { 4822 var reset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
4823 flipbook_2d_utils.pan(this, point, reset); 4824 } 4825 }, { 4826 key: "mouseMove", 4827 value: function mouseMove(event) { 4828 var viewer = this; 4829 var point = viewer.eventToPoint(event); 4830 if (event.touches != null && event.touches.length == 2) { 4831 this.pinchMove(event); 4832 return; 4833 } 4834 //PAN 4835 if (viewer.app.zoomValue !== 1 && viewer.startPoint != null && viewer.canSwipe === true) { 4836 viewer.pan(point); 4837 event.preventDefault(); 4838 } 4839 4840 /*Magnetic Pull*/ 4841 var targetSheet = viewer.dragSheet || point.sheet; 4842 if (viewer.flipPage == null && (viewer.dragSheet != null || point.isInsideCorner === true)) { 4843 if (viewer.dragSheet != null) { 4844 // utils.log("set mouse down move"); 4845 } else { 4846 point.y = flipbook_2d_utils.limitAt(point.y, 1, viewer.availablePageHeight() - 1); 4847 point.x = flipbook_2d_utils.limitAt(point.x, 1, point.fullWidth - 1); 4848 } 4849 var corner = viewer.dragSheet != null ? viewer.corner : point.corner; 4850 if (targetSheet.isHard) { 4851 var isRight = corner === flipbook_2d_DV.TURN_CORNER.BR || corner === flipbook_2d_DV.TURN_CORNER.TR; 4852 var angle = flipbook_2d_utils.angleByDistance(point.distance, point.fullWidth); 4853 targetSheet.updateAngle(angle * (isRight ? -1 : 1), isRight); 4854 } else { 4855 targetSheet.updatePoint(point); 4856 } 4857 targetSheet.magnetic = true; 4858 targetSheet.magneticCorner = point.corner; 4859 event.preventDefault(); 4860 //point.sheet.updatePoint(point); 4861 } 4862 /*Magnetic Release*/ 4863 if (viewer.dragSheet == null && targetSheet != null && point.isInsideCorner === false && targetSheet.magnetic === true) { 4864 targetSheet.pendingPoint = point; 4865 targetSheet.animateToReset = true; 4866 targetSheet.magnetic = false; 4867 viewer.corner = targetSheet.magneticCorner; 4868 targetSheet.flip(targetSheet.pendingPoint); 4869 targetSheet.pendingPoint = null; 4870 } 4871 //SWIPE 4872 viewer.checkSwipe(point, event); 4873 } 4874 4875 /** 4876 * Performs: 4877 * 1. If click is in inside the corner - flip the page 4878 * 2. If drag is active - complete the flip 4879 * 3. Clear any swipe flags 4880 * @param event 4881 */ 4882 }, { 4883 key: "mouseUp", 4884 value: function mouseUp(event) { 4885 var viewer = this; 4886 if (viewer.startPoint == null) return; 4887 if (!event.touches && event.button !== 0) return; 4888 if (viewer.dragSheet == null && event.touches != null && event.touches.length == 0) { 4889 this.pinchUp(event); 4890 return; 4891 } 4892 var point = viewer.eventToPoint(event); 4893 4894 //1 - 2 : if there is any page dragging - finish it 4895 var element = event.target || event.originalTarget; //check to see if the clicked element is a link, if so skip turn 4896 var isClick = viewer.app.zoomValue === 1 && point.x === viewer.startPoint.x && point.y === viewer.startPoint.y && element.nodeName !== "A"; 4897 if (event.ctrlKey === true && isClick) { 4898 this.zoomOnPoint(point); 4899 } else if (viewer.dragSheet) { 4900 event.preventDefault(); 4901 var sheet = viewer.dragSheet; 4902 sheet.pendingPoint = point; 4903 viewer.drag = point.drag; 4904 /*it was a valid CLICK and was inside the corner*/ 4905 if (isClick && (point.isInsideCorner === true || point.isInsideSheet && viewer.clickAction === flipbook_2d_DV.MOUSE_CLICK_ACTIONS.NAV)) { 4906 if (point.corner.indexOf("l") > -1) { 4907 viewer.app.openLeft(); 4908 } else { 4909 viewer.app.openRight(); 4910 } 4911 } else { 4912 var _currentPage = this.getBasePage(); 4913 if (point.distance > point.sheetWidth / 2) { 4914 if (point.sheet.side === defaults_DEARVIEWER.TURN_DIRECTION.LEFT) { 4915 viewer.app.openLeft(); 4916 } else { 4917 viewer.app.openRight(); 4918 } 4919 } 4920 //if no flip occurred reset the pages. 4921 if (_currentPage === this.getBasePage()) { 4922 sheet.animateToReset = true; 4923 sheet.flip(point); 4924 } 4925 } 4926 viewer.dragSheet = null; 4927 sheet.magnetic = false;
4928 } else if (isClick && !point.sheet.isFlipping && point.isInsideSheet && viewer.clickAction === flipbook_2d_DV.MOUSE_CLICK_ACTIONS.NAV) { 4929 if (point.sheet.side === "left") { 4930 viewer.app.openLeft(); 4931 } else { 4932 viewer.app.openRight(); 4933 } 4934 } 4935 /*3 if there is swipe - clean*/ 4936 viewer.startPoint = null; 4937 viewer.canSwipe = false; 4938 viewer.drag = flipbook_2d_DV.TURN_DIRECTION.NONE; 4939 } 4940 }, { 4941 key: "mouseDown", 4942 value: function mouseDown(event) { 4943 if (!event.touches && event.button !== 0) return; 4944 if (event.touches != null && event.touches.length == 2) { 4945 this.pinchDown(event); 4946 return; 4947 } 4948 var viewer = this; 4949 var point = viewer.eventToPoint(event); 4950 viewer.startPoint = point; 4951 viewer.lastPosX = point.x; 4952 viewer.lastPosY = point.y; 4953 if (point.isInsideCorner && viewer.flipPage == null) { 4954 viewer.dragSheet = point.sheet; 4955 viewer.drag = point.drag; 4956 viewer.corner = point.corner; 4957 if (point.sheet.pageNumber === 0) { 4958 viewer.bookShadow.css({ 4959 width: '50%', 4960 left: viewer.app.isRTL ? 0 : '50%', 4961 transitionDelay: '' 4962 }); 4963 } else if (point.sheet.pageNumber === Math.ceil(viewer.app.pageCount / 2) - 1) { 4964 viewer.bookShadow.css({ 4965 width: '50%', 4966 left: viewer.app.isRTL ? '50%' : 0, 4967 transitionDelay: '' 4968 }); 4969 } 4970 } else { 4971 viewer.canSwipe = true; 4972 } 4973 } 4974 }, { 4975 key: "onScroll", 4976 value: function onScroll(event) {} 4977 }, { 4978 key: "resetPageTween", 4979 value: function resetPageTween() { 4980 var viewer = this; 4981 for (var _pageCount = 0; _pageCount < viewer.stackCount; _pageCount++) { 4982 var sheets = viewer.sheets[_pageCount]; 4983 if (sheets.currentTween) { 4984 sheets.currentTween.complete(true); 4985 } 4986 } 4987 viewer.requestRefresh(); 4988 } 4989 }, { 4990 key: "pagesReady", 4991 value: function pagesReady() { 4992 if (this.isFlipping()) return; 4993 if (this.app.options.flipbookFitPages === false) { 4994 var basePage = this.app.viewer.getBasePage();
4995 var leftViewPort = this.leftViewport = this.getViewPort(basePage + (this.isBooklet ? 0 : this.isRTL ? 1 : 0)), 4996 rightViewPort = this.rightViewPort = this.getViewPort(basePage + (this.isBooklet ? 0 : this.isRTL ? 0 : 1)); 4997 if (leftViewPort) { 4998 var leftDimen = flipbook_2d_utils.contain(leftViewPort.width, leftViewPort.height, this.availablePageWidth(), this.availablePageHeight()); 4999 this.leftSheetWidth = Math.floor(leftDimen.width); 5000 this.leftSheetHeight = Math.floor(leftDimen.height); 5001 this.leftSheetTop = (this.availablePageHeight() - this.leftSheetHeight) / 2; 5002 } 5003 if (rightViewPort) { 5004 var rightDimen = flipbook_2d_utils.contain(rightViewPort.width, rightViewPort.height, this.availablePageWidth(), this.availablePageHeight()); 5005 this.rightSheetWidth = Math.floor(rightDimen.width); 5006 this.rightSheetHeight = Math.floor(rightDimen.height); 5007 this.rightSheetTop = (this.availablePageHeight() - this.rightSheetHeight) / 2; 5008 } 5009 this.totalSheetsWidth = this.leftSheetWidth + this.rightSheetWidth; 5010 for (var i = 0; i < this.sheets.length; i++) { 5011 var sheet = this.sheets[i]; 5012 if (sheet.side === flipbook_2d_DV.TURN_DIRECTION.LEFT) { 5013 sheet.updateSize(this.leftSheetWidth, this.leftSheetHeight, this.leftSheetTop); 5014 } else { 5015 sheet.updateSize(this.rightSheetWidth, this.rightSheetHeight, this.rightSheetTop); 5016 } 5017 } 5018 } 5019 this.updateCenter(); 5020 this.updatePendingStatusClass(); 5021 } 5022 }, { 5023 key: "textureLoadedCallback", 5024 value: function textureLoadedCallback(param) { 5025 var page = this.getPageByNumber(param.pageNumber); 5026 this.pagesReady(); 5027 } 5028 }]); 5029 return FlipBook2D; 5030}(BaseFlipBookViewer); 5031 5032;// CONCATENATED MODULE: ./src/js/dearviewer/viewers/slider.js 5033function slider_typeof(o) { "@babel/helpers - typeof"; return slider_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, slider_typeof(o); } 5034function slider_get() { if (typeof Reflect !== "undefined" && Reflect.get) { slider_get = Reflect.get.bind(); } else { slider_get = function _get(target, property, receiver) { var base = slider_superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return slider_get.apply(this, arguments); } 5035function slider_superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = slider_getPrototypeOf(object); if (object === null) break; } return object; } 5036function slider_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 5037function slider_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, slider_toPropertyKey(descriptor.key), descriptor); } } 5038function slider_createClass(Constructor, protoProps, staticProps) { if (protoProps) slider_defineProperties(Constructor.prototype, protoProps); if (staticProps) slider_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 5039function slider_toPropertyKey(arg) { var key = slider_toPrimitive(arg, "string"); return slider_typeof(key) === "symbol" ? key : String(key); } 5040function slider_toPrimitive(input, hint) { if (slider_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (slider_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } 5041function slider_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { c
5041onstructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) slider_setPrototypeOf(subClass, superClass); } 5042function slider_setPrototypeOf(o, p) { slider_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return slider_setPrototypeOf(o, p); } 5043function slider_createSuper(Derived) { var hasNativeReflectConstruct = slider_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = slider_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = slider_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return slider_possibleConstructorReturn(this, result); }; } 5044function slider_possibleConstructorReturn(self, call) { if (call && (slider_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return slider_assertThisInitialized(self); } 5045function slider_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 5046function slider_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } 5047function slider_getPrototypeOf(o) { slider_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return slider_getPrototypeOf(o); } 5048 5049 5050 5051var slider_utils = defaults_DEARVIEWER.utils; 5052var SliderPage = /*#__PURE__*/function (_BookSheet2D) { 5053 slider_inherits(SliderPage, _BookSheet2D); 5054 var _super = slider_createSuper(SliderPage); 5055 function SliderPage() { 5056 slider_classCallCheck(this, SliderPage); 5057 return _super.apply(this, arguments); 5058 } 5059 slider_createClass(SliderPage, [{ 5060 key: "init", 5061 value: function init() { 5062 var sheet = this, 5063 div = '<div>'; 5064 var element = sheet.element = jQuery(div, { 5065 "class": 'df-sheet' 5066 }); 5067 var frontPage = sheet.frontPage = new Page2D(); 5068 frontPage.element.addClass('df-page-front').appendTo(sheet.element); 5069 var backPage = sheet.backPage = new Page2D(); 5070 backPage.element.addClass('df-page-back').appendTo(sheet.element); 5071 this.parentElement.append(element); 5072 this.frontPage.sheet = this.backPage.sheet = this; 5073 } 5074 }, { 5075 key: "completeTween", 5076 value: function completeTween() { 5077 var sheet = this; 5078 sheet.isFlipping = false; 5079 sheet.viewer.onFlip(); 5080 sheet.viewer.afterFlip(); 5081 sheet.viewer.requestRefresh(); 5082 sheet.element[0].style.opacity = 1; 5083 } 5084 }, { 5085 key: "flip", 5086 value: function flip(point) { 5087 var sheet = this; 5088 sheet.side = sheet.targetSide; 5089 this.completeTween(); 5090 } 5091 }, { 5092 key: "updateSize", 5093 value: function updateSize(width, height, top) { 5094 width = Math.floor(width); 5095 height = Math.floor(height); 5096 top = Math.floor(top); 5097 this.element[0].style.height = this.frontPage.element[0].style.height = height + "px"; 5098 this.element[0].style.width = this.frontPage.element[0].style.width = width + "px"; 5099 this.element[0].style.transform = 'translateX(' + this.positionX + 'px) translateY(' + top + 'px)'; 5100 } 5101 }]); 5102 return SliderPage; 5103}(BookSheet2D); 5104var Slider = /*#__PURE__*/function (_FlipBook2D) { 5105 slider_inherits(Slider, _FlipBook2D); 5106 var _super2 = slider_createSuper(Slider); 5107 function Slider(options, appContext) { 5108 var _this; 5109 slider_classCallCheck(this, Slider); 5110 options.viewerClass = "df-slider"; 5111 options.pageMode = defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE; 5112 options.singlePageMode = defaults_DEARVIEWER.FLIPBOOK_SINGLE_PAGE_MODE.BOOKLET; 5113 options.pageSize = defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.SINGLE; 5114 _this = _super2.call(this, options, appContext); 5115 _this.stackCount = 10; 5116 _this.soundOn = false;
5117 _this.foldSense = 0; 5118 appContext._viewerPrepared(); 5119 return _this; 5120 } 5121 slider_createClass(Slider, [{ 5122 key: "initPages", 5123 value: function initPages() { 5124 for (var count = 0; count < this.stackCount; count++) { 5125 var sheet = new SliderPage({ 5126 parentElement: this.wrapper 5127 }); 5128 sheet.index = count; //just reference for debugging 5129 sheet.viewer = this; 5130 this.sheets.push(sheet); 5131 this.pages.push(sheet.frontPage); 5132 this.pages.push(sheet.backPage); 5133 } 5134 } 5135 }, { 5136 key: "resize", 5137 value: function resize() { 5138 slider_get(slider_getPrototypeOf(Slider.prototype), "resize", this).call(this); 5139 this.skipTransition = true; 5140 } 5141 }, { 5142 key: "refreshSheet", 5143 value: function refreshSheet(options) { 5144 var _sheet = options.sheet, 5145 sheetPageNumber = options.sheetNumber; 5146 _sheet.element.toggleClass("df-no-transition", _sheet.skipFlip || this.skipTransition); 5147 //Render Pages & flip 5148 if (_sheet.isFlipping === false) { 5149 if (options.needsFlip) { 5150 _sheet.flip(); 5151 } else { 5152 // page.depth = depth; 5153 _sheet.skipFlip = false; 5154 _sheet.element.removeClass("df-flipping df-quick-turn df-folding df-left-side df-right-side"); 5155 _sheet.element.addClass(_sheet.targetSide === defaults_DEARVIEWER.TURN_DIRECTION.LEFT ? "df-left-side" : "df-right-side"); 5156 _sheet.side = _sheet.targetSide; 5157 } 5158 } 5159 _sheet.visible = options.visible; 5160 _sheet.updateCSS({ 5161 display: options.sheetNumber > 0 && options.sheetNumber <= this.app.pageCount ? "block" : "none", 5162 zIndex: options.zIndex 5163 }); 5164 if (sheetPageNumber !== _sheet.pageNumber) { 5165 _sheet.element.attr("number", sheetPageNumber); 5166 _sheet.backPage.element.attr("pagenumber", _sheet.backPage.pageNumber); 5167 _sheet.frontPage.element.attr("pagenumber", _sheet.frontPage.pageNumber); 5168 } 5169 } 5170 }, { 5171 key: "refresh", 5172 value: function refresh() { 5173 slider_get(slider_getPrototypeOf(Slider.prototype), "refresh", this).call(this); 5174 this.skipTransition = false; 5175 } 5176 }, { 5177 key: "eventToPoint", 5178 value: function eventToPoint(event) { 5179 var point = slider_get(slider_getPrototypeOf(Slider.prototype), "eventToPoint", this).call(this, event); 5180 //setting isInsideSheet == true call every other match as right page slide 5181 point.isInsideSheet = jQuery(event.srcElement).closest(".df-page").length > 0; 5182 point.isInsideCorner = false;
5183 return point; 5184 } 5185 }, { 5186 key: "initCustomControls", 5187 value: function initCustomControls() { 5188 //added so that sound is removed 5189 var ui = this.app.ui; 5190 var controls = ui.controls; 5191 if (controls.pageMode) controls.pageMode.hide(); 5192 } 5193 }, { 5194 key: "setPageMode", 5195 value: function setPageMode(args) { 5196 args.isSingle = true; 5197 slider_get(slider_getPrototypeOf(Slider.prototype), "setPageMode", this).call(this, args); 5198 } 5199 }, { 5200 key: "pagesReady", 5201 value: function pagesReady() { 5202 if (this.isFlipping()) return; 5203 var leftPos = 0, 5204 rightPos = 0; 5205 var app = this.app; 5206 var midpoint = Math.floor(this.stackCount / 2); 5207 var pages = []; 5208 var page = app.currentPageNumber; 5209 for (var _count = 0; _count < this.stackCount / 2; _count++) { 5210 pages.push(page + _count); 5211 pages.push(page - _count - 1); 5212 } 5213 for (var i = 0; i < this.stackCount; i++) { 5214 var pageNumber = pages[i]; 5215 var _page = this.getPageByNumber(pageNumber); 5216 if (_page) { 5217 var sheet = this.getPageByNumber(pageNumber).sheet; 5218 var viewPort = this.getViewPort(sheet.pageNumber, true); 5219 var size = slider_utils.contain(viewPort.width, viewPort.height, this.availablePageWidth(), this.availablePageHeight()); 5220 if (app.currentPageNumber === sheet.pageNumber) { 5221 this.leftSheetWidth = this.rightSheetWidth = Math.floor(size.width); 5222 } 5223 if (app.currentPageNumber > sheet.pageNumber) { 5224 leftPos -= Math.floor(size.width) + 10; 5225 sheet.positionX = leftPos; 5226 } else { 5227 sheet.positionX = rightPos; 5228 rightPos += Math.floor(size.width) + 10; 5229 } 5230 var top = (this.availablePageHeight() - size.height) / 2; 5231 sheet.updateSize(Math.floor(size.width * app.zoomValue), Math.floor(size.height * app.zoomValue), top); 5232 } 5233 } 5234 this.updateCenter(); 5235 this.updatePendingStatusClass(); 5236 } 5237 }]); 5238 return Slider; 5239}(FlipBook2D); 5240 5241;// CONCATENATED MODULE: ./src/js/dearviewer/viewers/flipbook-3d.js 5242function flipbook_3d_typeof(o) { "@babel/helpers - typeof"; return flipbook_3d_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, flipbook_3d_typeof(o); } 5243function flipbook_3d_get() { if (typeof Reflect !== "undefined" && Reflect.get) { flipbook_3d_get = Reflect.get.bind(); } else { flipbook_3d_get = function _get(target, property, receiver) { var base = flipbook_3d_superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return flipbook_3d_get.apply(this, arguments); } 5244function flipbook_3d_superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = flipbook_3d_getPrototypeOf(object); if (object === null) break; } return object; } 5245function flipbook_3d_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 5246function flipbook_3d_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, flipbook_3d_toPropertyKey(descriptor.key), descriptor); } } 5247function flipbook_3d_createClass(Constructor, protoProps, staticProps) { if (protoProps) flipbook_3d_defineProperties(Constructor.prototype, protoProps); if (staticProps) flipbook_3d_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 5248function flipbook_3d_toPropertyKey(arg) { var key = flipbook_3d_toPrimitive(arg, "string");
5248 return flipbook_3d_typeof(key) === "symbol" ? key : String(key); } 5249function flipbook_3d_toPrimitive(input, hint) { if (flipbook_3d_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (flipbook_3d_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } 5250function flipbook_3d_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) flipbook_3d_setPrototypeOf(subClass, superClass); } 5251function flipbook_3d_setPrototypeOf(o, p) { flipbook_3d_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return flipbook_3d_setPrototypeOf(o, p); } 5252function flipbook_3d_createSuper(Derived) { var hasNativeReflectConstruct = flipbook_3d_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = flipbook_3d_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = flipbook_3d_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return flipbook_3d_possibleConstructorReturn(this, result); }; } 5253function flipbook_3d_possibleConstructorReturn(self, call) { if (call && (flipbook_3d_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return flipbook_3d_assertThisInitialized(self); } 5254function flipbook_3d_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 5255function flipbook_3d_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } 5256function flipbook_3d_getPrototypeOf(o) { flipbook_3d_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return flipbook_3d_getPrototypeOf(o); } 5257/* globals jQuery, pdfjsLib,THREE */ 5258 5259 5260 5261var flipbook_3d_DV = defaults_DEARVIEWER; 5262var flipbook_3d_utils = flipbook_3d_DV.utils; 5263var BookSheet3D = /*#__PURE__*/function (_BookSheet) { 5264 flipbook_3d_inherits(BookSheet3D, _BookSheet); 5265 var _super = flipbook_3d_createSuper(BookSheet3D); 5266 function BookSheet3D(options) { 5267 var _this; 5268 flipbook_3d_classCallCheck(this, BookSheet3D); 5269 _this = _super.call(this, options); 5270 _this.flexibility = options.flexibility; 5271 _this.sheetAngle = 180; 5272 _this.curveAngle = 0; 5273 _this.parent3D = options.parent3D; 5274 _this.segments = options.segments || 50; 5275 _this.width = options.width || 100; 5276 _this.height = options.height || 100; 5277 _this.depth = options.depth || 0.5; //is overridden from options 5278 _this.matColor = "white"; 5279 _this.fallbackMatColor = MOCKUP.WHITE_COLOR; 5280 _this.init(); 5281 _this.bumpScale = [0, 0, 0, 0, 1, 1]; 5282 return _this; 5283 } 5284 flipbook_3d_createClass(BookSheet3D, [{ 5285 key: "init", 5286 value: function init() { 5287 var sheet = this; 5288 sheet.element = new MOCKUP.Paper({ 5289 parent3D: sheet.parent3D, 5290 segments: sheet.segments, 5291 depth: sheet.depth, 5292 height: sheet.height, 5293 width: sheet.width, 5294 flatShading: sheet.flexibility === 0 ? true : false 5295 }); 5296 sheet.element.sheet = sheet; 5297 sheet.frontPage = new Page3D({ 5298 sheet: sheet, 5299 face: 5 5300 }); 5301 sheet.backPage = new Page3D({ 5302 sheet: sheet, 5303 face: 4 5304 }); 5305 sheet.reset(); 5306 sheet.updateAngle(); 5307 //sheet.element.loadBump("http://localhost/tmp/cardboard.png"); 5308 } 5309 }, { 5310 key: "setMatColor", 5311 value: function setMatColor(val, face) { 5312 this.matColor = new THREE.Color(val); 5313 if (face === void 0) { 5314 for (var i = 0; i < 6; i++) { 5315 this.element.material[i].color = this.matColor; 5316 } 5317 } else { 5318 this.element.material[face].color = this.matColor; 5319 } 5320 } 5321 }, { 5322 key: "getBumpScale", 5323 value: function getBumpScale(face) { 5324 return this.bumpScale[face]; 5325 } 5326 }, { 5327 key: "resetMatColor", 5328 value: function resetMatColor(face, applyMatColor) {
5329 this.element.material[face].color = applyMatColor ? this.matColor : this.fallbackMatColor; 5330 } 5331 }, { 5332 key: "frontImage", 5333 value: function frontImage(texture, callback) { 5334 this.element.frontImage(texture, callback); 5335 } 5336 }, { 5337 key: "backImage", 5338 value: function backImage(texture, callback) { 5339 this.element.backImage(texture, callback); 5340 } 5341 }, { 5342 key: "updateAngle", 5343 value: function updateAngle() { 5344 var sheet = this; 5345 if (this.viewer === undefined || this.viewer === null) return; 5346 var flexibility = sheet.isHard === true ? 0 : sheet.flexibility; 5347 var width = (this.viewer.orientation === 'vertical' ? this.height : this.width) * (1 - Math.sin(flexibility / 2 * (flexibility / 2)) / 2 - flexibility / 20); 5348 this.element.scale.y = (this.viewer.orientation === 'vertical' ? this.width : this.height) / this.element.geometry.parameters.height; 5349 // this.element.scale.x = this.width / this.element.geometry.parameters.width; 5350 // this.element.scale.z = 1; 5351 var segments = sheet.segments; 5352 var foldCount = 1; 5353 var foldWidth = width / foldCount; //fold-width 5354 var curveHandlePoint = foldWidth * flexibility; //bend control point distance 5355 var curveWidth = foldWidth; //curve width still not perfect 5356 //control pointsFront are a list of at least (degree+1) 5357 var curvesFront = []; 5358 var curvesBack = []; 5359 var verticesFront = []; 5360 var verticesBack = []; 5361 var pointsFront = []; 5362 var pointsBack = []; 5363 var sheetDepth = sheet.depth; // distance Bias 5364 5365 //calculate folds controls points 5366 var sum = 0, 5367 distances = []; 5368 distances.push(sum); 5369 // let test = false; 5370 5371 // region CalcPoints 5372 5373 pointsFront[0] = []; 5374 pointsBack[0] = []; 5375 var sheetAngle = sheet.sheetAngle * Math.PI / 180; // the angle at which the sheet will turn 5376 // if (this.viewer.pageOffset && this.viewer.hasSpiral) { 5377 if (this.viewer.orientation !== 'vertical') { 5378 this.element.position.x = -Math.cos(sheetAngle) * this.viewer.pageOffset; 5379 } 5380 if (this.viewer.orientation === 'vertical') { 5381 this.element.position.y = Math.cos(sheetAngle) * this.viewer.pageOffset; 5382 } 5383 // } 5384 var curveAngle = sheet.isHard === true ? sheetAngle : sheet.curveAngle * Math.PI / 180; // the angle at which curve will form due to curve handle point 5385 5386 var pointAngle = sheet.sheetAngle * Math.PI / 180; 5387 var pointAngleB = pointAngle - Math.PI / 2, 5388 zShift = Math.sin(pointAngleB) * sheetDepth / 2; 5389 pointsFront[0][0] = pointsFront[0][1] = new THREE.Vector3(-curveWidth * Math.cos(sheetAngle), 0, Math.sin(sheetAngle) * curveWidth - zShift); 5390 pointsBack[0][0] = pointsBack[0][1] = new THREE.Vector3(pointsFront[0][0].x - Math.cos(pointAngleB) * sheetDepth, 0, pointsFront[0][0].z + zShift * 2); 5391 pointsFront[0][1] = new THREE.Vector3(-curveWidth / 2 * Math.cos(curveAngle), 0, curveWidth / 2 * Math.sin(curveAngle) - zShift); 5392 pointsBack[0][1] = new THREE.Vector3(pointsFront[0][1].x - Math.cos(pointAngleB) * sheetDepth, 0, pointsFront[0][1].z + zShift * 2); 5393 pointAngle = (45 + sheet.sheetAngle / 2) * Math.PI / 180; 5394 pointsFront[0][2] = new THREE.Vector3(-Math.cos(pointAngle) * curveHandlePoint / 2, 0, Math.sin(pointAngle) * curveHandlePoint - zShift); 5395 pointsBack[0][2] = new THREE.Vector3(pointsFront[0][2].x + Math.cos(pointAngleB) * sheetDepth, 0, pointsFront[0][2].z + zShift * 2); 5396 if (Math.abs(pointsBack[0][2].x - 0) < 0.0005) pointsBack[0][2].x = 0; 5397 pointsFront[0][3] = new THREE.Vector3(0, 0, -zShift); 5398 pointsBack[0][3] = new THREE.Vector3(pointsFront[0][3].x - Math.cos(pointAngleB) * sheetDepth, 0, pointsFront[0][3].z + zShift * 2); //pointsFront[0][3]; 5399 if (Math.abs(pointsBack[0][3].x - 0) < 0.0005) pointsBack[0][3].x = 0; 5400 //endregion 5401 5402 for (var curveCount = 0; curveCount < foldCount; curveCount++) { 5403 var length = Math.max(sheet.segments - 1, 1); 5404 curvesFront[curveCount] = new THREE.CubicBezierCurve3(pointsFront[curveCount][0], pointsFront[curveCount][1], pointsFront[curveCount][2], pointsFront[curveCount][3]); 5405 verticesFront[curveCount] = curvesFront[curveCount].getPoints(length); 5406 if (length > 2) { 5407 verticesFront[curveCount].push(new THREE.Vector3().copy(verticesFront[curveCount][length])); 5408 } 5409 var current = void 0, 5410 last = verticesFront[curveCount][0]; 5411 for (var vcount = 1; vcount < verticesFront[curveCount].length;
5411 vcount++) { 5412 current = verticesFront[curveCount][vcount]; 5413 sum += current.distanceTo(last); 5414 distances.push(sum); 5415 last = current; 5416 } 5417 curvesBack[curveCount] = new THREE.CubicBezierCurve3(pointsBack[curveCount][0], pointsBack[curveCount][1], pointsBack[curveCount][2], pointsBack[curveCount][3]); 5418 verticesBack[curveCount] = curvesBack[curveCount].getPoints(length); 5419 if (length > 2) { 5420 verticesBack[curveCount].push(new THREE.Vector3().copy(verticesBack[curveCount][length])); 5421 } 5422 } 5423 /*var test = true; 5424 if (test === true) { 5425 if (sheet.handlesf === void 0) { 5426 let material = new THREE.LineBasicMaterial({color: 0x00ff00}); 5427 let geometry = new THREE.Geometry(); 5428 geometry.vertices.push( 5429 pointsFront[0][0], pointsFront[0][1], pointsFront[0][2], pointsFront[0][3] 5430 ); 5431 sheet.handlesf = new THREE.Line(geometry, material); 5432 sheet.element.add(sheet.handlesf); 5433 } 5434 else { 5435 let hvs = sheet.handlesf.geometry.vertices; 5436 for (let hcount = 0; hcount < hvs.length; hcount++) { 5437 hvs[hcount] = pointsFront[0][hcount]; 5438 } 5439 sheet.handlesf.geometry.verticesNeedUpdate = true; 5440 } 5441 if (sheet.handlesb === void 0) { 5442 let material = new THREE.LineBasicMaterial({color: 0x0000ff}); 5443 let geometry = new THREE.Geometry(); 5444 geometry.vertices.push( 5445 pointsBack[0][0], pointsBack[0][1], pointsBack[0][2], pointsBack[0][3] 5446 ); 5447 sheet.handlesb = new THREE.Line(geometry, material); 5448 sheet.element.add(sheet.handlesb); 5449 } 5450 else { 5451 let hvs = sheet.handlesb.geometry.vertices; 5452 for (let hcount = 0; hcount < hvs.length; hcount++) { 5453 hvs[hcount] = pointsBack[0][hcount]; 5454 } 5455 sheet.handlesb.geometry.verticesNeedUpdate = true; 5456 } 5457 } 5458 */ 5459 5460 var bodyG = sheet.element.geometry; 5461 if (bodyG.attributes !== void 0) { 5462 //5 segments have 56 vertices 5463 /* 5464 * 5 segments have 56 vertices 5465 * 8 are side vertices 5466 * remaining 48 in 4 faces 5467 * each 12 vertices 5468 *rowvertices = segments + 1 5469 * 1,7 - 2,8 - 3,9 - 4,10 - 5,11 - 6,12 x + rowvertices*0 + count, x + rowvertices*1 + count 5470 * 13,19 - 14,20 - 15,21 - 16,22 - 17,23 - 18,24 x + rowvertices*2 + 1, x + rowvertices*3 + 1 5471 * 25,31 - 26,32 - 27,33 - 28,34 - 29,35 - 30,36 5472 * 37,43 - 38,44 - 39,45 - 40,46 - 41,47 - 42,48 5473 * 5474 * */ 5475 5476 var positions = bodyG.attributes.position; 5477 var uvs = bodyG.attributes.uv; 5478 var rowVertices = segments + 1; 5479 var offset = 8; 5480 5481 //region basic side vertices 5482 //Update the geometry based on angles 5483 positions.setZ(0, verticesFront[0][segments].z); 5484 positions.setZ(2, verticesFront[0][segments].z); 5485 positions.setX(0, verticesFront[0][segments].x); 5486 positions.setX(2, verticesFront[0][segments].x); 5487 // verts[0].z = verts[2].z = verticesFront[0][segments].z; 5488 // verts[0].x = verts[2].x = verticesFront[0][segments].x; 5489 5490 positions.setZ(1, verticesBack[0][segments].z); 5491 positions.setZ(3, verticesBack[0][segments].z); 5492 positions.setX(1, verticesBack[0][segments].x); 5493 positions.setX(3, verticesBack[0][segments].x); 5494 // verts[1].z = verts[3].z = verticesBack[0][segments].z; 5495 // verts[1].x = verts[3].x = verticesBack[0][segments].x; 5496 5497 positions.setZ(5, verticesFront[0][0].z); 5498 positions.setZ(7, verticesFront[0][0].z); 5499 positions.setX(5, verticesFront[0][0].x); 5500 positions.setX(7, verticesFront[0][0].x); 5501 // verts[5].z = verts[7].z = verticesFront[0][0].z; 5502 // verts[5].x = verts[7].x = verticesFront[0][0].x; 5503 5504 positions.setZ(4, verticesBack[0][0].z); 5505 positions.setZ(6, verticesBack[0][0].z); 5506 positions.setX(4, verticesBack[0][0].x); 5507 positions.setX(6, verticesBack[0][0].x); 5508 // verts[4].z = verts[6].z = verticesBack[0][0].z; 5509 // verts[4].x = verts[6].x = verticesBack[0][0].x; 5510 5511 //endregion 5512 5513 for (var fold = 0; fold < foldCount; fold++) { 5514 for (var count = 0; count < rowVertices; count++) { 5515 positions.setZ(offset + rowVertices * 0 + count, verticesFront[0][count].z); 5516 positions.setX(offset + rowVertices * 0 + count, verticesFront[0][count].x); 5517 positions.setZ(offset + rowVertices * 1 + count, verticesBack[0][count].z); 5518 positions.setX(offset + rowVertices * 1 + count, verticesBack[0][count].x); 5519 positions.setZ(offset + rowVertices * 2 + count, verticesFront[0][count].z); 5520 positions.setX(offset + rowVertices * 2 + count, verticesFront[0][count].x); 5521 positions.setZ(offset + rowVertices * 3 + count, verticesBack[0][count].z); 5522 positions.setX(offset + rowVertices * 3 + count, verticesBack[0][count].x); 5523 positions.setZ(offset + rowVertices * 4 + count, verticesFront[0][count].z); 5524 positions.setX(offset + rowVertices * 4 + count, verticesFront[0][count].x); 5525 positions.setZ(offset + rowVertices * 5 + count, verticesFront[0][count].z); 5526 positions.setX(offset + rowVertices * 5 + count, verticesFront[0][count].x); 5527 uvs.setX(offset + rowVertices * 4 + count, distances[count] / sum); 5528 uvs.setX(offset + rowVertices * 5 + count, distances[count] / sum); 5529 positions.setZ(offset + rowVertices * 6 + count, verticesBack[0][segments - count].z); 5530 positions.setX(offset + rowVertices * 6 + count, verticesBack[0][segments - count].x); 5531 positions.setZ(offset + rowVertices * 7 + count, verticesBack[0][segments - count].z); 5532 positions.setX(offset + rowVertices * 7 + count, verticesBack[0][segments - count].x); 5533 uvs.setX(offset + rowVertices * 6 + count, 1 - distances[segments - count] / sum); 5534 uvs.setX(offset + rowVertices * 7 + count, 1 - distances[segments - count] / sum); 5535 5536 // verts[offset].z = verts[offset + rowVertices * 3].z = verticesBack[0][count].z; 5537 // verts[offset].x = verts[offset + rowVertices * 3].x = verticesBack[0][count].x; 5538 5539 // verts[offset + rowVertices].z = verts[offset + rowVertices * 2].z = verticesFront[0][count].z; 5540 // verts[offset + rowVertices].x = verts[offset + rowVertices * 2].x = verticesFront[0][count].x; 5541 5542 // offset++; 5543 } 5544 } 5545 5546 bodyG.computeBoundingBox(); 5547 sheet.element.scale.x = curveWidth * foldCount / sum; 5548 // sheet.element.scale.z = sheet.element.scale.x;//1 + (Math.cos(pointAngleB) * sheet.element.scale.x / sheet.element.scale.x); 5549 5550 bodyG.computeBoundingSphere(); 5551 positions.needsUpdate = true; 5552 uvs.needsUpdate = true; 5553 bodyG.computeVertexNormals(); 5554 } else { 5555 var verts = bodyG.vertices; 5556 var _rowVertices = segments - 1; 5557 var _offset = 8; 5558 5559 //Update the geometry based on angles 5560 verts[0].z = verts[2].z = verticesFront[0][segments].z; 5561 verts[0].x = verts[2].x = verticesFront[0][segments].x; 5562 verts[1].z = verts[3].z = verticesBack[0][segments].z; 5563 verts[1].x = verts[3].x = verticesBack[0][segments].x; 5564 verts[5].z = verts[7].z = verticesFront[0][0].z; 5565 verts[5].x = verts[7].x = verticesFront[0][0].x; 5566 verts[4].z = verts[6].z = verticesBack[0][0].z; 5567 verts[4].x = verts[6].x = verticesBack[0][0].x; 5568 for (var _fold = 0; _fold < foldCount; _fold++) { 5569 for (var _count = 1; _count < segments; _count++) { 5570 verts[_offset].z = verts[_offset + _rowVertices * 3].z = verticesBack[0][_count].z; 5571 verts[_offset].x = verts[_offset + _rowVertices * 3].x = verticesBack[0][_count].x; 5572 verts[_offset + _rowVertices].z = verts[_offset + _rowVertices * 2].z = verticesFront[0][_count].z; 5573 verts[_offset + _rowVertices].x = verts[_offset + _rowVertices * 2].x = verticesFront[0][_count].x; 5574 _offset++; 5575 } 5576 } 5577 var _uvs = bodyG.faceVertexUvs[0]; 5578 var faces = bodyG.faces; 5579 var uvIndexFront = 0; 5580 for (var _count2 = 0; _count2 < _uvs.length; _count2++) { 5581 if (faces[_count2].materialIndex === MOCKUP.MATERIAL_FACE.BACK) { 5582 var dist = distances[uvIndexFront] / sum; 5583 if (_count2 % 2 === 0) { 5584 _uvs[_count2][0].x = _uvs[_count2][1].x = _uvs[_count2 + 1][0].x = dist; 5585 uvIndexFront++; 5586 } else { 5587 _uvs[_count2 - 1][2].x = _uvs[_count2][1].x = _uvs[_count2][2].x = dist; 5588 } 5589 } else if (faces[_count2].materialIndex === MOCKUP.MATERIAL_FACE.FRONT) { 5590 var _dist = 1 - distances[uvIndexFront] / sum; 5591 //console.log(dist); 5592 if (_count2 % 2 === 0) { 5593 _uvs[_count2][0].x = _uvs[_count2][1].x = _uvs[_count2 + 1][0].x = _dist; 5594 uvIndexFront--; 5595 } else { 5596 _uvs[_count2 - 1][2].x = _uvs[_count2][1].x = _uvs[_count2][2].x = _dist; 5597 } 5598 } 5599 } 5600 bodyG.computeBoundingBox(); 5601 sheet.element.scale.x = curveWidth * foldCount / sum; 5602 // sheet.element.scale.z = sheet.element.scale.x;//1 + (Math.cos(pointAngleB) * sheet.element.scale.x / sheet.element.scale.x); 5603 5604 bodyG.computeBoundingSphere(); 5605 bodyG.verticesNeedUpdate = true; 5606 bodyG.computeFaceNormals(); 5607 bodyG.computeVertexNormals(); 5608 bodyG.uvsNeedUpdate = true; 5609 bodyG.normalsNeedUpdate = true; 5610 } 5611 curvesFront.forEach(function (curveF) { 5612 curveF = null; 5613 }); 5614 curvesBack.forEach(function (curveB) { 5615 curveB = null; 5616 }); 5617 verticesBack.forEach(function (vertexB) { 5618 vertexB = null; 5619 }); 5620 verticesFront.forEach(function (vertexF) { 5621 vertexF = null; 5622 }); 5623 } 5624 }, { 5625 key: "flip", 5626 value: function flip(oldAngle, newAngle) { 5627 var sheet = this; 5628 var isBooklet = sheet.viewer.isBooklet; 5629 5630 //https://github.com/deepak-ghimire/dearviewer/issues/494 5631 if (sheet.isCover == true) { 5632 if (oldAngle === 0) oldAngle = sheet.viewer.flexibility * 2.5; 5633 if (oldAngle === 180) oldAngle = oldAngle - sheet.viewer.flexibility * 2.5; 5634 } 5635 var diff = newAngle - oldAngle; //170 -5 == 165 : 5-170 = -165 5636 5637 var isRight = oldAngle > 90; 5638 var isRTL = sheet.viewer.isRTL; 5639 var pageNumber = isRight ? sheet.backPage.pageNumber : sheet.frontPage.pageNumber; 5640 var viewport = this.viewer.getViewPort(pageNumber); 5641 if (viewport) viewport = flipbook_3d_utils.contain(viewport.width, viewport.height, sheet.viewer.availablePageWidth(), sheet.viewer.availablePageHeight()); 5642 var coverAdjustmentWidth = -(sheet.viewer.has3DCover && sheet.viewer.isClosedPage() ? sheet.viewer.coverExtraWidth : 0), 5643 coverAdjustmentHeight = -(sheet.viewer.has3DCover && sheet.viewer.isClosedPage() ? sheet.viewer.coverExtraHeight : 0); 5644 sheet.init = { 5645 angle: oldAngle, 5646 angle2: !isRight ? 0 : 180, 5647 height: isRight ? sheet.viewer.rightSheetHeight : sheet.viewer.leftSheetHeight, 5648 width: isRight ? sheet.viewer.rightSheetWidth : sheet.viewer.leftSheetWidth, 5649 index: isRight && !isRTL || !isRight && isRTL ? 1 : 0, 5650 _index: 0 5651 }; 5652 sheet.first = { 5653 angle: oldAngle + diff / 4, 5654 angle2: !isRight ? 90 : 90, 5655 index: isRight && !isRTL || !isRight && isRTL ? 1 : 0.25 5656 }; 5657 sheet.mid = { 5658 angle: oldAngle + diff * 2 / 4, 5659 angle2: !isRight ? 135 : 45, 5660 index: isRight && !isRTL || !isRight && isRTL ? 0.5 : 0.5 5661 }; 5662 sheet.mid2 = { 5663 angle: oldAngle + diff * 3 / 4, 5664 angle2: !isRight ? 180 : 0, 5665 index: isRight && !isRTL || !isRight && isRTL ? 0.25 : 1 5666 }; 5667 sheet.end = { 5668 angle: newAngle, 5669 angle2: !isRight ? 180 : 0, 5670 index: isRight && !isRTL || !isRight && isRTL ? 0 : 1, 5671 height: coverAdjustmentHeight + (viewport ? viewport.height : sheet.height), 5672 width: coverAdjustmentWidth + (viewport ? viewport.width : sheet.width) 5673 }; 5674 5675 //console.log(sheet.init, sheet.first, sheet.mid, sheet.end); 5676 sheet.isFlipping = true; 5677 var update = function update(tween) { 5678 sheet.sheetAngle = tween.angle; 5679 sheet.curveAngle = sheet.isHard ? tween.angle : tween.angle2; 5680 if (sheet.isHard === true) { 5681 sheet.flexibility = 0; 5682 if (sheet.isCover) { 5683 sheet.viewer.flipCover(sheet); 5684 } 5685 } else { 5686 sheet.flexibility = tween.angle < 90 ? sheet.leftFlexibility : sheet.rightFlexibility; 5687 } 5688 sheet.element.position.z = (tween.angle < 90 ? sheet.leftPos : sheet.rightPos) + sheet.depth; 5689 if (isBooklet) { 5690 sheet.element.material[5].opacity = sheet.element.material[4].opacity = tween.index; 5691 sheet.element.castShadow = isRight && !isRTL || !isRight && isRTL ? tween.index > 0.5 : tween.index > 0.5; 5692 } 5693 sheet.height = tween.height; 5694 sheet.width = tween.width; 5695 sheet.updateAngle(true); 5696 }; 5697 if (isBooklet && (!isRight && !isRTL || isRight && isRTL)) { 5698 sheet.element.material[5].opacity = sheet.element.material[4].opacity = 0; 5699 sheet.element.castShadow = false;
5700 } 5701 sheet.currentTween = new TWEEN.Tween(sheet.init).to({ 5702 angle: [sheet.first.angle, sheet.mid.angle, sheet.mid2.angle, sheet.end.angle], 5703 angle2: [sheet.first.angle2, sheet.mid.angle2, sheet.mid2.angle2, sheet.end.angle2], 5704 index: [sheet.first.index, sheet.mid.index, sheet.mid2.index, sheet.end.index], 5705 _index: 1, 5706 height: sheet.end.height, 5707 width: sheet.end.width 5708 }, sheet.viewer.app.options.duration).onUpdate(function (event) { 5709 update(this, event); 5710 }).easing(TWEEN.Easing.Sinusoidal.Out).onStop(function () { 5711 sheet.currentTween = null; 5712 sheet.isFlipping = false; 5713 if (sheet.isCover) { 5714 sheet.viewer.leftCover.isFlipping = false; 5715 sheet.viewer.rightCover.isFlipping = false; 5716 } 5717 sheet.element.material[5].opacity = sheet.element.material[4].opacity = 1; 5718 }).onComplete(function () { 5719 sheet.updateAngle(); 5720 sheet.element.material[5].opacity = sheet.element.material[4].opacity = 1; 5721 sheet.element.castShadow = true; 5722 sheet.isFlipping = false; 5723 if (sheet.isCover) { 5724 sheet.viewer.leftCover.isFlipping = false; 5725 sheet.viewer.rightCover.isFlipping = false; 5726 } 5727 sheet.side = sheet.targetSide; 5728 sheet.viewer.onFlip(); 5729 sheet.viewer.afterFlip(); 5730 sheet.currentTween = null; 5731 if (sheet.viewer && sheet.viewer.requestRefresh) sheet.viewer.requestRefresh(); 5732 }).start(); 5733 //calling instantly will fix the render and postioning update issue 5734 //https://github.com/deepak-ghimire/dearviewer/issues/494 5735 sheet.currentTween.update(window.performance.now()); 5736 } 5737 }]); 5738 return BookSheet3D; 5739}(BookSheet); 5740var FlipBook3D = /*#__PURE__*/function (_BaseFlipBookViewer) { 5741 flipbook_3d_inherits(FlipBook3D, _BaseFlipBookViewer); 5742 var _super2 = flipbook_3d_createSuper(FlipBook3D); 5743 function FlipBook3D(options, appContext) { 5744 var _options$groundDistan, _options$flexibility, _options$texturePower, _this2$app$options$co; 5745 var _this2; 5746 flipbook_3d_classCallCheck(this, FlipBook3D); 5747 options.viewerClass = "df-flipbook-3d"; 5748 _this2 = _super2.call(this, options, appContext); 5749 _this2.pageOffset = 5; //space between pages in spiral book 5750 _this2.spiralCount = 20; 5751 _this2.groundDistance = (_options$groundDistan = options.groundDistance) !== null && _options$groundDistan !== void 0 ? _options$groundDistan : 2; //relative sizing distance of ground from book when cover is closed. 5752 5753 _this2.hasSpiral = options.hasSpiral === "true" || options.hasSpiral === true; 5754 _this2.flexibility = flipbook_3d_utils.limitAt((_options$flexibility = options.flexibility) !== null && _options$flexibility !== void 0 ? _options$flexibility : 0.9, 0, 10); 5755 if (_this2.hasSpiral) _this2.flexibility = 0; 5756 _this2.drag3D = false; //todo complete this and take from options 5757 _this2.texturePowerOfTwo = (_options$texturePower = options.texturePowerOfTwo) !== null && _options$texturePower !== void 0 ? _options$texturePower : true; 5758 _this2.color3DSheets = (_this2$app$options$co = _this2.app.options.color3DSheets) !== null && _this2$app$options$co !== void 0 ? _this2$app$options$co : 'white'; 5759 _this2.midPosition = 0; 5760 _this2.initMOCKUP(function () { 5761 appContext._viewerPrepared(); 5762 }); 5763 return _this2; 5764 } 5765 flipbook_3d_createClass(FlipBook3D, [{ 5766 key: "initMOCKUP", 5767 value: function initMOCKUP(callback) { 5768 var app = this.app; 5769 if (typeof THREE === "undefined") { 5770 app.updateInfo(app.options.text.loading + " WEBGL 3D ..."); 5771 if (typeof window.define === 'function' && window.define.amd && window.requirejs) { 5772 window.requirejs.config({ 5773 "paths": { 5774 "three": app.options.threejsSrc.replace(".js", "") 5775 }, 5776 shim: { 5777 'three': { 5778 exports: 'THREE' 5779 } 5780 } 5781 }); 5782 window.require(['three'], function (THREE) { 5783 window.THREE = THREE; 5784 MOCKUP.init(); 5785 if (typeof callback === "function") callback(); 5786 return THREE; 5787 }); 5788 } else if (typeof window.define === 'function' && window.define.amd) { 5789 window.require(["three", app.options.threejsSrc.replace(".js", "")], function (ready) { 5790 ready(function () {
5791 MOCKUP.init(); 5792 if (typeof callback === "function") callback(); 5793 }); 5794 }); 5795 } else { 5796 flipbook_3d_utils.getScript(app.options.threejsSrc + "?ver=" + flipbook_3d_DV.version, function () { 5797 MOCKUP.init(); 5798 if (typeof callback === "function") callback(); 5799 }, function () { 5800 app.updateInfo("Unable to load THREE.js..."); 5801 }); 5802 } 5803 } else { 5804 MOCKUP.init(); 5805 if (typeof callback === "function") callback(); 5806 } 5807 } 5808 }, { 5809 key: "init", 5810 value: function init() { 5811 var app = this.app; 5812 flipbook_3d_get(flipbook_3d_getPrototypeOf(FlipBook3D.prototype), "init", this).call(this); 5813 var _pageRatio = app.provider.defaultPage.pageRatio; 5814 this.pageScaleX = 1; 5815 this.initDepth(); 5816 this.initStage(); 5817 this.initPages(); 5818 this.initEvents(); 5819 this.render(); //until render is called none of the css pages are added. 5820 } 5821 }, { 5822 key: "updatePageMode", 5823 value: function updatePageMode() { 5824 flipbook_3d_get(flipbook_3d_getPrototypeOf(FlipBook3D.prototype), "updatePageMode", this).call(this); 5825 var app = this.app; 5826 this.has3DCover = app.options.cover3DType !== defaults_DEARVIEWER.FLIPBOOK_COVER_TYPE.NONE && app.pageCount > 7 && !this.isBooklet; 5827 if (this.has3DCover && app.options.flipbookHardPages === "none") { 5828 app.options.flipbookHardPages = "cover"; 5829 } 5830 } 5831 }, { 5832 key: "initDepth", 5833 value: function initDepth() { 5834 var _this$app$options$she, _this$app$options$she2; 5835 this.sheetDepth = this.pageScaleX * ((_this$app$options$she = this.app.options.sheetDepth) !== null && _this$app$options$she !== void 0 ? _this$app$options$she : 0.5); 5836 this.sheetSegments = (_this$app$options$she2 = this.app.options.sheetSegments) !== null && _this$app$options$she2 !== void 0 ? _this$app$options$she2 : 20; 5837 this.coverDepth = 2 * this.sheetDepth; 5838 this.sheetsDepth = Math.min(10, this.app.pageCount / 4) * this.sheetDepth; 5839 } 5840 }, { 5841 key: "initStage", 5842 value: function initStage() { 5843 var viewer = this; 5844 var stage = viewer.stage = new MOCKUP.Stage({ 5845 pixelRatio: window.devicePixelRatio 5846 }); 5847 var canvas = stage.canvas = jQuery(stage.renderer.domElement).addClass("df-3dcanvas"); 5848 canvas.appendTo(this.element); 5849 stage.camera.position.set(0, 0, 600); 5850 stage.camera.lookAt(new THREE.Vector3(0, 0, 0)); 5851 viewer.camera = stage.camera; 5852 //shadows are zigzag due to shadow camera position 5853 stage.spotLight.position.set(-220, 220, 550); 5854 stage.spotLight.castShadow = flipbook_3d_utils.isMobile ? false : viewer.app.options.has3DShadow; 5855 if (stage.spotLight.shadow) { 5856 stage.spotLight.shadow.bias = -0.0035; 5857 } 5858 5859 // stage.spotLight.intensity = 0.22; 5860 stage.ambientLight.color = new THREE.Color("#fff"); 5861 stage.ambientLight.intensity = 0.82; 5862 var material = new THREE.ShadowMaterial(); 5863 material.opacity = viewer.app.options.shadowOpacity; 5864 stage.ground.oldMaterial = stage.ground.material; 5865 stage.ground.material = material; 5866 stage.ground.position.z = this.has3DCover ? -6 : -4; 5867 stage.selectiveRendering = true; 5868 var cssRenderer = stage.cssRenderer = new THREE.CSS3DRenderer(); 5869 jQuery(cssRenderer.domElement).css({ 5870 position: "absolute", 5871 top: 0, 5872 pointerEvents: "none" 5873 }).addClass("df-3dcanvas df-csscanvas"); 5874 viewer.element[0].appendChild(cssRenderer.domElement); 5875 stage.cssScene = new THREE.Scene(); 5876 viewer.wrapper.remove(); 5877 viewer.wrapper = new THREE.Group(); 5878 viewer.stage.add(viewer.wrapper); 5879 viewer.wrapper.add(stage.ground); 5880 viewer.bookWrapper = new THREE.Group(); 5881 viewer.bookWrapper.name = "bookwrapper"; 5882 // stage.bookWrapper.add(stage.camera); 5883 viewer.wrapper.add(viewer.bookWrapper); 5884 viewer.bookHelper = stage.bookHelper = new THREE.BoxHelper(viewer.bookWrapper, 0xffff00); 5885 stage.add(viewer.bookHelper); 5886 viewer.bookHelper.visible = false;
5887 viewer.cameraWrapper = new THREE.Group(); 5888 viewer.cameraWrapper.add(stage.camera); 5889 stage.add(viewer.cameraWrapper); 5890 // viewer.wrapper.add(stage.spotLight); 5891 5892 viewer.app.renderRequestStatus = flipbook_3d_DV.REQUEST_STATUS.ON; 5893 } 5894 }, { 5895 key: "initPages", 5896 value: function initPages() { 5897 var options = { 5898 parent3D: this.bookWrapper, 5899 viewer: this, 5900 segments: this.sheetSegments, 5901 depth: this.sheetDepth, 5902 flexibility: this.flexibility 5903 }; 5904 for (var count = 0; count < this.stackCount; count++) { 5905 var sheet = new BookSheet3D(options); 5906 sheet.index = count; //just reference for debugging 5907 sheet.viewer = this; 5908 this.sheets.push(sheet); 5909 sheet.setMatColor(this.color3DSheets); 5910 this.pages.push(sheet.frontPage); 5911 this.pages.push(sheet.backPage); 5912 this.stage.cssScene.add(sheet.frontPage.cssPage); 5913 this.stage.cssScene.add(sheet.backPage.cssPage); 5914 } 5915 options.depth = this.sheetsDepth; 5916 options.segments = 1; 5917 options.flexibility = 0; 5918 this.leftSheets = new BookSheet3D(options); //to display sheet stack on left side of Realistic book 5919 this.rightSheets = new BookSheet3D(options); //to display sheet stack on right side of Realistic book 5920 this.leftSheets.setMatColor(this.color3DSheets); 5921 this.rightSheets.setMatColor(this.color3DSheets); 5922 options.depth = this.coverDepth; 5923 this.leftCover = new BookSheet3D(options); 5924 this.rightCover = new BookSheet3D(options); 5925 5926 // this.leftCover.element.loadNormalMap(this.app.options.imagesLocation + "/book-cover-normal.jpg", MOCKUP.MATERIAL_FACE.FRONT); 5927 // this.rightCover.element.loadNormalMap(this.app.options.imagesLocation + "/book-cover-normal.jpg", MOCKUP.MATERIAL_FACE.BACK); 5928 this.leftCover.isHard = true; 5929 this.rightCover.isHard = true; 5930 this.set3DCoverNormal(); 5931 this.setcolor3DCover(this.app.options.color3DCover); 5932 this.stage.cssScene.add(this.leftCover.frontPage.cssPage); 5933 this.stage.cssScene.add(this.rightCover.backPage.cssPage); 5934 this.zoomViewer.leftPage.element.css({ 5935 backgroundColor: this.color3DSheets 5936 }); 5937 this.zoomViewer.rightPage.element.css({ 5938 backgroundColor: this.color3DSheets 5939 }); 5940 if (this.orientation === 'vertical') { 5941 this.bookWrapper.children.forEach(function (childPaper) { 5942 childPaper.rotateZ(THREE.MathUtils.degToRad(-90)); 5943 childPaper.textureCenter = new THREE.Vector2(0.5, 0.5); 5944 childPaper.textureRotation = 90; 5945 }); 5946 } 5947 this.initSpiral(); 5948 } 5949 }, { 5950 key: "initSpiral", 5951 value: function initSpiral() { 5952 var _this$app$options$spi; 5953 if (this.app.pageCount < 3) this.hasSpiral = false; 5954 if (this.hasSpiral !== true) return; 5955 //TorusGeometry(radius : Float, tube : Float, radialSegments : Integer, tubularSegments : Integer, arc : Float) 5956 var spirals = this.spirals = new THREE.Group(); 5957 var leftHoles = this.leftHoles = new THREE.Group(); 5958 var rightHoles = this.rightHoles = new THREE.Group(); 5959 var spiralGroup = this.spiralGroup = new THREE.Group(); 5960 var geometry = new THREE.TorusGeometry(30, 2, 6, 20); 5961 var material = new THREE.MeshPhongMaterial({ 5962 color: (_this$app$options$spi = this.app.options.spiralColor) !== null && _this$app$options$spi !== void 0 ? _this$app$options$spi : 0x888888 5963 }); 5964 var torus = new THREE.Mesh(geometry, material); 5965 torus.castShadow = true; 5966 torus.rotateX(-THREE.MathUtils.degToRad(-90)); 5967 var box = new THREE.Mesh(new THREE.BoxGeometry(8, 15, 5, 1, 1, 1), new THREE.MeshBasicMaterial({ 5968 color: 0x444444 5969 })); 5970 var box2 = new THREE.Mesh(new THREE.BoxGeometry(8, 15, 5, 1, 1, 1), new THREE.MeshBasicMaterial({ 5971 color: 0x444444 5972 })); 5973 for (var count = 0; count < this.spiralCount; count++) { 5974 var pos = -935 / 2 + count * 935 / this.spiralCount + 935 / this.spiralCount / 2; 5975 var clone = torus.clone(); 5976 clone.position.y = pos - 4; 5977 this.spirals.add(clone); 5978 clone = torus.clone(); 5979 clone.position.y = pos + 4; 5980 this.spirals.add(clone); 5981 clone = box.clone(); 5982 clone.position.y = pos; 5983 clone.position.x = -28; 5984 this.leftHoles.add(clone); 5985 clone = box2.clone(); 5986 clone.position.y = pos; 5987 clone.position.x = 28; 5988 this.rightHoles.add(clone); 5989 } 5990 this.spiralGroup.add(this.spirals); 5991 this.spiralGroup.add(this.leftHoles); 5992 this.spiralGroup.add(this.rightHoles); 5993 this.bookWrapper.add(this.spiralGroup); 5994 if (this.orientation === 'vertical') { 5995 this.spiralGroup.rotateZ(THREE.MathUtils.degToRad(-90)); 5996 } 5997 this.spiralGroup.scale.set(0.1, 0.1, 0.1); //big spiral makes flipbook fitting wrong 5998 } 5999 }, { 6000 key: "set3DCoverNormal", 6001 value: function set3DCoverNormal() { 6002 var cover3DType = this.app.options.cover3DType; 6003 if (cover3DType === defaults_DEARVIEWER.FLIPBOOK_COVER_TYPE.PLAIN) return; 6004 var hasRidge = cover3DType == defaults_DEARVIEWER.FLIPBOOK_COVER_TYPE.RIDGE, 6005 grd;
6006 if (this.hasSpiral && hasRidge == true) hasRidge = false; 6007 this.leftCover.fallbackMatColor = new THREE.Color("#f7f7f7"); 6008 this.rightCover.fallbackMatColor = new THREE.Color("#f7f7f7"); 6009 this.leftCover.setMatColor(this.color3DSheets, 5); 6010 this.rightCover.setMatColor(this.color3DSheets, 4); 6011 var resolution = 128; 6012 var centerColor = "rgb(127,127,255)"; 6013 6014 //region LeftCover 6015 var canvas = document.createElement("canvas"); 6016 canvas.height = resolution; 6017 canvas.width = resolution; 6018 var ctx = canvas.getContext("2d"); 6019 ctx.fillStyle = centerColor; 6020 ctx.fillRect(0, 0, resolution, resolution); 6021 var width = resolution * 1.5 / 100; 6022 6023 //left shade 6024 grd = ctx.createLinearGradient(0, 0, width, 0); 6025 grd.addColorStop(0, centerColor); 6026 grd.addColorStop(1, "rgb(127,255,255)"); 6027 ctx.fillStyle = grd; 6028 ctx.beginPath(); 6029 ctx.moveTo(0, 0); 6030 ctx.lineTo(width, width); 6031 ctx.lineTo(width, resolution - width); 6032 ctx.lineTo(0, resolution - width); 6033 ctx.closePath(); 6034 ctx.fill(); 6035 if (hasRidge) { 6036 grd = ctx.createLinearGradient(width, 0, width * 4, 0); 6037 grd.addColorStop(0, "rgb(127,127,255)"); 6038 grd.addColorStop(0.25, "rgb(255,127,255)"); 6039 grd.addColorStop(0.5, "rgb(0,127,255)"); 6040 grd.addColorStop(0.75, "rgb(127,127,255)"); 6041 grd.addColorStop(1, "rgb(127,127,255)"); 6042 ctx.fillStyle = grd; 6043 ctx.fillRect(width, 0, width * 4, resolution); 6044 } 6045 6046 //top shade 6047 grd = ctx.createLinearGradient(0, width, 0, 0); 6048 grd.addColorStop(0, centerColor); 6049 grd.addColorStop(1, "rgb(127,255,255)"); 6050 ctx.fillStyle = grd; 6051 ctx.beginPath(); 6052 ctx.moveTo(hasRidge ? width * 3 : width, 0); 6053 ctx.lineTo(resolution, 0); 6054 ctx.lineTo(resolution - width, width); 6055 ctx.lineTo(hasRidge ? width * 4 : width, width); 6056 ctx.closePath(); 6057 ctx.fill(); 6058 6059 //right shade 6060 grd = ctx.createLinearGradient(resolution - width, 0, resolution, 0); 6061 grd.addColorStop(0, centerColor); 6062 grd.addColorStop(1, "rgb(255,127,255)"); 6063 ctx.fillStyle = grd; 6064 ctx.beginPath(); 6065 ctx.moveTo(resolution - width, width); 6066 ctx.lineTo(resolution, 0); 6067 ctx.lineTo(resolution, resolution); 6068 ctx.lineTo(resolution - width, resolution - width); 6069 ctx.closePath(); 6070 ctx.fill(); 6071 6072 //bottom shade 6073 grd = ctx.createLinearGradient(0, resolution - width, 0, resolution); 6074 grd.addColorStop(0, centerColor); 6075 grd.addColorStop(1, "rgb(127,0,255)"); 6076 ctx.fillStyle = grd; 6077 ctx.beginPath(); 6078 ctx.moveTo(hasRidge ? width * 4 : width, resolution - width); 6079 ctx.lineTo(resolution - width, resolution - width); 6080 ctx.lineTo(resolution, resolution); 6081 ctx.lineTo(hasRidge ? width * 3 : width, resolution); 6082 ctx.closePath(); 6083 ctx.fill(); 6084 this.leftCover.element.loadNormalMap(canvas, MOCKUP.MATERIAL_FACE.FRONT); 6085 //endregion 6086 6087 //region RightCover 6088 var canvasRight = document.createElement("canvas"); 6089 canvasRight.height = resolution; 6090 canvasRight.width = resolution; 6091 var ctxRight = canvasRight.getContext("2d"); 6092 ctxRight.fillStyle = centerColor; 6093 ctxRight.fillRect(0, 0, resolution, resolution); 6094 6095 //right shade 6096 grd = ctxRight.createLinearGradient(resolution - width, 0, resolution, 0); 6097 grd.addColorStop(0, centerColor); 6098 grd.addColorStop(1, "rgb(255,127,255)"); 6099 ctxRight.fillStyle = grd; 6100 ctxRight.beginPath(); 6101 ctxRight.moveTo(resolution - width, width); 6102 ctxRight.lineTo(resolution, 0); 6103 ctxRight.lineTo(resolution, resolution); 6104 ctxRight.lineTo(resolution - width, resolution - width); 6105 ctxRight.closePath(); 6106 ctxRight.fill(); 6107 if (hasRidge) { 6108 grd = ctxRight.createLinearGradient(resolution - width * 4, 0, resolution - width, 0); 6109 grd.addColorStop(0, "rgb(127,127,255)"); 6110 grd.addColorStop(0.25, "rgb(127,127,255)"); 6111 grd.addColorStop(0.5, "rgb(255,127,255)"); 6112 grd.addColorStop(0.75, "rgb(0,127,255)"); 6113 grd.addColorStop(1, "rgb(127,127,255)"); 6114 ctxRight.fillStyle = grd; 6115 ctxRight.fillRect(resolution - width * 4, 0, width * 3, resolution); 6116 } 6117 6118 //top shade 6119 grd = ctxRight.createLinearGradient(0, width, 0, 0); 6120 grd.addColorStop(0, centerColor); 6121 grd.addColorStop(1, "rgb(127,255,255)"); 6122 ctxRight.fillStyle = grd; 6123 ctxRight.beginPath(); 6124 ctxRight.moveTo(0, 0); 6125 ctxRight.lineTo(resolution - width * (hasRidge ? 3 : 0), 0); 6126 ctxRight.lineTo(resolution - width * (hasRidge ? 4 : 1), width); 6127 ctxRight.lineTo(width, width); 6128 ctxRight.closePath(); 6129 ctxRight.fill(); 6130 6131 //left shade 6132 grd = ctxRight.createLinearGradient(0, 0, width, 0); 6133 grd.addColorStop(0, centerColor); 6134 grd.addColorStop(1, "rgb(127,255,255)"); 6135 ctxRight.fillStyle = grd; 6136 ctxRight.beginPath(); 6137 ctxRight.moveTo(0, 0); 6138 ctxRight.lineTo(width, width); 6139 ctxRight.lineTo(width, resolution - width); 6140 ctxRight.lineTo(0, resolution - width); 6141 ctxRight.closePath(); 6142 ctxRight.fill(); 6143 6144 //bottom shade 6145 grd = ctxRight.createLinearGradient(0, resolution - width, 0, resolution); 6146 grd.addColorStop(0, centerColor); 6147 grd.addColorStop(1, "rgb(127,0,255)"); 6148 ctxRight.fillStyle = grd; 6149 ctxRight.beginPath(); 6150 ctxRight.moveTo(width, resolution - width); 6151 ctxRight.lineTo(resolution - width * (hasRidge ? 4 : 1), resolution - width); 6152 ctxRight.lineTo(resolution - width * (hasRidge ? 3 : 0), resolution); 6153 ctxRight.lineTo(0, resolution); 6154 ctxRight.closePath(); 6155 ctxRight.fill(); 6156 this.rightCover.element.loadNormalMap(canvasRight, MOCKUP.MATERIAL_FACE.BACK); 6157 //endregion 6158 } 6159 6160 /** 6161 * Creates the inside of 3D cover 6162 * @param val The color of Cover 6163 */ 6164 }, { 6165 key: "setcolor3DCover", 6166 value: function setcolor3DCover() { 6167 var val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ""; 6168 val = val.trim(); 6169 if (val.indexOf("#") == 0 && val.length === 4) { 6170 val = val.split("").map(function (item) { 6171 if (item == "#") { 6172 return item; 6173 } 6174 return item + item; 6175 }).join(""); 6176 } 6177 var brightness = flipbook_3d_utils.color.getBrightness(val); 6178 if (isNaN(brightness)) { 6179 console.log("Improper Color code value. Needs a hex value! Using default 0.25"); 6180 brightness = 0.25; 6181 }
6182 //more dark more opacity, more bright less opacity 6183 var baseOpacity = (255 - brightness) / 255; 6184 // console.log(baseOpacity); 6185 6186 // console.time("Texture Calculation"); 6187 var resolution = 1024; 6188 var canvas = document.createElement('canvas'); 6189 canvas.height = resolution; 6190 canvas.width = resolution; 6191 var ctx = canvas.getContext("2d"); 6192 ctx.fillStyle = val; 6193 ctx.fillRect(0, 0, resolution, resolution); 6194 ctx.strokeStyle = 'rgba(50,50,50,' + (baseOpacity / 2 + 0.4) + ')'; 6195 ctx.strokeRect(resolution * .1, resolution * .05, resolution * (this.hasSpiral ? 0.9 : 0.85), resolution * 0.9); 6196 6197 //crease 6198 ctx.beginPath(); 6199 ctx.strokeStyle = 'rgba(50,50,50,' + (baseOpacity / 2 + 0.3) + ')'; 6200 ctx.lineWidth = 2; 6201 ctx.moveTo(0, 0); 6202 ctx.lineTo(resolution * .1, resolution * .05); 6203 ctx.stroke(); 6204 ctx.beginPath(); 6205 ctx.strokeStyle = 'rgba(50,50,50,' + (baseOpacity / 2 + 0.4) + ')'; 6206 ctx.moveTo(0, resolution); 6207 ctx.lineTo(resolution * .1, resolution * .95); 6208 ctx.stroke(); 6209 ctx.beginPath(); 6210 ctx.strokeStyle = 'rgba(255,255,255,0.3)'; 6211 ctx.lineWidth = 4; 6212 ctx.moveTo(0, 0); 6213 ctx.lineTo(0, resolution); 6214 ctx.moveTo(0, 0); 6215 ctx.lineTo(resolution, 0); 6216 ctx.stroke(); 6217 ctx.beginPath(); 6218 ctx.strokeStyle = 'rgba(50,50,50,' + (baseOpacity / 2 + 0.3) + ')'; 6219 ctx.lineWidth = 4; 6220 ctx.moveTo(0, resolution); 6221 ctx.lineTo(resolution, resolution); 6222 ctx.stroke(); 6223 if (this.hasSpiral === false) { 6224 ctx.beginPath(); 6225 var grd = ctx.createLinearGradient(resolution * .95, 0, resolution, 0); 6226 grd.addColorStop(0, 'rgba(30,30,30,' + (baseOpacity + 0.3) + ')'); 6227 // grd.addColorStop(0.2, "rgba(40,40,40,0.5)"); 6228 grd.addColorStop(1, 'rgba(60,60,60,' + (baseOpacity + 0.3) + ')'); 6229 ctx.fillStyle = grd; 6230 ctx.fillRect(resolution * .95, 0, resolution * .05, resolution); 6231 ctx.beginPath(); 6232 ctx.lineWidth = 1; 6233 ctx.strokeStyle = 'rgba(40,40,40,' + (baseOpacity + 0.3) + ')'; 6234 for (var _count3 = 0; _count3 < 17; _count3++) { 6235 ctx.moveTo(resolution - _count3 * 3, 0); 6236 ctx.lineTo(resolution - _count3 * 3, resolution); 6237 } 6238 ctx.stroke(); 6239 } else { 6240 ctx.beginPath(); 6241 ctx.strokeStyle = 'rgba(50,50,50,0.2)'; 6242 ctx.lineWidth = 4; 6243 ctx.moveTo(resolution, 0); 6244 ctx.lineTo(resolution, resolution); 6245 ctx.stroke(); 6246 } 6247 this.leftCover.backImage(canvas); 6248 // console.timeLog("Texture Calculation"); 6249 6250 var canvas2 = document.createElement('canvas'); 6251 canvas2.height = resolution; 6252 canvas2.width = resolution; 6253 var ctx2 = canvas2.getContext("2d"); 6254 ctx2.fillStyle = val; 6255 ctx2.fillRect(0, 0, resolution, resolution); 6256 ctx2.strokeStyle = 'rgba(50,50,50,' + (baseOpacity / 2 + 0.5) + ')'; 6257 ctx2.strokeRect(resolution * (this.hasSpiral ? 0 : 0.05), resolution * .05, resolution * (this.hasSpiral ? 0.9 : 0.85), resolution * 0.9); 6258 6259 //crease 6260 ctx2.beginPath(); 6261 ctx2.strokeStyle = 'rgba(50,50,50,' + (baseOpacity / 2 + 0.3) + ')'; 6262 ctx2.lineWidth = 2; 6263 ctx2.moveTo(resolution, 0); 6264 ctx2.lineTo(resolution * .9, resolution * .05); 6265 ctx2.stroke(); 6266 ctx2.beginPath(); 6267 ctx2.strokeStyle = 'rgba(50,50,50,' + (baseOpacity / 2 + 0.5) + ')'; 6268 ctx2.moveTo(resolution, resolution); 6269 ctx2.lineTo(resolution * .9, resolution * .95); 6270 ctx2.stroke(); 6271 6272 //outline 6273 ctx2.beginPath(); 6274 ctx2.strokeStyle = 'rgba(255,255,255,0.3)'; 6275 ctx2.lineWidth = 4; 6276 ctx2.moveTo(0, 0); 6277 ctx2.lineTo(resolution, 0); 6278 ctx2.stroke(); 6279 ctx2.beginPath(); 6280 ctx2.strokeStyle = 'rgba(50,50,50,' + (baseOpacity / 2 + 0.3) + ')'; 6281 ctx2.lineWidth = 4; 6282 ctx2.moveTo(resolution, 0); 6283 ctx2.lineTo(resolution, resolution); 6284 ctx2.moveTo(0, resolution); 6285 ctx2.lineTo(resolution, resolution); 6286 ctx2.stroke(); 6287 if (this.hasSpiral === false) { 6288 ctx2.beginPath(); 6289 var grd2 = ctx2.createLinearGradient(0, 0, resolution * .05, 0); 6290 grd2.addColorStop(0, 'rgba(0,0,0,' + (baseOpacity + 0.3) + ')'); 6291 grd2.addColorStop(0.2, 'rgba(10,10,10,' + (baseOpacity + 0.3) + ')'); 6292 grd2.addColorStop(1, 'rgba(80,80,80,' + (baseOpacity + 0.3) + ')'); 6293 ctx2.fillStyle = grd2; 6294 ctx2.fillRect(0, 0, resolution * .05, resolution); 6295 ctx2.beginPath(); 6296 ctx2.lineWidth = 1; 6297 ctx2.strokeStyle = 'rgba(40,40,40,' + (baseOpacity + 0.3) + ')'; 6298 for (var _count4 = 0; _count4 < 17; _count4++) { 6299 ctx2.moveTo(_count4 * 3, 0); 6300 ctx2.lineTo(_count4 * 3, resolution); 6301 } 6302 ctx2.stroke(); 6303 } else { 6304 ctx2.beginPath(); 6305 ctx2.strokeStyle = 'rgba(255,255,255,0.2)'; 6306 ctx2.lineWidth = 4; 6307 ctx2.moveTo(0, 0); 6308 ctx2.lineTo(0, resolution); 6309 ctx2.stroke(); 6310 } 6311 this.rightCover.frontImage(canvas2); 6312 // console.timeEnd("Texture Calculation"); 6313 6314 var canvas3 = document.createElement('canvas'); 6315 resolution = 128; 6316 canvas3.height = resolution; 6317 canvas3.width = resolution; 6318 var ctx3 = canvas3.getContext("2d"); 6319 ctx3.fillStyle = "#ffffff"; 6320 ctx3.fillRect(0, 0, resolution, resolution); 6321 ctx3.strokeStyle = "#cccccc"; 6322 ctx3.lineWidth = 1; 6323 for (var count = 0; count < resolution / 4; count++) { 6324 ctx3.moveTo(count * 4, 0); 6325 ctx3.lineTo(count * 4, resolution); 6326 } 6327 ctx3.stroke();
6328 this.leftSheets.element.loadImage(canvas3, 1, null); 6329 this.rightSheets.element.loadImage(canvas3, 3, null); 6330 this.app.renderRequestStatus = defaults_DEARVIEWER.REQUEST_STATUS.ON; 6331 } 6332 }, { 6333 key: "initEvents", 6334 value: function initEvents() { 6335 this.stageDOM = this.element[0]; 6336 flipbook_3d_get(flipbook_3d_getPrototypeOf(FlipBook3D.prototype), "initEvents", this).call(this); 6337 } 6338 }, { 6339 key: "dispose", 6340 value: function dispose() { 6341 flipbook_3d_get(flipbook_3d_getPrototypeOf(FlipBook3D.prototype), "dispose", this).call(this); 6342 var viewer = this; 6343 if (viewer.stage) { 6344 viewer.stage.clearChild(); 6345 viewer.stage.cssRenderer.domElement.parentNode.removeChild(viewer.stage.cssRenderer.domElement); 6346 viewer.stage.cssRenderer = null; 6347 viewer.stage.orbitControl = flipbook_3d_utils.disposeObject(viewer.stage.orbitControl); 6348 viewer.stage.renderer = flipbook_3d_utils.disposeObject(viewer.stage.renderer); 6349 jQuery(viewer.stage.canvas).remove(); 6350 viewer.stage.canvas = null; 6351 viewer.stage = flipbook_3d_utils.disposeObject(viewer.stage); 6352 } 6353 if (viewer.centerTween && viewer.centerTween.stop) viewer.centerTween.stop(); 6354 } 6355 }, { 6356 key: "render", 6357 value: function render() { 6358 this.stage.render(); 6359 this.stage.cssRenderer.render(this.stage.cssScene, this.stage.camera); 6360 } 6361 }, { 6362 key: "resize", 6363 value: function resize() { 6364 flipbook_3d_get(flipbook_3d_getPrototypeOf(FlipBook3D.prototype), "resize", this).call(this); 6365 var viewer = this; 6366 var app = viewer.app, 6367 stage = viewer.stage; 6368 var dimensions = app.dimensions; 6369 var padding = dimensions.padding; 6370 var isSingle = viewer.isSingle; 6371 var zoomWidth = this.availablePageWidth(), 6372 zoomHeight = this.availablePageHeight(); 6373 stage.resizeCanvas(dimensions.stage.width, dimensions.stage.height); 6374 stage.cssRenderer.setSize(dimensions.stage.width, dimensions.stage.height); 6375 this.pageScaleX = Math.max(Math.max(zoomWidth, zoomHeight) / 400, 1); 6376 this.initDepth(); 6377 this.sheets.forEach(function (sheet) { 6378 sheet.depth = viewer.sheetDepth; 6379 }); 6380 app.refreshRequestStart(); 6381 var ref = this.refSize = Math.min(zoomHeight, zoomWidth); 6382 this.coverExtraWidth = (viewer.orientation == 'vertical' ? 2 : 1) * ref * .025; 6383 this.coverExtraHeight = (viewer.orientation == 'vertical' ? 1 : 2) * ref * .025; 6384 if (this.has3DCover !== true) { 6385 this.coverExtraWidth = 0; 6386 this.coverExtraHeight = 0; 6387 } 6388 //viewer.app.renderRequestStatus = DV.REQUEST_STATUS.ON; 6389 6390 viewer.zoomViewer.resize(); 6391 viewer.cameraPositionDirty = true; 6392 viewer.centerNeedsUpdate = true; 6393 viewer.checkCenter(true); 6394 viewer.pagesReady(); 6395 this.pageOffset = (this.hasSpiral ? 6 : 0) * Math.min(this._defaultPageSize.width, this._defaultPageSize.height) / 1000; 6396 } 6397 }, { 6398 key: "fitCameraToCenteredObject", 6399 value: function fitCameraToCenteredObject(camera, object, offset, orbitControls) { 6400 var boundingBox = new THREE.Box3(); 6401 boundingBox.setFromObject(object); 6402 var middle = new THREE.Vector3(); 6403 var size = new THREE.Vector3(); 6404 boundingBox.getSize(size); 6405 var coverExtraHeight = this.coverExtraHeight; 6406 var coverExtraWidth = this.coverExtraWidth * 2; 6407 if (this.isClosedPage()) { 6408 coverExtraWidth = 0; 6409 coverExtraHeight = 0; 6410 } 6411 size.x = size.x - coverExtraWidth + this.app.dimensions.padding.width; 6412 size.y = size.y - coverExtraHeight + this.app.dimensions.padding.height; 6413 6414 // figure out how to fit the box in the view: 6415 // 1. figure out horizontal FOV (on non-1.0 aspects) 6416 // 2. figure out distance from the object in X and Y planes 6417 // 3. select the max distance (to fit both sides in) 6418 // 6419 // The reason is as follows: 6420 // 6421 // Imagine a bounding box (BB) is centered at (0,0,0). 6422 // Camera has vertical FOV (camera.fov) and horizontal FOV 6423 // (camera.fov scaled by aspect, see fovh below) 6424 // 6425 // Therefore if you want to put the entire object into the field of view, 6426 // you have to compute the distance as: z/2 (half of Z size of the BB 6427 // protruding towards us) plus for both X and Y size of BB you have to 6428 // figure out the distance created by the appropriate FOV. 6429 // 6430 // The FOV is always a triangle: 6431 // 6432 // (size/2) 6433 // +--------+ 6434 // | / 6435 // | / 6436 // | / 6437 // | F° / 6438 // | / 6439 // | / 6440 // | / 6441 // |/ 6442 // 6443 // F° is half of respective FOV, so to compute the distance (the length 6444 // of the straight line) one has to: `size/2 / Math.tan(F)`. 6445 // 6446 // FTR, from https://threejs.org/docs/#api/en/cameras/PerspectiveCamera 6447 // the camera.fov is the vertical FOV. 6448 6449 var fov = camera.fov * (Math.PI / 180); 6450 var fovh = 2 * Math.atan(Math.tan(fov / 2) * camera.aspect); 6451 var dx = size.z / 2 + Math.abs(size.x / 2 / Math.tan(fovh / 2)); 6452 var dy = size.z / 2 + Math.abs(size.y / 2 / Math.tan(fov / 2)); 6453 var cameraZ = Math.max(dx, dy); 6454 6455 // offset the camera, if desired (to avoid filling the whole canvas) 6456 if (offset !== undefined && offset !== 0) cameraZ *= offset; 6457 camera.position.set(0, 0, cameraZ); 6458 6459 // set the far plane of the camera so that it easily encompasses the whole object 6460 var minZ = boundingBox.min.z; 6461 var cameraToFarEdge = minZ < 0 ? -minZ + cameraZ : cameraZ - minZ; 6462 camera.far = cameraToFarEdge * 3; 6463 camera.updateProjectionMatrix(); 6464 if (orbitControls !== undefined) { 6465 // set camera to rotate around the center 6466 orbitControls.target = new THREE.Vector3(0, 0, 0); 6467 6468 // prevent camera from zooming out far enough to create far plane cutoff 6469 orbitControls.maxDistance = cameraToFarEdge * 2; 6470 } 6471 } 6472 }, { 6473 key: "updateShadowSize", 6474 value: function updateShadowSize() { 6475 return; 6476 var shadowSize = this.pageScaleX > 2.5 ? 1024 : 512; 6477 var shadow = this.stage.spotLight.shadow; 6478 if (this.stage.spotLight.castShadow === true && shadow.mapSize.height != shadowSize) { 6479 shadow.radius = shadowSize / 256; 6480 shadow.mapSize.width = shadowSize; 6481 shadow.mapSize.height = shadowSize; 6482 shadow.needsUpdate = true; 6483 } 6484 } 6485 }, { 6486 key: "refresh", 6487 value: function refresh() { 6488 var viewer = this, 6489 app = this.app, 6490 basePage = viewer.getBasePage(); 6491 this.refreshRequested = true; //flag to check if refresh has beem requested 6492 6493 var ratioStep = 1 / app.pageCount, 6494 ratio = ratioStep * basePage; 6495 var leftWeight = this.isRTL ? 1 - ratio : ratio, 6496 rightWeight = 1 - leftWeight; 6497 var minSheetStack = Math.min(viewer.stackCount, viewer.totalSheets); 6498 var maxSheetStack = flipbook_3d_utils.limitAt(viewer.totalSheets, viewer.stackCount, viewer.stackCount * 2); 6499 var midWeight = Math.max(leftWeight, rightWeight); 6500 var flexibilityFactor = this.isBooklet ? 0 : this.flexibility / maxSheetStack; 6501 viewer.leftFlexibility = flexibilityFactor * rightWeight; 6502 viewer.rightFlexibility = flexibilityFactor * leftWeight; 6503 viewer.midPosition = 0.5 * minSheetStack * viewer.sheetDepth; 6504 flipbook_3d_get(flipbook_3d_getPrototypeOf(FlipBook3D.prototype), "refresh", this).call(this); 6505 var displayCover = this.has3DCover === true; 6506 this.leftCover.element.visible = this.rightCover.element.visible = this.leftSheets.element.visible = this.rightSheets.element.visible = displayCover; 6507 this.wrapper.position.z = -this.midPosition; 6508 var depthLeft = 0, 6509 depthRight = 0, 6510 isRTL = viewer.isRTL; 6511 var isFrontPage = this.isFirstPage(), 6512 isLastPage = this.isLastPage(); 6513 var isLeftClosed = this.isLeftClosed = this.isClosedPage() && (isRTL && isLastPage || !isRTL && isFrontPage), 6514 isRightClosed = this.isRightClosed = this.isClosedPage() && (!isRTL && isLastPage || isRTL && isFrontPage); 6515 if (displayCover) { 6516 viewer.leftSheets.depth = isRTL ? viewer.sheetsDepth * (1 - viewer.getBasePage() / app.pageCount) : viewer.sheetsDepth * basePage / app.pageCount; 6517 viewer.leftSheets.element.visible = isRTL ? app.pageCount - viewer.getBasePage() > 2 : basePage > 2; 6518 depthLeft -= viewer.leftSheets.depth / 2; 6519 viewer.leftSheets.element.position.z = depthLeft; 6520 depthLeft -= viewer.coverDepth + (viewer.leftSheets.element.visible ? viewer.leftSheets.depth / 2 : 0) + viewer.coverDepth * 3; 6521 viewer.leftCover.depth = viewer.rightCover.depth = viewer.coverDepth; 6522 var maxSheetHeight = Math.max(this.leftSheetHeight, this.rightSheetHeight); 6523 if (isRightClosed) maxSheetHeight = this.leftSheetHeight; 6524 if (isLeftClosed) maxSheetHeight = this.rightSheetHeight; 6525 if (viewer.leftCover.isFlipping !== true) { 6526 viewer.leftCover.element.position.z = isLeftClosed ? viewer.midPosition + viewer.coverDepth : depthLeft + viewer.coverDepth / 2; 6527 viewer.leftCover.element.position.z = Math.max(viewer.leftCover.element.position.z, -viewer.refSize * 0.05); 6528 viewer.leftCover.element.position.x = 0; 6529 viewer.leftSheets.sheetAngle = viewer.leftCover.sheetAngle = isLeftClosed ? 180 : 0; 6530 viewer.leftSheets.curveAngle = viewer.leftCover.curveAngle = isLeftClosed ? 180 : 0; 6531 if (viewer.rightCover.isFlipping !== true) { 6532 viewer.leftCover.height = maxSheetHeight; 6533 viewer.leftCover.width = viewer.leftCover.sheetAngle < 90 ? this.leftSheetWidth : this.rightSheetWidth; 6534 if (!this.isClosedPage()) { 6535 viewer.leftCover.width += this.coverExtraWidth; 6536 viewer.leftCover.height += this.coverExtraHeight; 6537 } 6538 } 6539 viewer.leftSheets.updateAngle(); 6540 viewer.leftCover.updateAngle(); 6541 } 6542 viewer.rightSheets.depth = viewer.sheetsDepth - viewer.leftSheets.depth; 6543 viewer.rightSheets.element.visible = isRTL ? basePage > 2 : app.pageCount - viewer.getBasePage() > 2; 6544 depthRight -= viewer.rightSheets.depth / 2; 6545 viewer.rightSheets.element.position.z = depthRight; 6546 depthRight -= viewer.coverDepth + (viewer.rightSheets.element.visible ? viewer.rightSheets.depth / 2 : 0) + viewer.coverDepth * 3; 6547 if (viewer.rightCover.isFlipping !== true) { 6548 viewer.rightCover.element.position.z = isRightClosed ? viewer.midPosition + viewer.coverDepth : depthRight + viewer.coverDepth / 2; 6549 viewer.rightCover.element.position.z = Math.max(viewer.rightCover.element.position.z, -viewer.refSize * 0.05); 6550 viewer.rightCover.element.position.x = 0; 6551 viewer.rightSheets.sheetAngle = viewer.rightCover.sheetAngle = isRightClosed ? 0 : 180; 6552 viewer.rightSheets.curveAngle = viewer.rightCover.curveAngle = isRightClosed ? 0 : 180; 6553 if (viewer.leftCover.isFlipping !== true) { 6554 viewer.rightCover.height = maxSheetHeight; 6555 viewer.rightCover.width = viewer.rightCover.sheetAngle < 90 ? this.leftSheetWidth : this.rightSheetWidth; 6556 if (!this.isClosedPage()) { 6557 viewer.rightCover.width += this.coverExtraWidth; 6558 viewer.rightCover.height += this.coverExtraHeight; 6559 } 6560 } 6561 viewer.rightSheets.updateAngle(); 6562 viewer.rightCover.updateAngle(); 6563 } 6564 viewer.updateSheets(); 6565 viewer.stage.ground.position.z = Math.min(depthLeft, depthRight) - viewer.refSize * viewer.groundDistance / 100; 6566 // if (this.isClosedPage()) { 6567 // viewer.stage.ground.position.z -= viewer.coverDepth * 2; 6568 // } 6569 6570 viewer.stage.ground.position.z = Math.max(viewer.stage.ground.position.z, -viewer.refSize * 0.1); 6571 } else { 6572 viewer.stage.ground.position.z = -viewer.midPosition - viewer.sheetDepth * 15; 6573 } 6574 if (viewer.cameraPositionDirty === true) { 6575 viewer.updateCameraPosition(); 6576 } 6577 viewer.spiralRefreshRequested = true; 6578 this.refreshSpiral(); 6579 } 6580 }, { 6581 key: "refreshSpiral", 6582 value: function refreshSpiral() {
6583 if (this.hasSpiral !== true) return; 6584 var maxPos = this.midPosition + this.sheetDepth; 6585 this.bookWrapper.children.forEach(function (page) { 6586 if (page && page.sheetAngle) { 6587 if (page.position.z + page.depth / 2 > maxPos) maxPos = page.position.z + page.depth / 2; 6588 } 6589 }); 6590 this.leftHoles.visible = this.isBooklet ? this.isRTL : this.isLeftClosed == false && this.leftCover.isFlipping == false; 6591 this.rightHoles.visible = this.isBooklet ? !this.isRTL : this.isRightClosed == false && this.rightCover.isFlipping == false; 6592 var scale = this.orientation === 'vertical' ? Math.max(this.leftHoles.visible ? this.leftSheetWidth : 0, this.rightHoles.visible ? this.rightSheetWidth : 0) : Math.max(this.leftHoles.visible ? this.leftSheetHeight : 0, this.rightHoles.visible ? this.rightSheetHeight : 0); 6593 scale /= 1000; 6594 this.leftHoles.position.z = this.rightHoles.position.z = maxPos + 2 / scale + (this.isClosedPage() ? 2 * this.leftCover.depth : 0) / scale; //(this.isBooklet ? 4 : 0) + (this.isClosedPage() ? 5 : 0); 6595 6596 this.spiralGroup.scale.set(scale, scale, scale); 6597 } 6598 }, { 6599 key: "updateCameraPosition", 6600 value: function updateCameraPosition() { 6601 var viewer = this; 6602 var app = viewer.app, 6603 stage = viewer.stage; 6604 var dimensions = app.dimensions; 6605 var padding = dimensions.padding; 6606 var cameraZ = 1 / (2 * Math.tan(Math.PI * stage.camera.fov * 0.5 / 180) / (dimensions.stage.height / app.zoomValue)) + 2.2; 6607 this.updateShadowSize(); 6608 this.stage.spotLight.position.x = -this.pageScaleX * 440; 6609 this.stage.spotLight.position.y = this.pageScaleX * 440; 6610 this.stage.spotLight.position.z = this.pageScaleX * 660; 6611 this.stage.spotLight.shadow.camera.far = this.pageScaleX * 1200; 6612 this.stage.spotLight.shadow.camera.updateProjectionMatrix(); 6613 var shiftY = (padding.top - padding.bottom) / app.zoomValue / 2, 6614 shiftX = -(padding.left - padding.right) / app.zoomValue / 2; 6615 if (stage.camera.position.z !== cameraZ && app.pendingZoom === true) { 6616 stage.camera.position.z = cameraZ; 6617 } 6618 if (app.zoomValue === 1) { 6619 viewer.bookWrapper.rotation.set(0, 0, 0); 6620 viewer.bookHelper.rotation.set(0, 0, 0); 6621 viewer.cameraWrapper.rotation.set(0, 0, 0); 6622 if (app.options.flipbook3DTiltAngleUp !== 0 || app.options.flipbook3DTiltAngleLeft !== 0) { 6623 stage.camera.aspect = dimensions.stage.width / dimensions.stage.height; 6624 stage.camera.updateProjectionMatrix(); 6625 //upward rotation is on X axis and is done after left Rotation , Z axis. 6626 //Since book need to rotate upwward, rotate X later works 6627 viewer.bookWrapper.rotateZ(THREE.Math.degToRad(-app.options.flipbook3DTiltAngleLeft)); //negative goes left 6628 viewer.bookWrapper.rotateX(THREE.Math.degToRad(-app.options.flipbook3DTiltAngleUp)); //negative goes upward 6629 if (viewer.orientation == 'vertical') { 6630 viewer.bookWrapper.scale.y = 1 / (this.isSingle ? 2 : 1); 6631 } else { 6632 viewer.bookWrapper.scale.x = 1 / (this.isSingle ? 2 : 1); 6633 } 6634 viewer.bookHelper.update(); 6635 viewer.fitCameraToCenteredObject(stage.camera, viewer.bookWrapper); 6636 viewer.bookWrapper.rotation.set(0, 0, 0); 6637 viewer.bookWrapper.scale.x = 1; 6638 viewer.bookWrapper.scale.y = 1; 6639 //upward rotation is on X axis and is done after left Rotation , Z axis. 6640 //Since book need to rotate upwward, rotate X later works 6641 // viewer.bookHelper.rotateZ(THREE.Math.degToRad(app.options.flipbook3DTiltAngleLeft)); //negative goes left 6642 // viewer.bookHelper.rotateX(THREE.Math.degToRad(-app.options.flipbook3DTiltAngleUp)); //negative goes upward 6643 6644 stage.camera.position.set(shiftX, shiftY, stage.camera.position.z + stage.ground.position.z); 6645 this.camera.aspect = dimensions.stage.width / dimensions.stage.height; 6646 this.camera.updateProjectionMatrix(); 6647 6648 //upward rotation is on X axis and is done after left Rotation , Z axis. 6649 //Since book need to rotate upwward, rotate X later works 6650 viewer.cameraWrapper.rotateX(THREE.Math.degToRad(app.options.flipbook3DTiltAngleUp)); //negative goes upward 6651 viewer.cameraWrapper.rotateZ(THREE.Math.degToRad(app.options.flipbook3DTiltAngleLeft)); //positive goes left 6652 } else { 6653 stage.camera.position.set(shiftX, shiftY, cameraZ); 6654 } 6655 } 6656 stage.camera.updateProjectionMatrix(); 6657 viewer.app.renderRequestStatus = flipbook_3d_DV.REQUEST_STATUS.ON; 6658 viewer.cameraPositionDirty = false;
6659 } 6660 }, { 6661 key: "refreshSheet", 6662 value: function refreshSheet(options) { 6663 var viewer = this, 6664 _sheet = options.sheet, 6665 _sheetStackIndex = options.index; 6666 6667 // region Determine Next Position, angle and Flexibility based on pageLocation 6668 var oldAngle = _sheet.sheetAngle, 6669 newAngle, 6670 isFlexible = !(_sheet.isHard || this.flexibility === 0); 6671 _sheet.leftFlexibility = !isFlexible ? 0 : viewer.leftFlexibility; 6672 _sheet.rightFlexibility = !isFlexible ? 0 : viewer.rightFlexibility; 6673 _sheet.leftPos = viewer.midPosition + (_sheetStackIndex - options.midPoint + 1) * viewer.sheetDepth - viewer.sheetDepth / 2; 6674 _sheet.rightPos = viewer.midPosition - (_sheetStackIndex - options.midPoint) * viewer.sheetDepth - viewer.sheetDepth / 2; 6675 newAngle = _sheet.targetSide === defaults_DEARVIEWER.TURN_DIRECTION.LEFT ? 0 : 180; 6676 6677 //endregion 6678 if (_sheet.isFlipping === false) { 6679 if (options.needsFlip) { 6680 _sheet.isFlipping = true; 6681 if (_sheet.isCover && options.sheetNumber === 0) if (viewer.isRTL) viewer.rightCover.isFlipping = true;else viewer.leftCover.isFlipping = true; 6682 if (_sheet.isCover && viewer.totalSheets - options.sheetNumber === 1) if (viewer.isRTL) viewer.leftCover.isFlipping = true;else viewer.rightCover.isFlipping = true; 6683 _sheet.element.position.z = Math.max(oldAngle < 90 ? _sheet.leftPos : _sheet.rightPos, viewer.midPosition) + viewer.sheetDepth; 6684 //this.beforeFlip(); 6685 _sheet.flexibility = oldAngle < 90 ? _sheet.leftFlexibility : _sheet.rightFlexibility; 6686 _sheet.flip(oldAngle, newAngle); 6687 } else { 6688 _sheet.skipFlip = false; 6689 _sheet.sheetAngle = _sheet.curveAngle = newAngle; 6690 _sheet.flexibility = newAngle < 90 ? _sheet.leftFlexibility : _sheet.rightFlexibility; 6691 _sheet.element.position.z = newAngle < 90 ? _sheet.leftPos : _sheet.rightPos; 6692 _sheet.side = _sheet.targetSide; 6693 6694 //sheets from left side coming to right should follow the right side dimension and vice versa 6695 _sheet.height = newAngle < 90 ? this.leftSheetHeight : this.rightSheetHeight; 6696 _sheet.width = newAngle < 90 ? this.leftSheetWidth : this.rightSheetWidth; 6697 } 6698 _sheet.updateAngle(); 6699 this.app.renderRequestStatus = flipbook_3d_DV.REQUEST_STATUS.ON; 6700 } else { 6701 // _sheet.element.position.z = oldAngle < 90 ? _sheet.leftPos : _sheet.rightPos; 6702 } 6703 6704 //determine visibility 6705 _sheet.element.visible = options.visible; 6706 } 6707 }, { 6708 key: "updateCenter", 6709 value: function updateCenter() { 6710 var viewer = this, 6711 app = this.app; 6712 var init = this.orientation == 'vertical' ? viewer.wrapper.position.y : viewer.wrapper.position.x, 6713 centerShift = (this.orientation === 'vertical' ? -1 : 1) * viewer.centerShift, 6714 length = this.isLeftPage() ? this.orientation == 'vertical' ? this.leftSheetHeight : this.leftSheetWidth : this.orientation == 'vertical' ? this.rightSheetHeight : this.rightSheetWidth; 6715 var end = centerShift * length / 2; 6716 viewer.seamPosition = (-app.dimensions.offset.width + app.dimensions.containerWidth) / 2 + end; 6717 //create a centerTween 6718 if (end !== viewer.centerEnd) { 6719 //avoid recreating the tween if the target is same as before 6720 if (viewer.centerTween && viewer.centerTween.stop) viewer.centerTween.stop(); 6721 viewer.onCenterStartAnimation(this); //solves issue 301 - called early so that waiting doesn't cause flicker 6722 viewer.centerTween = new TWEEN.Tween({ 6723 x: init 6724 }).delay(0).to({ 6725 x: end 6726 }, app.zoomValue === 1 && viewer.skipCenterAnimation !== true ? viewer.app.options.duration : 1).onStart(function () { 6727 /*viewer.onCenterStartAnimation(this); //is delayed for some reason - maybe waiting for request frame and causes flicker - issue 301*/ 6728 }).onUpdate(function () { 6729 viewer.onCenterUpdateAnimation(this); 6730 }).onComplete(function () { 6731 viewer.onCenterCompleteAnimation(this); 6732 }).onStop(function () { 6733 viewer.onCenterStopAnimation(this); 6734 }).easing(TWEEN.Easing.Cubic.InOut).start(); 6735 this.updatePendingStatusClass(); 6736 viewer.skipCenterAnimation = false;
6737 viewer.centerEnd = end; 6738 } 6739 viewer.renderRequestStatus = flipbook_3d_DV.REQUEST_STATUS.ON; 6740 this.zoomViewer.updateCenter(); 6741 } 6742 }, { 6743 key: "onCenterUpdateAnimation", 6744 value: function onCenterUpdateAnimation(tween) { 6745 if (this.orientation == 'vertical') { 6746 this.wrapper.position.y = tween.x; 6747 //noinspection JSUnresolvedVariable 6748 if (this.stage && this.stage.cssScene) this.stage.cssScene.position.y = tween.x; 6749 } else { 6750 this.wrapper.position.x = tween.x; 6751 //noinspection JSUnresolvedVariable 6752 if (this.stage && this.stage.cssScene) this.stage.cssScene.position.x = tween.x; 6753 } 6754 } 6755 }, { 6756 key: "onCenterStartAnimation", 6757 value: function onCenterStartAnimation(tween) {} 6758 }, { 6759 key: "onCenterStopAnimation", 6760 value: function onCenterStopAnimation(tween) {} 6761 }, { 6762 key: "onCenterCompleteAnimation", 6763 value: function onCenterCompleteAnimation(tween) {} 6764 }, { 6765 key: "flipCover", 6766 value: function flipCover(sheet) { 6767 var viewer = this, 6768 cover = null, 6769 multiplier, 6770 diff; 6771 if (sheet.pageNumber === 0 || this.isBooklet && sheet.pageNumber === 1) { 6772 cover = this.isRTL ? this.rightCover : this.leftCover; 6773 multiplier = this.isRTL ? 1 : -1; 6774 } else if (sheet.pageNumber === this.totalSheets - 1) { 6775 cover = this.isRTL ? this.leftCover : this.rightCover; 6776 multiplier = this.isRTL ? -1 : 1; 6777 } 6778 if (cover === null) return; 6779 diff = cover.depth + sheet.depth + 1; 6780 cover.sheetAngle = sheet.sheetAngle; 6781 cover.curveAngle = sheet.curveAngle; 6782 this.rightCover.height = this.leftCover.height = sheet.height + this.coverExtraHeight; 6783 this.rightCover.width = this.leftCover.width = sheet.width + this.coverExtraWidth; 6784 cover.flexibility = sheet.flexibility; 6785 this.rightCover.updateAngle(); 6786 this.leftCover.updateAngle(); 6787 cover.element.position.x = sheet.element.position.x + multiplier * Math.sin(sheet.sheetAngle * Math.PI / 180) * diff; 6788 cover.element.position.z = sheet.element.position.z + multiplier * Math.cos(sheet.sheetAngle * Math.PI / 180) * diff; 6789 } 6790 }, { 6791 key: "pagesReady", 6792 value: function pagesReady() { 6793 if (this.isAnimating()) return; 6794 if (this.refreshRequested !== true) return; 6795 if (this.app.options.flipbookFitPages === false) { 6796 var basePage = this.app.viewer.getBasePage();
6797 var leftViewPort = this.leftViewport = this.getViewPort(basePage + (this.isBooklet ? 0 : this.isRTL ? 1 : 0)), 6798 rightViewPort = this.rightViewPort = this.getViewPort(basePage + (this.isBooklet ? 0 : this.isRTL ? 0 : 1)); 6799 if (leftViewPort) { 6800 var leftDimen = flipbook_3d_utils.contain(leftViewPort.width, leftViewPort.height, this.availablePageWidth(), this.availablePageHeight()); 6801 if (this.leftSheetWidth != Math.floor(leftDimen.width) || this.leftSheetHeight != Math.floor(leftDimen.height)) { 6802 this.cameraPositionDirty = true; 6803 } 6804 this.leftSheetWidth = Math.floor(leftDimen.width); 6805 this.leftSheetHeight = Math.floor(leftDimen.height); 6806 } 6807 if (rightViewPort) { 6808 var rightDimen = flipbook_3d_utils.contain(rightViewPort.width, rightViewPort.height, this.availablePageWidth(), this.availablePageHeight()); 6809 if (this.rightSheetWidth != Math.floor(rightDimen.width) || this.rightSheetWidth != Math.floor(rightDimen.height)) { 6810 this.cameraPositionDirty = true; 6811 } 6812 this.rightSheetWidth = Math.floor(rightDimen.width); 6813 this.rightSheetHeight = Math.floor(rightDimen.height); 6814 } 6815 for (var i = 0; i < this.sheets.length; i++) { 6816 var sheet = this.sheets[i]; 6817 if (sheet.side === flipbook_3d_DV.TURN_DIRECTION.LEFT) { 6818 sheet.height = this.leftSheetHeight; 6819 sheet.width = this.leftSheetWidth; 6820 sheet.updateAngle(); 6821 } else { 6822 sheet.height = this.rightSheetHeight; 6823 sheet.width = this.rightSheetWidth; 6824 sheet.updateAngle(); 6825 } 6826 } 6827 if (this.isClosedPage()) { 6828 var isClosedOnRight = this.isRTL && this.isLastPage() || !this.isRTL && this.isFirstPage(); 6829 this.leftCover.width = this.rightCover.width = isClosedOnRight ? this.rightSheetWidth : this.leftSheetWidth; 6830 this.leftCover.height = this.rightCover.height = isClosedOnRight ? this.rightSheetHeight : this.leftSheetHeight; 6831 } else { 6832 this.leftCover.height = this.rightCover.height = this.coverExtraHeight + Math.max(this.leftSheetHeight, this.rightSheetHeight); 6833 this.leftCover.width = this.coverExtraWidth + this.leftSheetWidth; 6834 this.rightCover.width = this.coverExtraWidth + this.rightSheetWidth; 6835 } 6836 this.leftSheets.width = this.leftSheetWidth; 6837 this.leftSheets.height = this.leftSheetHeight; 6838 this.rightSheets.height = this.rightSheetHeight; 6839 this.rightSheets.width = this.rightSheetWidth; 6840 this.leftCover.updateAngle(); 6841 this.leftSheets.updateAngle(); 6842 this.rightCover.updateAngle(); 6843 this.rightSheets.updateAngle(); 6844 this.updateSheets(true); 6845 } 6846 this.updateCenter(); 6847 this.updateCSSLayer(); 6848 this.updatePendingStatusClass(); 6849 this.refreshSpiral(); 6850 if (this.cameraPositionDirty === true) { 6851 this.updateCameraPosition(); 6852 } 6853 } 6854 }, { 6855 key: "updateSheets", 6856 value: function updateSheets(update) { 6857 if (this.isClosedPage() !== true) { 6858 var rightPage = this.getPageByNumber(this.getRightPageNumber()); 6859 if (this.rightCover.isFlipping !== true && rightPage && rightPage.sheet.element.geometry.attributes) { 6860 var pos = this.rightSheets.element.geometry.attributes.position, 6861 posX = update ? rightPage.sheet.element.geometry.boundingBox.max.x * rightPage.sheet.element.scale.x : this.rightSheets.lastSlopeX; 6862 pos.setX(21, posX); 6863 pos.setX(23, posX); 6864 pos.setX(4, posX); 6865 pos.setX(6, posX); 6866 pos.setX(10, posX); 6867 pos.setX(14, posX); 6868 pos.needsUpdate = true; 6869 this.rightSheets.element.geometry.attributes.uv.needsUpdate = true; 6870 this.rightSheets.element.geometry.computeVertexNormals(); 6871 if (update) this.rightSheets.lastSlopeX = posX; 6872 } 6873 var leftPage = this.getPageByNumber(this.getLeftPageNumber()); 6874 if (this.leftCover.isFlipping !== true && leftPage && leftPage.sheet.element.geometry.attributes) { 6875 var _pos = this.leftSheets.element.geometry.attributes.position, 6876 _posX = update ? leftPage.sheet.element.geometry.boundingBox.min.x * leftPage.sheet.element.scale.x : this.leftSheets.lastSlopeX; 6877 _pos.setX(16, _posX); 6878 _pos.setX(18, _posX); 6879 _pos.setX(5, _posX); 6880 _pos.setX(7, _posX); 6881 _pos.setX(8, _posX); 6882 _pos.setX(12, _posX); 6883 _pos.needsUpdate = true; 6884 this.leftSheets.element.geometry.attributes.uv.needsUpdate = true; 6885 this.leftSheets.element.geometry.computeVertexNormals(); 6886 if (update) this.leftSheets.lastSlopeX = _posX; 6887 } 6888 } 6889 } 6890 }, { 6891 key: "updateCSSLayer", 6892 value: function updateCSSLayer() { 6893 var viewer = this; 6894 var baseActive = viewer.getBasePage(); 6895 var width, height; 6896 var leftPageNumber = baseActive + (viewer.isBooklet ? 0 : viewer.isRTL ? 1 : 0), 6897 rightPageNumber = baseActive + (viewer.isBooklet ? 0 : this.isRTL ? 0 : 1); 6898 var pageLeft = !this.isRTL && viewer.isBooklet ? undefined : viewer.getPageByNumber(leftPageNumber), 6899 pageRight = this.isRTL && viewer.isBooklet ? undefined : viewer.getPageByNumber(rightPageNumber); 6900 jQuery(viewer.stage.cssRenderer.domElement).find(".df-page-content").css({ 6901 display: "none" 6902 }); 6903 var isVertical = this.orientation == 'vertical';
6904 if (this.leftViewport && pageLeft != null && pageLeft.sheet.element.visible) { 6905 var divLeft = pageLeft.cssPage; 6906 if (divLeft != null) { 6907 var boundLeft = pageLeft.sheet.element.geometry.boundingBox; 6908 width = Math.abs(boundLeft.max.x - boundLeft.min.x) * pageLeft.sheet.element.scale.x; 6909 height = Math.abs(boundLeft.max.y - boundLeft.min.y) * pageLeft.sheet.element.scale.y; 6910 divLeft.rotation.y = 0; //-Math.atan2(height, width) * 0.9; 6911 divLeft.position.z = 0; //pageLeft.sheet.element.position.z + height * 0.5; 6912 divLeft.position.x = 0; //height / 2.5; 6913 jQuery(divLeft.element).css({ 6914 width: isVertical ? height : width, 6915 height: isVertical ? width : height, 6916 top: isVertical ? this.pageOffset + width / 2 : 0, 6917 left: isVertical ? 0 : -this.pageOffset - width / 2, 6918 display: 'block' 6919 }); 6920 6921 // if (this.texturePowerOfTwo) { 6922 this.resizeAnnotations(leftPageNumber); 6923 // } 6924 } 6925 } 6926 6927 if (this.rightViewPort && pageRight != null && pageRight.sheet.element.visible) { 6928 var divRight = pageRight.cssPage; 6929 if (divRight != null) { 6930 var boundRight = pageRight.sheet.element.geometry.boundingBox; 6931 width = Math.abs(boundRight.max.x - boundRight.min.x) * pageRight.sheet.element.scale.x; 6932 height = Math.abs(boundRight.max.y - boundRight.min.y) * pageRight.sheet.element.scale.y; 6933 divRight.rotation.y = 0; //Math.atan2(height, width) * 0.9; 6934 divRight.position.z = 0; //pageRight.sheet.element.position.z + height * 0.5; 6935 divRight.position.x = 0; //-height / 2.5; 6936 jQuery(divRight.element).css({ 6937 width: isVertical ? height : width, 6938 height: isVertical ? width : height, 6939 top: isVertical ? -this.pageOffset - width / 2 : 0, 6940 left: isVertical ? 0 : this.pageOffset + width / 2, 6941 display: 'block' 6942 }); 6943 // if (t/his.texturePowerOfTwo) { 6944 this.resizeAnnotations(rightPageNumber); 6945 // } 6946 } 6947 } 6948 } 6949 }, { 6950 key: "mouseMove", 6951 value: function mouseMove(event) { 6952 event = flipbook_3d_utils.fixMouseEvent(event); 6953 this.app.renderRequestStatus = flipbook_3d_DV.REQUEST_STATUS.ON; 6954 if (event.touches != null && event.touches.length == 2) { 6955 this.pinchMove(event); 6956 return; 6957 } 6958 var viewer = this; 6959 var point = viewer.eventToPoint(event); 6960 if (viewer.dragSheet !== null && viewer.drag3D !== false) { 6961 // if(point.x < this.app.dimensions.width /2){ 6962 var angle = Math.acos(flipbook_3d_utils.limitAt(1 - (point.x - point.left) / this.leftSheetWidth, -1, 1)) * 180 / Math.PI; 6963 // angle = utils.limitAt(angle, 0, 180); 6964 var sheet = viewer.dragSheet; 6965 var isLeftPage = viewer.drag === flipbook_3d_DV.TURN_DIRECTION.LEFT; 6966 sheet.sheetAngle = angle; 6967 var curveAngle = isLeftPage ? flipbook_3d_utils.limitAt(sheet.sheetAngle + 45, 0, 180) : flipbook_3d_utils.limitAt(sheet.sheetAngle, 0, 180); 6968 sheet.curveAngle = sheet.isHard ? sheet.sheetAngle : curveAngle * TWEEN.Easing.Sinusoidal.Out(curveAngle * .8 / 180); 6969 // utils.log("x:" + (1 - ((point.x - point.left) / this.leftSheetWidth)) + "angle: " + angle + " curveAngle:" + curveAngle) 6970 sheet.updateAngle(); 6971 } 6972 viewer.checkSwipe(point, event); 6973 } 6974 6975 /** 6976 * @param {MouseEvent & jQueryMouseEvent} event 6977 */ 6978 }, { 6979 key: "mouseUp", 6980 value: function mouseUp(event) { 6981 var viewer = this; 6982 event = flipbook_3d_utils.fixMouseEvent(event); 6983 if (!event.touches && event.button !== 0) return; 6984 if (viewer.dragSheet == null && event.touches != null && event.touches.length == 0) { 6985 this.pinchUp(event); 6986 return; 6987 } 6988 var point = viewer.eventToPoint(event); 6989 if (viewer.app.zoomValue === 1) { 6990 if (viewer.dragSheet !== null) { 6991 if (point.x > viewer.app.dimensions.width / 2) { 6992 if (viewer.drag === flipbook_3d_DV.TURN_DIRECTION.LEFT) viewer.app.openLeft(); 6993 } else { 6994 if (viewer.drag === flipbook_3d_DV.TURN_DIRECTION.RIGHT) viewer.app.openRight(); 6995 } 6996 viewer.requestRefresh(); 6997 } 6998 var element = event.target || event.originalTarget; //check to see if the clicked element is a link, if so skip turn
6999 var isClick = viewer.startPoint && point.x === viewer.startPoint.x && point.y === viewer.startPoint.y && element.nodeName !== "A"; 7000 if (event.ctrlKey === true && isClick) { 7001 this.zoomOnPoint(point); 7002 } else if (isClick && viewer.clickAction === flipbook_3d_DV.MOUSE_CLICK_ACTIONS.NAV) { 7003 viewer.raycastCLick(event); 7004 } 7005 } 7006 viewer.dragSheet = null; 7007 viewer.drag = null; 7008 7009 /*3 if there is swipe - clean*/ 7010 viewer.startPoint = null; 7011 viewer.canSwipe = false; 7012 viewer.app.renderRequestStatus = flipbook_3d_DV.REQUEST_STATUS.ON; 7013 } 7014 }, { 7015 key: "raycastCLick", 7016 value: function raycastCLick(event) { 7017 var viewer = this; 7018 viewer.mouse = new THREE.Vector2(); 7019 viewer.raycaster = new THREE.Raycaster(); 7020 viewer.mouse.x = event.offsetX / viewer.app.dimensions.stage.width * 2 - 1; 7021 viewer.mouse.y = 1 - event.offsetY / viewer.app.dimensions.stage.height * 2; 7022 viewer.raycaster.setFromCamera(viewer.mouse, viewer.camera); 7023 var intersects = viewer.raycaster.intersectObjects(viewer.bookWrapper.children, true); 7024 if (intersects.length > 0) { 7025 var object, 7026 objectCount = 0; 7027 do { 7028 object = intersects[objectCount] != null ? intersects[objectCount].object : null; 7029 if (object.sheet) { 7030 if (object.sheet.isFlipping !== true) { 7031 if (object.sheet.sheetAngle > 90) { 7032 viewer.app.openRight(); 7033 } else { 7034 viewer.app.openLeft(); 7035 } 7036 break; 7037 } 7038 } 7039 objectCount++; 7040 } while (objectCount < intersects.length); 7041 } 7042 } 7043 }, { 7044 key: "mouseDown", 7045 value: function mouseDown(event) { 7046 event = flipbook_3d_utils.fixMouseEvent(event); 7047 if (!event.touches && event.button !== 0) return; 7048 if (event.touches != null && event.touches.length == 2) { 7049 this.pinchDown(event); 7050 return; 7051 } else { 7052 event = flipbook_3d_utils.fixMouseEvent(event); 7053 var viewer = this; 7054 var point = viewer.eventToPoint(event); 7055 viewer.startPoint = point; 7056 viewer.lastPosX = point.x; 7057 viewer.lastPosY = point.y; 7058 if (point.isInsideDragZone && viewer.drag3D !== false) { 7059 viewer.dragSheet = point.sheet; 7060 viewer.drag = point.sheet.sheetAngle < 90 ? flipbook_3d_DV.TURN_DIRECTION.LEFT : flipbook_3d_DV.TURN_DIRECTION.RIGHT; 7061 } else { 7062 viewer.canSwipe = true; 7063 } 7064 } 7065 } 7066 }, { 7067 key: "eventToPoint", 7068 value: function eventToPoint(event) { 7069 var viewer = this, 7070 dimensions = this.app.dimensions; 7071 event = flipbook_3d_utils.fixMouseEvent(event); 7072 var point = { 7073 x: event.clientX, 7074 y: event.clientY 7075 }; 7076 7077 //calculate x and y relative to container 7078 point.x = point.x - viewer.parentElement[0].getBoundingClientRect().left; 7079 point.y = point.y - viewer.parentElement[0].getBoundingClientRect().top; 7080 var left = (-dimensions.offset.width + dimensions.containerWidth) / 2 - dimensions.stage.width / 2, 7081 right = (-dimensions.offset.width + dimensions.containerWidth) / 2 + dimensions.stage.width / 2, 7082 top = dimensions.padding.top, 7083 bottom = dimensions.padding.top + viewer.availablePageHeight(); 7084 var isLeftSheet = point.x < viewer.seamPosition; 7085 var pageNumber = viewer.getBasePage() + (isLeftSheet ? 0 : 1); 7086 var sheet = this.getPageByNumber(pageNumber); 7087 if (sheet) sheet = sheet.sheet; 7088 var isInsideSheet = point.x > left && point.x < right && point.y > top && point.y < bottom; 7089 return { 7090 isInsideSheet: isInsideSheet, 7091 isInsideDragZone: isInsideSheet && point.x - left < viewer.foldSense || right - point.x < viewer.foldSense, 7092 x: point.x, 7093 y: point.y, 7094 left: left, 7095 top: top, 7096 right: right, 7097 bottom: bottom, 7098 raw: point, 7099 isLeftSheet: isLeftSheet, 7100 sheet: sheet 7101 }; 7102 } 7103 }, { 7104 key: "checkPageLoading", 7105 value: function checkPageLoading() { 7106 var isLoaded = true; 7107 var pages = this.getVisiblePages().main; 7108 for (var index = 0; index < (this.isBooklet ? 1 : 2); index++) { 7109 var page = this.getPageByNumber(pages[index]); 7110 if (page) { 7111 isLoaded = page.textureLoaded && isLoaded; 7112 } 7113 } 7114 this.element.toggleClass("df-loading", !isLoaded); 7115 } 7116 }, { 7117 key: "textureLoadedCallback", 7118 value: function textureLoadedCallback(param) { 7119 this.app.renderRequestStart(); 7120 this.pagesReady(); 7121 } 7122 }, { 7123 key: "getTextureSize", 7124 value: function getTextureSize(param) { 7125 var size = flipbook_3d_get(flipbook_3d_getPrototypeOf(FlipBook3D.prototype), "getTextureSize", this).call(this, param); 7126 if (this.app.zoomValue !== 1 || param.isAnnotation === true) return size; 7127 var height = flipbook_3d_utils.nearestPowerOfTwo(size.height); 7128 var width = size.width * height / size.height; 7129 return this.texturePowerOfTwo ? { 7130 height: height, 7131 width: width 7132 } : size; 7133 } 7134 }, { 7135 key: "getPageByNumber", 7136 value: function getPageByNumber(pageNumber) { 7137 if (this.has3DCover) { 7138 var isLastPage = !this.isBooklet && pageNumber === this.app.pageCount && pageNumber % 2 === 0, 7139 isFirstPage = pageNumber === 1; 7140 if (!this.isRTL && isFirstPage || this.isRTL && isLastPage) return this.leftCover.frontPage; 7141 if (!this.isRTL && isLastPage || this.isRTL && isFirstPage) return this.rightCover.backPage; 7142 } 7143 return flipbook_3d_get(flipbook_3d_getPrototypeOf(FlipBook3D.prototype), "getPageByNumber", this).call(this, pageNumber); 7144 } 7145 }, { 7146 key: "setPage", 7147 value: function setPage(param) { 7148 return flipbook_3d_get(flipbook_3d_getPrototypeOf(FlipBook3D.prototype), "setPage", this).call(this, param); 7149 } 7150 }, { 7151 key: "beforeFlip", 7152 value: function beforeFlip() { 7153 flipbook_3d_get(flipbook_3d_getPrototypeOf(FlipBook3D.prototype), "beforeFlip", this).call(this); 7154 } 7155 }, { 7156 key: "resizeAnnotations", 7157 value: function resizeAnnotations(pageNumber) { 7158 //if there is no transform origin, update 2.15 and above, no need for resizing 7159 //https://github.com/mozilla/pdf.js/pull/15036 7160 var annotationElement = this.getAnnotationElement(pageNumber); 7161 if (annotationElement && annotationElement.style.width !== "") return; 7162 if (this.texturePowerOfTwo === false) return; 7163 var page = this.getPageByNumber(pageNumber); 7164 var viewport = flipbook_3d_get(flipbook_3d_getPrototypeOf(FlipBook3D.prototype), "getViewPort", this).call(this, pageNumber); 7165 if (page && viewport) { 7166 viewport = viewport.clone({ 7167 dontFlip: true 7168 }); 7169 var reqStamp = pageNumber + "|" + this.rightSheetHeight; 7170 var cssPage = page.cssPage; 7171 if (cssPage.lastStamp != reqStamp) { 7172 cssPage.lastStamp = reqStamp; 7173 var boundRight = page.sheet.element.geometry.boundingBox; 7174 var width = Math.abs(boundRight.max.x - boundRight.min.x) * page.sheet.element.scale.x; 7175 var widthX = this.getDoublePageWidthFix(pageNumber) * width / viewport.width, 7176 heightX = page.sheet.height / viewport.height; 7177 var links = cssPage.element.querySelectorAll("section"); 7178 if (links.length > 0) { 7179 links.forEach(function (link) {
7180 link.style.transform = "matrix(" + widthX + ", 0, 0, " + heightX + "," + viewport.transform[4] * widthX + "," + viewport.transform[5] * heightX + ")"; 7181 }); 7182 } 7183 this.app.provider.processTextContent(pageNumber, this.getTextElement(pageNumber, true)); 7184 } 7185 } 7186 } 7187 }, { 7188 key: "finalizeAnnotations", 7189 value: function finalizeAnnotations(element, pageNumber) { 7190 flipbook_3d_get(flipbook_3d_getPrototypeOf(FlipBook3D.prototype), "finalizeAnnotations", this).call(this, element, pageNumber); 7191 this.resizeAnnotations(pageNumber); 7192 } 7193 }]); 7194 return FlipBook3D; 7195}(BaseFlipBookViewer); 7196/** 7197 * Page3D represents only the material side of the booksheet 7198 */ 7199var Page3D = /*#__PURE__*/function (_Page2D) { 7200 flipbook_3d_inherits(Page3D, _Page2D); 7201 var _super3 = flipbook_3d_createSuper(Page3D); 7202 function Page3D(options) { 7203 var _this3; 7204 flipbook_3d_classCallCheck(this, Page3D); 7205 _this3 = _super3.call(this, options); 7206 var page = flipbook_3d_assertThisInitialized(_this3); 7207 page.element = null; 7208 page.face = options.face; 7209 page.parent3D = options.sheet; 7210 page.sheet = options.sheet; 7211 page.cssPage = new THREE.CSS3DObject(page.contentLayer[0]); 7212 return _this3; 7213 } 7214 flipbook_3d_createClass(Page3D, [{ 7215 key: "setLoading", 7216 value: function setLoading() { 7217 this.sheet.viewer.checkPageLoading(); 7218 } 7219 }, { 7220 key: "clearMap", 7221 value: function clearMap() { 7222 this.sheet.element.material[this.face].map = null; 7223 this.sheet.element.material[this.face].needsUpdate = true; 7224 } 7225 }, { 7226 key: "loadTexture", 7227 value: function loadTexture(param) { 7228 var page = this, 7229 texture = param.texture, 7230 callback = param.callback; 7231 page.textureSrc = texture; 7232 function completed(object, texture3D) { 7233 page.updateTextureLoadStatus(true); 7234 page.sheet.resetMatColor(page.face, param.texture === page.textureLoadFallback); 7235 if (typeof callback == 'function') callback(param); 7236 } 7237 if (this.face === 4) { 7238 this.sheet.backImage(texture, completed); 7239 } else { 7240 this.sheet.frontImage(texture, completed); 7241 } 7242 } 7243 }]); 7244 return Page3D; 7245}(Page2D); 7246var MOCKUP = {}; 7247MOCKUP.init = function () { 7248 //region MOCKUP 7249 if (MOCKUP.initialized === true) return; 7250 var THREE = window.THREE; 7251 MOCKUP = { 7252 init: function init() {}, 7253 initialized: true, 7254 GEOMETRY_TYPE: { 7255 PLANE: 0, 7256 BOX: 1, 7257 MODEL: 2 7258 }, 7259 MATERIAL_FACE: { 7260 FRONT: 5, 7261 BACK: 4 7262 }, 7263 WHITE_COLOR: new THREE.Color("white"), 7264 defaults: { 7265 anisotropy: 8, 7266 maxTextureSize: 2048, 7267 groundTexture: "blank", 7268 color: 0xffffff, 7269 shininess: 15, 7270 width: 210, 7271 height: 297, 7272 depth: 0.2, 7273 segments: 150, 7274 textureLoadFallback: "blank" 7275 }, 7276 textureLoader: new THREE.TextureLoader(), 7277 clearChild: function clearChild(child) { 7278 var material = child.material; 7279 child.parent.remove(child); 7280 var texture; 7281 child = flipbook_3d_utils.disposeObject(child); 7282 if (material == null) return; 7283 if (material.length == null) { 7284 if (material.map) { 7285 texture = material.map; 7286 material.dispose(); 7287 texture.dispose(); 7288 } 7289 if (material.bumpMap) { 7290 texture = material.bumpMap; 7291 material.dispose(); 7292 texture.dispose(); 7293 } 7294 if (material.normalMap) { 7295 texture = material.normalMap; 7296 material.dispose(); 7297 texture.dispose(); 7298 } 7299 } else { 7300 for (var matCount = 0; matCount < material.length; matCount++) { 7301 if (material[matCount]) { 7302 if (material[matCount].map) { 7303 texture = material[matCount].map; 7304 material[matCount].dispose(); 7305 texture.dispose(); 7306 } 7307 if (material[matCount].bumpMap) { 7308 texture = material[matCount].bumpMap; 7309 material[matCount].dispose(); 7310 texture.dispose(); 7311 } 7312 if (material[matCount].normalMap) { 7313 texture = material[matCount].normalMap; 7314 material[matCount].dispose(); 7315 texture.dispose(); 7316 } 7317 } 7318 material[matCount] = null; 7319 } 7320 } 7321 material = null; 7322 texture = null; 7323 }, 7324 /** 7325 * @param {Paper} object 7326 * @param image 7327 * @param faceNumber 7328 * @param mapType 7329 * @param callback 7330 * @returns {number|*} 7331 */ 7332 loadImage: function loadImage(object, image, faceNumber, mapType, callback) { 7333 if (image == null) { 7334 //get value 7335 var value = object.material[faceNumber] == null ? null : object.material[faceNumber][mapType] ? object.material[faceNumber][mapType].sourceFile : null; 7336 return value == null ? null : value.indexOf("data:image") > -1 ? null : value; 7337 } else { 7338 var _texture = null; 7339 if (image.nodeName === "CANVAS" || image.nodeName === "IMG") { 7340 _texture = new THREE.Texture(image); 7341 _texture.needsUpdate = true; 7342 MOCKUP.loadTexture(_texture, object, mapType, faceNumber); 7343 if (typeof callback === "function") callback(object, _texture); 7344 } else { 7345 if (image !== "blank") { 7346 _texture = image == null ? null : MOCKUP.textureLoader.load(image, 7347 // THREE.UVMapping, 7348 function textureOnLoad(texture) { 7349 texture.sourceFile = image; 7350 MOCKUP.loadTexture(texture, object, mapType, faceNumber); 7351 if (typeof callback === "function") callback(object, texture); 7352 }, void 0, 7353 //the other end expects explicitly void 0 7354 function textureOnError() { 7355 if (_texture.image == null) { 7356 MOCKUP.loadImage(object, MOCKUP.defaults.textureLoadFallback, faceNumber, mapType); 7357 } 7358 MOCKUP.loadTextureFailed(); 7359 }); 7360 if (_texture) _texture.mapping = THREE.UVMapping; 7361 } else { 7362 MOCKUP.loadTexture(null, object, mapType, faceNumber); 7363 if (typeof callback === "function") callback(object, _texture); 7364 } 7365 } 7366 return 0; 7367 } 7368 }, 7369 //load image to texture 7370 loadTexture: function loadTexture(texture, object, mapType, faceNumber) { 7371 if (texture) { 7372 var img = texture.image;
7373 texture.naturalWidth = img.naturalWidth; 7374 texture.naturalHeight = img.naturalHeight; 7375 texture.needsUpdate = true; 7376 if (object.textureRotation != void 0) { 7377 texture.rotation = THREE.MathUtils.degToRad(object.textureRotation); 7378 texture.center = object.textureCenter; 7379 } 7380 } 7381 if (texture !== null && mapType === "map") { 7382 texture.anisotropy = 0; 7383 if (MOCKUP.defaults.anisotropy > 0) texture.anisotropy = MOCKUP.defaults.anisotropy; 7384 if (THREE.skipPowerOfTwo === true) { 7385 texture.minFilter = THREE.LinearFilter; 7386 texture.magFilter = THREE.LinearFilter; 7387 } 7388 texture.name = new Date().toTimeString(); 7389 } 7390 MOCKUP.clearTexture(object.material[faceNumber][mapType]); 7391 object.material[faceNumber][mapType] = texture; 7392 if (mapType === "bumpMap") object.material[faceNumber].bumpScale = object.sheet.getBumpScale(faceNumber); 7393 // if (mapType === "normalMap") 7394 // object.material[faceNumber].normalScale = object.sheet.getBumpScale(faceNumber); 7395 7396 object.material[faceNumber].needsUpdate = true; 7397 }, 7398 //load image to texture 7399 loadTextureFailed: function loadTextureFailed() { 7400 //console.log("Failed to load texture:" + image); 7401 return null; 7402 }, 7403 clearTexture: function clearTexture(texture) { 7404 if (texture) { 7405 if (texture.image) { 7406 if (texture.image.nodeName === "CANVAS") { 7407 if (texture.image.remove) texture.image.remove(); 7408 delete texture.image; 7409 } 7410 } 7411 texture = flipbook_3d_utils.disposeObject(texture); 7412 } 7413 } 7414 }; 7415 THREE.skipPowerOfTwo = true; 7416 7417 /** 7418 * @typedef {Object} Paper 7419 * @property material 7420 */ 7421 var Paper = /*#__PURE__*/function (_THREE$Mesh) { 7422 flipbook_3d_inherits(Paper, _THREE$Mesh); 7423 var _super4 = flipbook_3d_createSuper(Paper); 7424 function Paper(options) { 7425 var _this4; 7426 flipbook_3d_classCallCheck(this, Paper); 7427 var width = options.width || MOCKUP.defaults.width, 7428 height = options.height || MOCKUP.defaults.height, 7429 color = options.color || MOCKUP.defaults.color, 7430 segments = options.segments || MOCKUP.defaults.segments, 7431 depth = options.depth || MOCKUP.defaults.depth; 7432 var _matParameters = { 7433 color: color, 7434 flatShading: false, 7435 //options.flatShading === void 0 ? true : options.flatShading, 7436 shininess: options.shininess || MOCKUP.defaults.shininess 7437 }; 7438 var _material = new THREE.MeshPhongMaterial(_matParameters); 7439 // _matParameters.flatShading = false; smooth-shading causes shadow in the middle of books - solved with extra vertex in updateAngle() 7440 var _materials = [_material, _material, _material, _material, new THREE.MeshPhongMaterial(_matParameters), new THREE.MeshPhongMaterial(_matParameters)]; 7441 _this4 = _super4.call(this, new THREE.BoxGeometry(width, height, depth, segments, 1, 1), _materials); 7442 _this4.material[5].transparent = true; 7443 _this4.material[4].transparent = true; 7444 _this4.baseType = "Paper"; 7445 _this4.type = "Paper"; 7446 _this4.castShadow = true; 7447 _this4.receiveShadow = true; 7448 options.parent3D.add(flipbook_3d_assertThisInitialized(_this4)); 7449 return _this4; 7450 } 7451 flipbook_3d_createClass(Paper, [{ 7452 key: "loadImage", 7453 value: function loadImage(texture, face, callback) { 7454 MOCKUP.loadImage(this, texture, face, "map", callback); 7455 } 7456 }, { 7457 key: "frontImage", 7458 value: function frontImage(texture, callback) { 7459 MOCKUP.loadImage(this, texture, MOCKUP.MATERIAL_FACE.FRONT, "map", callback); 7460 } 7461 }, { 7462 key: "backImage", 7463 value: function backImage(texture, callback) { 7464 MOCKUP.loadImage(this, texture, MOCKUP.MATERIAL_FACE.BACK, "map", callback); 7465 } 7466 }, { 7467 key: "loadBump", 7468 value: function loadBump(texture) { 7469 MOCKUP.loadImage(this, texture, MOCKUP.MATERIAL_FACE.FRONT, "bumpMap", null); 7470 MOCKUP.loadImage(this, texture, MOCKUP.MATERIAL_FACE.BACK, "bumpMap", null); 7471 } 7472 }, {
7473 key: "loadNormalMap", 7474 value: function loadNormalMap(texture, face) { 7475 if (face !== void 0) { 7476 MOCKUP.loadImage(this, texture, face, "normalMap", null); 7477 return; 7478 } 7479 MOCKUP.loadImage(this, texture, MOCKUP.MATERIAL_FACE.FRONT, "normalMap", null); 7480 MOCKUP.loadImage(this, texture, MOCKUP.MATERIAL_FACE.BACK, "normalMap", null); 7481 } 7482 }]); 7483 return Paper; 7484 }(THREE.Mesh); 7485 var Ground = /*#__PURE__*/function (_Paper) { 7486 flipbook_3d_inherits(Ground, _Paper); 7487 var _super5 = flipbook_3d_createSuper(Ground); 7488 function Ground(options) { 7489 var _this5; 7490 flipbook_3d_classCallCheck(this, Ground); 7491 _this5 = _super5.call(this, options); 7492 _this5.receiveShadow = true; 7493 _this5.frontImage(MOCKUP.defaults.groundTexture); 7494 _this5.backImage(MOCKUP.defaults.groundTexture); 7495 _this5.type = "Ground"; 7496 return _this5; 7497 } 7498 return flipbook_3d_createClass(Ground); 7499 }(Paper); 7500 var Stage = /*#__PURE__*/function (_THREE$Scene) { 7501 flipbook_3d_inherits(Stage, _THREE$Scene); 7502 var _super6 = flipbook_3d_createSuper(Stage); 7503 /** 7504 * @typedef {Object} StageParameters 7505 * @property {HTMLCanvasElement} canvas - The canvas element. 7506 * @property {Number} pixelRatio - Device PixelRatio 7507 * @property {Boolean} castShadow - If the elements will cast shadow 7508 */ 7509 /** 7510 * @param {{}} parameters 7511 */ 7512 function Stage(parameters) { 7513 var _this6; 7514 flipbook_3d_classCallCheck(this, Stage); 7515 _this6 = _super6.call(this); 7516 var stage = flipbook_3d_assertThisInitialized(_this6); 7517 //currently canvas is compulsory 7518 stage.canvas = parameters.canvas || document.createElement('canvas'); 7519 stage.canvas = jQuery(_this6.canvas); 7520 stage.camera = new THREE.PerspectiveCamera(20, stage.width / stage.height, 4, 50000); 7521 stage.renderer = new THREE.WebGLRenderer({ 7522 canvas: stage.canvas[0], 7523 antialias: true, 7524 alpha: true 7525 }); 7526 stage.renderer.setPixelRatio(parameters.pixelRatio); 7527 stage.renderer.setSize(stage.width, stage.height); 7528 stage.renderer.setClearColor(0xffffff, 0); 7529 7530 // let orbitControl = stage.orbitControl = new THREE.SimpleOrbitControls(stage.renderer, stage, stage.camera); 7531 7532 stage.renderer.shadowMap.enabled = true; 7533 stage.renderer.shadowMap.type = 1; 7534 stage.ground = new Ground({ 7535 color: 0xffffff, 7536 height: stage.camera.far / 10, 7537 width: stage.camera.far / 10, 7538 segments: 2, 7539 parent3D: stage 7540 }); 7541 stage.ambientLight = new THREE.AmbientLight(0x444444); 7542 stage.add(stage.ambientLight); 7543 var spotLight = stage.spotLight = new THREE.DirectionalLight(0xffffff, 0.25); 7544 spotLight.position.set(0, 1, 0); 7545 if (parameters.castShadow !== false) { 7546 spotLight.castShadow = true; 7547 spotLight.shadow.camera.near = 200; 7548 spotLight.shadow.camera.far = 2000; 7549 spotLight.shadow.camera.top = 1350; 7550 spotLight.shadow.camera.bottom = -1350; 7551 spotLight.shadow.camera.left = -1350; 7552 spotLight.shadow.camera.right = 1350; 7553 spotLight.shadow.radius = 2; 7554 spotLight.shadow.mapSize.width = 1024; 7555 spotLight.shadow.mapSize.height = 1024; 7556 } 7557 stage.add(spotLight); 7558 stage.animateCount = 0; 7559 stage.renderCount = 0; 7560 stage.camera.position.set(-300, 300, 300); 7561 stage.camera.lookAt(new THREE.Vector3(0, 0, 0)); 7562 // stage.orbitControl.center.set(0, 0, 0); 7563 // stage.orbitControl.update(); 7564 return _this6; 7565 } 7566 flipbook_3d_createClass(Stage, [{ 7567 key: "resizeCanvas", 7568 value: function resizeCanvas(width, height) { 7569 this.renderer.setSize(width, height); 7570 this.camera.aspect = width / height; 7571 this.camera.updateProjectionMatrix(); 7572 } 7573 }, { 7574 key: "render", 7575 value: function render() { 7576 this.animateCount++; 7577 this.renderer.render(this, this.camera); 7578 if (this.stats != null) this.stats.update(); 7579 } 7580 }, { 7581 key: "clearMaterials", 7582 value: function clearMaterials() { 7583 var totalChild = this.children.length; 7584 for (var count = totalChild - 1; count >= 0; count--) { 7585 var child = this.children[count]; 7586 if (child.baseType && child.baseType === "Paper") { 7587 if (child.material) { 7588 if (child.material.length) { 7589 for (var countMat = 0; countMat < child.material.length; countMat++) child.material[countMat].needsUpdate = true; 7590 } else { 7591 child.material.needsUpdate = true; 7592 } 7593 } 7594 } 7595 } 7596 } 7597 }, {
7598 key: "clearChild", 7599 value: function clearChild() { 7600 this.spotLight.shadow.map = flipbook_3d_utils.disposeObject(this.spotLight.shadow.map); 7601 this.spotLight.castShadow = false; 7602 this.clearMaterials(); 7603 var totalChild = this.children.length; 7604 for (var count = totalChild - 1; count >= 0; count--) { 7605 var child = this.children[count]; 7606 if (child.children && child.children.length > 0) { 7607 for (var stackCount = child.children.length - 1; stackCount >= 0; stackCount--) { 7608 MOCKUP.clearChild(child.children[stackCount]); 7609 } 7610 } 7611 MOCKUP.clearChild(child); 7612 child = null; 7613 } 7614 this.render(); 7615 } 7616 }]); 7617 return Stage; 7618 }(THREE.Scene); 7619 MOCKUP.Paper = Paper; 7620 MOCKUP.Stage = Stage; 7621 //endregion 7622 7623 //region CSS3DObject 7624 var CSS3DObject = /*#__PURE__*/function (_THREE$Object3D) { 7625 flipbook_3d_inherits(CSS3DObject, _THREE$Object3D); 7626 var _super7 = flipbook_3d_createSuper(CSS3DObject); 7627 function CSS3DObject(e) { 7628 var _this7; 7629 flipbook_3d_classCallCheck(this, CSS3DObject); 7630 _this7 = _super7.call(this); 7631 _this7.element = e; 7632 _this7.element.style.position = "absolute"; 7633 _this7.addEventListener("removed", function () { 7634 if (this.element.parentNode !== null) { 7635 this.element.parentNode.removeChild(this.element); 7636 } 7637 }); 7638 return _this7; 7639 } 7640 return flipbook_3d_createClass(CSS3DObject); 7641 }(THREE.Object3D); 7642 THREE.CSS3DObject = CSS3DObject; 7643 var CSS3DSprite = /*#__PURE__*/function (_THREE$CSS3DObject) { 7644 flipbook_3d_inherits(CSS3DSprite, _THREE$CSS3DObject); 7645 var _super8 = flipbook_3d_createSuper(CSS3DSprite); 7646 function CSS3DSprite(e) { 7647 flipbook_3d_classCallCheck(this, CSS3DSprite); 7648 return _super8.call(this, e); 7649 } 7650 return flipbook_3d_createClass(CSS3DSprite); 7651 }(THREE.CSS3DObject); 7652 THREE.CSS3DSprite = CSS3DSprite; 7653 if (THREE.MathUtils) THREE.Math = THREE.MathUtils; 7654 THREE.CSS3DRenderer = function () { 7655 flipbook_3d_utils.log("THREE.CSS3DRenderer", THREE.REVISION); 7656 var e, t; 7657 var r, i; 7658 var n = new THREE.Matrix4(); 7659 var a = { 7660 camera: { 7661 fov: 0, 7662 style: "" 7663 }, 7664 objects: {} 7665 }; 7666 var o = document.createElement("div"); 7667 o.style.overflow = "hidden"; 7668 o.style.WebkitTransformStyle = "preserve-3d"; 7669 o.style.MozTransformStyle = "preserve-3d"; 7670 o.style.oTransformStyle = "preserve-3d"; 7671 o.style.transformStyle = "preserve-3d"; 7672 this.domElement = o; 7673 var s = document.createElement("div"); 7674 s.style.WebkitTransformStyle = "preserve-3d"; 7675 s.style.MozTransformStyle = "preserve-3d"; 7676 s.style.oTransformStyle = "preserve-3d"; 7677 s.style.transformStyle = "preserve-3d"; 7678 o.appendChild(s); 7679 this.setClearColor = function () {}; 7680 this.getSize = function () { 7681 return { 7682 width: e, 7683 height: t 7684 }; 7685 }; 7686 this.setSize = function (n, a) { 7687 e = n; 7688 t = a; 7689 r = e / 2; 7690 i = t / 2; 7691 o.style.width = n + "px"; 7692 o.style.height = a + "px"; 7693 s.style.width = n + "px"; 7694 s.style.height = a + "px"; 7695 }; 7696 var h = function h(e) { 7697 return Math.abs(e) < Number.EPSILON ? 0 : e; 7698 }; 7699 var u = function u(e) { 7700 var t = e.elements; 7701 return "matrix3d(" + h(t[0]) + "," + h(-t[1]) + "," + h(t[2]) + "," + h(t[3]) + "," + h(t[4]) + "," + h(-t[5]) + "," + h(t[6]) + "," + h(t[7]
7701) + "," + h(t[8]) + "," + h(-t[9]) + "," + h(t[10]) + "," + h(t[11]) + "," + h(t[12]) + "," + h(-t[13]) + "," + h(t[14]) + "," + h(t[15]) + ")"; 7702 }; 7703 var c = function c(e) { 7704 var t = e.elements; 7705 return "translate3d(-50%,-50%,0) matrix3d(" + h(t[0]) + "," + h(t[1]) + "," + h(t[2]) + "," + h(t[3]) + "," + h(-t[4]) + "," + h(-t[5]) + "," + h(-t[6]) + "," + h(-t[7]) + "," + h(t[8]) + "," + h(t[9]) + "," + h(t[10]) + "," + h(t[11]) + "," + h(t[12]) + "," + h(t[13]) + "," + h(t[14]) + "," + h(t[15]) + ")"; 7706 }; 7707 var l = function l(e, t) { 7708 if (e instanceof THREE.CSS3DObject) { 7709 var _r; 7710 if (e instanceof THREE.CSS3DSprite) { 7711 n.copy(t.matrixWorldInverse); 7712 n.transpose(); 7713 n.copyPosition(e.matrixWorld); 7714 n.scale(e.scale); 7715 n.elements[3] = 0; 7716 n.elements[7] = 0; 7717 n.elements[11] = 0; 7718 n.elements[15] = 1; 7719 _r = c(n); 7720 } else { 7721 _r = c(e.matrixWorld); 7722 } 7723 var _i = e.element; 7724 var _o = a.objects[e.id]; 7725 if (_o === undefined || _o !== _r) { 7726 _i.style.WebkitTransform = _r; 7727 _i.style.MozTransform = _r; 7728 _i.style.oTransform = _r; 7729 _i.style.transform = _r; 7730 a.objects[e.id] = _r; 7731 } 7732 if (_i.parentNode !== s) { 7733 s.appendChild(_i); 7734 } 7735 } 7736 for (var _h = 0, _u = e.children.length; _h < _u; _h++) { 7737 l(e.children[_h], t); 7738 } 7739 }; 7740 this.render = function (e, n) { 7741 var h = .5 / Math.tan(THREE.Math.degToRad(n.fov * .5)) * t; 7742 if (a.camera.fov !== h) { 7743 o.style.WebkitPerspective = h + "px"; 7744 o.style.MozPerspective = h + "px"; 7745 o.style.oPerspective = h + "px"; 7746 o.style.perspective = h + "px"; 7747 a.camera.fov = h; 7748 } 7749 e.updateMatrixWorld(); 7750 if (n.parent === null) n.updateMatrixWorld(); 7751 if (n.matrixWorldInverse.invert) n.matrixWorldInverse.copy(n.matrixWorld).invert();else n.matrixWorldInverse.getInverse(n.matrixWorld); 7752 var c = "translate3d(0,0," + h + "px)" + u(n.matrixWorldInverse) + " translate3d(" + r + "px," + i + "px, 0)"; 7753 if (a.camera.style !== c) { 7754 s.style.WebkitTransform = c; 7755 s.style.MozTransform = c; 7756 s.style.oTransform = c; 7757 s.style.transform = c; 7758 a.camera.style = c; 7759 } 7760 l(e, n); 7761 }; 7762 }; 7763 //endregion 7764}; 7765 7766 7767;// CONCATENATED MODULE: ./src/js/dearviewer/viewers/viewer-pros.js 7768function viewer_pros_typeof(o) { "@babel/helpers - typeof"; return viewer_pros_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, viewer_pros_typeof(o); } 7769function viewer_pros_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 7770function viewer_pros_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, viewer_pros_toPropertyKey(descriptor.key), descriptor); } } 7771function viewer_pros_createClass(Constructor, protoProps, staticProps) { if (protoProps) viewer_pros_defineProperties(Constructor.prototype, protoProps); if (staticProps) viewer_pros_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 7772function viewer_pros_toPropertyKey(arg) { var key = viewer_pros_toPrimitive(arg, "string"); return viewer_pros_typeof(key) === "symbol" ? key : String(key); } 7773function viewer_pros_toPrimitive(input, hint) { if (viewer_pros_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (viewer_pros_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } 7774function viewer_pros_get() { if (typeof Reflect !== "undefined" && Reflect.get) { viewer_pros_get = Reflect.get.bind(); } else { viewer_pros_get = function _get(target, property, receiver) { var base = viewer_pros_superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return viewer_pros_get.apply(this, arguments); } 7775function viewer_pros_superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = viewer_pros_getPrototypeOf(object); if (object === null) break; } return object; } 7776function viewer_pros_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { c
7776onstructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) viewer_pros_setPrototypeOf(subClass, superClass); } 7777function viewer_pros_setPrototypeOf(o, p) { viewer_pros_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return viewer_pros_setPrototypeOf(o, p); } 7778function viewer_pros_createSuper(Derived) { var hasNativeReflectConstruct = viewer_pros_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = viewer_pros_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = viewer_pros_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return viewer_pros_possibleConstructorReturn(this, result); }; } 7779function viewer_pros_possibleConstructorReturn(self, call) { if (call && (viewer_pros_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return viewer_pros_assertThisInitialized(self); } 7780function viewer_pros_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 7781function viewer_pros_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } 7782function viewer_pros_getPrototypeOf(o) { viewer_pros_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return viewer_pros_getPrototypeOf(o); } 7783 7784 7785 7786 7787 7788 7789var viewer_pros_utils = defaults_DEARVIEWER.utils; 7790 7791//region Pinch To Zoom 7792 7793BaseViewer.prototype.pinchDown = function (event) { 7794 if (event.touches != null && event.touches.length == 2 && this.startTouches == null) { 7795 this.startTouches = viewer_pros_utils.getTouches(event); 7796 this.app.viewer.zoomCenter = viewer_pros_utils.getVectorAvg(viewer_pros_utils.getTouches(event, this.parentElement.offset())); 7797 this.lastScale = 1; 7798 } 7799}; 7800BaseViewer.prototype.pinchUp = function (event) { 7801 if (event.touches != null && event.touches.length < 2 && this.pinchZoomDirty == true) { 7802 this.app.viewer.lastScale = this.lastScale; 7803 this.app.container.removeClass("df-pinch-zoom"); 7804 this.updateTemporaryScale(true); 7805 this.app.zoom(); 7806 this.lastScale = null; 7807 this.app.viewer.canSwipe = false; 7808 this.pinchZoomDirty = false; 7809 this.app.viewer._pinchZoomLastScale = null; 7810 this.startTouches = null; 7811 } 7812}; 7813BaseViewer.prototype.pinchMove = function (event) { 7814 if (event.touches != null && event.touches.length == 2 && this.startTouches != null) { 7815 this.pinchZoomDirty = true; 7816 this.app.container.addClass("df-pinch-zoom"); 7817 var newScale = viewer_pros_utils.calculateScale(this.startTouches, viewer_pros_utils.getTouches(event)), 7818 scale = newScale / this.lastScale; 7819 this.lastScale = newScale; 7820 this.app.viewer.pinchZoomUpdateScale = viewer_pros_utils.limitAt(newScale, this.app.viewer.minZoom / this.app.zoomValue, this.app.viewer.maxZoom / this.app.zoomValue); 7821 if (this.app.viewer._pinchZoomLastScale != this.app.viewer.pinchZoomUpdateScale) { 7822 this.app.viewer.pinchZoomRequestStatus = defaults_DEARVIEWER.REQUEST_STATUS.ON; 7823 this.app.viewer._pinchZoomLastScale = this.app.viewer.pinchZoomUpdateScale; 7824 } 7825 event.preventDefault(); 7826 return; 7827 } 7828}; 7829 7830//endregion 7831var HybridFlipbook3D = /*#__PURE__*/function (_FlipBook3D) { 7832 viewer_pros_inherits(HybridFlipbook3D, _FlipBook3D); 7833 var _super = viewer_pros_createSuper(HybridFlipbook3D); 7834 function HybridFlipbook3D(options, appContext) { 7835 viewer_pros_classCallCheck(this, HybridFlipbook3D); 7836 options.flipbook3DTiltAngleUp = 0; 7837 options.flipbook3DTiltAngleLeft = 0; 7838 options.hasSpiral = false;
7839 if (options.cover3DType === defaults_DEARVIEWER.FLIPBOOK_COVER_TYPE.RIDGE || options.cover3DType === defaults_DEARVIEWER.FLIPBOOK_COVER_TYPE.BASIC) { 7840 options.cover3DType = defaults_DEARVIEWER.FLIPBOOK_COVER_TYPE.PLAIN; 7841 } 7842 return _super.call(this, options, appContext); 7843 } 7844 viewer_pros_createClass(HybridFlipbook3D, [{ 7845 key: "init", 7846 value: function init() { 7847 viewer_pros_get(viewer_pros_getPrototypeOf(HybridFlipbook3D.prototype), "init", this).call(this); 7848 this.texturePowerOfTwo = false; 7849 this.app.container.addClass("df-hybrid-viewer df-pending"); 7850 } 7851 }, { 7852 key: "getAnnotationElement", 7853 value: function getAnnotationElement(pageNumber) { 7854 var clean = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 7855 return this.zoomViewer.getAnnotationElement(pageNumber, clean); 7856 } 7857 }, { 7858 key: "getTextElement", 7859 value: function getTextElement(pageNumber) { 7860 var clean = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 7861 return this.zoomViewer.getTextElement(pageNumber, clean); 7862 } 7863 }, { 7864 key: "isAnimating", 7865 value: function isAnimating() { 7866 return this.isFlipping(); 7867 } 7868 }, { 7869 key: "onCenterStartAnimation", 7870 value: function onCenterStartAnimation(tween) { 7871 this.app.container.addClass("df-hide-zoomview"); 7872 } 7873 }, { 7874 key: "onCenterStopAnimation", 7875 value: function onCenterStopAnimation(tween) { 7876 this.finalizeCenterAnimation(); 7877 } 7878 }, { 7879 key: "onCenterCompleteAnimation", 7880 value: function onCenterCompleteAnimation(tween) { 7881 this.zoomViewer.updateCenter(); 7882 this.finalizeCenterAnimation(); 7883 } 7884 }, { 7885 key: "finalizeCenterAnimation", 7886 value: function finalizeCenterAnimation() { 7887 this.app.container.removeClass("df-hide-zoomview"); 7888 } 7889 }, { 7890 key: "afterFlip", 7891 value: function afterFlip() { 7892 var skip = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 7893 var viewer = this; 7894 if (this.isAnimating() !== true) { 7895 this.pagesReady(); 7896 this.updatePendingStatusClass(); 7897 this.updateZoomViewerTexture({ 7898 pageNumber: this.getBasePage() 7899 }); 7900 this.updateZoomViewerTexture({ 7901 pageNumber: this.getBasePage() + 1 7902 }); 7903 } 7904 } 7905 }, { 7906 key: "exchangeTexture", 7907 value: function exchangeTexture(from, to) { 7908 this.skipCenterAnimation = true; 7909 viewer_pros_get(viewer_pros_getPrototypeOf(HybridFlipbook3D.prototype), "exchangeTexture", this).call(this, from, to); 7910 this.updateZoomViewerTextContent({ 7911 pageNumber: this.getBasePage() 7912 }); 7913 this.updateZoomViewerTextContent({ 7914 pageNumber: this.getBasePage() + 1 7915 }); 7916 } 7917 }, { 7918 key: "updateZoomViewerTexture", 7919 value: function updateZoomViewerTexture(param) { 7920 var page = this.zoomViewer.getPageByNumber(param.pageNumber); 7921 if (page && page.textureStamp === "-1") { 7922 var set = this.zoomViewer.setPage({ 7923 pageNumber: page.pageNumber, 7924 texture: this.getPageByNumber(page.pageNumber).getTexture() 7925 }); 7926 if (set) { 7927 this.updateZoomViewerTextContent(param); 7928 } 7929 } 7930 } 7931 }, { 7932 key: "updateZoomViewerTextContent", 7933 value: function updateZoomViewerTextContent(param) { 7934 this.app.provider.processAnnotations(param.pageNumber, this.app.viewer.getAnnotationElement(param.pageNumber, true)); 7935 this.app.provider.processTextContent(param.pageNumber, this.app.viewer.getTextElement(param.pageNumber, true)); 7936 } 7937 }, { 7938 key: "textureLoadedCallback", 7939 value: function textureLoadedCallback(param) { 7940 this.app.renderRequestStart(); 7941 this.updateZoomViewerTexture(param); 7942 this.pagesReady(); 7943 } 7944 }]); 7945 return HybridFlipbook3D; 7946}(FlipBook3D); 7947var Calendar3D = /*#__PURE__*/function (_FlipBook3D2) { 7948 viewer_pros_inherits(Calendar3D, _FlipBook3D2); 7949 var _super2 = viewer_pros_createSuper(Calendar3D); 7950 function Calendar3D(options, appContext) { 7951 var _this; 7952 viewer_pros_classCallCheck(this, Calendar3D); 7953 _this = _super2.call(this, options, appContext); 7954 _this.orientation = 'vertical'; 7955 return _this; 7956 } 7957 return viewer_pros_createClass(Calendar3D); 7958}(FlipBook3D); 7959var FlipBook = /*#__PURE__*/viewer_pros_createClass(function FlipBook(options, appContext) { 7960 viewer_pros_classCallCheck(this, FlipBook); 7961 if (defaults_DEARVIEWER.utils.canSupport3D() == false || options.is3D === void 0) { 7962 options.is3D = false; //IE 11 7963 } 7964 7965 if (options.is3D === 'flat3D') { 7966 options.flexibility = 0; 7967 return new HybridFlipbook3D(options, appContext); 7968 } else if (options.is3D === 'calendar3D') { 7969 return new Calendar3D(options, appContext); 7970 } 7971 // else if (options.is3D === 'spiral3D') { 7972 // return new FlipBook3D(options, appContext); 7973 // } 7974 else if (viewer_pros_utils.isTrue(options.is3D)) { 7975 return new FlipBook3D(options, appContext); 7976 } else return new FlipBook2D(options, appContext); 7977}); 7978defaults_DEARVIEWER.viewers = defaults_DEARVIEWER.viewers || {}; 7979defaults_DEARVIEWER.viewers['flipbook'] = FlipBook; 7980defaults_DEARVIEWER.viewers['default'] = defaults_DEARVIEWER.viewers['reader'] = Reader; 7981defaults_DEARVIEWER.viewers['slider'] = Slider; 7982;
vendor: 6,305 bytes, lines 7982-8089
7982// CONCATENATED MODULE: ./src/js/dearviewer/utils/provider.js 7983function provider_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) provider_setPrototypeOf(subClass, superClass); } 7984function provider_setPrototypeOf(o, p) { provider_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return provider_setPrototypeOf(o, p); } 7985function provider_createSuper(Derived) { var hasNativeReflectConstruct = provider_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = provider_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = provider_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return provider_possibleConstructorReturn(this, result); }; } 7986function provider_possibleConstructorReturn(self, call) { if (call && (provider_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return provider_assertThisInitialized(self); } 7987function provider_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 7988function provider_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } 7989function provider_getPrototypeOf(o) { provider_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return provider_getPrototypeOf(o); } 7990function provider_typeof(o) { "@babel/helpers - typeof"; return provider_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, provider_typeof(o); } 7991function provider_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 7992function provider_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, provider_toPropertyKey(descriptor.key), descriptor); } } 7993function provider_createClass(Constructor, protoProps, staticProps) { if (protoProps) provider_defineProperties(Constructor.prototype, protoProps); if (staticProps) provider_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 7994function provider_toPropertyKey(arg) { var key = provider_toPrimitive(arg, "string"); return provider_typeof(key) === "symbol" ? key : String(key); } 7995function provider_toPrimitive(input, hint) { if (provider_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (provider_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } 7996/* globals requirejs, jQuery*/ 7997 7998var provider_utils = defaults_DEARVIEWER.utils; 7999 8000/** 8001 * @typedef {Object} PDFDocument 8002 * @property {Function} getPage - Gets the Page 8003 * @property {Function} numPages - Total number of pages 8004 * @property {Function} getPageIndex - Gets the Page Index 8005 * @property {Function} getOutline - Gets the Outline 8006 * @property {Function} getDestination - Gets the Destination 8007 */ 8008 8009/** 8010 * @typedef {Object} PDFPage 8011 * @property {Function} getViewport - Gets the Viewport 8012 * @property {Function} getAnnotations - Gets the Annotation 8013 */ 8014 8015//region Link Service 8016/** 8017 * Performs navigation functions inside PDF, such as opening specified page, 8018 * or destination. 8019 * @class 8020 */ 8021var PDFLinkService = /*#__PURE__*/function () { 8022 /** 8023 * @constructs PDFLinkService 8024 */ 8025 function PDFLinkService() { 8026 provider_classCallCheck(this, PDFLinkService); 8027 this.baseUrl = null; 8028 this.pdfDocument = null; 8029 this.pdfApp = null; 8030 this.pdfHistory = null; 8031 this.externalLinkRel = null; 8032 this.externalLinkEnabled = true; 8033 this._pagesRefCache = null; 8034 } 8035 provider_createClass(PDFLinkService, [{ 8036 key: "dispose", 8037 value: function dispose() { 8038 this.baseUrl = null; 8039 this.pdfDocument = null; 8040 this.pdfApp = null; 8041 this.pdfHistory = null; 8042 this._pagesRefCache = null; 8043 } 8044 }, { 8045 key: "setDocument", 8046 value: function setDocument(pdfDocument, baseUrl) { 8047 this.baseUrl = baseUrl; 8048 this.pdfDocument = pdfDocument; 8049 this._pagesRefCache = Object.create(null); 8050 } 8051 }, { 8052 key: "setViewer", 8053 value: function setViewer(pdfApp) { 8054 this.pdfApp = pdfApp; 8055 this.externalLinkTarget = pdfApp.options.linkTarget; 8056 } 8057 }, { 8058 key: "setHistory", 8059 value: function setHistory(pdfHistory) { 8060 this.pdfHistory = pdfHistory; 8061 } 8062 }, { 8063 key: "pagesCount", 8064 get: 8065 /** 8066 * @returns {number} 8067 */ 8068 function get() { 8069 return this.pdfDocument.numPages; 8070 } 8071 }, { 8072 key: "page", 8073 get: 8074 /** 8075 * @returns {number} 8076 */ 8077 function get() { 8078 return this.pdfApp.currentPageNumber; 8079 }, 8080 set: 8081 /** 8082 * @param {number} value 8083 */ 8084 function set(value) { 8085 this.pdfApp.gotoPage(value); 8086 } 8087 }, { 8088 key: "navigateTo", 8089 value: function navigateTo(dest) {
8090 //Deprecated in pdf.js 2.7.570 8091 this.goToDestination(dest); 8092 } 8093 8094 /** 8095 * Wrapper around the `addLinkAttributes`-function in the API. 8096 * @param {HTMLAnchorElement} link 8097 * @param {string} url 8098 * @param {boolean} [newWindow] 8099 */ 8100 }, { 8101 key: "addLinkAttributes", 8102 value: function addLinkAttributes(link, url) { 8103 var newWindow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 8104 /* pdfjsLib.addLinkAttributes(link, { 8105 url, 8106 target: this.externalLinkTarget, 8107 rel: this.externalLinkRel, 8108 enabled: this.externalLinkEnabled, 8109 });*/ 8110 8111 var target = this.externalLinkTarget, 8112 rel = this.externalLinkRel, 8113 enabled = this.externalLinkEnabled; 8114 if (!url || typeof url !== "string") { 8115 throw new Error('A valid "url" parameter must provided.'); 8116 } 8117 var urlNullRemoved = (0, provider_utils.removeNullCharacters)(url); 8118 if (enabled) { 8119 link.href = link.title = urlNullRemoved; 8120 } else { 8121 link.href = ""; 8122 link.title = "Disabled: ".concat(urlNullRemoved); 8123 link.onclick = function () { 8124 return false; 8125 }; 8126 } 8127 var targetStr = ""; 8128 switch (target) { 8129 case defaults_DEARVIEWER.LINK_TARGET.NONE: 8130 break; 8131 case defaults_DEARVIEWER.LINK_TARGET.SELF: 8132 targetStr = "_self"; 8133 break; 8134 case defaults_DEARVIEWER.LINK_TARGET.BLANK: 8135 targetStr = "_blank"; 8136 break; 8137 case defaults_DEARVIEWER.LINK_TARGET.PARENT: 8138 targetStr = "_parent"; 8139 break; 8140 case defaults_DEARVIEWER.LINK_TARGET.TOP: 8141 targetStr = "_top"; 8142 break; 8143 } 8144 link.target = targetStr; 8145 link.rel = typeof rel === "string" ? rel : "noopener noreferrer nofollow"; 8146 } 8147 8148 /** 8149 * @param dest - The PDF destination object. 8150 */ 8151 }, { 8152 key: "goToDestination", 8153 value: function goToDestination(dest) { 8154 var destString = ''; 8155 var self = this; 8156 var goToDestination = function goToDestination(destRef) { 8157 provider_utils.log("Requested: ", destRef); 8158 // dest array looks like that: <page-ref> </XYZ|FitXXX> <args..> 8159 var pageNumber = destRef instanceof Object ? self._pagesRefCache[destRef.num + ' ' + destRef.gen + ' R'] : destRef + 1; 8160 if (pageNumber) { 8161 pageNumber = self.pdfApp.viewer.getViewerPageNumber(pageNumber); 8162 if (pageNumber > self.pdfApp.pageCount) { 8163 pageNumber = self.pdfApp.pageCount; 8164 } 8165 provider_utils.log("Loading for:", destRef, " at page ", pageNumber); 8166 if (self.pdfApp.requestDestRefKey === destRef.num + ' ' + destRef.gen + ' R') { 8167 self.pdfApp.gotoPage(pageNumber); 8168 if (self.pdfHistory) { 8169 // Update the browsing history. 8170 self.pdfHistory.push({ 8171 dest: dest, 8172 hash: destString, 8173 page: pageNumber 8174 }); 8175 } 8176 } else { 8177 provider_utils.log("Expired Request for ", pageNumber, " with ", destRef); 8178 } 8179 } else { 8180 self.pdfApp.container.addClass('df-fetch-pdf'); 8181 self.pdfDocument.getPageIndex(destRef).then(function (pageIndex) { 8182 var pageNum = pageIndex + 1; 8183 var cacheKey = destRef.num + ' ' + destRef.gen + ' R'; 8184 self._pagesRefCache[cacheKey] = pageNum; 8185 goToDestination(destRef); 8186 }); 8187 } 8188 }; 8189 var destinationPromise; 8190 if (typeof dest === 'string') { 8191 destString = dest; 8192 destinationPromise = this.pdfDocument.getDestination(dest); 8193 } else { 8194 destinationPromise = Promise.resolve(dest); 8195 } 8196 destinationPromise.then(function (destination) { 8197 provider_utils.log("Started:", destination); 8198 dest = destination; 8199 if (!(destination instanceof Array)) { 8200 return; // invalid destination 8201 } 8202 8203 self.pdfApp.requestDestRefKey = destination[0].num + ' ' + destination[0].gen + ' R'; 8204 goToDestination(destination[0]); 8205 }); 8206 } 8207 }, { 8208 key: "customNavigateTo", 8209 value: 8210 /** 8211 * @param dest - The PDF destination object. 8212 */ 8213 function customNavigateTo(dest) { 8214 if (dest === '' || dest == null || dest === 'null') return; 8215 var pageNumber = null; 8216 if (!isNaN(Math.floor(dest))) { 8217 pageNumber = dest; 8218 } else if (typeof dest === 'string') { 8219 pageNumber = parseInt(dest.replace("#", ""), 10); 8220 if (isNaN(pageNumber)) { 8221 window.open(dest, this.pdfApp.options.linkTarget === defaults_DEARVIEWER.LINK_TARGET.SELF ? "_self" : "_blank"); 8222 return; 8223 } 8224 } 8225 if (pageNumber != null) this.pdfApp.gotoPage(pageNumber); 8226 } 8227 }, { 8228 key: "getDestinationHash", 8229 value: 8230 /** 8231 * @param dest - The PDF destination object. 8232 * @returns {string} The hyperlink to the PDF object. 8233 */ 8234 function getDestinationHash(dest) { 8235 if (typeof dest === 'string') { 8236 return this.getAnchorUrl('#' + escape(dest)); 8237 } 8238 if (dest instanceof Array) { 8239 var destRef = dest[0]; // see navigateTo method for dest format 8240 var pageNumber = destRef instanceof Object ? this._pagesRefCache[destRef.num + ' ' + destRef.gen + ' R']
8240: destRef + 1; 8241 if (pageNumber) { 8242 var pdfOpenParams = this.getAnchorUrl('#page=' + pageNumber); 8243 var destKind = dest[1]; 8244 if (provider_typeof(destKind) === 'object' && 'name' in destKind && destKind.name === 'XYZ') { 8245 var scale = dest[4] || this.pdfApp.pageScaleValue; 8246 var scaleNumber = parseFloat(scale); 8247 if (scaleNumber) { 8248 scale = scaleNumber * 100; 8249 } 8250 pdfOpenParams += '&zoom=' + scale; 8251 if (dest[2] || dest[3]) { 8252 pdfOpenParams += ',' + (dest[2] || 0) + ',' + (dest[3] || 0); 8253 } 8254 } 8255 return pdfOpenParams; 8256 } 8257 } 8258 return this.getAnchorUrl(''); 8259 } 8260 }, { 8261 key: "getCustomDestinationHash", 8262 value: 8263 /** 8264 * @param dest - The PDF destination object. 8265 * @returns {string} The hyperlink to the PDF object. 8266 */ 8267 function getCustomDestinationHash(dest) { 8268 //if (typeof dest === 'string') { 8269 return '#' + escape(dest); 8270 //} 8271 //return this.getAnchorUrl(''); 8272 } 8273 }, { 8274 key: "getAnchorUrl", 8275 value: 8276 /** 8277 * Prefix the full url on anchor links to make sure that links are resolved 8278 * relative to the current URL instead of the one defined in <base href>. 8279 * @param {String} anchor The anchor hash, including the #. 8280 * @returns {string} The hyperlink to the PDF object. 8281 */ 8282 function getAnchorUrl(anchor) { 8283 return (this.baseUrl || '') + anchor; 8284 } 8285 }, { 8286 key: "executeNamedAction", 8287 value: 8288 /** 8289 * @param {string} action 8290 */ 8291 function executeNamedAction(action) { 8292 // See PDF reference, table 8.45 - Named action 8293 switch (action) { 8294 case 'GoBack': 8295 if (this.pdfHistory) { 8296 this.pdfHistory.back(); 8297 } 8298 break; 8299 case 'GoForward': 8300 if (this.pdfHistory) { 8301 this.pdfHistory.forward(); 8302 } 8303 break; 8304 case 'NextPage': 8305 this.page++; 8306 break; 8307 case 'PrevPage': 8308 this.page--; 8309 break; 8310 case 'LastPage': 8311 this.page = this.pagesCount; 8312 break; 8313 case 'FirstPage': 8314 this.page = 1; 8315 break; 8316 default: 8317 break; 8318 // No action according to spec 8319 } 8320 8321 var event = document.createEvent('CustomEvent'); 8322 event.initCustomEvent('namedaction', true, true, { 8323 action: action 8324 }); 8325 this.pdfApp.container.dispatchEvent(event); 8326 } 8327 }, { 8328 key: "cachePageRef", 8329 value: 8330 // noinspection JSUnusedGlobalSymbols 8331 /** 8332 * @param {number} pageNum - page number. 8333 * @param {Object} pageRef - reference to the page. 8334 */ 8335 function cachePageRef(pageNum, pageRef) { 8336 var refStr = pageRef.num + ' ' + pageRef.gen + ' R'; 8337 this._pagesRefCache[refStr] = pageNum; 8338 } 8339 }]); 8340 return PDFLinkService; 8341}(); 8342var DocumentProvider = /*#__PURE__*/function () { 8343 function DocumentProvider(props, context) { 8344 provider_classCallCheck(this, DocumentProvider); 8345 this.props = props; 8346 this.app = context; 8347 this.textureCache = []; 8348 this.pageCount = 0; 8349 this.numPages = 0; 8350 this.outline = []; 8351 this.viewPorts = []; 8352 this.requestedPages = ''; 8353 this.requestIndex = 0; 8354 this.pagesToClean = []; 8355 this.defaultPage = undefined; 8356 this.pageSize = this.app.options.pageSize; 8357 this._page1Pass = false; 8358 this._page2Pass = false; 8359 this.pageLabels = void 0; 8360 this.textSearchLength = 0; 8361 this.textSearch = ""; 8362 this.textContent = []; 8363 this.textContentJoined = []; 8364 this.textOffset = []; 8365 this.autoLinkItemsCache = []; 8366 this.autoLinkHitsCache = []; 8367 this.searchHitItemsCache = []; 8368 this.searchHits = []; 8369 this.PDFLinkItemsCache = []; 8370 this.textPostion = []; 8371 } 8372 provider_createClass(DocumentProvider, [{ 8373 key: "finalize", 8374 value: function finalize() {} 8375 }, { 8376 key: "dispose", 8377 value: function dispose() {} 8378 }, { 8379 key: "softDispose", 8380 value: function softDispose() {} 8381 }, { 8382 key: "setCache",
8383 value: function setCache(index, src, cacheIndexSize) { 8384 var provider = this; 8385 var cacheIndex = cacheIndexSize; 8386 if (cacheIndexSize) { 8387 if (provider.textureCache[cacheIndex] === undefined) provider.textureCache[cacheIndex] = []; 8388 provider.textureCache[cacheIndex][index] = src; 8389 } 8390 } 8391 }, { 8392 key: "getCache", 8393 value: function getCache(index, textureIndex) { 8394 var provider = this; 8395 return provider.textureCache[textureIndex] === undefined ? undefined : provider.textureCache[textureIndex][index]; 8396 } 8397 }, { 8398 key: "_isValidPage", 8399 value: function _isValidPage(pageNumber) { 8400 return pageNumber > 0 && pageNumber <= this.pageCount; 8401 } 8402 }, { 8403 key: "getLabelforPage", 8404 value: function getLabelforPage(pageNumber) { 8405 if (this.pageLabels && this.pageLabels[pageNumber - 1] !== void 0) return this.pageLabels[pageNumber - 1]; 8406 return pageNumber; 8407 } 8408 }, { 8409 key: "getThumbLabel", 8410 value: function getThumbLabel(pageNumber) { 8411 var label = this.getLabelforPage(pageNumber); 8412 if (label !== pageNumber) { 8413 return label + " (" + pageNumber + ")"; 8414 } 8415 return pageNumber; 8416 } 8417 }, { 8418 key: "getPageNumberForLabel", 8419 value: function getPageNumberForLabel(label) { 8420 if (!this.pageLabels) { 8421 return label; 8422 } 8423 var i = this.pageLabels.indexOf(label); 8424 if (i < 0) { 8425 return null; 8426 } 8427 return i + 1; 8428 } 8429 }, { 8430 key: "processPage", 8431 value: function processPage(param) {} 8432 }, { 8433 key: "cleanUpPages", 8434 value: function cleanUpPages() {} 8435 }, { 8436 key: "checkRequestQueue", 8437 value: function checkRequestQueue() {} 8438 }, { 8439 key: "processAnnotations", 8440 value: function processAnnotations() {} 8441 }, { 8442 key: "processTextContent", 8443 value: function processTextContent() {} 8444 }, { 8445 key: "loadDocument", 8446 value: function loadDocument() {} 8447 }, { 8448 key: "pagesLoaded", 8449 value: function pagesLoaded() { 8450 var provider = this; 8451 if (provider._page1Pass && provider._page2Pass) { 8452 provider.app.viewer.checkDocumentPageSizes(); 8453 provider.finalize(); 8454 } 8455 } 8456 }, { 8457 key: "_documentLoaded", 8458 value: function _documentLoaded() { 8459 this.finalizeOutLine(); 8460 //checks so that new providers fulfill all the required steps 8461 if (this.app && this.app.dimensions && this.app.dimensions.pageFit === undefined) provider_utils.log("Provider needs to initialize page properties for the app"); 8462 this.app._documentLoaded(); 8463 } 8464 }, { 8465 key: "finalizeOutLine", 8466 value: function finalizeOutLine() { 8467 if (this.app === null || this.app.options === null) return; 8468 var outline = this.app.options.outline, 8469 provider = this; 8470 if (outline) { 8471 for (var count = 0; count < outline.length; count++) { 8472 outline[count].custom = true; 8473 provider.outline.push(outline[count]); 8474 } 8475 } 8476 } 8477 }, { 8478 key: "search", 8479 value: function search() {} 8480 }]); 8481 return DocumentProvider; 8482}(); 8483var PDFDocumentProvider = /*#__PURE__*/function (_DocumentProvider) { 8484 provider_inherits(PDFDocumentProvider, _DocumentProvider); 8485 var _super = provider_createSuper(PDFDocumentProvider); 8486 function PDFDocumentProvider(props, context) { 8487 var _this; 8488 provider_classCallCheck(this, PDFDocumentProvider); 8489 _this = _super.call(this, props, context); 8490 var app = _this.app, 8491 provider = provider_assertThisInitialized(_this); 8492 provider.pdfDocument = undefined; 8493 provider._page2Ratio = undefined; 8494 function getPDFScript(callback) { 8495 if (typeof pdfjsLib === "undefined") { 8496 app.updateInfo(app.options.text.loading + " PDF Service ..."); 8497 provider_utils.getScript(app.options.pdfjsSrc + "?ver=" + defaults_DEARVIEWER.version, function () { 8498 if (typeof define === 'function' && __webpack_require__.amdO && window.requirejs) { 8499 app.updateInfo(app.options.text.loading + " PDF Service (require) ..."); 8500 window.require.config({ 8501 paths: { 8502 'pdfjs-dist/build/pdf.worker': app.options.pdfjsWorkerSrc.replace(".js", "") 8503 } 8504 }); 8505 window.require(['pdfjs-dist/build/pdf'], function (pdfjsLib) { 8506 window.pdfjsLib = pdfjsLib; 8507 getWorkerScript(callback); 8508 }); 8509 } else { 8510 getWorkerScript(callback); 8511 } 8512 }, function () { 8513 app.updateInfo("Unable to load PDF service.."); 8514 provider.dispose(); 8515 }); 8516 } else { 8517 if (typeof callback === "function") callback(); 8518 } 8519 } 8520 function getWorkerScript(callback) { 8521 app.options.pdfjsWorkerSrc += "?ver=" + defaults_DEARVIEWER.version; 8522 app.updateInfo(app.options.text.loading + " PDF Worker ..."); 8523 var tmp = document.createElement('a'); 8524 tmp.href = app.options.pdfjsWorkerSrc; 8525 if (tmp.hostname !== window.location.hostname && defaults_DEARVIEWER['loadCorsPdfjsWorker'] === true) { 8526 app.updateInfo(app.options.text.loading + " PDF Worker CORS ..."); 8527 jQuery.ajax({ 8528 url: app.options.pdfjsWorkerSrc, 8529 cache: true, 8530 success: function success(data) { 8531 app.options.pdfjsWorkerSrc = provider_utils.createObjectURL(data, "text/javascript"); 8532 if (typeof callback === "function") callback(); 8533 } 8534 }); 8535 } else { 8536 if (typeof callback === "function") callback(); 8537 } 8538 } 8539 getPDFScript(function () { 8540 pdfjsLib.GlobalWorkerOptions.workerSrc = app.options.pdfjsWorkerSrc; 8541 pdfjsLib.canvasWillReadFrequently = defaults_DEARVIEWER.defaults.canvasWillReadFrequently; 8542 provider.loadDocument(); 8543 }); 8544 return _this; 8545 } 8546 provider_createClass(PDFDocumentProvider, [{ 8547 key: "dispose", 8548 value: function dispose() { 8549 if (this.pdfDocument) this.pdfDocument.destroy(); 8550 this.linkService = provider_utils.disposeObject(this.linkService); 8551 if (this.pdfLoadProgress) this.pdfLoadProgress.destroy(); 8552 this.pdfLoadProgress = null; 8553 this.pdfDocument = null; 8554 } 8555 }, { 8556 key: "loadDocument", 8557 value: function loadDocument() { 8558 var app = this.app, 8559 options = this.app.options, 8560 provider = this; 8561 var parameters = options.pdfParameters || {}; 8562 parameters.url = provider_utils.httpsCorrection(parameters.url || options.source); 8563 parameters.rangeChunkSize = options.rangeChunkSize; 8564 parameters.cMapPacked = true; 8565 parameters.disableAutoFetch = options.disableAutoFetch; 8566 parameters.disableStream = options.disableStream; 8567 parameters.disableRange = options.disableRange === true; 8568 parameters.disableFontFace = options.disableFontFace; 8569 parameters.cMapUrl = options.cMapUrl; 8570 parameters.imagesLocation = options.imagesLocation; 8571 parameters.imageResourcesPath = options.imageResourcesPath; 8572 8573 //region Loading Document 8574 if (!parameters.url && !parameters.data && !parameters.range) { 8575 //Display No PDF file found error 8576 app.updateInfo("ERROR : No PDF File provided! ", "df-error"); 8577 return; 8578 } 8579 // app.updateInfo(app.options.text.loading + " PDF ..."); 8580 var pdfLoadProcess = provider.pdfLoadProgress = pdfjsLib.getDocument(parameters); 8581 pdfLoadProcess._worker.promise.then(function (a) { 8582 app.updateInfo(app.options.text.loading + " PDF ..."); 8583 }); 8584 pdfLoadProcess.promise.then( 8585 /** 8586 * @constructs pdfLoaded 8587 * @param {PDFDocument} pdf 8588 */ 8589 function pdfLoaded(pdf) { 8590 provider.pdfDocument = pdf; 8591 pdf.getPage(1).then(function (page) { 8592 var _options$maxTextureSi; 8593 //set defaultPage details 8594 provider.defaultPage = page; 8595 var _defaultViewPort = provider.defaultPage.viewPort = page.getViewport({ 8596 scale: 1, 8597 rotation: page._pageInfo.rotate + app.options.pageRotation 8598 }); 8599 var _defaultPageRatio = provider.defaultPage.pageRatio = _defaultViewPort.width / _defaultViewPort.height; 8600 var _isDefaultPageWide = _defaultPageRatio > 1; 8601 provider.viewPorts[1] = _defaultViewPort; 8602 app.dimensions.defaultPage = { 8603 ratio: _defaultPageRatio, 8604 viewPort: _defaultViewPort, 8605 width: _defaultViewPort.width, 8606 height: _defaultViewPort.height 8607 }; 8608 app.dimensions.maxTextureHeight = ((_options$maxTextureSi = options.maxTextureSize) !== null && _options$maxTextureSi !== void 0 ? _options$maxTextureSi : 4096) / (!_isDefaultPageWide ? 1 : _defaultPageRatio); 8609 app.dimensions.maxTextureWidth = app.dimensions.maxTextureHeight * _defaultPageRatio; 8610 app.dimensions.autoHeightRatio = 1 / _defaultPageRatio;
8611 provider.pageCount = pdf.numPages; 8612 provider.numPages = pdf.numPages; 8613 provider._page1Pass = true; 8614 provider.pagesLoaded(); 8615 }); 8616 8617 //check if internal pages are of double sizes. 8618 if (pdf.numPages > 1 && app.checkSecondPage === true) { 8619 /** 8620 * @constructs checkInternalPages 8621 * @param {PDFPageProxy} page 8622 */ 8623 pdf.getPage(2).then(function checkInternalPages(page) { 8624 var _page2ViewPort = page.getViewport({ 8625 scale: 1, 8626 rotation: page._pageInfo.rotate + app.options.pageRotation 8627 }); 8628 provider._page2Ratio = _page2ViewPort.width / _page2ViewPort.height; 8629 provider.viewPorts[2] = _page2ViewPort; 8630 provider._page2Pass = true; 8631 provider.pagesLoaded(); 8632 }); 8633 } else { 8634 provider._page2Pass = true; 8635 provider.pagesLoaded(); 8636 } 8637 })["catch"](function (error) { 8638 if (app !== null && app.options != null) { 8639 var _app$options; 8640 //Find errors condition 8641 var cors = "", 8642 _a = document.createElement('a'); 8643 _a.href = app.options.source; 8644 if (_a.hostname !== window.location.hostname && _a.href.indexOf("file://") === -1 && !provider_utils.isChromeExtension() && _a.href.indexOf("blob:") === -1) cors = "<strong>CROSS ORIGIN!! </strong>"; 8645 var fileName = ((_app$options = app.options) === null || _app$options === void 0 ? void 0 : _app$options.fileName) || _a.href; 8646 //Display error reason 8647 app.updateInfo(cors + "<strong>Error: Cannot access file! </strong>" + unescape(fileName) + "<br><br>" + error.message, "df-error"); 8648 console.log(error); 8649 app.container.removeClass('df-loading').addClass("df-error"); 8650 provider.dispose(); 8651 } 8652 }); 8653 pdfLoadProcess.getTotalLength = function () { 8654 return provider.pdfLoadProgress._transport._networkStream._fullRequestReader.contentLength; 8655 }; 8656 pdfLoadProcess.onProgress = function getDocumentProgress(progressData) { 8657 if (app !== null) { 8658 var percentage = 100 * progressData.loaded / pdfLoadProcess.getTotalLength(); 8659 if (isNaN(percentage)) { 8660 //in case divided by zero/undefined -- don't have total value 8661 if (progressData && progressData.loaded) { 8662 // skip loading value if the differnces is less than 250kb, 8663 // not required in percentage since percentage only updates in partial load chunk completion 8664 if (pdfLoadProcess.lastLoaded === void 0 || pdfLoadProcess.lastLoaded + 250000 < progressData.loaded) { 8665 pdfLoadProcess.lastLoaded = progressData.loaded; 8666 app.updateInfo(app.options.text.loading + " PDF " + (Math.ceil(progressData.loaded / 10000) / 100).toFixed(2).toString() + "MB ..."); 8667 } 8668 } else { 8669 app.updateInfo(app.options.text.loading + " PDF ..."); 8670 } 8671 } else { 8672 app.updateInfo(app.options.text.loading + " PDF " + Math.ceil(Math.min(100, percentage)).toString().split(".")[0] + "% ..."); 8673 } 8674 } 8675 }; 8676 //endregion 8677 } 8678 }, { 8679 key: "pdfFetchStarted", 8680 value: function pdfFetchStarted() { 8681 this.pdfFetchStatusCount = 0; 8682 this.app.container.addClass('df-fetch-pdf'); 8683 this.pdfFetchStatus = defaults_DEARVIEWER.REQUEST_STATUS.COUNT; 8684 } 8685 }, { 8686 key: "checkRequestQueue", 8687 value: function checkRequestQueue() { 8688 return; 8689 var REQUEST_STATUS = defaults_DEARVIEWER.REQUEST_STATUS; 8690 if (this.pdfFetchStatus === REQUEST_STATUS.ON) { 8691 this.app.container.removeClass('df-fetch-pdf'); 8692 this.pdfFetchStatus = REQUEST_STATUS.OFF; 8693 } else if (this.pdfFetchStatus === REQUEST_STATUS.COUNT) { 8694 this.pdfFetchStatusCount++; 8695 if (this.pdfFetchStatusCount > 30) { 8696 this.pdfFetchStatusCount = 0; 8697 this.pdfFetchStatus = REQUEST_STATUS.ON; 8698 } 8699 } 8700 } 8701 }, { 8702 key: "finalize", 8703 value: function finalize() { 8704 var app = this.app, 8705 provider = this; 8706 if (app === null || app.options === null) return; 8707 provider.linkService = new PDFLinkService(); 8708 provider.linkService.setDocument(provider.pdfDocument, null); 8709 provider.linkService.setViewer(app); 8710 provider.pdfDocument.getOutline().then(function (pdfOutline) { 8711 if (app.options.overwritePDFOutline === true) { 8712 pdfOutline = []; 8713 } 8714 pdfOutline = pdfOutline || []; 8715 provider.outline = pdfOutline; 8716 provider.pdfDocument.getPageLabels().then(function (pageLabels) { 8717 if (!pageLabels || app.options.disablePageLabels === true) { 8718 return; 8719 } 8720 var numLabels = pageLabels.length; 8721 // Ignore page labels that correspond to standard page numbering, 8722 // or page labels that are all empty. 8723 var standardLabels = 0, 8724 emptyLabels = 0; 8725 for (var i = 0; i < numLabels; i++) { 8726 var label = pageLabels[i]; 8727 if (label === (i + 1).toString()) { 8728 standardLabels++; 8729 } else if (label === "") { 8730 emptyLabels++; 8731 } else { 8732 break; 8733 } 8734 } 8735 if (standardLabels >= numLabels || emptyLabels >= numLabels) { 8736 return; 8737 } 8738 provider.pageLabels = pageLabels; 8739 })["finally"](function () { 8740 provider._documentLoaded(); 8741 }); 8742 }); 8743 } 8744 }, { 8745 key: "processPage", 8746 value: function processPage(param) { 8747 var app = this.app, 8748 provider = this, 8749 pageNumber = param.pageNumber, 8750 startTime = performance.now(); 8751 8752 //region determine page to render 8753 var pdfPageNumberToRender = app.viewer.getDocumentPageNumber(pageNumber); 8754 8755 //endregion 8756 provider_utils.log("Requesting PDF Page:" + pdfPageNumberToRender); 8757 provider.pdfDocument.getPage(pdfPageNumberToRender).then(function (pdfPage) { 8758 if (!provider.viewPorts[pageNumber]) { 8759 param.isFreshPage = true; 8760 provider.viewPorts[pageNumber] = pdfPage.getViewport({ 8761 scale: 1, 8762 rotation: pdfPage._pageInfo.rotate + app.options.pageRotation 8763 }); 8764 } 8765 //region Render the Page 8766 8767 var renderContext = app.viewer.getRenderContext(pdfPage, param); 8768 if (param.isFreshPage) { 8769 var _app$viewer$getPageBy; 8770 (_app$viewer$getPageBy = app.viewer.getPageByNumber(param.pageNumber)) === null || _app$viewer$getPageBy === void 0 || _app$viewer$getPageBy.changeTexture(param.pageNumber, renderContext.canvas.height); 8771 } 8772 provider_utils.log("Page " + pageNumber + " rendering - " + renderContext.canvas.width + "x" + renderContext.canvas.height); 8773 param.trace = provider.requestIndex++; 8774 provider.requestedPages += "," + param.trace + "[" + pdfPageNumberToRender + "|" + renderContext.canvas.height + "]"; 8775 pdfPage.cleanupAfterRender = false; //needs to disable the cleanup after render code in pdf.js 8776 var pageRendering = pdfPage.render(renderContext); 8777 pageRendering.promise.then(function () { 8778 app.applyTexture(renderContext.canvas, param); 8779 if (app.options.cleanupAfterRender === true) { 8780 var checkString = "," + param.trace + "[" + pdfPageNumberToRender + "|" + renderContext.canvas.height + "]"; 8781 provider_utils.log("CleanUp Requesting for (" + pageNumber + ") actual " + pdfPageNumberToRender); 8782 if (provider.requestedPages.indexOf(checkString) > -1) { 8783 provider.requestedPages = provider.requestedPages.replace(checkString, ""); 8784 if (provider.requestedPages.indexOf("[" + pdfPageNumberToRender + "|") == -1) { 8785 provider_utils.log("CleanUp Passed for (" + pageNumber + ") actual " + pdfPageNumberToRender); 8786 provider.pagesToClean.push(pdfPage); 8787 if (provider.pagesToClean.length > 0) provider.cleanUpPages(); 8788 } else { 8789 provider_utils.log("CleanUp Cancelled waiting for (" + pageNumber + ") actual " + pdfPageNumberToRender + " : " + provider.requestedPages); 8790 } 8791 } 8792 } 8793 renderContext = null; 8794 provider_utils.log("Rendered " + pageNumber + " in " + (performance.now() - startTime) + " milliseconds"); 8795 })["catch"](function (error) { 8796 console.log(error); 8797 }); 8798 //endregion 8799 })["catch"](function (error) { 8800 console.log(error); 8801 }); 8802 } 8803 }, { 8804 key: "cleanUpPages", 8805 value: function cleanUpPages() { 8806 while (this.pagesToClean.length > 0) { 8807 var page = this.pagesToClean.splice(-1)[0]; 8808 provider_utils.log("Cleanup Completed for PDF page: " + (page._pageIndex + 1)); 8809 page.cleanup(); 8810 } 8811 } 8812 }, { 8813 key: "clearSearch", 8814 value: function clearSearch() { 8815 var provider = this; 8816 provider.searchHits = []; 8817 provider.searchHitItemsCache = []; 8818 provider.totalHits = 0; 8819 provider.app.searchResults.html(""); 8820 provider.app.container.removeClass("df-search-open"); 8821 provider.textSearch = ""; 8822 provider.app.container.find(".df-search-hits").remove(); 8823 } 8824 }, { 8825 key: "search", 8826 value: function search(text) { 8827 var provider = this; 8828 if (provider.textSearch === text) return; 8829 provider.clearSearch(); 8830 if (text.length < 3 && text != "") { 8831 provider.app.updateSearchInfo("Minimum 3 letters required."); 8832 return; 8833 } 8834 provider.textSearch = text; 8835 provider.textSearchLength = text.length; 8836 provider.app.searchContainer.addClass("df-searching"); 8837 provider.app.container.addClass('df-fetch-pdf'); 8838 provider._search(text, 1); 8839 } 8840 }, { 8841 key: "_search", 8842 value: function _search(text) { 8843 var pageNumber = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; 8844 var provider = this; 8845 provider.app.updateSearchInfo("Searching Page: " + pageNumber); 8846 provider.searchPage(pageNumber).then(function (textContent) { 8847 // console.log(textContent); 8848 var searchString = textContent, 8849 pos = 0, 8850 myRegexp = new RegExp(text, 'gi'), 8851 result; 8852 var hits = []; 8853 while (result = myRegexp.exec(searchString)) { 8854 hits.push({ 8855 index: result.index, 8856 length: provider.textSearchLength 8857 }); 8858 } 8859 provider.searchHits[pageNumber] = hits; 8860 if (hits.length > 0) { 8861 var searchPage = provider.app.viewer.searchPage(pageNumber); 8862 if (searchPage.include === true) { 8863 provider.totalHits += hits.length; 8864 provider.app.searchResults.append('<div class="df-search-result ' + (provider.app.currentPageNumber === pageNumber ? 'df-active' : '') + '" data-page="' + pageNumber + '">' + '<span>Page ' + searchPage.label + '</span><span>' + hits.length + ' ' + (hits.length > 1 ? 'results' : 'result') + '</span></div>'); 8865 } 8866 } 8867 if (provider.app.viewer.isActivePage(pageNumber)) { 8868 provider.processTextContent(pageNumber, provider.app.viewer.getTextElement(pageNumber, true)); 8869 provider.app.ui.update(); 8870 } 8871 provider._search(text, pageNumber + 1); 8872 })["catch"](function () {})["finally"](function () { 8873 if (provider.totalHits == 0) { 8874 provider.app.updateSearchInfo("No results Found!"); 8875 } else { 8876 provider.app.updateSearchInfo(provider.totalHits + " results found"); 8877 } 8878 provider.app.searchContainer.removeClass("df-searching"); 8879 provider.app.container.removeClass('df-fetch-pdf'); 8880 }); 8881 } 8882 }, { 8883 key: "prepareTextContent", 8884 value: function prepareTextContent(textContent, pageNumbertoSearch) { 8885 var rePrepare = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
8886 var provider = this; 8887 if (provider.textContentJoined[pageNumbertoSearch] == void 0 || rePrepare) { 8888 var provider = this; 8889 provider.textContent[pageNumbertoSearch] = textContent.items.map(function (item) { 8890 if (item.hasEOL == false) return item.str; 8891 return item.str + " "; 8892 }); 8893 var p = 0, 8894 len = 0; 8895 provider.textOffset[pageNumbertoSearch] = textContent.items.map(function (item, index) { 8896 len = (item.str.length || 0) + (item.hasEOL == false ? 0 : 1); 8897 p += len; 8898 return { 8899 length: len, 8900 offset: p - len 8901 }; 8902 }); 8903 provider.textContentJoined[pageNumbertoSearch] = provider.textContent[pageNumbertoSearch].join(""); 8904 } 8905 } 8906 }, { 8907 key: "searchPage", 8908 value: function searchPage(pageNumber) { 8909 var provider = this; 8910 return new Promise(function (resolve, reject) { 8911 if (!provider._isValidPage(pageNumber)) { 8912 reject(); 8913 } else { 8914 try { 8915 var pageNumbertoSearch = provider.app.viewer.getDocumentPageNumber(pageNumber); 8916 if (provider.textContentJoined[pageNumbertoSearch] == void 0) { 8917 provider.pdfDocument.getPage(pageNumbertoSearch).then(function (page) { 8918 page.getTextContent().then(function (textContent) { 8919 provider.prepareTextContent(textContent, pageNumbertoSearch); 8920 resolve(provider.textContentJoined[pageNumbertoSearch]); 8921 }); 8922 }); 8923 } else { 8924 resolve(provider.textContentJoined[pageNumbertoSearch]); 8925 } 8926 } catch (error) { 8927 provider_utils.log(error); 8928 reject(error); 8929 } 8930 } 8931 }); 8932 } 8933 }]); 8934 return PDFDocumentProvider; 8935}(DocumentProvider); 8936defaults_DEARVIEWER.providers['pdf'] = PDFDocumentProvider; 8937 8938;// CONCATENATED MODULE: ./src/js/dearviewer/utils/image-provider.js 8939function image_provider_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) image_provider_setPrototypeOf(subClass, superClass); } 8940function image_provider_setPrototypeOf(o, p) { image_provider_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return image_provider_setPrototypeOf(o, p); } 8941function image_provider_createSuper(Derived) { var hasNativeReflectConstruct = image_provider_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = image_provider_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = image_provider_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return image_provider_possibleConstructorReturn(this, result); }; } 8942function image_provider_possibleConstructorReturn(self, call) { if (call && (image_provider_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return image_provider_assertThisInitialized(self); } 8943function image_provider_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 8944function image_provider_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } 8945function image_provider_getPrototypeOf(o) { image_provider_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o
8945) { return o.__proto__ || Object.getPrototypeOf(o); }; return image_provider_getPrototypeOf(o); } 8946function image_provider_typeof(o) { "@babel/helpers - typeof"; return image_provider_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, image_provider_typeof(o); } 8947function image_provider_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 8948function image_provider_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, image_provider_toPropertyKey(descriptor.key), descriptor); } } 8949function image_provider_createClass(Constructor, protoProps, staticProps) { if (protoProps) image_provider_defineProperties(Constructor.prototype, protoProps); if (staticProps) image_provider_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 8950function image_provider_toPropertyKey(arg) { var key = image_provider_toPrimitive(arg, "string"); return image_provider_typeof(key) === "symbol" ? key : String(key); } 8951function image_provider_toPrimitive(input, hint) { if (image_provider_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (image_provider_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } 8952 8953 8954var image_provider_utils = defaults_DEARVIEWER.utils; 8955var ImagePage = /*#__PURE__*/function () { 8956 function ImagePage(props) { 8957 image_provider_classCallCheck(this, ImagePage); 8958 this._viewPort = new Viewport(0, 0); 8959 this._pageInfo = { 8960 rotate: 0 8961 }; 8962 this.src = props.src; 8963 } 8964 image_provider_createClass(ImagePage, [{ 8965 key: "getViewport", 8966 value: function getViewport() { 8967 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { 8968 scale: 1 8969 }; 8970 return new Viewport(this._viewPort.height * params.scale, this._viewPort.width * params.scale, params.scale); 8971 } 8972 }]); 8973 return ImagePage; 8974}(); 8975var ImageDocument = /*#__PURE__*/function () { 8976 function ImageDocument(source) { 8977 image_provider_classCallCheck(this, ImageDocument); 8978 this.source = []; 8979 this.pages = []; 8980 this.numPages = source.length; 8981 for (var _correct = 0; _correct < source.length; _correct++) { 8982 this.source[_correct] = image_provider_utils.httpsCorrection(source[_correct].toString()); 8983 this.pages.push(new ImagePage({ 8984 src: this.source[_correct] 8985 })); 8986 } 8987 } 8988 image_provider_createClass(ImageDocument, [{ 8989 key: "getPage", 8990 value: function getPage(pageNumber) { 8991 var provider = this; 8992 return new Promise(function (resolve, reject) { 8993 try { 8994 jQuery("<img/>").attr("src", provider.source[pageNumber - 1]).prop("crossOrigin", "Anonymous").on('load', function () { 8995 jQuery(this).off(); 8996 var page = new ImagePage({ 8997 src: this.src 8998 }); 8999 page._viewPort.height = this.height; 9000 page._viewPort.width = this.width; 9001 page._viewPort.scale = 1; 9002 page.image = this; 9003 resolve(page); 9004 }); 9005 } catch (error) { 9006 reject(error); 9007 } 9008 }); 9009 } 9010 }]); 9011 return ImageDocument; 9012}(); 9013var Viewport = /*#__PURE__*/function () { 9014 function Viewport(height, width) { 9015 var scale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; 9016 image_provider_classCallCheck(this, Viewport); 9017 this.scale = scale; 9018 this.height = height; 9019 this.width = width; 9020 this.scale = scale; 9021 this.transform = [0, 0, 0, 0, 0, this.height]; 9022 } 9023 image_provider_createClass(Viewport, [{ 9024 key: "clone", 9025 value: function clone() { 9026 return new Viewport(this.height, this.width, this.scale); 9027 } 9028 }]); 9029 return Viewport; 9030}(); 9031var ImageDocumentProvider = /*#__PURE__*/function (_DocumentProvider) { 9032 image_provider_inherits(ImageDocumentProvider, _DocumentProvider); 9033 var _super = image_provider_createSuper(ImageDocumentProvider); 9034 function ImageDocumentProvider(options, context) { 9035 var _this; 9036 image_provider_classCallCheck(this, ImageDocumentProvider); 9037 _this = _super.call(this, options, context); 9038 var app = _this.app, 9039 provider = image_provider_assertThisInitialized(_this); 9040 provider.document = new ImageDocument(app.options.source);
9041 provider.pageCount = provider.document.numPages; 9042 provider.numPages = provider.document.numPages; 9043 provider.loadDocument(); 9044 return _this; 9045 } 9046 image_provider_createClass(ImageDocumentProvider, [{ 9047 key: "dispose", 9048 value: function dispose() {} 9049 }, { 9050 key: "loadDocument", 9051 value: function loadDocument() { 9052 var app = this.app, 9053 options = this.app.options, 9054 provider = this; 9055 provider.document.getPage(1).then(function (page) { 9056 var _options$maxTextureSi; 9057 provider.defaultPage = page; 9058 var _defaultViewPort = provider.defaultPage.viewPort = page._viewPort; 9059 var _defaultPageRatio = provider.defaultPage.pageRatio = _defaultViewPort.width / _defaultViewPort.height; 9060 var _isdefaultPageWide = _defaultPageRatio > 1; 9061 provider.viewPorts[1] = _defaultViewPort; 9062 app.dimensions.defaultPage = { 9063 ratio: _defaultPageRatio, 9064 viewPort: _defaultViewPort, 9065 width: _defaultViewPort.width, 9066 height: _defaultViewPort.height 9067 }; 9068 app.dimensions.maxTextureHeight = ((_options$maxTextureSi = options.maxTextureSize) !== null && _options$maxTextureSi !== void 0 ? _options$maxTextureSi : 4096) / (!_isdefaultPageWide ? 1 : _defaultPageRatio); 9069 app.dimensions.maxTextureWidth = app.dimensions.maxTextureHeight * _defaultPageRatio; 9070 app.dimensions.autoHeightRatio = 1 / _defaultPageRatio; 9071 provider._page1Pass = true; 9072 provider.pagesLoaded(); 9073 }); 9074 9075 //check if internal pages are of double sizes. 9076 if (provider.pageCount > 1 && app.checkSecondPage === true) { 9077 provider.document.getPage(2).then(function (page) { 9078 var _page2ViewPort = page._viewPort; 9079 provider._page2Ratio = _page2ViewPort.width / _page2ViewPort.height; 9080 provider.viewPorts[2] = _page2ViewPort; 9081 provider._page2Pass = true; 9082 provider.pagesLoaded(); 9083 }); 9084 } else { 9085 provider._page2Pass = true; 9086 provider.pagesLoaded(); 9087 } 9088 } 9089 }, { 9090 key: "finalize", 9091 value: function finalize() { 9092 var app = this.app, 9093 provider = this; 9094 if (app === null || app.options === null) return; 9095 provider.linkService = new PDFLinkService(); 9096 // provider.linkService.setDocument(provider.pdfDocument, null); 9097 provider.linkService.setViewer(app); 9098 provider._documentLoaded(); 9099 } 9100 }, { 9101 key: "processPage", 9102 value: function processPage(param) { 9103 var app = this.app, 9104 provider = this, 9105 pageNumber = param.pageNumber, 9106 startTime = performance.now(); 9107 9108 //region determine page to render 9109 var pdfPageNumberToRender = app.viewer.getDocumentPageNumber(pageNumber); 9110 image_provider_utils.log("Requesting PDF Page:" + pdfPageNumberToRender); 9111 provider.document.getPage(pdfPageNumberToRender).then(function (page) { 9112 if (!provider.viewPorts[pageNumber]) { 9113 param.isFreshPage = true; 9114 provider.viewPorts[pageNumber] = page._viewPort; 9115 } 9116 var renderContext = app.viewer.getRenderContext(page, param); 9117 if (param.isFreshPage) { 9118 var _app$viewer$getPageBy; 9119 (_app$viewer$getPageBy = app.viewer.getPageByNumber(param.pageNumber)) === null || _app$viewer$getPageBy === void 0 || _app$viewer$getPageBy.changeTexture(param.pageNumber, renderContext.canvas.height); 9120 } 9121 param.preferCanvas = true; 9122 if (param.preferCanvas === true) { 9123 var _renderContext$viewpo; 9124 var context = renderContext.canvas.getContext("2d"); 9125 context.drawImage(page.image, renderContext.viewport.transform[4], 0, renderContext.canvas.width * ((_renderContext$viewpo = renderContext.viewport.widthFix) !== null && _renderContext$viewpo !== void 0 ? _renderContext$viewpo : 1), renderContext.canvas.height); 9126 //todo cleanup page.image , don't keep in memory 9127 app.applyTexture(renderContext.canvas, param); 9128 } else { 9129 app.applyTexture({ 9130 src: page.src, 9131 height: renderContext.canvas.height, 9132 width: renderContext.canvas.width 9133 }, param); 9134 } 9135 image_provider_utils.log("Rendered " + pageNumber + " in " + (performance.now() - startTime) + " milliseconds"); 9136 }); 9137 } 9138 }]); 9139 return ImageDocumentProvider; 9140}(DocumentProvider); 9141defaults_DEARVIEWER.providers['image'] = ImageDocumentProvider; 9142 9143// EXTERNAL MODULE: ./src/js/dearviewer/utils/tween.js 9144var tween = __webpack_require__(745); 9145;
9145// CONCATENATED MODULE: ./src/js/dearviewer/utils/controls.js 9146function controls_typeof(o) { "@babel/helpers - typeof"; return controls_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, controls_typeof(o); } 9147function controls_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 9148function controls_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, controls_toPropertyKey(descriptor.key), descriptor); } } 9149function controls_createClass(Constructor, protoProps, staticProps) { if (protoProps) controls_defineProperties(Constructor.prototype, protoProps); if (staticProps) controls_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 9150function controls_toPropertyKey(arg) { var key = controls_toPrimitive(arg, "string"); return controls_typeof(key) === "symbol" ? key : String(key); } 9151function controls_toPrimitive(input, hint) { if (controls_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (controls_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } 9152/* globals jQuery */ 9153 9154var controls_DV = (/* unused pure expression or super */ null && (DEARVIEWER)); 9155var controls_jQuery = defaults_DEARVIEWER.jQuery; 9156var controls_utils = defaults_DEARVIEWER.utils, 9157 REQUEST_STATUS = defaults_DEARVIEWER.REQUEST_STATUS; 9158var UI = /*#__PURE__*/function () { 9159 function UI(options, appContext) { 9160 controls_classCallCheck(this, UI); 9161 this.options = options; 9162 this.app = appContext; 9163 this.parentElement = this.app.container; 9164 this.element = controls_jQuery('<div>', { 9165 "class": "df-ui" 9166 }); 9167 this.leftElement = controls_jQuery('<div>', { 9168 "class": "df-ui-left" 9169 }).appendTo(this.element); 9170 this.centerElement = controls_jQuery('<div>', { 9171 "class": "df-ui-center" 9172 }).appendTo(this.element); 9173 this.rightElement = controls_jQuery('<div>', { 9174 "class": "df-ui-right" 9175 }).appendTo(this.element); 9176 this.parentElement.append(this.element); 9177 this.events = {}; 9178 this.controls = {}; 9179 } 9180 controls_createClass(UI, [{ 9181 key: "init", 9182 value: function init() { 9183 var ui = this, 9184 div = '<div>', 9185 app = this.app, 9186 controls = this.controls; 9187 var text = app.options.text, 9188 icons = app.options.icons; 9189 ui.createLogo(); 9190 this.openRight = controls.openRight = controls_jQuery(div, { 9191 "class": "df-ui-nav df-ui-next", 9192 title: app.isRTL ? text.previousPage : text.nextPage, 9193 html: '<div class="df-ui-btn ' + icons['next'] + '"</div>' 9194 }).on("click", function () { 9195 app.openRight(); 9196 }); 9197 this.openLeft = controls.openLeft = controls_jQuery(div, { 9198 "class": "df-ui-nav df-ui-prev", 9199 title: app.isRTL ? text.nextPage : text.previousPage, 9200 html: '<div class="df-ui-btn ' + icons['prev'] + '"</div>' 9201 }).on("click", function () { 9202 app.openLeft(); 9203 }); 9204 if (app.options.autoPlay == true) { 9205 this.play = controls.play = controls_utils.createBtn('play', icons['play'], text.play).on("click", function () { 9206 var el = controls_jQuery(this); 9207 app.setAutoPlay(!el.hasClass(app.options.icons['pause'])); 9208 }); 9209 app.setAutoPlay(app.options.autoPlayStart); 9210 } 9211 this.pageNumber = controls.pageNumber = controls_utils.createBtn('page').on("change", function () {
9212 app.gotoPageLabel(controls.pageInput.val()); 9213 }).on("keyup", function (event) { 9214 if (event.keyCode === 13) { 9215 app.gotoPageLabel(controls.pageInput.val()); 9216 } 9217 }); 9218 var rnd_id = "df_book_page_number_" + Math.ceil(performance.now() / 10); 9219 this.pageInput = controls.pageInput = controls_jQuery('<input id="' + rnd_id + '" type="text"/>').appendTo(controls.pageNumber); 9220 this.pageLabel = controls.pageLabel = controls_jQuery('<label for="' + rnd_id + '"></label>').appendTo(controls.pageNumber); 9221 this.thumbnail = controls.thumbnail = controls_utils.createBtn('thumbnail', icons['thumbnail'], text.toggleThumbnails); 9222 controls.thumbnail.on("click", function () { 9223 var el = controls_jQuery(this); 9224 if (app.thumblist == null) { 9225 app.initThumbs(); 9226 } 9227 var thumbContainer = app.thumbContainer; 9228 thumbContainer.toggleClass("df-sidemenu-visible"); 9229 el.toggleClass('df-active'); 9230 if (el.hasClass("df-active")) { 9231 el.siblings(".df-active").trigger("click"); 9232 app.thumbRequestStatus = REQUEST_STATUS.ON; 9233 } 9234 ui.update(); 9235 if (app.options.sideMenuOverlay === false) app.resizeRequestStart(); 9236 }).addClass("df-sidemenu-trigger"); 9237 if (app.hasOutline()) { 9238 this.outline = controls.outline = controls_utils.createBtn('outline', icons['outline'], text.toggleOutline); 9239 controls.outline.on("click", function () { 9240 var el = controls_jQuery(this); 9241 if (app.outlineViewer == null) { 9242 app.initOutline(); 9243 } 9244 if (app.outlineContainer) { 9245 var outlineContainer = app.outlineContainer; 9246 el.toggleClass('df-active'); 9247 outlineContainer.toggleClass("df-sidemenu-visible"); 9248 if (el.hasClass("df-active")) { 9249 el.siblings(".df-active").trigger("click"); 9250 } 9251 ui.update(); 9252 if (app.options.sideMenuOverlay === false) app.resizeRequestStart(); 9253 } 9254 }).addClass("df-sidemenu-trigger"); 9255 } 9256 if (app.options.showSearchControl === true && controls_utils.isMobile !== true && typeof app.options.source === 'string') { 9257 controls.search = controls_utils.createBtn('search', icons['search'], text.search); 9258 controls.search.on("click", function () { 9259 var el = controls_jQuery(this); 9260 if (app.searchContainer == null) { 9261 app.initSearch(); 9262 } 9263 if (app.searchContainer) { 9264 var searchContainer = app.searchContainer; 9265 el.toggleClass('df-active'); 9266 searchContainer.toggleClass("df-sidemenu-visible"); 9267 if (el.hasClass("df-active")) { 9268 el.siblings(".df-active").trigger("click"); 9269 app.searchBox.focus(); 9270 } 9271 ui.update(); 9272 if (app.options.sideMenuOverlay === false) app.resizeRequestStart(); 9273 } 9274 }).addClass("df-sidemenu-trigger"); 9275 } 9276 var controlsContainer = ui.element; 9277 this.zoomIn = controls.zoomIn = controls_utils.createBtn('zoomin', icons['zoomin'], text.zoomIn).on("click", function () { 9278 app.zoom(1); 9279 ui.update(); 9280 }); 9281 this.zoomOut = controls.zoomOut = controls_utils.createBtn('zoomout', icons['zoomout'], text.zoomOut).on("click", function () { 9282 app.zoom(-1); 9283 ui.update(); 9284 }); 9285 this.resetZoom = controls.resetZoom = controls_utils.createBtn('resetzoom', icons['resetzoom'], text.resetZoom).on("click", function () { 9286 app.resetZoom(-1); 9287 ui.update(); 9288 }); 9289 9290 /*PAGEMODE/PAGEFIT*/ 9291 if (app.viewer.isFlipBook) { 9292 //todo PageMode buttons to be added through viewers 9293 if (app.pageCount > 2) { 9294 var isSingle = app.viewer.pageMode === defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE; 9295 this.pageMode = controls.pageMode = controls_utils.createBtn('pagemode', icons[isSingle ? 'doublepage' : 'singlepage'], isSingle ? text.doublePageMode : text.singlePageMode).on("click", function () { 9296 var el = controls_jQuery(this); 9297 app.viewer.setPageMode({ 9298 isSingle: !el.hasClass(icons['doublepage']) 9299 }); 9300 app.viewer.pageModeChangedManually = true; 9301 }); 9302 } 9303 } else { 9304 this.pageFit = controls.pageFit = controls_utils.createBtn('pagefit', icons['pagefit'], text.pageFit).on("click", function () { 9305 var pageFit = controls.pageFit; 9306 var isPageFit = !pageFit.hasClass(icons['widthfit']); 9307 if (isPageFit === true) { 9308 pageFit.addClass(icons['widthfit']); 9309 pageFit.html("<span>" + text.widthFit + "</span>"); 9310 pageFit.attr("title", text.widthFit); 9311 } else { 9312 pageFit.removeClass(icons['widthfit']); 9313 pageFit.html("<span>" + text.pageFit + "</span>"); 9314 pageFit.attr("title", text.pageFit); 9315 } 9316 // jQuery(this).toggleClass(buttonClass + " " + uiClass + "-widthfit "); 9317 }); 9318 } 9319 9320 ui.shareBox = new DV_Share(app.container, app.options); 9321 this.share = controls.share = controls_utils.createBtn('share', icons['share'], text.share).on("click", function () { 9322 if (ui.shareBox.isOpen === true) ui.shareBox.close();else { 9323 ui.shareBox.update(app.getURLHash()); 9324 ui.shareBox.show(); 9325 } 9326 }); 9327 9328 //More button 9329 this.more = controls.more = controls_utils.createBtn('more', icons['more']).on("click", function (event) { 9330 if (ui.moreContainerOpen !== true) { 9331 controls_jQuery(this).addClass("df-active"); 9332 ui.moreContainerOpen = true; 9333 event.stopPropagation(); 9334 } 9335 }); 9336 this.startPage = controls.startPage = controls_utils.createBtn('start', icons['start'], text.gotoFirstPage).on("click", function () { 9337 app.start(); 9338 }); 9339 this.endPage = controls.endPage = controls_utils.createBtn('end', icons['end'], text.gotoLastPage).on("click", function () { 9340 app.end(); 9341 }); 9342 if (app.options.showPrintControl === true && controls_utils.isMobile !== true && typeof app.options.source === 'string') { 9343 this.print = controls.print = controls_utils.createBtn('print', icons['print'], text.print).on("click", function () { 9344 defaults_DEARVIEWER.printHandler = defaults_DEARVIEWER.printHandler || new PrintHandler(); 9345 defaults_DEARVIEWER.printHandler.printPDF(app.options.source); 9346 }); 9347 } 9348 if (app.options.showDownloadControl === true && typeof app.options.source === 'string') { 9349 var downloadClass = "df-ui-btn df-ui" + "-download " + icons['download']; 9350 this.download = controls.download = controls_jQuery('<a download target="_blank" class="' + downloadClass + '"><span>' + text.downloadPDFFile + '</span></a>'); 9351 controls.download.attr("href", controls_utils.httpsCorrection(app.options.source)).attr("title", text.downloadPDFFile); 9352 //moreContainer.append(download); 9353 } 9354 9355 //endregion 9356 9357 //region MoreContainer 9358 ui.moreContainer = controls_jQuery(div, { 9359 "class": "df-more-container" 9360 }); 9361 controls.more.append(ui.moreContainer); 9362 //endregion 9363 9364 if (!(app.options.isLightBox === true && app.fullscreenSupported !== true)) { 9365 this.fullScreen = controls.fullScreen = controls_utils.createBtn('fullscreen', icons['fullscreen'], text.toggleFullscreen).on("click", app.switchFullscreen.bind(app)); 9366 } 9367 app.viewer.initCustomControls(); 9368 /** 9369 * Controls position and placement is determined by options.moreControls and options.hideControls 9370 */ 9371 var allControls = app.options.allControls.replace(/ /g, '').split(','), 9372 moreControls = ',' + app.options.moreControls.replace(/ /g, '') + ',', 9373 hideControls = ',' + app.options.hideControls.replace(/ /g, '') + ',', 9374 leftControls = ',' + app.options.leftControls.replace(/ /g, '') + ',', 9375 rightControls = ',' + app.options.rightControls.replace(/ /g, '') + ',', 9376 devControls = ','; // + app.options.devControls.replace(/ /g, '') + ','; 9377 9378 // if (utils.isIOS) { 9379 // hideControls += ",fullScreen,"; 9380 // } 9381 hideControls += devControls; 9382 for (var controlCount = 0; controlCount < allControls.length; controlCount++) { 9383 //if hidden skip 9384 var controlName = allControls[controlCount]; 9385 if (hideControls.indexOf(',' + controlName + ',') < 0) { 9386 //not found in hide list 9387 var control = controls[controlName];
9388 if (control != null && controls_typeof(control) == "object") { 9389 if (moreControls.indexOf(',' + controlName + ',') > -1 && controlName !== 'more' && controlName !== 'pageNumber') { 9390 //found in more controls 9391 ui.moreContainer.append(control); 9392 } else if (app.options.controlsFloating == true) { 9393 controlsContainer.append(control); 9394 } 9395 // else if (leftControls.indexOf(',' + controlName + ',') > -1) { 9396 // this.leftElement.append(control); 9397 // } 9398 // else if (rightControls.indexOf(',' + controlName + ',') > -1) { 9399 // this.rightElement.append(control); 9400 // } 9401 else { 9402 this.centerElement.append(control); 9403 } 9404 } 9405 } 9406 } 9407 if (ui.moreContainer.children().length == 0) { 9408 //fixes #347 9409 this.more.addClass("df-hidden"); 9410 } 9411 app.container.append(controlsContainer); 9412 app.container.append(controls.openLeft); 9413 app.container.append(this.controls.openRight); 9414 9415 //register a click event on window to close the more-options and search options 9416 window.addEventListener('click', ui.events.closePanels = ui.closePanels.bind(ui), false); 9417 window.addEventListener('keyup', ui.events.keyup = ui.keyUp.bind(ui), false); 9418 document.addEventListener('fullscreenchange', ui.events.fullscreenChange = ui.fullscreenChange.bind(u
9418i), false); 9419 if (app.options.autoOpenThumbnail === true) { 9420 ui.controls.thumbnail.trigger("click"); 9421 } 9422 if (app.hasOutline() && app.options.autoOpenOutline === true) { 9423 ui.controls.outline.trigger("click"); 9424 } 9425 app.executeCallback('onCreateUI'); 9426 } 9427 }, { 9428 key: "closePanels", 9429 value: function closePanels(event) { 9430 if (this.moreContainerOpen === true) { 9431 var _this$controls$more; 9432 (_this$controls$more = this.controls.more) === null || _this$controls$more === void 0 || _this$controls$more.removeClass("df-active"); 9433 this.moreContainerOpen = false; 9434 } 9435 } 9436 }, { 9437 key: "fullscreenChange", 9438 value: function fullscreenChange(event) { 9439 var isExit = controls_utils.getFullscreenElement() === void 0; 9440 if (isExit && this.app.isFullscreen === true) { 9441 this.app.switchFullscreen(); 9442 } 9443 } 9444 }, { 9445 key: "keyUp", 9446 value: function keyUp(event) { 9447 var ui = this, 9448 app = this.app; 9449 //bail out if the keys are getting entered in some input box. 9450 if (event.target.nodeName === "INPUT") return; 9451 var navKeysValid = app.isFullscreen === true || app.options.isLightBox === true || app.options.arrowKeysAction === defaults_DEARVIEWER.ARROW_KEYS_ACTIONS.NAV; 9452 switch (event.keyCode) { 9453 case 27: 9454 //escKey 9455 if (defaults_DEARVIEWER.activeLightBox && defaults_DEARVIEWER.activeLightBox.app && !controls_utils.isChromeExtension()) { 9456 defaults_DEARVIEWER.activeLightBox.closeButton.trigger("click"); 9457 } 9458 break; 9459 case 37: 9460 //leftKey: 9461 if (navKeysValid) app.openLeft(); 9462 break; 9463 case 39: 9464 //rightKey: 9465 if (navKeysValid) app.openRight(); 9466 break; 9467 default: 9468 break; 9469 } 9470 } 9471 }, { 9472 key: "createLogo", 9473 value: function createLogo() { 9474 var app = this.app; 9475 var logo = null; 9476 if (app.options.logo.indexOf("<") > -1) { 9477 logo = controls_jQuery(app.options.logo).addClass("df-logo df-logo-html"); 9478 } else if (app.options.logo.trim().length > 2) { 9479 logo = controls_jQuery('<a class="df-logo df-logo-img" target="_blank" href="' + app.options.logoUrl + '"><img alt="" src="' + app.options.logo + '"/>'); 9480 } 9481 this.element.append(logo); 9482 } 9483 }, { 9484 key: "dispose", 9485 value: function dispose() { 9486 var ui = this; 9487 for (var key in this.controls) { 9488 if (this.controls.hasOwnProperty(key)) { 9489 var control = this.controls[key]; 9490 if (control !== null && controls_typeof(control) == "object") control.off().remove(); 9491 } 9492 } 9493 ui.element.remove(); 9494 ui.shareBox = controls_utils.disposeObject(ui.shareBox); 9495 window.removeEventListener('click', ui.events.closePanels, false); 9496 window.removeEventListener('keyup', ui.events.keyup, false); 9497 document.removeEventListener('fullscreenchange', ui.events.fullscreenChange, false); 9498 } 9499 }, { 9500 key: "update", 9501 value: function update() { 9502 var app = this.app, 9503 controls = this.controls; 9504 if (this._pageLabelWidthSet !== true) { 9505 //https://github.com/deepak-ghimire/dearviewer/issues/349 9506 this.pageLabel.width(""); 9507 if (app.provider.pageLabels) { 9508 this.pageLabel.html("88888888888888888".substring(0, app.pageCount.toString().length * 3 + 4)); 9509 } else { 9510 this.pageLabel.html("88888888888".substring(0, app.pageCount.toString().length * 2 + 3)); 9511 } 9512 this.pageNumber.width(this.pageLabel.width()); 9513 this.pageLabel.width(this.pageLabel.width()); 9514 this.pageLabel.html(""); 9515 this._pageLabelWidthSet = true; 9516 } 9517 var pageLabel = app.getCurrentLabel(); 9518 if (pageLabel.toString() !== app.currentPageNumber.toString()) { 9519 controls.pageLabel.html(pageLabel + "(" + app.currentPageNumber + "/" + app.pageCount + ")"); 9520 } else { 9521 controls.pageLabel.html(pageLabel + "/" + app.pageCount); 9522 } 9523 controls.pageInput.val(pageLabel);
9524 app.container.toggleClass("df-sidemenu-open", app.container.find(".df-sidemenu-visible").length > 0); 9525 var isSearchOpen = app.provider.totalHits > 0 && app.container.find(".df-sidemenu-visible.df-search-container").length > 0; 9526 app.container.toggleClass("df-search-open", isSearchOpen); 9527 if (isSearchOpen) { 9528 var targetSearchresult = app.searchContainer.find(".df-search-result[data-page=" + app.currentPageNumber + "]"); 9529 app.searchContainer.find(".df-search-result.df-active").removeClass("df-active"); 9530 if (targetSearchresult.length > 0 && !targetSearchresult.hasClass(".df-active")) { 9531 targetSearchresult.addClass("df-active"); 9532 var searchWrapper = app.searchResults[0]; 9533 var searchWrapperScrollTop = searchWrapper.scrollTop, 9534 searchWrapperScrollHeight = searchWrapper.getBoundingClientRect().height; 9535 targetSearchresult = targetSearchresult[0]; 9536 //when the thumb is below the display area scroll so that just it's fully visible 9537 if (searchWrapperScrollTop + searchWrapperScrollHeight < targetSearchresult.offsetTop + targetSearchresult.scrollHeight) controls_utils.scrollIntoView(targetSearchresult, null, false); 9538 //when the thumb is above the display area scroll so that just it's fully visible 9539 else if (searchWrapperScrollTop > targetSearchresult.offsetTop) controls_utils.scrollIntoView(targetSearchresult); 9540 } 9541 } 9542 controls.zoomIn.toggleClass("disabled", app.zoomValue === app.viewer.maxZoom); 9543 controls.zoomOut.toggleClass("disabled", app.zoomValue === app.viewer.minZoom); 9544 var isRTL = app.isRTL, 9545 isStart = app.currentPageNumber === app.startPage, 9546 isEnd = app.currentPageNumber === app.endPage; 9547 var noPrev = isStart && !isRTL || isEnd && isRTL, 9548 noNext = isEnd && !isRTL || isStart && isRTL; 9549 controls.openRight.toggleClass("df-hidden", noNext); 9550 controls.openLeft.toggleClass("df-hidden", noPrev); 9551 app.viewer.afterControlUpdate(); 9552 } 9553 }]); 9554 return UI; 9555}(); 9556var DV_Share = /*#__PURE__*/function () { 9557 function DV_Share(container, options) { 9558 controls_classCallCheck(this, DV_Share); 9559 var dfShare = this;
9560 dfShare.isOpen = false; 9561 dfShare.shareUrl = ""; 9562 dfShare.init(container, options); 9563 } 9564 controls_createClass(DV_Share, [{ 9565 key: "init", 9566 value: function init(container, options) { 9567 var dfShare = this; 9568 var shareButtonClass = "df-share-button"; 9569 var windowParameters = "width=500,height=400"; 9570 dfShare.wrapper = controls_jQuery('<div class="df-share-wrapper" style="display: none;">').on("click", function () { 9571 dfShare.close(); 9572 }); 9573 dfShare.box = controls_jQuery('<div class="df-share-box">'); 9574 dfShare.box.on("click", function (e) { 9575 e.preventDefault(); 9576 e.stopPropagation(); 9577 }); 9578 dfShare.box.appendTo(dfShare.wrapper).html('<span class="df-share-title">' + options.text.share + '</span>'); 9579 dfShare.urlInput = controls_jQuery('<textarea name="df-share-url" class="df-share-url">').on("click", function () { 9580 controls_jQuery(this).select(); 9581 }); 9582 dfShare.box.append(dfShare.urlInput); 9583 var _loop = function _loop() { 9584 if (options.share.hasOwnProperty(shareKey) && options.hideShareControls.indexOf(shareKey) < 0) { 9585 var shareTemplate = options.share[shareKey]; 9586 if (shareTemplate !== null) { 9587 dfShare[shareKey] = controls_jQuery('<div>', { 9588 "class": shareButtonClass + " df-share-" + shareKey + " " + options.icons[shareKey] 9589 }).on("click", function (e) { 9590 e.preventDefault(); 9591 window.open(shareTemplate.replace("{{url}}", encodeURIComponent(dfShare.shareUrl)).replace("{{mailsubject}}", options.text.mailSubject), "Sharer", windowParameters); 9592 e.stopPropagation(); //so the default event is not cancelled by parent element 9593 }); 9594 9595 dfShare.box.append(dfShare[shareKey]); 9596 } 9597 } 9598 }; 9599 for (var shareKey in options.share) { 9600 _loop(); 9601 } 9602 controls_jQuery(container).append(dfShare.wrapper); 9603 } 9604 }, { 9605 key: "show", 9606 value: function show() { 9607 this.wrapper.fadeIn(300); 9608 this.urlInput.val(this.shareUrl); 9609 this.urlInput.trigger("click"); 9610 this.isOpen = true; 9611 } 9612 }, { 9613 key: "dispose", 9614 value: function dispose() { 9615 var dfShare = this; 9616 for (var key in dfShare) { 9617 if (dfShare.hasOwnProperty(key)) { 9618 if (dfShare[key] && dfShare[key].off) dfShare[key].off(); 9619 } 9620 } 9621 dfShare.wrapper.remove(); 9622 } 9623 }, { 9624 key: "close", 9625 value: function close() { 9626 this.wrapper.fadeOut(300); 9627 this.isOpen = false; 9628 } 9629 }, { 9630 key: "update", 9631 value: function update(url) { 9632 this.shareUrl = url; 9633 } 9634 }]); 9635 return DV_Share; 9636}(); 9637var DVLightBox = /*#__PURE__*/function () { 9638 /** 9639 * @constructs LightBox 9640 * @param closeCallback callBack function when lightbox is closed 9641 */ 9642 function DVLightBox(closeCallback) { 9643 controls_classCallCheck(this, DVLightBox); 9644 this.duration = 300; 9645 9646 //cache this 9647 var lightbox = this; 9648 //lightbox wrapper div 9649 lightbox.lightboxWrapper = controls_jQuery("<div>").addClass("df-lightbox-wrapper"); 9650 //lightbox background 9651 lightbox.backGround = controls_jQuery("<div>").addClass("df-lightbox-bg").appendTo(lightbox.lightboxWrapper); 9652 //lightbox element 9653 lightbox.element = controls_jQuery("<div>").addClass("df-app").appendTo(lightbox.lightboxWrapper); 9654 //lightbox controls 9655 lightbox.controls = controls_jQuery("<div>").addClass("df-lightbox-controls").appendTo(lightbox.lightboxWrapper); 9656 9657 //lightbox close button 9658 lightbox.closeButton = controls_jQuery("<div>").addClass("df-lightbox-close df-ui-btn " + defaults_DEARVIEWER.defaults.icons['close']).on("click", function () { 9659 lightbox.close(closeCallback); 9660 }
9660).appendTo(lightbox.controls); 9661 lightbox.lightboxWrapper.append(lightbox.element); 9662 return lightbox; 9663 } 9664 controls_createClass(DVLightBox, [{ 9665 key: "show", 9666 value: function show(callback) { 9667 if (this.lightboxWrapper.parent().length === 0) controls_jQuery("body").append(this.lightboxWrapper); 9668 controls_jQuery("html,body").addClass("df-lightbox-open"); 9669 this.lightboxWrapper.fadeIn(this.duration); 9670 if (typeof callback === "function") callback(); 9671 return this; 9672 } 9673 }, { 9674 key: "close", 9675 value: function close(callback) { 9676 this.lightboxWrapper.fadeOut(this.duration); 9677 Array.prototype.forEach.call(defaults_DEARVIEWER.utils.getSharePrefixes(), function (prefix) { 9678 if (window.location.hash.indexOf("#" + prefix) === 0) history.replaceState(undefined, undefined, "#_"); 9679 //window.location.hash = "#_"; 9680 }); 9681 9682 if (typeof callback === "function") setTimeout(callback, this.duration); 9683 controls_jQuery("html,body").removeClass("df-lightbox-open"); 9684 9685 //cleanup any classes to remove old CSS classes 9686 this.element.attr("class", "df-app").attr("style", ""); 9687 this.lightboxWrapper.attr("class", "df-lightbox-wrapper").attr("style", ""); 9688 this.backGround.attr("style", ""); 9689 return this; 9690 } 9691 }]); 9692 return DVLightBox; 9693}(); 9694var PrintHandler = /*#__PURE__*/function () { 9695 function PrintHandler() { 9696 controls_classCallCheck(this, PrintHandler); 9697 //cache this 9698 var printHandler = this; 9699 printHandler.frame = controls_jQuery('<iframe id="df-print-frame" style="display:none">').appendTo(controls_jQuery("body")); 9700 printHandler.frame.on("load", function () { 9701 try { 9702 printHandler.frame[0].contentWindow.print(); 9703 } catch (e) { 9704 console.log(e); 9705 } 9706 }); 9707 return printHandler; 9708 } 9709 controls_createClass(PrintHandler, [{ 9710 key: "printPDF", 9711 value: function printPDF(source) { 9712 this.frame[0].src = source; 9713 } 9714 }]); 9715 return PrintHandler; 9716}(); 9717var Sidemenu = /*#__PURE__*/function () { 9718 function Sidemenu(options, appContext) { 9719 controls_classCallCheck(this, Sidemenu); 9720 this.options = options; 9721 this.app = appContext; 9722 this.parentElement = options.parentElement; 9723 this.element = controls_jQuery('<div>', { 9724 "class": "df-sidemenu-wrapper" 9725 }); 9726 this.parentElement.append(this.element); 9727 this.buttons = controls_jQuery('<div>', { 9728 "class": "df-sidemenu-buttons df-ui-wrapper" 9729 }).appendTo(this.element); 9730 9731 /* 9732 let icons = this.app.options.icons, 9733 text = this.app.options.text; 9734 this.thumbnail = utils.createBtn('thumbnail', icons['thumbnail'], text.toggleThumbnails); 9735 this.outline = utils.createBtn('outline', icons['outline'], text.toggleOutline);*/ 9736 this.close = controls_utils.createBtn('close', appContext.options.icons['close'], appContext.options.text.close); //todo 9737 9738 this.buttons.append(this.close); 9739 } 9740 controls_createClass(Sidemenu, [{ 9741 key: "dispose", 9742 value: function dispose() { 9743 this.element.remove(); 9744 } 9745 }]); 9746 return Sidemenu; 9747}(); 9748var BookMarkViewer = /*#__PURE__*/function () { 9749 /** 9750 * @typedef {Object} BookMarkViewerOptions 9751 * @property {HTMLDivElement} container - The viewer element. 9752 * @property {Object} linkService - the serviceProvider 9753 * @property {Object} outlineItemClass - custom class for outline item 9754 * @property {Object} outlineToggleClass - custom class for outline toggle 9755 * @property {Object} outlineToggleHiddenClass - custom class for outline hidden item 9756 */ 9757 9758 /** 9759 * @typedef {Object} BookMarkViewerRenderParameters 9760 * @property {Array|null} outline - An array of outline objects. 9761 */ 9762 9763 /** 9764 * @constructs BookMarkViewer 9765 * @param {BookMarkViewerOptions} options 9766 */ 9767 function BookMarkViewer(options) { 9768 controls_classCallCheck(this, BookMarkViewer); 9769 this.outline = null; 9770 this.lastToggleIsShow = true; 9771 this.container = options.container; 9772 this.linkService = options.linkService; 9773 this.outlineItemClass = options.outlineItemClass || "outlineItem"; 9774 this.outlineToggleClass = options.outlineToggleClass || "outlineItemToggler"; 9775 this.outlineToggleHiddenClass = options.outlineToggleHiddenClass || "outlineItemsHidden"; 9776 } 9777 controls_createClass(BookMarkViewer, [{ 9778 key: "dispose", 9779 value: function dispose() { 9780 if (this.container) { 9781 if (this.container.parentNode) { 9782 this.container.parentNode.removeChild(this.container); 9783 } 9784 } 9785 this.linkService = null; 9786 } 9787 }, { 9788 key: "reset", 9789 value: function reset() { 9790 this.outline = null; 9791 this.lastToggleIsShow = true; 9792 var container = this.container; 9793 while (container.firstChild) { 9794 container.removeChild(container.firstChild); 9795 } 9796 } 9797 }, { 9798 key: "_dispatchEvent", 9799 value: 9800 /** 9801 * @private 9802 */ 9803 function _dispatchEvent(outlineCount) { 9804 var event = document.createEvent('CustomEvent'); 9805 event.initCustomEvent('outlineloaded', true, true, { 9806 outlineCount: outlineCount 9807 });
9808 this.container.dispatchEvent(event); 9809 } 9810 }, { 9811 key: "_bindLink", 9812 value: 9813 /** 9814 * @private 9815 */ 9816 function _bindLink(element, item) { 9817 var linkService = this.linkService; 9818 if (item.custom === true) { 9819 element.href = linkService.getCustomDestinationHash(item.dest); 9820 element.onclick = function goToDestination() { 9821 linkService.customNavigateTo(item.dest); 9822 return false; 9823 }; 9824 } else { 9825 if (item.url) { 9826 pdfjsLib.addLinkAttributes(element, { 9827 url: item.url 9828 }); 9829 return; 9830 } 9831 element.href = linkService.getDestinationHash(item.dest); 9832 element.onclick = function goToDestination() { 9833 linkService.navigateTo(item.dest); 9834 return false; 9835 }; 9836 } 9837 } 9838 }, { 9839 key: "_addToggleButton", 9840 value: 9841 /** 9842 * Prepend a button before an outline item which allows the user to toggle 9843 * the visibility of all outline items at that level. 9844 * 9845 * @private 9846 */ 9847 function _addToggleButton(div) { 9848 var _bookMarkViewer = this; 9849 var toggler = document.createElement('div'); 9850 toggler.className = this.outlineToggleClass + " " + this.outlineToggleHiddenClass; 9851 toggler.onclick = function (event) { 9852 event.stopPropagation(); 9853 toggler.classList.toggle(this.outlineToggleHiddenClass); 9854 if (event.shiftKey) { 9855 var shouldShowAll = !toggler.classList.contains(this.outlineToggleHiddenClass); 9856 _bookMarkViewer._toggleOutlineItem(div, shouldShowAll); 9857 } 9858 }.bind(this); 9859 div.insertBefore(toggler, div.firstChild); 9860 } 9861 }, { 9862 key: "_toggleOutlineItem", 9863 value: 9864 /** 9865 * Toggle the visibility of the subtree of an outline item. 9866 * 9867 * @param {Element} root - the root of the outline (sub)tree. 9868 * @param {boolean} show - whether to show the outline (sub)tree. If false, 9869 * the outline subtree rooted at |root| will be collapsed. 9870 * 9871 * @private 9872 */ 9873 function _toggleOutlineItem(root, show) { 9874 this.lastToggleIsShow = show; 9875 var togglers = root.querySelectorAll('.' + this.outlineToggleClass); 9876 for (var i = 0, ii = togglers.length; i < ii; ++i) { 9877 togglers[i].classList[show ? 'remove' : 'add'](this.outlineToggleHiddenClass); 9878 } 9879 } 9880 }, { 9881 key: "render", 9882 value: 9883 /** 9884 * @param {BookMarkViewerRenderParameters} params 9885 */ 9886 function render(params) { 9887 var outline = params && params.outline || null; 9888 var outlineCount = 0; 9889 if (this.outline) { 9890 this.reset(); 9891 } 9892 this.outline = outline; 9893 if (!outline) { 9894 //this._dispatchEvent(outlineCount); 9895 return; 9896 } 9897 var fragment = document.createDocumentFragment(); 9898 var queue = [{ 9899 parent: fragment, 9900 items: this.outline, 9901 custom: false 9902 }]; 9903 var hasAnyNesting = false; 9904 while (queue.length > 0) { 9905 var levelData = queue.shift(); 9906 var isCustom = levelData.custom; 9907 for (var i = 0, len = levelData.items.length; i < len; i++) { 9908 var item = levelData.items[i]; 9909 var div = document.createElement('div'); 9910 div.className = this.outlineItemClass; 9911 var element = document.createElement('a'); 9912 if (item.custom == null && isCustom != null) item.custom = isCustom; 9913 this._bindLink(element, item); 9914 //element. 9915 element.textContent = item.title.replace(/\x00/g, ''); 9916 //pdfjsLib.removeNullCharacters(item.title) || "Untitled Bookmark"; 9917 9918 div.appendChild(element); 9919 if (item.items && item.items.length > 0) { 9920 hasAnyNesting = true; 9921 this._addToggleButton(div); 9922 var itemsDiv = document.createElement('div'); 9923 itemsDiv.className = this.outlineItemClass + "s"; 9924 div.appendChild(itemsDiv); 9925 // noinspection JSCheckFunctionSignatures 9926 queue.push({ 9927 parent: itemsDiv, 9928 custom: item.custom, 9929 items: item.items 9930 }); 9931 } 9932 levelData.parent.appendChild(div); 9933 outlineCount++; 9934 } 9935 } 9936 if (hasAnyNesting) { 9937 if (this.container.classList != null) { 9938 this.container.classList.add(this.outlineItemClass + "s"); 9939 } else if (this.container.className != null) { 9940 this.container.className += " picWindow"; 9941 } 9942 } 9943 this.container.appendChild(fragment); 9944 this._dispatchEvent(outlineCount); 9945 } 9946 }]); 9947 return BookMarkViewer; 9948}(); 9949var ThumbList = /*#__PURE__*/function () { 9950 function ThumbList(config) { 9951 controls_classCallCheck(this, ThumbList); 9952 var itemHeight = this.itemHeight = config.itemHeight; 9953 var itemWidth = this.itemWidth = config.itemWidth; 9954 var app = this.app = config.app; 9955 this.items = config.items; 9956 this.generatorFn = config.generatorFn; 9957 this.totalRows = config.totalRows || config.items && config.items.length; 9958 this.addFn = config.addFn; 9959 this.scrollFn = config.scrollFn; 9960 this.container = document.createElement('div'); 9961 var self = this; 9962 for (var count = 0; count < this.totalRows; count++) { 9963 var el = document.createElement("div"); 9964 var pageNumber = count + 1; 9965 el.id = "df-thumb" + pageNumber; 9966 var image = document.createElement("div"), 9967 thumbNumber = document.createElement("div"), 9968 wrapper = document.createElement("div"); 9969 wrapper.className = "df-wrapper"; 9970 thumbNumber.className = "df-thumb-number"; 9971 el.className = "df-thumb"; 9972 image.className = "df-bg-image"; 9973 wrapper.style.height = itemHeight + 'px'; 9974 wrapper.style.width = itemWidth + 'px'; 9975 thumbNumber.innerText = app.provider.getLabelforPage(pageNumber); 9976 el.appendChild(wrapper); 9977 wrapper.appendChild(thumbNumber); 9978 wrapper.appendChild(image); 9979 this.container.appendChild(el); 9980 } 9981 function onScroll() { 9982 app.thumbRequestCount = 0; 9983 app.thumbRequestStatus = REQUEST_STATUS.COUNT; 9984 }
9985 self.dispose = function () { 9986 if (self.container) { 9987 if (self.container.parentNode) { 9988 self.container.parentNode.removeChild(self.container); 9989 } 9990 } 9991 self.container.removeEventListener('scroll', onScroll); 9992 }; 9993 self.container.addEventListener('scroll', onScroll); 9994 } 9995 controls_createClass(ThumbList, [{ 9996 key: "processThumbRequest", 9997 value: function processThumbRequest() { 9998 controls_utils.log("Thumb Request Initiated"); 9999 var app = this.app; 10000 app.thumbRequestStatus = REQUEST_STATUS.OFF; 10001 10002 //move to thumb if thumb is on 10003 if (app.activeThumb !== app.currentPageNumber) { 10004 var thumbVisible = app.thumbContainer != null && app.thumbContainer.hasClass("df-sidemenu-visible"); 10005 if (thumbVisible) { 10006 var thumbWrapper = app.thumblist.container; 10007 var thumbWrapperScrollTop = thumbWrapper.scrollTop, 10008 thumbWrapperScrollHeight = thumbWrapper.getBoundingClientRect().height; 10009 var thumb = app.thumbContainer.find("#df-thumb" + app.currentPageNumber); 10010 if (thumb.length > 0) { 10011 //TODO direct jumps won't work.. 10012 app.thumbContainer.find(".df-selected").removeClass("df-selected"); 10013 thumb.addClass("df-selected"); 10014 //js calculation 10015 thumb = thumb[0]; 10016 10017 //when the thumb is below the display area scroll so that just it's fully visible 10018 if (thumbWrapperScrollTop + thumbWrapperScrollHeight < thumb.offsetTop + thumb.scrollHeight) controls_utils.scrollIntoView(thumb, null, false); 10019 //when the thumb is above the display area scroll so that just it's fully visible 10020 else if (thumbWrapperScrollTop > thumb.offsetTop) controls_utils.scrollIntoView(thumb); 10021 app.activeThumb = app.currentPageNumber; 10022 } else { 10023 //TODO: Why is this written?? 10024 //noinspection JSValidateTypes 10025 controls_jQuery(thumbWrapper).scrollTop(app.currentPageNumber * 124); 10026 app.thumbRequestStatus = REQUEST_STATUS.ON; 10027 } 10028 } 10029 } 10030 if (app.thumblist.container.getElementsByClassName("df-thumb-requested").length === 0) { 10031 var visible = controls_utils.getVisibleElements({ 10032 container: app.thumblist.container, 10033 elements: app.thumblist.container.children 10034 }); 10035 if (controls_jQuery.inArray(visible)) visible.unshift(app.activeThumb); 10036 for (var count = 0; count < visible.length; count++) { 10037 var _thumb = app.thumblist.container.children[visible[count] - 1]; 10038 if (_thumb !== void 0 && _thumb.classList.contains("df-thumb-loaded") === false && _thumb.classList.contains("df-thumb-requested") === false) { 10039 _thumb.classList.add("df-thumb-requested"); 10040 controls_utils.log("Thumb Requested for " + visible[count]); 10041 app.provider.processPage({ 10042 pageNumber: visible[count], 10043 textureTarget: defaults_DEARVIEWER.TEXTURE_TARGET.THUMB 10044 }); 10045 return false; 10046 } 10047 } 10048 } 10049 } 10050 }, { 10051 key: "setPage", 10052 value: function setPage(param) { 10053 var app = this.app, 10054 pageNumber = param.pageNumber, 10055 texture = param.texture, 10056 textureTarget = param.textureTarget; 10057 if (textureTarget === defaults_DEARVIEWER.TEXTURE_TARGET.THUMB) { 10058 var thumb = app.container.find("#df-thumb" + pageNumber); 10059 thumb.find(".df-wrapper").css({ 10060 height: param.height, 10061 width: param.width 10062 }); 10063 thumb.find(".df-bg-image").css({ 10064 backgroundImage: controls_utils.bgImage(texture) 10065 }); 10066 thumb.addClass("df-thumb-loaded").removeClass("df-thumb-requested"); 10067 } 10068 controls_utils.log("Thumbnail set for " + param.pageNumber); 10069 app.thumbRequestStatus = REQUEST_STATUS.ON; 10070 } 10071 }]); 10072 return ThumbList; 10073}(); 10074defaults_DEARVIEWER.openLightBox = function openLightBox(app) { 10075 if (!defaults_DEARVIEWER.activeLightBox) { 10076 defaults_DEARVIEWER.activeLightBox = new DVLightBox(function () { 10077 if (defaults_DEARVIEWER.activeLightBox.app) { 10078 defaults_DEARVIEWER.activeLightBox.app.closeRequested = true; 10079 defaults_DEARVIEWER.activeLightBox.app.analytics({ 10080 eventAction: defaults_DEARVIEWER.activeLightBox.app.options.analyticsViewerClose, 10081 options: defaults_DEARVIEWER.activeLightBox.app.options 10082 }); 10083 } 10084 defaults_DEARVIEWER.activeLightBox.app = controls_utils.disposeObject(defaults_DEARVIEWER.activeLightBox.app); 10085 }); 10086 } 10087 defaults_DEARVIEWER.activeLightBox.duration = 300; 10088 if ( 10089 //valid states to close existing lightbox and open new 10090 defaults_DEARVIEWER.activeLightBox.app === undefined || defaults_DEARVIEWER.activeLightBox.app === null || defaults_DEARVIEWER.activeLightBox.app.closeRequested === true || defaults_DEARVIEWER.openLocalFileInput == app // request is through OpenFile function 10091 ) { 10092 defaults_DEARVIEWER.activeLightBox.app = controls_utils.disposeObject(defaults_DEARVIEWER.activeLightBox.app); 10093 if (defaults_DEARVIEWER.activeLightBox.app === null) { 10094 defaults_DEARVIEWER.activeLightBox.show(function () { 10095 defaults_DEARVIEWER.activeLightBox.app = controls_jQuery(defaults_DEARVIEWER.activeLightBox.element).dearviewer({ 10096 transparent: false, 10097 //todo transparent is not available so set to a default background https://github.com/deepak-ghimire/dearviewer/issues/330 10098 isLightBox: true, 10099 hashNavigationEnabled: true, 10100 height: "100%", 10101 dataElement: app 10102 }); 10103 defaults_DEARVIEWER.activeLightBox.lightboxWrapper.toggleClass("df-lightbox-padded", defaults_DEARVIEWER.activeLightBox.app.options.popupFullsize === false); 10104 defaults_DEARVIEWER.activeLightBox.lightboxWrapper.toggleClass("df-rtl", defaults_DEARVIEWER.activeLightBox.app.options.readDirection === defaults_DEARVIEWER.READ_DIRECTION.RTL); 10105 defaults_DEARVIEWER.activeLightBox.backGround.css({ 10106 "backgroundColor": defaults_DEARVIEWER.activeLightBox.app.options.backgroundColor === "transparent" ? defaults_DEARVIEWER.defaults.popupBackGroundColor : defaults_DEARVIEWER.activeLightBox.app.options.backgroundColor 10107 }); 10108 }); 10109 } 10110 } 10111}; 10112defaults_DEARVIEWER.checkBrowserURLforDefaults = function () {
10113 if (controls_utils.isIEUnsupported) return; 10114 var viewerType = new URL(location.href).searchParams.get('viewer-type') || new URL(location.href).searchParams.get('viewertype'); 10115 var is3D = new URL(location.href).searchParams.get('is-3d') || new URL(location.href).searchParams.get('is3d'); 10116 if (viewerType) { 10117 defaults_DEARVIEWER.defaults.viewerType = viewerType; 10118 } 10119 if (is3D === "true" || is3D === "false") { 10120 defaults_DEARVIEWER.defaults.is3D = is3D === "true"; 10121 } 10122}; 10123defaults_DEARVIEWER.checkBrowserURLforPDF = function () { 10124 var openFlipbook = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 10125 if (controls_utils.isIEUnsupported) return; 10126 var pdf = new URL(location.href).searchParams.get('pdf-source'); 10127 if (pdf) { 10128 pdf = unescape(pdf); 10129 if (openFlipbook) { 10130 defaults_DEARVIEWER.openURL(pdf); 10131 } 10132 } 10133 return pdf; 10134}; 10135 10136//Exists if there is need for open file and other lightbox present in the same page. They cannot share same settings. 10137//also is needed just be a dummy elemet for lightbox dataElement 10138function createFileInput() { 10139 if (defaults_DEARVIEWER.openLocalFileInput === void 0) { 10140 var input = defaults_DEARVIEWER.openLocalFileInput = controls_jQuery('<input type="file" accept=".pdf" style="display:none">').appendTo(controls_jQuery("body")).data('option', defaults_DEARVIEWER.openFileOptions); 10141 input.change(function () { 10142 var files = input[0].files; 10143 var file; 10144 if (files.length) { 10145 file = files[0]; 10146 input.val(""); 10147 defaults_DEARVIEWER.openFile(file); 10148 } 10149 }); 10150 } 10151} 10152 10153//default fileDropHandler 10154defaults_DEARVIEWER.fileDropHandler = function (files, e) { 10155 var file = files[0]; 10156 if (file.type === "application/pdf") { 10157 e.preventDefault(); 10158 e.stopPropagation(); 10159 defaults_DEARVIEWER.openFile(file); 10160 } 10161}; 10162defaults_DEARVIEWER.openFile = function (file) { 10163 if (file) { 10164 var _DEARVIEWER$openFileS; 10165 if (defaults_DEARVIEWER.oldLocalFileObjectURL) window.URL.revokeObjectURL(defaults_DEARVIEWER.oldLocalFileObjectURL); 10166 defaults_DEARVIEWER.oldLocalFileObjectURL = window.URL.createObjectURL(file); 10167 10168 //callback to handle any actions once file is selected. 10169 (_DEARVIEWER$openFileS = defaults_DEARVIEWER['openFileSelected']) === null || _DEARVIEWER$openFileS === void 0 || _DEARVIEWER$openFileS.call(defaults_DEARVIEWER, { 10170 url: defaults_DEARVIEWER.oldLocalFileObjectURL, 10171 file: file 10172 }); 10173 defaults_DEARVIEWER.openURL(defaults_DEARVIEWER.oldLocalFileObjectURL); 10174 } else { 10175 defaults_DEARVIEWER.openURL(); 10176 } 10177}; 10178defaults_DEARVIEWER.openURL = function (src) { 10179 createFileInput(); 10180 if (src) { 10181 defaults_DEARVIEWER.openFileOptions.source = src; 10182 defaults_DEARVIEWER.openFileOptions.pdfParameters = null; 10183 } 10184 defaults_DEARVIEWER.openLightBox(defaults_DEARVIEWER.openLocalFileInput); 10185}; 10186defaults_DEARVIEWER.openBase64 = function (data) { 10187 defaults_DEARVIEWER.openFileOptions.source = null; 10188 defaults_DEARVIEWER.openFileOptions.pdfParameters = { 10189 data: atob(data) 10190 }; 10191 defaults_DEARVIEWER.openURL(); 10192}; 10193defaults_DEARVIEWER.openLocalFile = function () { 10194 createFileInput(); 10195 defaults_DEARVIEWER.openLocalFileInput.click(); 10196}; 10197 10198//jQuery events 10199defaults_DEARVIEWER.initControls = function () { 10200 //Lightbox Trigger 10201 var body = controls_jQuery('body'); 10202 if (defaults_DEARVIEWER.defaults.autoPDFLinktoViewer !== false) { 10203 body.on('click', 'a[href$=".pdf"]', function (event) { 10204 var app = controls_jQuery(this); 10205 //prevent Download button to trigger Flipbook! 10206 if (app.attr("download") !== undefined || app.attr("target") === "_blank" || app.hasClass("df-ui-btn") || app.parents(".df-app").length > 0) {} else { 10207 event.preventDefault(); 10208 app.data('source', app.attr('href')); 10209 defaults_DEARVIEWER.openLightBox(app); 10210 } 10211 }); 10212 } 10213 body.on('click', '.df-open-local-file', function (event) { 10214 defaults_DEARVIEWER.openLocalFile(); 10215 }); 10216 body.on('click', '.df-sidemenu-buttons .df-ui-close', function () { 10217 var el = controls_jQuery(this); 10218 el.closest(".df-app").find(".df-ui-btn.df-active").trigger("click"); 10219 }); 10220 body.on('mouseout', '.df-link-content section.squareAnnotation, .df-link-content section.textAnnotation, .df-link-content section.freeTextAnnotation', function () { 10221 var el = controls_jQuery(this); 10222 defaults_DEARVIEWER.handlePopup(el, false); 10223 }); 10224 body.on('mouseover', '.df-link-content section.squareAnnotation, .df-link-content section.textAnnotation, .df-link-content section.freeTextAnnotation', function () { 10225 var el = controls_jQuery(this); 10226 defaults_DEARVIEWER.handlePopup(el, true); 10227 }); 10228 defaults_DEARVIEWER.handlePopup = function (el) { 10229 var show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; 10230 var container = el.closest('.df-container'); 10231 var commentPopup = container.find('.df-comment-popup'); 10232 commentPopup.toggleClass("df-active", show); 10233 if (show) { 10234 var elBounds = el[0].getBoundingClientRect(); 10235 var containerBounds = container[0].getBoundingClientRect(); 10236 var popup = el.find(".popupWrapper").first(); 10237 commentPopup.html(popup.html()); 10238 var left = elBounds.left - containerBounds.left; 10239 if (left + 360 > containerBounds.width) left = containerBounds.width - 360 - 10;else if (left < 10) left = 10; 10240 var top = elBounds.top - containerBounds.top + elBounds.height + 5; 10241 if (top + commentPopup.height() > containerBounds.height) top = elBounds.top - commentPopup.height() - elBounds.height - 10;else if (top < 10) top = 10; 10242 commentPopup.css({ 10243 "left": left, 10244 "top": top 10245 }); 10246 } 10247 }; 10248 if (defaults_DEARVIEWER.fileDropElement != void 0) { 10249 var fileDropElement = controls_jQuery(defaults_DEARVIEWER.fileDropElement); 10250 if (fileDropElement.length > 0) { 10251 fileDropElement.on("dragover", function (event) { 10252 event.preventDefault(); 10253 event.stopPropagation(); 10254 controls_jQuery(this).addClass('df-dragging'); 10255 }); 10256 fileDropElement.on("dragleave", function (event) { 10257 event.preventDefault(); 10258 event.stopPropagation(); 10259 controls_jQuery(this).removeClass('df-dragging'); 10260 }); 10261 fileDropElement.on("drop", function (e) { 10262 var files = e.originalEvent.dataTransfer.files; // Array of all files 10263 var file; 10264 if (files.length) { 10265 defaults_DEARVIEWER.fileDropHandler(files, e); 10266 } 10267 }); 10268 } 10269 } 10270}; 10271 10272;// CONCATENATED MODULE: ./src/js/dearviewer/app.js 10273function app_typeof(o) { "@babel/helpers - typeof"; return app_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, app_typeof(o); } 10274function app_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 10275function app_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, app_toPropertyKey(descriptor.key), descriptor); } } 10276function app_createClass(Constructor, protoProps, staticProps) { if (protoProps) app_defineProperties(Constructor.prototype, protoProps); if (staticProps) app_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 10277function app_toPropertyKey(arg) { var key = app_toPrimitive(arg, "string");
10277 return app_typeof(key) === "symbol" ? key : String(key); } 10278function app_toPrimitive(input, hint) { if (app_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (app_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } 10279/* globals pdfjsLib,THREE */ 10280 10281 10282 10283var app_DV = (/* unused pure expression or super */ null && (DEARVIEWER)); 10284var app_jQuery = defaults_DEARVIEWER.jQuery; 10285var app_REQUEST_STATUS = defaults_DEARVIEWER.REQUEST_STATUS, 10286 app_utils = defaults_DEARVIEWER.utils; 10287var App = /*#__PURE__*/function () { 10288 function App(options) { 10289 var _options$maxTextureSi, _this$options$isExter; 10290 app_classCallCheck(this, App); 10291 this.options = options; 10292 this.viewerType = this.options.viewerType; 10293 this.startPage = 1; 10294 this.endPage = 1; 10295 this.element = app_jQuery(this.options.element); 10296 this.dimensions = { 10297 padding: {}, 10298 offset: {}, 10299 pageFit: {}, 10300 stage: {}, 10301 isAutoHeight: options.height === "auto", 10302 maxTextureSize: (_options$maxTextureSi = options.maxTextureSize) !== null && _options$maxTextureSi !== void 0 ? _options$maxTextureSi : 4096 10303 }; 10304 this.is3D = options.is3D; 10305 this.events = {}; 10306 this.links = options.links; 10307 this.thumbSize = 128; 10308 this.pendingZoom = true; 10309 this.currentPageNumber = this.options.openPage || this.startPage; 10310 this.hashNavigationEnabled = this.options.hashNavigationEnabled === true; 10311 this.pendingZoom = true; 10312 this.zoomValue = 1; 10313 this.pageScaling = defaults_DEARVIEWER.PAGE_SCALE.MANUAL; 10314 this.isRTL = options.readDirection === defaults_DEARVIEWER.READ_DIRECTION.RTL; 10315 this.jumpStep = 1; 10316 this.resizeRequestStatus = app_REQUEST_STATUS.OFF; 10317 this.refreshRequestStatus = app_REQUEST_STATUS.OFF; 10318 this.refreshRequestCount = 0; 10319 this.resizeRequestCount = 0; 10320 this.fullscreenSupported = app_utils.hasFullscreenEnabled(); 10321 this.thumbRequestCount = 0; 10322 this.isExternalReady = (_this$options$isExter = this.options.isExternalReady) !== null && _this$options$isExter !== void 0 ? _this$options$isExter : true; //used when external document viewer or logic needs to wait 10323 this.init(); 10324 if (this.options.autoLightBoxFullscreen === true && this.options.isLightBox === true) this.switchFullscreen(); //doesn't work properly https://github.com/deepak-ghimire/dearviewer/issues/332 10325 10326 this.executeCallback('onCreate'); 10327 this.target = this; 10328 } 10329 app_createClass(App, [{ 10330 key: "init", 10331 value: function init() { 10332 var options = this.options, 10333 app = this; 10334 app.initDOM(); 10335 app.initResourcesLocation(); 10336 app.initInfo(); 10337 10338 //region Source Validation 10339 if ((options.source == null || options.source.length === 0) && options.pdfParameters == null) { 10340 app.updateInfo("ERROR: Set a Valid Document Source.", defaults_DEARVIEWER.INFO_TYPE.ERROR); 10341 app.container.removeClass('df-loading').addClass("df-error"); 10342 return; 10343 } 10344 //endregion 10345 10346 //region Old Browsers 10347 if (app_utils.isIEUnsupported) { 10348 app.updateInfo("Your browser (Internet Explorer) is out of date! <br><a href='https://browsehappy.com/'>Upgrade to a new browser.</a>", "df-old-browser"); 10349 app.container.removeClass('df-loading').addClass("df-error"); 10350 return; 10351 } 10352 //endregion 10353 10354 app.commentPopup = app_jQuery('<div class="df-comment-popup">').appendTo(app.container); 10355 app.viewer = new app.viewerType(options, this); 10356 app.sideMenu = new Sidemenu({ 10357 parentElement: this.container 10358 }, app); 10359 app.provider = new defaults_DEARVIEWER.providers[options.providerType](options, app); 10360 app.state = 'loading'; 10361 app.checkRequestQueue(); 10362 } 10363 }, { 10364 key: "initDOM", 10365 value: function initDOM() { 10366 this.element.addClass("df-app").removeClass("df-container df-loading"); 10367 this.container = app_jQuery("<div>").appendTo(this.element); 10368 // Q. Why are this.element and this.container defined separately? 10369 // A. In IOS when fullscreen is used, then the whole this.container can be transferred to the pseudo fullscreen container that stays at the last of the DOM. 10370 10371 this.container.addClass('df-container df-loading df-init' + " df-control
10371s-" + this.options.controlsPosition + (this.options.controlsFloating === true ? " df-float" : " df-float-off") + (this.options.backgroundColor === 'transparent' ? " df-transparent" : "") + (this.isRTL === true ? " df-rtl" : "") + (app_utils.isIOS === true || app_utils.isIPad === true ? " df-ios" : "")); 10372 this._offsetParent = this.container[0].offsetParent; 10373 this.backGround = app_jQuery("<div class='df-bg'>").appendTo(this.container).css({ 10374 "backgroundColor": this.options.backgroundColor, 10375 "backgroundImage": this.options.backgroundImage ? "url('" + this.options.backgroundImage + "')" : '' 10376 }); 10377 this.viewerContainer = app_jQuery("<div>").appendTo(this.container); 10378 this.viewerContainer.addClass('df-viewer-container'); 10379 } 10380 10381 /** 10382 * Prepares Resource location based on the window[DEARVIEWER.locationVar] 10383 */ 10384 }, { 10385 key: "initResourcesLocation", 10386 value: function initResourcesLocation() { 10387 var options = this.options; 10388 if (typeof window[defaults_DEARVIEWER.locationVar] !== 'undefined') { 10389 options.pdfjsSrc = window[defaults_DEARVIEWER.locationVar] + "js/libs/pdf.min.js"; 10390 options.threejsSrc = window[defaults_DEARVIEWER.locationVar] + "js/libs/three.min.js"; 10391 options.pdfjsWorkerSrc = window[defaults_DEARVIEWER.locationVar] + "js/libs/pdf.worker.min.js"; 10392 options.soundFile = window[defaults_DEARVIEWER.locationVar] + options.soundFile; 10393 options.imagesLocation = window[defaults_DEARVIEWER.locationVar] + options.imagesLocation; 10394 options.imageResourcesPath = window[defaults_DEARVIEWER.locationVar] + options.imageResourcesPath; 10395 options.cMapUrl = window[defaults_DEARVIEWER.locationVar] + options.cMapUrl; 10396 if (options.pdfVersion !== undefined) { 10397 var pdfDir = ""; 10398 if (options.pdfVersion == "latest" || options.pdfVersion == "beta") { 10399 pdfDir = "latest"; 10400 } else if (options.pdfVersion == "stable") { 10401 //old stable version 10402 pdfDir = "stable"; 10403 } 10404 if (pdfDir !== "default" && pdfDir !== "") { 10405 options.pdfjsSrc = window[defaults_DEARVIEWER.locationVar] + "js/libs/pdfjs/" + pdfDir + "/pdf.min.js"; 10406 options.pdfjsWorkerSrc = window[defaults_DEARVIEWER.locationVar] + "js/libs/pdfjs/" + pdfDir + "/pdf.worker.min.js"; 10407 } 10408 } 10409 } else { 10410 console.warn("DEARVIEWER locationVar not found!"); 10411 } 10412 this.executeCallback('onInitResourcesLocation'); 10413 } 10414 }, { 10415 key: "initEvents", 10416 value: function initEvents() { 10417 var app = this, 10418 containerDOM = this.container[0]; 10419 // Use our detect's results. passive applied if supported, capture will be false either way. 10420 // let opts = utils.supportsPassive ? {passive: true} : false; 10421 var opts = false; //passive is not possible. like it's in https://www.google.com/maps/ 10422 window.addEventListener("resize", app.events.resize = app.resetResizeRequest.bind(app), false); 10423 containerDOM.addEventListener("mousemove", app.events.mousemove = app.mouseMove.bind(app), false); 10424 containerDOM.addEventListener("mousedown", app.events.mousedown = app.mouseDown.bind(app), false); 10425 window.addEventListener("mouseup", app.events.mouseup = app.mouseUp.bind(app), false); 10426 containerDOM.addEventListener("touchmove", app.events.touchmove = app.mouseMove.bind(app), opts); 10427 containerDOM.addEventListener("touchstart", app.events.touchstart = app.mouseDown.bind(app), opts); 10428 window.addEventListener("touchend", app.events.touchend = app.mouseUp.bind(app), false); 10429 } 10430 }, { 10431 key: "mouseMove", 10432 value: function mouseMove(event) { 10433 if (event.touches && event.touches.length > 1) { 10434 event.preventDefault(); 10435 } 10436 if (this.viewer.acceptAppMouseEvents === true) this.viewer.mouseMove(event); 10437 } 10438 }, { 10439 key: "mouseDown", 10440 value: function mouseDown(event) { 10441 this.userHasInteracted = true; 10442 if (this.viewer.acceptAppMouseEvents === true && app_jQuery(event.srcElement).closest(".df-sidemenu").length === 0) this.viewer.mouseDown(event); 10443 } 10444 }, { 10445 key: "mouseUp", 10446 value: function mouseUp(event) { 10447 if (this.viewer && this.viewer.acceptAppMouseEvents === true) this.viewer.mouseUp(event); 10448 } 10449 }, { 10450 key: "softDispose", 10451 value: function softDispose() { 10452 var app = this; 10453 app.softDisposed = true; 10454 app.provider.dispose(); 10455 app.viewer.dispose(); 10456 } 10457 }, { 10458 key: "softInit", 10459 value: function softInit() { 10460 var app = this; 10461 app.viewer = new app.viewerType(app.options, this); 10462 app.provider = new defaults_DEARVIEWER.providers[app.options.providerType](app.options, app); 10463 app.softDisposed = false;
10464 } 10465 }, { 10466 key: "dispose", 10467 value: function dispose() { 10468 var _app$info, _app$loadingIcon, _app$backGround, _app$outlineContainer, _app$commentPopup; 10469 var app = this, 10470 containerDOM = this.container[0]; 10471 clearInterval(this.autoPlayTimer); 10472 this.autoPlayTimer = null; 10473 this.autoPlayFunction = null; 10474 app.provider = app_utils.disposeObject(app.provider); 10475 app.contentProvider = null; 10476 app.target = null; 10477 app.viewer = app_utils.disposeObject(app.viewer); 10478 app.sideMenu = app_utils.disposeObject(app.sideMenu); 10479 app.ui = app_utils.disposeObject(app.ui); 10480 app.thumblist = app_utils.disposeObject(app.thumblist); 10481 app.outlineViewer = app_utils.disposeObject(app.outlineViewer); 10482 if (this.events) { 10483 window.removeEventListener("resize", app.events.resize, false); 10484 containerDOM.removeEventListener("mousemove", app.events.mousemove, false); 10485 containerDOM.removeEventListener("mousedown", app.events.mousedown, false); 10486 window.removeEventListener("mouseup", app.events.mouseup, false); 10487 containerDOM.removeEventListener("touchmove", app.events.touchmove, false); 10488 containerDOM.removeEventListener("touchstart", app.events.touchstart, false); 10489 window.removeEventListener("touchend", app.events.touchend, false); 10490 } 10491 app.events = null; 10492 app.options = null; 10493 app.element.removeClass("df-app"); 10494 app.viewerType = null; 10495 app.checkRequestQueue = null; 10496 (_app$info = app.info) === null || _app$info === void 0 || _app$info.remove(); 10497 app.info = null; 10498 (_app$loadingIcon = app.loadingIcon) === null || _app$loadingIcon === void 0 || _app$loadingIcon.remove(); 10499 app.loadingIcon = null; 10500 (_app$backGround = app.backGround) === null || _app$backGround === void 0 || _app$backGround.remove(); 10501 app.backGround = null; 10502 (_app$outlineContainer = app.outlineContainer) === null || _app$outlineContainer === void 0 || _app$outlineContainer.remove(); 10503 app.outlineContainer = null; 10504 (_app$commentPopup = app.commentPopup) === null || _app$commentPopup === void 0 || _app$commentPopup.remove(); 10505 app.commentPopup = null; 10506 app.viewerContainer.off(); 10507 app.viewerContainer.remove(); 10508 app.viewerContainer = null; 10509 app.container.off(); 10510 app.container.remove(); 10511 app.container = null; 10512 app.element.off(); 10513 app.element.data("df-app", null); 10514 app.element = null; 10515 app._offsetParent = null; 10516 app.dimensions = null; 10517 } 10518 }, { 10519 key: "resetResizeRequest", 10520 value: function resetResizeRequest() { 10521 this.resizeRequestStatus = app_REQUEST_STATUS.COUNT; 10522 this.resizeRequestCount = 0; 10523 this.container.addClass("df-pendingresize"); 10524 this.pendingResize = true; 10525 } 10526 10527 /** 10528 * Prepares the element for displaying Loading icon 10529 */ 10530 }, { 10531 key: "initInfo", 10532 value: function initInfo() { 10533 this.info = app_jQuery('<div>', { 10534 "class": 'df-loading-info' 10535 }); 10536 this.container.append(this.info); 10537 this.info.html(this.options.text.loading + "..."); 10538 this.loadingIcon = app_jQuery('<div>', { 10539 "class": 'df-loading-icon' 10540 }).appendTo(this.container); 10541 } 10542 10543 // noinspection JSUnusedLocalSymbols 10544 }, { 10545 key: "updateInfo", 10546 value: function updateInfo(message, className) { 10547 app_utils.log(message); 10548 if (this.info !== void 0) { 10549 this.info.html(message); 10550 } 10551 } 10552 }, { 10553 key: "_documentLoaded", 10554 value: function _documentLoaded() { 10555 app_utils.log("Document Loaded"); 10556 this.isDocumentReady = true; 10557 this.contentProvider = this.provider; 10558 this.executeCallback('onDocumentLoad'); 10559 this.endPage = this.pageCount = this.provider.pageCount; 10560 this.currentPageNumber = this.getValidPage(this.currentPageNumber); 10561 } 10562 }, { 10563 key: "_viewerPrepared", 10564 value: function _viewerPrepared() { 10565 app_utils.log("Viewer Prepared"); 10566 this.isViewerPrepared = true; 10567 this.executeCallback('onViewerLoad'); 10568 } 10569 }, { 10570 key: "requestFinalize", 10571 value: function requestFinalize() { 10572 if (this.isDocumentReady !== true || this.isViewerPrepared !== true || this.isExternalReady !== true || this.finalizeRequested === true) return; 10573 this.finalizeRequested = true; 10574 this.finalize(); 10575 } 10576 }, { 10577 key: "finalizeComponents", 10578 value: function finalizeComponents() { 10579 this.ui = new UI({}, this); 10580 this.ui.init(); 10581 this.calculateLayout(); 10582 this.viewer.init(); 10583 } 10584 }, { 10585 key: "finalize", 10586 value: function finalize() { 10587 this.resize(); 10588 this.ui.update(); 10589 this.initEvents(); 10590 if (this.options.isLightBox == true) { 10591 this.analytics({ 10592 eventAction: this.options.analyticsViewerOpen, 10593 options: this.options 10594 }); 10595 } 10596 this.container.removeClass('df-loading df-init'); 10597 this.viewer.onReady(); 10598 this.analytics({ 10599 eventAction: this.options.analyticsViewerReady, 10600 options: this.options 10601 }); 10602 this.executeCallback('onReady'); 10603 if (this.options.dataElement.hasClass("df-hash-focused") === true) { 10604 app_utils.focusHash(this.options.dataElement); 10605 this.options.dataElement.removeClass("df-hash-focused"); 10606 } 10607 app_utils.log("App Finalized"); 10608 } 10609 }, { 10610 key: "initOutline", 10611 value: function initOutline() { 10612 var app = this; 10613 var outlineContainer = app_jQuery('<div>').addClass("df-outline-container df-sidemenu"); 10614 outlineContainer.append('<div class="df-sidemenu-title">Table of Contents</div>'); 10615 var outlineWrapper = app_jQuery('<div>').addClass("df-wrapper"); 10616 outlineContainer.append(outlineWrapper); 10617 app.sideMenu.element.append(outlineContainer); 10618 app.outlineContainer = outlineContainer; 10619 app.outlineViewer = new BookMarkViewer({ 10620 container: outlineWrapper[0], 10621 linkService: app.provider.linkService, 10622 outlineItemClass: "df-outline-item", 10623 outlineToggleClass: "df-outline-toggle", 10624 outlineToggleHiddenClass: "df-outlines-hidden" 10625 }); 10626 app.outlineViewer.render({ 10627 outline: app.provider.outline 10628 }); 10629 } 10630 }, { 10631 key: "initThumbs", 10632 value: function initThumbs() { 10633 var app = this; 10634 app.thumblist = new ThumbList({ 10635 app: app, 10636 addFn: function addFn(row) {}, 10637 scrollFn: function scrollFn() { 10638 app.thumbRequestStatus = app_REQUEST_STATUS.ON; 10639 }, 10640 itemHeight: app.thumbSize, 10641 itemWidth: app_utils.limitAt(Math.floor(app.dimensions.defaultPage.ratio * app.thumbSize), 32, 180), 10642 totalRows: app.pageCount 10643 }); 10644 app.thumblist.lastScrolled = Date.now(); 10645 app.thumbRequestStatus = app_REQUEST_STATUS.ON; 10646 var thumbContainer = app_jQuery('<div>').addClass("df-thumb-container df-sidemenu"); 10647 thumbContainer.append('<div class="df-sidemenu-title">Thumbnails</div>'); 10648 thumbContainer.append(app_jQuery(app.thumblist.container).addClass("df-wrapper")); 10649 app.thumbContainer = thumbContainer; 10650 app.sideMenu.element.append(thumbContainer); 10651 app.container.on('click', '.df-thumb-container .df-thumb', function (e) { 10652 e.stopPropagation(); 10653 var id = app_jQuery(this).attr("id").replace("df-thumb", ""); 10654 app.gotoPage(parseInt(id, 10)); 10655 }); 10656 } 10657 }, { 10658 key: "initSearch", 10659 value: function initSearch() { 10660 var app = this; 10661 var searchContainer = app_jQuery('<div>').addClass("df-search-container df-sidemenu"); 10662 searchContainer.append('<div class="df-sidemenu-title">Search</div>'); 10663 app.searchForm = app_jQuery('<div class="df-search-form">').appendTo(searchContainer); 10664 app.searchBox = app_jQuery('<input type="text" class="df-search-text" placeholder="Search">').on("keyup", function (event) { 10665 if (event.keyCode === 13) { 10666 app.search(); 10667 } 10668 }).appendTo(app.searchForm); 10669 app.searchButton = app_jQuery('<div class="df-ui-btn df-search-btn df-icon-search">').on("click", function (event) { 10670 app.search(); 10671 }).appendTo(app.searchForm); 10672 app.clearButton = app_jQuery('<a class="df-search-clear">Clear</a>').on("click", function (event) { 10673 app.clearSearch(); 10674 }).appendTo(app.searchForm); 10675 app.searchInfo = app_jQuery('<div class="df-search-info">').appendTo(searchContainer); 10676 app.searchResults = app_jQuery('<div class="df-wrapper df-search-results">').appendTo(searchContainer); 10677 app.searchContainer = searchContainer; 10678 app.sideMenu.element.append(searchContainer); 10679 app.container.on('click', '.df-search-result', function (e) { 10680 e.stopPropagation(); 10681 var element = app_jQuery(this); 10682 var id = element.data("page"); 10683 app.gotoPage(parseInt(id, 10)); 10684 }); 10685 } 10686 }, { 10687 key: "search", 10688 value: function search(text) { 10689 if (text == void 0) { 10690 text = this.searchBox.val(); 10691 } 10692 this.provider.search(text.trim()); 10693 } 10694 }, { 10695 key: "clearSearch", 10696 value: function clearSearch() { 10697 this.searchBox.val(""); 10698 this.searchInfo.html(""); 10699 this.provider.clearSearch(); 10700 } 10701 }, { 10702 key: "updateSearchInfo", 10703 value: function updateSearchInfo(message) { 10704 app_utils.log(message); 10705 if (this.searchInfo !== void 0) { 10706 this.searchInfo.html(message); 10707 } 10708 } 10709 }, { 10710 key: "checkRequestQueue", 10711 value: function checkRequestQueue() { 10712 var app = this; 10713 if (app.checkRequestQueue) { 10714 requestAnimationFrame(function () { 10715 if (app && app.checkRequestQueue) app.checkRequestQueue(); 10716 }); 10717 } 10718 if (app.softDisposed) return; 10719 10720 //region loading & initiaization 10721 if (app.state != 'ready') { 10722 if (app.state === 'loading' && this.isDocumentReady === true && this.isViewerPrepared === true && this.isExternalReady === true) { 10723 app.state = 'finalizing'; //need to add ahead else it can keep running multiple times if the funcion throws error. 10724 this.finalizeComponents(); 10725 } 10726 if (app.state === 'finalizing') { 10727 app.state = 'ready'; 10728 app.finalize(); 10729 } 10730 return; 10731 } 10732 //endregion 10733 10734 //offsetParent changes when display : none to block changes, scenarios in tab 10735 if (app.container && app.container[0] 10736 // && app.options.isLightBox !== true 10737 && app._offsetParent !== app.container[0].offsetParent) { 10738 app._offsetParent = app.container[0].offsetParent; 10739 if (app._offsetParent !== null) { 10740 app.resize(); 10741 app.resizeRequestStatus = app_REQUEST_STATUS.OFF; 10742 } 10743 app_utils.log("Visibility Resize Detected"); 10744 } 10745 if (app._offsetParent === null && !app.isFullscreen) return; 10746 10747 // Removed since stage.render() is called from app.viewer.render(); - encapsulated 10748 // if (app.viewer.stage && app.viewer.stage.render) 10749 // app.viewer.stage.render(); 10750 10751 if (TWEEN.getAll().length > 0) { 10752 TWEEN.update(); 10753 app.renderRequestStatus = app_REQUEST_STATUS.ON; 10754 } 10755 if (app.resizeRequestStatus === app_REQUEST_STATUS.ON) { 10756 app.resizeRequestStatus = app_REQUEST_STATUS.OFF; 10757 app.resize(); 10758 } else if (app.resizeRequestStatus === app_REQUEST_STATUS.COUNT) { 10759 app.resizeRequestCount++; 10760 if (app.resizeRequestCount > 10) { 10761 app.resizeRequestCount = 0; 10762 app.resizeRequestStatus = app_REQUEST_STATUS.ON; 10763 } 10764 } 10765 if (app.refreshRequestStatus === app_REQUEST_STATUS.ON) { 10766 app.refreshRequestStatus = app_REQUEST_STATUS.OFF; 10767 app.pendingResize = false;
10768 app.viewer.refresh(); 10769 this.container.removeClass("df-pendingresize"); 10770 } else if (app.refreshRequestStatus === app_REQUEST_STATUS.COUNT) { 10771 app.refreshRequestCount++; 10772 if (app.refreshRequestCount > 3) { 10773 app.refreshRequestCount = 0; 10774 app.refreshRequestStatus = app_REQUEST_STATUS.ON; 10775 } 10776 } 10777 if (app.textureRequestStatus === app_REQUEST_STATUS.ON) { 10778 app.processTextureRequest(); 10779 } 10780 if (app.thumbRequestStatus === app_REQUEST_STATUS.ON) app.processThumbRequest();else if (app.thumbRequestStatus === app_REQUEST_STATUS.COUNT) { 10781 app.thumbRequestCount++; 10782 if (app.thumbRequestCount > 3) { 10783 app.thumbRequestCount = 0; 10784 app.thumbRequestStatus = app_REQUEST_STATUS.ON; 10785 } 10786 } 10787 if (app.renderRequestStatus === app_REQUEST_STATUS.ON) { 10788 app.viewer.render(); 10789 app.renderRequestStatus = app_REQUEST_STATUS.OFF; 10790 } 10791 app.provider.checkRequestQueue(); 10792 app.viewer.checkRequestQueue(); 10793 } 10794 }, { 10795 key: "processTextureRequest", 10796 value: function processTextureRequest() { 10797 // utils.log("Texture Request Preparing"); 10798 var app = this, 10799 viewer = this.viewer, 10800 provider = this.provider; 10801 var visible = viewer.getVisiblePages().main, 10802 page, 10803 textureSize, 10804 requestCount = 0, 10805 zoomView = app.zoomValue > 1; //this should be independent of zoomview 10806 10807 if (!viewer.isAnimating()) { 10808 app_utils.log("Texture Request Working"); 10809 for (var i = 0; i < visible.length; i++) { 10810 requestCount = 0; 10811 var pageNumber = visible[i]; 10812 if (pageNumber > 0 && pageNumber <= app.pageCount) { 10813 page = zoomView ? viewer.zoomViewer.getPageByNumber(pageNumber) : viewer.getPageByNumber(pageNumber); 10814 if (page) { 10815 textureSize = viewer.getTextureSize({ 10816 pageNumber: pageNumber 10817 }); 10818 if (page.changeTexture(pageNumber, Math.floor(textureSize.height))) { 10819 provider.processPage({ 10820 pageNumber: pageNumber, 10821 textureTarget: zoomView ? defaults_DEARVIEWER.TEXTURE_TARGET.ZOOM : defaults_DEARVIEWER.TEXTURE_TARGET.VIEWER 10822 }); 10823 requestCount++; 10824 app.viewer.getAnnotationElement(pageNumber, true); 10825 } 10826 } 10827 if (requestCount > 0) break; 10828 } 10829 } 10830 if (requestCount === 0) { 10831 app.textureRequestStatus = app_REQUEST_STATUS.OFF; 10832 } 10833 } else { 10834 app.textureRequestStatus = app_REQUEST_STATUS.ON; 10835 } 10836 } 10837 }, { 10838 key: "applyTexture", 10839 value: function applyTexture(canvas, param) { 10840 var app = this; 10841 var isCanvas = canvas.toDataURL !== void 0; 10842 if (param.textureTarget === defaults_DEARVIEWER.TEXTURE_TARGET.THUMB) { 10843 param.height = canvas.height; 10844 param.width = canvas.width; 10845 if (!isCanvas) { 10846 //case of direct image 10847 param.texture = canvas.src; 10848 } else { 10849 var src = canvas.toDataURL('image/png'); 10850 app.provider.setCache(param.pageNumber, src, app.thumbSize); 10851 param.texture = src; 10852 } 10853 app.thumblist.setPage(param); 10854 } else { 10855 param.texture = isCanvas ? canvas : canvas.src; 10856 var set = app.viewer.setPage(param); 10857 if (set === true) { 10858 app.provider.processAnnotations(param.pageNumber, app.viewer.getAnnotationElement(param.pageNumber, true)); 10859 app.provider.processTextContent(param.pageNumber, app.viewer.getTextElement(param.pageNumber, true)); 10860 } 10861 } 10862 } 10863 }, { 10864 key: "processThumbRequest", 10865 value: function processThumbRequest() { 10866 if (this.thumblist !== null && this.thumblist !== undefined) this.thumblist.processThumbRequest(); 10867 } 10868 }, { 10869 key: "refreshRequestStart", 10870 value: function refreshRequestStart() { 10871 this.refreshRequestStatus = app_REQUEST_STATUS.COUNT; 10872 this.refreshRequestCount = 0; 10873 } 10874 }, { 10875 key: "renderRequestStart", 10876 value: function renderRequestStart() { 10877 this.renderRequestStatus = app_REQUEST_STATUS.ON; 10878 } 10879 }, { 10880 key: "resizeRequestStart", 10881 value: function resizeRequestStart() { 10882 this.resizeRequestStatus = app_REQUEST_STATUS.ON; 10883 } 10884 }, { 10885 key: "zoom", 10886 value: function zoom(delta) { 10887 var app = this; 10888 app.pendingZoom = true; 10889 app.zoomDelta = delta; 10890 app.resize(); 10891 } 10892 }, { 10893 key: "resetZoom", 10894 value: function resetZoom() { 10895 if (this.zoomValue !== 1) { 10896 this.zoomValue = 1.001; 10897 this.zoom(-1); 10898 } 10899 } 10900 }, { 10901 key: "calculateLayout", 10902 value: function calculateLayout() { 10903 var _jQuery$height, _app$options$headerEl; 10904 var app = this, 10905 isSideMenuOpen = app.isSideMenuOpen = app.container.hasClass("df-sidemenu-open"), 10906 dimensions = app.dimensions, 10907 padding = app.dimensions.padding, 10908 windowHeight = app_jQuery(window).height(); 10909 10910 // region Calculation of Offset and Padding 10911 dimensions.offset = { 10912 top: 0, 10913 left: !app.options.sideMenuOverlay && isSideMenuOpen && !app.isRTL ? 220 : 0, 10914 right: !app.options.sideMenuOverlay && isSideMenuOpen && app.isRTL ? 220 : 0, 10915 bottom: 0, 10916 width: !app.options.sideMenuOverlay && isSideMenuOpen ? 220 : 0 10917 }; 10918 app.viewerContainer.css({ 10919 left: dimensions.offset.left, 10920 right: dimensions.offset.right 10921 }); 10922 var controlsHeight = dimensions.controlsHeight = app.container.find(".df-ui").height(); 10923 padding.top = app.options.paddingTop + (app.options.controlsPosition === defaults_DEARVIEWER.CONTROLS_POSITION.TOP ? controlsHeight : 0); 10924 padding.left = app.options.paddingLeft; 10925 padding.right = app.options.paddingRight; 10926 padding.bottom = app.options.paddingBottom + (app.options.controlsPosition === defaults_DEARVIEWER.CONTROLS_POSITION.BOTTOM ? controlsHeight : 0); 10927 padding.height = padding.top + padding.bottom; 10928 padding.width = padding.left + padding.right; 10929 padding.heightDiff = padding.top - padding.bottom; 10930 padding.widthDiff = padding.left - padding.right; 10931 //endregion 10932 10933 //Priority: (isFullSize|isLockedHeight > isLockedHeight) > autoHeight 10934 dimensions.isFullSize = app.isFullscreen === true; 10935 dimensions.isFixedHeight = dimensions.isFullSize || !dimensions.isAutoHeight; 10936 dimensions.containerWidth = dimensions.isFullSize ? app_jQuery(window).width() : this.element.width(); 10937 app.container.toggleClass('df-xs', dimensions.containerWidth < 400).toggleClass('df-xss', dimensions.containerWidth < 320); 10938 10939 //region Determine MaxHeight 10940 dimensions.maxHeight = windowHeight - (dimensions.containerWidth > 600 ? (_jQuery$height = app_jQuery((_app$options$headerEl = app.options.headerElementSelector) !== null && _app$options$headerEl !== void 0 ? _app$options$headerEl : "#wpadminbar").height()) !== null && _jQuery$height !== void 0 ? _jQuery$height : 0 : 0); 10941 if (dimensions.isFixedHeight) { 10942 if (dimensions.isFullSize) { 10943 dimensions.maxHeight = windowHeight; 10944 } else { 10945 //locked height but not in fullsize 10946 //incase height is restricted by value provided by user, we need to determine that first 10947 //test height on element, but apply on container. 10948 app.element.height(app.options.height); 10949 var _height = app.element.height(); 10950 dimensions.maxHeight = Math.min(_height, dimensions.maxHeight); 10951 } 10952 } else {} 10953 //endregion 10954 10955 //Reference size is not the cover page. IT IS THE VIRTUAL AVAILABLE ZONE 10956 //we have outerWidth, it gives innerwidth 10957 //with innerwidth we get innerheight and then outerHeight 10958 //app should only store outerWidth and outerHeight 10959 var outerWidth = dimensions.width, 10960 innerWidth = dimensions.stage.innerWidth = this.viewer._getInnerWidth(), 10961 // innerwidth finalized by viewers
10962 innerHeight = dimensions.stage.innerHeight = this.viewer._getInnerHeight(), 10963 outerHeight = this.viewer._getOuterHeight(innerHeight + dimensions.padding.height); 10964 dimensions.containerHeight = dimensions.isFullSize ? windowHeight : outerHeight; 10965 app.element.height(dimensions.containerHeight); 10966 10967 //Case when User sets height through CSS override. #199 10968 var testHeight = app.element.height(); 10969 if (!dimensions.isFullSize && testHeight != dimensions.containerHeight) { 10970 dimensions.containerHeight = testHeight; 10971 dimensions.stage.innerHeight = testHeight - dimensions.padding.height; 10972 dimensions.stage.height = testHeight; 10973 } 10974 10975 /*ZOOM values*/ 10976 dimensions.origin = { 10977 //required in zoom 10978 x: (padding.widthDiff + dimensions.containerWidth - dimensions.offset.left - dimensions.offset.right) / 2, 10979 y: (padding.heightDiff + dimensions.containerHeight) / 2 10980 }; 10981 app.viewer.determinePageMode(); 10982 } 10983 }, { 10984 key: "resize", 10985 value: function resize() { 10986 var textureRefresh = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; 10987 app_utils.log("Resize Request Initiated"); 10988 var app = this; 10989 this.calculateLayout(); 10990 app.viewer.handleZoom(); 10991 app.viewer.resize(); 10992 if (textureRefresh === false) return; 10993 if (app.pendingZoom) { 10994 this.viewer.refresh(); 10995 app_utils.log("Pending Zoom updated"); 10996 } else this.refreshRequestStart(); 10997 this.ui.update(); 10998 this.renderRequestStatus = app_REQUEST_STATUS.ON; 10999 app.zoomChanged = false; 11000 app.pendingZoom = false;
11001 this.executeCallback('afterResize'); 11002 } 11003 }, { 11004 key: "hasOutline", 11005 value: function hasOutline() { 11006 if (this.provider.outline.length > 0) return true; 11007 } 11008 }, { 11009 key: "switchFullscreen", 11010 value: function switchFullscreen() { 11011 var _app$ui; 11012 var app = this; 11013 // ui = viewer.ui; 11014 11015 var element = app.container[0]; 11016 app.container.toggleClass("df-fullscreen", app.isFullscreen !== true); 11017 if (app !== null && app !== void 0 && (_app$ui = app.ui) !== null && _app$ui !== void 0 && (_app$ui = _app$ui.controls) !== null && _app$ui !== void 0 && _app$ui.fullscreen) app.ui.controls.fullScreen.toggleClass(app.options.icons["fullscreen-off"], app.isFullscreen !== true); 11018 if (app.isFullscreen !== true) { 11019 var _promise = null; 11020 //noinspection JSUnresolvedVariable 11021 if (element['requestFullscreen']) { 11022 _promise = element['requestFullscreen'](); 11023 } else if (element['msRequestFullscreen']) { 11024 _promise = element['msRequestFullscreen'](); 11025 } else if (element['mozRequestFullScreen']) { 11026 _promise = element['mozRequestFullScreen'](); 11027 } else if (element['webkitRequestFullscreen']) { 11028 _promise = element['webkitRequestFullscreen'](); 11029 } 11030 if (_promise && _promise["then"]) { 11031 _promise.then(function () { 11032 app.refreshRequestStatus === app_REQUEST_STATUS.ON; 11033 app.resize(); 11034 }); 11035 } 11036 app.isFullscreen = true; 11037 } else { 11038 app.isFullscreen = false; 11039 if (document['exitFullscreen']) { 11040 if (document.fullscreenElement) document['exitFullscreen'](); 11041 } else if (document['msExitFullscreen']) { 11042 document['msExitFullscreen'](); 11043 } else if (document['mozCancelFullScreen']) { 11044 document['mozCancelFullScreen'](); 11045 } else if (document['webkitExitFullscreen']) { 11046 document['webkitExitFullscreen'](); 11047 } 11048 // if (app.options.autoLightBoxFullscreen === true && app.options.isLightBox === true) { 11049 // DEARPDF.activeLightBox.close(); 11050 // } 11051 if (!app_utils.hasFullscreenEnabled()) { 11052 app.container[0].scrollIntoView(); 11053 } 11054 } 11055 if (!app_utils.hasFullscreenEnabled()) { 11056 app.resizeRequestStatus = app_REQUEST_STATUS.ON; 11057 } 11058 } 11059 11060 //region Navigation 11061 }, { 11062 key: "next", 11063 value: function next() { 11064 this.jumpBy(this.jumpStep); 11065 } 11066 }, { 11067 key: "prev", 11068 value: function prev() { 11069 this.jumpBy(-this.jumpStep); 11070 } 11071 }, { 11072 key: "jumpBy", 11073 value: function jumpBy(step) { 11074 var nextPage = this.currentPageNumber + step; 11075 nextPage = app_utils.limitAt(nextPage, this.startPage, this.endPage); 11076 if (this.anyFirstPageChanged != true) { 11077 this.analytics({ 11078 eventAction: this.options.analyticsFirstPageChange, 11079 options: this.options 11080 }); 11081 this.anyFirstPageChanged = true; 11082 } 11083 this.gotoPage(nextPage); 11084 this.ui.update(); 11085 } 11086 }, { 11087 key: "openRight", 11088 value: function openRight() { 11089 this.isRTL ? this.prev() : this.next(); 11090 } 11091 }, { 11092 key: "openLeft", 11093 value: function openLeft() { 11094 this.isRTL ? this.next() : this.prev(); 11095 } 11096 }, { 11097 key: "start", 11098 value: function start() { 11099 this.gotoPage(this.startPage); 11100 } 11101 }, { 11102 key: "end", 11103 value: function end() { 11104 this.gotoPage(this.endPage); 11105 } 11106 }, { 11107 key: "gotoPage", 11108 value: function gotoPage(pageNumber) { 11109 var app = this; 11110 pageNumber = app.getValidPage(parseInt(pageNumber, 10)); 11111 if (app.viewer === null || app.viewer.validatePageChange(pageNumber) === false) return; 11112 this.executeCallback('beforePageChanged'); 11113 app.requestDestRefKey = undefined; 11114 app.container.removeClass('df-fetch-pdf'); 11115 app.oldPageNumber = app.currentPageNumber; 11116 app.currentPageNumber = pageNumber; 11117 app.thumbRequestStatus = app_REQUEST_STATUS.ON; 11118 if (app.viewer.gotoPageCallBack) app.viewer.gotoPageCallBack(); 11119 app.ui.update(); 11120 if (this.autoPlay == true) { 11121 this.setAutoPlay(this.autoPlay); 11122 } 11123 if (this.hashNavigationEnabled === true) this.getURLHash(); 11124 this.executeCallback('onPageChanged'); 11125 } 11126 }, { 11127 key: "gotoPageLabel", 11128 value: function gotoPageLabel(pageLabel) { 11129 this.gotoPage(this.provider.getPageNumberForLabel(pageLabel.toString().trim())); 11130 } 11131 }, { 11132 key: "getCurrentLabel", 11133 value: function getCurrentLabel() { 11134 return this.provider.getLabelforPage(this.currentPageNumber); 11135 } 11136 }, { 11137 key: "autoPlayFunction", 11138 value: function autoPlayFunction() { 11139 if (this && this.autoPlay) { 11140 var nextPage = app_utils.limitAt(this.currentPageNumber + this.jumpStep, this.startPage, this.endPage); 11141 if (nextPage !== this.currentPageNumber) { 11142 this.next(); 11143 } else { 11144 this.setAutoPlay(false); 11145 } 11146 } 11147 } 11148 }, { 11149 key: "setAutoPlay", 11150 value: function setAutoPlay(isPlay) { 11151 if (this.options.autoPlay) { 11152 isPlay = isPlay == true; 11153 var text = isPlay ? this.options.text.pause : this.options.text.play; 11154 this.ui.controls.play.toggleClass(this.options.icons['pause'], isPlay); 11155 this.ui.controls.play.html("<span>
11155" + text + "</span>"); 11156 this.ui.controls.play.attr("title", text); 11157 clearInterval(this.autoPlayTimer); 11158 if (isPlay) { 11159 this.autoPlayTimer = setInterval(this.autoPlayFunction.bind(this), this.options.autoPlayDuration); 11160 } 11161 this.autoPlay = isPlay; 11162 } 11163 } 11164 11165 //endregion 11166 }, { 11167 key: "isValidPage", 11168 value: function isValidPage(pageNumber) { 11169 return this.provider._isValidPage(pageNumber); 11170 } 11171 }, { 11172 key: "getValidPage", 11173 value: function getValidPage(pageNumber) { 11174 var app = this; 11175 if (isNaN(pageNumber)) pageNumber = app.currentPageNumber;else if (pageNumber < 1) pageNumber = 1;else if (pageNumber > app.pageCount) pageNumber = app.pageCount; 11176 return pageNumber; 11177 } 11178 }, { 11179 key: "getURLHash", 11180 value: function getURLHash() { 11181 if (this.options.id != null) { 11182 var hash = app_utils.getSharePrefix(this.options.sharePrefix) + (this.options.slug != null ? this.options.slug : this.options.id) + "/"; 11183 if (this.currentPageNumber != null) { 11184 hash += this.currentPageNumber + "/"; 11185 } 11186 history.replaceState(undefined, undefined, "#" + hash); 11187 } 11188 return window.location.href; 11189 } 11190 }, { 11191 key: "executeCallback", 11192 value: function executeCallback(callbackName) {} 11193 }, { 11194 key: "analytics", 11195 value: function analytics(eventData) {} 11196 }]); 11197 return App; 11198}(); 11199defaults_DEARVIEWER.prepareOptions = function (options) { 11200 //convert the element to jQuery Element 11201 if (!(options.element instanceof app_jQuery)) options.element = app_jQuery(options.element); 11202 var element = options.element; 11203 /** 11204 * @type {jQuery|HTMLElement} - is useful when lightbox is displayed in one location but the options are pulled from another button or thumb element. Used by internal lightbox. No external use. 11205 */ 11206 if (options.dataElement == null) { 11207 options.dataElement = element; 11208 } 11209 var dataElement = options.dataElement; 11210 11211 //region Merge Options 11212 var elementOptions = defaults_DEARVIEWER.utils.getOptions(dataElement); 11213 var customOptions = app_jQuery.extend(true, 11214 //deep scan and merge 11215 {}, 11216 //an empty object – this is to keep from overriding our "defaults" object 11217 defaults_DEARVIEWER.defaults, options, elementOptions); 11218 customOptions = app_utils.fallbackOptions(customOptions); 11219 app_utils.log(customOptions); 11220 11221 //Note: ... spread will overwrite undefined variables too and won't perform deep scan 11222 var opts = app_jQuery.extend( 11223 // Extend our default options with those provided. 11224 true, 11225 //deep scan and merge 11226 {}, 11227 //an empty object – this is to keep from overriding our "defaults" object 11228 defaults_DEARVIEWER._defaults, customOptions); 11229 11230 //endregion 11231 11232 //check for mobile ViewerType 11233 if (app_utils.isMobile && typeof defaults_DEARVIEWER.viewers[opts.mobileViewerType] == "function") { 11234 opts.viewerType = opts.mobileViewerType; 11235 } 11236 if (typeof defaults_DEARVIEWER.viewers[opts.viewerType] !== "function") { 11237 console.warn("Invalid Viewer Type! " + opts.viewerType + " | Using default Viewer!"); 11238 opts.viewerType = defaults_DEARVIEWER.viewers["default"]; 11239 } else { 11240 opts.viewerType = defaults_DEARVIEWER.viewers[opts.viewerType]; 11241 } 11242 opts = app_utils.finalizeOptions(app_utils.sanitizeOptions(opts)); 11243 return opts; 11244}; 11245defaults_DEARVIEWER.Application = function (options) { 11246 var opts = defaults_DEARVIEWER.prepareOptions(options); 11247 var app = new App(opts); 11248 options.element.data("df-app", app); 11249 if (opts.id != null && opts.isLightBox !== true) { 11250 window[opts.id.toString()] = app; 11251 } 11252 return app; 11253}; 11254 11255//region jQuery Extension and Triggers 11256//jQuery Extension 11257app_jQuery.fn.extend({ 11258 dearviewer_options: function dearviewer_options(options) { 11259 if (options == null) options = {}; 11260 options.element = app_jQuery(this); 11261 return new defaults_DEARVIEWER.prepareOptions(options); 11262 }, 11263 dearviewer: function dearviewer(options) { 11264 if (options == null) options = {}; 11265 options.element = app_jQuery(this); 11266 return new defaults_DEARVIEWER.Application(options); 11267 } 11268}); 11269 11270;// CONCATENATED MODULE: ./src/js/common-pro.js 11271function common_pro_typeof(o) { "@babel/helpers - typeof"; return common_pro_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, common_pro_typeof(o); } 11272function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } 11273function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {};
11273 r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } 11274function _defineProperty(obj, key, value) { key = common_pro_toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 11275function common_pro_toPropertyKey(arg) { var key = common_pro_toPrimitive(arg, "string"); return common_pro_typeof(key) === "symbol" ? key : String(key); } 11276function common_pro_toPrimitive(input, hint) { if (common_pro_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (common_pro_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } 11277 11278 11279 11280 11281defaults_DEARVIEWER.defaults.search = true; 11282App.prototype.executeCallback = function (callbackName) { 11283 if (this.options && typeof this.options[callbackName] === "function") this.options[callbackName](this); 11284}; 11285App.prototype.analytics = function (eventData) { 11286 if (this.options.enableAnalytics == true) { 11287 try { 11288 var options = eventData.options, 11289 eventLabel = undefined; 11290 if (options) { 11291 eventLabel = options.bookTitle || options.slug || options.id; 11292 } 11293 var analyticsTag = window.gtag; 11294 if (analyticsTag) { 11295 analyticsTag('event', eventData.eventAction, { 11296 'event_category': options.analyticsEventCategory, 11297 'event_label': eventLabel 11298 }); 11299 } else { 11300 var analytics = window.ga || window.__gaTracker; 11301 analytics("send", { 11302 hitType: 'event', 11303 eventCategory: options.analyticsEventCategory, 11304 eventAction: eventData.eventAction, 11305 eventLabel: eventLabel 11306 }); 11307 } 11308 } catch (e) { 11309 //silent suppress 11310 } 11311 } 11312}; 11313defaults_DEARVIEWER.executeCallback = function (functionName) { 11314 var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window; 11315 if (typeof context[functionName] === 'function') { 11316 context[functionName](); 11317 } 11318}; 11319defaults_DEARVIEWER.openAttachmentLightBoxes = function () { 11320 //opening lightbox in attachment page. 11321 var attachments = jQuery("body .df-auto-open-lightbox"); 11322 if (attachments.length > 0) { 11323 jQuery(attachments[0]).trigger("click"); 11324 } 11325 11326 //Deeplink on same page #392 11327 jQuery(window).on('hashchange', function (e) { 11328 var hash = location.hash; 11329 if (hash && hash.length > 5) { 11330 defaults_DEARVIEWER.hashFocusBookFound = false; 11331 utils.detectHash(); 11332 } 11333 }); 11334}; 11335DocumentProvider.prototype.processCustomLinks = function (pageNumber, element) { 11336 var provider = this, 11337 app = this.app; 11338 if (app.options.enableAnnotation === false || !provider._isValidPage(pageNumber) || element == null) return; 11339 var pageNumberToRender = app.viewer.getDocumentPageNumber(pageNumber); 11340 var links = app.options.links; 11341 if (links != null && links[pageNumberToRender] != null) { 11342 var pageLinks = links[pageNumberToRender]; 11343 for (var index = 0; index < pageLinks.length; index++) { 11344 var pageLink = pageLinks[index]; 11345 var annotation = void 0; 11346 if (pageLink.dest && pageLink.dest.indexOf && pageLink.dest.indexOf('[html]') == 0) { 11347 annotation = document.createElement('div'); 11348 annotation.innerHTML = pageLink.dest.substr(6); 11349 annotation.className = "customHtmlAnnotation"; 11350 } else { 11351 annotation = document.createElement('a'); 11352 annotation.setAttribute("dest", pageLink.dest); 11353 annotation.className = "customLinkAnnotation"; 11354 annotation.href = "#" + pageLink.dest; 11355 annotation.onclick = function () { 11356 var dest = this.getAttribute("dest"); 11357 if (dest) { 11358 provider.linkService.customNavigateTo(dest); 11359 } 11360 return false;
11361 }; 11362 } 11363 annotation.style.left = pageLink.x + "%"; 11364 annotation.style.top = pageLink.y + "%"; 11365 annotation.style.width = pageLink.w + "%"; 11366 annotation.style.height = pageLink.h + "%"; 11367 element.appendChild(annotation); 11368 } 11369 } 11370 app.viewer.finalizeAnnotations(element, pageNumber); 11371}; 11372function detectHitItems(items, textOffsets, searchHits) { 11373 var searchItems = []; 11374 var hitOverFlow = false, 11375 hitLength = 0, 11376 start = 0, 11377 end = 0, 11378 hitLocation = void 0, 11379 hitIndex = 0; 11380 for (var itemIndex = 0; itemIndex < items.length; itemIndex++) { 11381 var item = _objectSpread({}, items[itemIndex]); 11382 start = textOffsets[itemIndex].offset; 11383 end = start + textOffsets[itemIndex].length; 11384 if (hitOverFlow == false) { 11385 var _searchHits$hitIndex, _searchHits$hitIndex2; 11386 hitLocation = (_searchHits$hitIndex = searchHits[hitIndex]) === null || _searchHits$hitIndex === void 0 ? void 0 : _searchHits$hitIndex.index; 11387 hitLength = (_searchHits$hitIndex2 = searchHits[hitIndex]) === null || _searchHits$hitIndex2 === void 0 ? void 0 : _searchHits$hitIndex2.length; 11388 } 11389 while (hitLocation >= start && hitLocation < end) { 11390 if (!item.searchHits) { 11391 item.searchHits = []; 11392 } 11393 item.searchHits.push({ 11394 start: hitLocation - start, 11395 length: hitLength, 11396 text: searchHits[hitIndex].text 11397 }); 11398 if (item.searchHits.length == 1) { 11399 searchItems.push(item); 11400 } 11401 if (hitLocation + hitLength > end) { 11402 hitLength = hitLocation + hitLength - end; 11403 hitLocation = end; //hitOverflow detected on the same hitIndexx 11404 hitOverFlow = true; 11405 } else { 11406 var _searchHits$hitIndex3, _searchHits$hitIndex4; 11407 hitIndex++; 11408 hitOverFlow = false; 11409 hitLocation = (_searchHits$hitIndex3 = searchHits[hitIndex]) === null || _searchHits$hitIndex3 === void 0 ? void 0 : _searchHits$hitIndex3.index; 11410 hitLength = (_searchHits$hitIndex4 = searchHits[hitIndex]) === null || _searchHits$hitIndex4 === void 0 ? void 0 : _searchHits$hitIndex4.length; 11411 } 11412 } 11413 } 11414 return searchItems; 11415} 11416PDFDocumentProvider.prototype.processTextContent = function (pageNumber, element) { 11417 // return; //too much costly https://github.com/deepak-ghimire/dearviewer/issues/337 11418 var provider = this, 11419 app = this.app; 11420 if (!provider._isValidPage(pageNumber) || element == null) return; 11421 var createAutoLinks = app.options.enableAnnotation === true && app.options.enableAutoLinks === true; 11422 if (!createAutoLinks && app.options.showSearchControl === false) return; 11423 var pageNumberToRender = app.viewer.getDocumentPageNumber(pageNumber); 11424 element.innerHTML = ""; 11425 provider.pdfDocument.getPage(pageNumberToRender).then( 11426 /** 11427 * @param {PDFPage} page 11428 */ 11429 function (page) { 11430 var viewport = page.getViewport({ 11431 scale: 1, 11432 rotation: page._pageInfo.rotate + app.options.pageRotation 11433 }); 11434 viewport = page.getViewport({ 11435 scale: app.viewer.getTextureSize({ 11436 pageNumber: pageNumber, 11437 isAnnotation: true 11438 }).height / (viewport.height * window.devicePixelRatio), 11439 rotation: page._pageInfo.rotate + app.options.pageRotation 11440 }); 11441 element.parentNode.style.setProperty('--scale-factor', viewport.scale); 11442 page.getTextContent().then(function (textData) { 11443 var _app$viewer; 11444 provider.prepareTextContent(textData, pageNumberToRender); 11445 var autoLinkItems = provider.autoLinkItemsCache[pageNumberToRender], 11446 autoLinkHits = provider.autoLinkHitsCache[pageNumberToRender], 11447 searchItems = provider.searchHitItemsCache[pageNumberToRender], 11448 searchHits = provider.searchHits[pageNumber], 11449 textOffsets = provider.textOffset[pageNumberToRender]; 11450 if (createAutoLinks === true && autoLinkItems == void 0) { 11451 autoLinkItems = []; 11452 autoLinkHits = utils.urlify(provider.textContentJoined[pageNumberToRender].toLowerCase()); 11453 // console.log(autoLinkHits); 11454 var PDFlinks = provider.PDFLinkItemsCache[pageNumberToRender]; 11455 if (PDFlinks && PDFlinks.length < 5) { 11456 PDFlinks = void 0; 11457 } 11458 /* for (let itemIndex = 0; itemIndex < textData.items.length; itemIndex++) { 11459 let item = textData.items[itemIndex]; 11460 if (item.str.length < 5) continue; //minimum url is ab.us 11461 let test = utils.urlify(item.str); 11462 if (test !== item.str) { 11463 item.autolinkHTML = test; 11464 autoLinkItems.push(item); 11465 } 11466 }*/ 11467 autoLinkItems = detectHitItems(textData.items, textOffsets, autoLinkHits); 11468 provider.autoLinkItemsCache[pageNumberToRender] = autoLinkItems; 11469 provider.autoLinkHitsCache[pageNumberToRender] = autoLinkHits; 11470 } 11471 11472 //Find Items that match search hits 11473 if (searchItems == void 0 && textOffsets != void 0 && searchHits && searchHits.length > 0) { 11474 searchItems = detectHitItems(textData.items, textOffsets, searchHits); 11475 provider.searchHitItemsCache[pageNumberToRender] = searchItems; 11476 } 11477 11478 //Render Autolinks 11479 if (autoLinkItems && autoLinkItems.length > 0) { 11480 var divAutoLink = jQuery(element).siblings(".df-auto-link-content"); 11481 if (divAutoLink.length == 0) { 11482 divAutoLink = jQuery('<div class="df-auto-link-content">'); 11483 jQuery(element).parent().prepend(divAutoLink); 11484 } 11485 divAutoLink.html(""); 11486 textData.items = autoLinkItems; 11487 var finalString = ""; 11488 var task = pdfjsLib.renderTextLayer({ 11489 textContentSource: textData, 11490 textContent: textData, 11491 container: divAutoLink[0], 11492 viewport: viewport, 11493 textDivs: [] 11494 }); 11495 // console.log(performance.now()); 11496 var index = 0;
11497 task._textDivs.forEach(function (div) { 11498 var item = textData.items[index]; 11499 var _html = "", 11500 pos = 0, 11501 length = 0, 11502 _searchPart = 0, 11503 text = '', 11504 url = ''; 11505 for (_searchPart = 0; _searchPart < item.searchHits.length; _searchPart++) { 11506 _html += item.str.substring(pos, item.searchHits[_searchPart].start); 11507 pos = item.searchHits[_searchPart].start; 11508 length = item.searchHits[_searchPart].length; 11509 text = item.str.substring(pos, pos + length); 11510 url = item.searchHits[_searchPart].text; 11511 if (text.indexOf("@") > 0) { 11512 url = url.toLowerCase(); 11513 if (url.indexOf("mailto:" === -1)) url = "mailto:" + text; 11514 _html += '<a href="' + url + '" ' + 'class="df-autolink" target="_blank">' + text + '</a>'; 11515 } else { 11516 if (url.indexOf('www.') === 0) { 11517 url = 'http://' + url; 11518 } 11519 _html += '<a href="' + url + '" class="df-autolink" target="_blank">' + text + '</a>'; 11520 } 11521 utils.log("AutoLink: " + url + " for " + text); 11522 pos += length; 11523 } 11524 //last remaining part 11525 _html += item.str.substring(pos, item.str.length); 11526 index++; 11527 div.innerHTML = _html; 11528 }); 11529 11530 // for (let divCount = 0; divCount < task._textDivs.length; divCount++) { 11531 // task._textDivs[divCount].innerHTML = autoLinkItems[divCount].autolinkHTML; 11532 // } 11533 } 11534 //Render Search Items 11535 if (searchItems && searchItems.length > 0) { 11536 textData.items = searchItems; 11537 var task = pdfjsLib.renderTextLayer({ 11538 textContentSource: textData, 11539 textContent: textData, 11540 container: element, 11541 viewport: viewport, 11542 textDivs: [] 11543 }); 11544 var _index = 0; 11545 task._textDivs.forEach(function (div) { 11546 var item = textData.items[_index]; 11547 var _html = "", 11548 pos = 0, 11549 length = 0, 11550 _searchPart = 0; 11551 for (_searchPart = 0; _searchPart < item.searchHits.length; _searchPart++) { 11552 _html += item.str.substring(pos, item.searchHits[_searchPart].start); 11553 pos = item.searchHits[_searchPart].start; 11554 length = item.searchHits[_searchPart].length; 11555 _html += '<span class="df-search-highlight">' + item.str.substring(pos, pos + length) + '</span>'; 11556 pos += length; 11557 } 11558 //last remaining part 11559 _html += item.str.substring(pos, item.str.length); 11560 _index++; 11561 div.innerHTML = _html; 11562 div.classList += " df-search-hits"; 11563 }); 11564 } 11565 11566 // console.log(performance.now()); 11567 app === null || app === void 0 || (_app$viewer = app.viewer) === null || _app$viewer === void 0 || _app$viewer.finalizeTextContent(element, pageNumber); 11568 }); 11569 }); 11570}; 11571PDFDocumentProvider.prototype.processAnnotations = function (pageNumber, element) { 11572 var provider = this, 11573 app = this.app; 11574 if (app.options.enableAnnotation === false || !provider._isValidPage(pageNumber) || element == null) return; 11575 var pageNumberToRender = app.viewer.getDocumentPageNumber(pageNumber); 11576 provider.pdfDocument.getPage(pageNumberToRender).then( 11577 /** 11578 * @param {PDFPage} page 11579 */ 11580 function (page) { 11581 var viewport = page.getViewport({ 11582 scale: 1, 11583 rotation: page._pageInfo.rotate + app.options.pageRotation 11584 }); 11585 viewport = page.getViewport({ 11586 scale: app.viewer.getTextureSize({ 11587 pageNumber: pageNumber, 11588 isAnnotation: true 11589 }).height / (viewport.height * window.devicePixelRatio), 11590 rotation: page._pageInfo.rotate + app.options.pageRotation 11591 }); 11592 page.getAnnotations().then(function (annotationsData) { 11593 if (app.options === null || app.viewer === null || annotationsData.length == 0) return; 11594 viewport = viewport.clone({ 11595 dontFlip: true 11596 }); 11597 var parameters = { 11598 annotations: annotationsData, 11599 div: element, 11600 page: page, 11601 viewport: viewport, 11602 imageResourcesPath: app.options.imageResourcesPath, 11603 linkService: provider.linkService 11604 }; 11605 pdfjsLib.AnnotationLayer.render(parameters); 11606 // pdfjsLib.AnnotationLayer.update(parameters); 11607 11608 if (app.options.annotationClass && app.options.annotationClass !== "") { 11609 jQuery(element).find(" > section").addClass(app.options.annotationClass); 11610 } 11611 if (provider.PDFLinkItemsCache[pageNumberToRender] == void 0) { 11612 var pdfLinks = "," + jQuery(element).find("a:not([href^='#'])").map(function () { 11613 return jQuery(this).attr("href"); 11614 }).get().join(",") + ","; 11615 // provider.PDFLinkItemsCache[pageNumberToRender] = pdfLinks.replaceAll("https://", "").replaceAll("http://", "").replaceAll("/", ""); 11616 } 11617 11618 provider.processCustomLinks(pageNumber, element); 11619 app.viewer.finalizeAnnotations(element, pageNumber); 11620 }); 11621 }); 11622}; 11623defaults_DEARVIEWER.getPDFThumb = function (options) { 11624 var parameters = {}; 11625 parameters.url = utils.httpsCorrection(options.pdfURL); 11626 parameters.rangeChunkSize = 524288; 11627 parameters.cMapPacked = true; 11628 parameters.disableAutoFetch = true; 11629 parameters.disableStream = true; 11630 parameters.disableFontFace = defaults_DEARVIEWER.defaults.disableFontFace; 11631 parameters.cMapUrl = defaults_DEARVIEWER.defaults.cMapUrl; 11632 parameters.imagesLocation = defaults_DEARVIEWER.defaults.imagesLocation; 11633 parameters.imageResourcesPath = defaults_DEARVIEWER.defaults.imageResourcesPath; 11634 var progress = pdfjsLib.getDocument(parameters); 11635 var pdfDoc = progress.promise.then(function (pdf) { 11636 pdf.getPage(1).then(function (pdfPage) { 11637 var scale = 1; 11638 var canvas = document.createElement('canvas'),
11639 viewport = pdfPage.getViewport({ 11640 scale: scale 11641 }); 11642 if (viewport.width > viewport.height) { 11643 scale = scale * 400 / viewport.width; 11644 } else { 11645 scale = scale * 400 / viewport.height; 11646 } 11647 viewport = pdfPage.getViewport({ 11648 scale: scale 11649 }); 11650 canvas.height = Math.floor(viewport.height); 11651 canvas.width = Math.floor(viewport.width); 11652 var pageRendering = pdfPage.render({ 11653 canvas: canvas, 11654 canvasContext: canvas.getContext('2d'), 11655 viewport: viewport 11656 }); 11657 pageRendering.promise.then(function () { 11658 var _options$callback; 11659 var src = canvas.toDataURL('image/jpeg', 0.9); 11660 (_options$callback = options.callback) === null || _options$callback === void 0 || _options$callback.call(options, src); 11661 if (pdfDoc.destroy) pdfDoc.destroy(); 11662 if (progress.destroy) progress.destroy(); 11663 pdfDoc = null; 11664 progress = null; 11665 }); 11666 }); 11667 }); 11668 progress.onProgress = function getDocumentProgress(progressData) { 11669 // if (app !== null) { 11670 var percentage = 100 * progressData.loaded / progressData.total; 11671 if (isNaN(percentage)) { 11672 //in case divided by zero/undefined -- don't have total value 11673 if (progressData && progressData.loaded) { 11674 options.updateInfo("Loading PDF " + (Math.ceil(progressData.loaded / 10000) / 100).toFixed(2).toString() + "MB ..."); 11675 } else { 11676 options.updateInfo("Loading PDF ..."); 11677 } 11678 } else { 11679 options.updateInfo("Loading PDF " + Math.ceil(percentage).toString().split(".")[0] + "% ..."); 11680 } 11681 // } 11682 }; 11683}; 11684;// CONCATENATED MODULE: ./src/js/dflip.js 11685/* globals jQuery, pdfjsLib, THREE */ 11686 11687 11688 11689 11690 11691 11692var dflip_jQuery = defaults_DEARVIEWER.jQuery; 11693var DEARFLIP = window.DFLIP = window.DEARFLIP = defaults_DEARVIEWER; 11694DEARFLIP.defaults.viewerType = 'flipbook'; 11695DEARFLIP.defaults.analyticsEventCategory = "Flipbook"; 11696DEARFLIP.defaults.analyticsViewerReady = "Book Ready"; 11697DEARFLIP.defaults.analyticsViewerOpen = "Open Book"; 11698DEARFLIP.defaults.analyticsViewerClose = "Book Closed"; 11699DEARFLIP.defaults.analyticsFirstPageChange = "First Page Flip"; 11700DEARFLIP.slug = 'dflip'; 11701DEARFLIP.locationVar = 'dFlipLocation'; 11702DEARFLIP.locationFile = "dflip"; 11703 11704//region old Constants 11705//These are depreciated , so do not use them anymore 11706DEARFLIP.PAGE_MODE = { 11707 SINGLE: 1, 11708 DOUBLE: 2, 11709 AUTO: null 11710}; 11711DEARFLIP.SINGLE_PAGE_MODE = { 11712 ZOOM: 1, 11713 BOOKLET: 2, 11714 AUTO: null 11715}; 11716DEARFLIP.CONTROLSPOSITION = { 11717 HIDDEN: 'hide', 11718 TOP: 'top', 11719 BOTTOM: 'bottom' 11720}; 11721DEARFLIP.DIRECTION = { 11722 LTR: 1, 11723 RTL: 2 11724}; 11725DEARFLIP.PAGE_SIZE = { 11726 AUTO: 0, 11727 SINGLE: 1, 11728 DOUBLEINTERNAL: 2 11729}; 11730//endregion 11731 11732DEARFLIP.ConvertPageLinks = function () { 11733 var w = arguments[0] / 100, 11734 h = arguments[1] / 100; 11735 var toPercent = function toPercent(_x, _y, _w, _h, _dest) { 11736 return { 11737 x: _x / w, 11738 y: _y / h, 11739 w: _w / w, 11740 h: _h / h, 11741 dest: _dest 11742 }; 11743 }; 11744 var percents = []; 11745 var input; 11746 for (var index = 2; index < arguments.length; index++) { 11747 input = arguments[index]; 11748 percents[index - 2] = toPercent.apply(this, input); 11749 } 11750 return percents; 11751}; 11752DEARFLIP.parseLinks = function (links) { 11753 var _links; 11754 if (links != null && links.length > 0) { 11755 for (var index = 0; index < links.length; index++) { 11756 _links = links[index]; 11757 if (_links != null && _links[0] != null && _links[0].dest == null) { 11758 _links = DEARFLIP.ConvertPageLinks.apply(this, _links); 11759 links[index] = _links; 11760 } 11761 } 11762 } 11763 return links; 11764}; 11765DEARFLIP.parseFallBack = function () { 11766 //region pre-parse fix for DFLIP 11767 dflip_jQuery('.df-posts').addClass("dflip-books"); //backward-compatibity 11768 dflip_jQuery('.dflip-books').addClass("df-posts"); //backward-compatibity 11769 11770 dflip_jQuery('._df_button, ._df_thumb, ._df_custom, ._df_book, ._df_hidden').each(function () { 11771 var app = dflip_jQuery(this); 11772 var isParsed = app.data("parsed"); 11773 if (isParsed !== "true") { 11774 app.addClass("df-element"); 11775 if (app.hasClass("_df_book")) {} else { 11776 if (app.hasClass("_df_thumb")) { 11777 app.attr("data-lightbox", "thumb"); 11778 if (app.attr("thumb") !== void 0) { 11779 app.data("thumb", app.attr("thumb")); 11780 } 11781 } else if (app.hasClass("_df_button")) { 11782 app.attr("data-lightbox", "button"); 11783 } else if (app.hasClass("_df_hidden")) { 11784 app.attr("data-lightbox", "hidden"); 11785 } else { 11786 app.attr("data-lightbox", "custom"); 11787 } 11788 } 11789 //set the option id 11790 if (app.data("option") == void 0) { 11791 app.data("option", "option_" + app.attr("id")); 11792 } 11793 if (app.attr("source") !== void 0) { 11794 app.data("source", app.attr("source")); 11795 } 11796 } 11797 }); 11798 //todo update this so that - this is also done in ajax calls, better use in getOptions fallback 11799 //endregion 11800}; 11801 11802DEARFLIP.parseBooks = function () { 11803 DEARFLIP.parseFallBack(); 11804 DEARFLIP.parseElements(); 11805}; 11806var updateOptions = function updateOptions(options) { 11807 if (options.source != null && (Array === options.source.constructor || Array.isArray(options.source) || options.source instanceof Array)) { 11808 options.providerType = "image"; 11809 } 11810 //Replaced with cover3DType 11811 //options.has3DCover = utils.isTrue(options.has3DCover); 11812 if (options.cover3DType != null) { 11813 if (options.cover3DType == true || options.cover3DType == "true") { 11814 options.cover3DType = DEARFLIP.FLIPBOOK_COVER_TYPE.BASIC; 11815 } else if (options.cover3DType == false || options.cover3DType == "false") { 11816 options.cover3DType = DEARFLIP.FLIPBOOK_COVER_TYPE.NONE; 11817 } 11818 } 11819 11820 //existing but modified 11821 if (options.pageSize !== void 0) { 11822 if (options.pageSize === "1" || options.pageSize === 1 || options.pageSize === DEARFLIP.FLIPBOOK_PAGE_SIZE.SINGLE) { 11823 options.pageSize = DEARFLIP.FLIPBOOK_PAGE_SIZE.SINGLE; 11824 } else if (options.pageSize === "2" || options.pageSize === 2 || options.pageSize === DEARFLIP.FLIPBOOK_PAGE_SIZE.DOUBLE_INTERNAL) { 11825 options.pageSize = DEARFLIP.FLIPBOOK_PAGE_SIZE.DOUBLE_INTERNAL; 11826 } else { 11827 options.pageSize = DEARFLIP.FLIPBOOK_PAGE_SIZE.AUTO; 11828 } 11829 } 11830 if (options.pageMode !== void 0) { 11831 if (options.pageMode === "1" || options.pageMode === 1 || options.pageMode === DEARFLIP.FLIPBOOK_PAGE_MODE.SINGLE) { 11832 options.pageMode = DEARFLIP.FLIPBOOK_PAGE_MODE.SINGLE; 11833 } else if (options.pageMode === "2" || options.pageMode === 2 || options.pageMode === DEARFLIP.FLIPBOOK_PAGE_MODE.DOUBLE) { 11834 options.pageMode = DEARFLIP.FLIPBOOK_PAGE_MODE.DOUBLE; 11835 } else { 11836 options.pageMode = DEARFLIP.FLIPBOOK_PAGE_MODE.AUTO; 11837 } 11838 } 11839 if (options.singlePageMode !== void 0) { 11840 if (options.singlePageMode === "1" || options.singlePageMode === 1 || options.singlePageMode === DEARFLIP.FLIPBOOK_SINGLE_PAGE_MODE.ZOOM) { 11841 options.singlePageMode = DEARFLIP.FLIPBOOK_SINGLE_PAGE_MODE.ZOOM; 11842 } else if (options.singlePageMode === "2" || options.singlePageMode === 2 || options.singlePageMode === DEARFLIP.FLIPBOOK_SINGLE_PAGE_MODE.BOOKLET) { 11843 options.singlePageMode = DEARFLIP.FLIPBOOK_SINGLE_PAGE_MODE.BOOKLET; 11844 } else { 11845 options.singlePageMode = DEARFLIP.FLIPBOOK_SINGLE_PAGE_MODE.AUTO; 11846 } 11847 } 11848 if (options.controlsPosition !== void 0) { 11849 if (options.controlsPosition === "hide") { 11850 options.controlsPosition = DEARFLIP.CONTROLS_POSITION.HIDDEN; 11851 } 11852 } 11853 if (options.overwritePDFOutline !== void 0) { 11854 options.overwritePDFOutline = utils.isTrue(options.overwritePDFOutline); 11855 } 11856 11857 //replaced 11858 if (options.webgl !== void 0) { 11859 options.is3D = options.webgl = options.webgl; 11860 delete options.webgl; 11861 } 11862 if (options.webglShadow !== void 0) { 11863 options.has3DShadow = utils.isTrue(options.webglShadow); 11864 delete options.webglShadow; 11865 } 11866 if (options.scrollWheel !== void 0) { 11867 if (utils.isTrue(options.scrollWheel)) { 11868 options.mouseScrollAction = DEARFLIP.MOUSE_SCROLL_ACTIONS.ZOOM; 11869 } 11870 delete options.scrollWheel; 11871 } 11872 if (options.stiffness !== void 0) { 11873 delete options.stiffness; 11874 } 11875 if (options.soundEnable !== void 0) { 11876 options.enableSound = utils.isTrue(options.soundEnable); 11877 delete options.soundEnable; 11878 } 11879 if (options.enableDownload !== void 0) { 11880 options.showDownloadControl = utils.isTrue(options.enableDownload); 11881 delete options.enableDownload; 11882 } 11883 if (options.autoEnableOutline !== void 0) { 11884 options.autoOpenOutline = utils.isTrue(options.autoEnableOutline); 11885 delete options.autoEnableOutline; 11886 } 11887 if (options.autoEnableThumbnail !== void 0) { 11888 options.autoOpenThumbnail = utils.isTrue(options.autoEnableThumbnail); 11889 delete options.autoEnableThumbnail; 11890 } 11891 if (options.direction !== void 0) { 11892 if (options.direction === "2" || options.direction === 2 || options.direction === DEARFLIP.READ_DIRECTION.RTL) { 11893 options.readDirection = DEARFLIP.READ_DIRECTION.RTL; 11894 } else { 11895 options.readDirection = DEARFLIP.READ_DIRECTION.LTR; 11896 } 11897 delete options.direction; 11898 } 11899 if (options.hard !== void 0) { 11900 options.flipbookHardPages = options.hard; 11901 if (options.flipbookHardPages === "hard") { 11902 options.flipbookHardPages = "all"; 11903 } 11904 delete options.hard; 11905 } 11906 11907 //removed 11908 //forcefit is no longer required in DearPDF 11909 if (options.forceFit !== void 0) { 11910 delete options.forceFit; 11911 } 11912 11913 //region ParseLinks 11914 if (typeof dFlipWPGlobal !== 'undefined' && options.wpOptions === 'true') { 11915 if (options.linksparsed !== true) { 11916 options.linksparsed = true; 11917 var links = [];
11918 try { 11919 for (var key in options.links) { 11920 var _pagelinks = options.links[key]; 11921 var pagelink = [100, 100]; 11922 for (var l = 0; l < _pagelinks.length; l++) { 11923 var _link = _pagelinks[l]; 11924 var _values = _link.substr(1).slice(0, -1).split(","); 11925 var _linkarr = []; 11926 for (var v = 0; v < 5; v++) { 11927 _linkarr[v] = _values[v]; 11928 } 11929 pagelink.push(_linkarr); 11930 } 11931 links[parseInt(key, 10) + 1] = pagelink; 11932 } 11933 } catch (error) { 11934 console.error(error.stack); 11935 } 11936 options.links = DEARFLIP.parseLinks(links); 11937 } 11938 } else { 11939 options.links = DEARFLIP.parseLinks(options.links); 11940 } 11941 11942 //endregion 11943 11944 return utils.sanitizeOptions(options); 11945}; 11946 11947//region jQuery Extension and Triggers 11948//jQuery Extension 11949dflip_jQuery.fn.extend({ 11950 flipBook: function flipBook(source, options) { 11951 if (options == null) options = {}; 11952 options.source = source; 11953 options.element = dflip_jQuery(this); 11954 return new defaults_DEARVIEWER.Application(options); 11955 } 11956}); 11957 11958//jQuery events 11959dflip_jQuery(document).ready(function () { 11960 //Lightbox Trigger 11961 var body = dflip_jQuery('body'); 11962 DEARFLIP.executeCallback("beforeDearFlipInit"); 11963 if (typeof window['dFlipWPGlobal'] !== 'undefined') { 11964 dflip_jQuery.extend(true, DEARFLIP.defaults, updateOptions(window['dFlipWPGlobal'])); 11965 } 11966 DEARFLIP.initUtils(); 11967 DEARFLIP.initControls(); 11968 body.on('click', '.df-element[data-lightbox]', function (event) { 11969 var originElement = dflip_jQuery(event.target || event.originalTarget); 11970 if (originElement && originElement.hasClass("df-edit-link")) return; 11971 var element = dflip_jQuery(this); 11972 var target = element.attr("target"), 11973 href = element.attr("href"), 11974 isPopup = false; 11975 if (href === '#' || href === void 0 || element.hasClass("df-hash-focused")) { 11976 isPopup = true; 11977 } else if (target === "_self" || target === "_blank") {} else if (target == void 0 && DEARFLIP.defaults.targetWindow === "_self") { 11978 element.attr("target", "_self"); 11979 } else if (target == void 0 && DEARFLIP.defaults.targetWindow === "_blank") { 11980 element.attr("target", "_blank"); 11981 } else { 11982 isPopup = true; 11983 } 11984 if (isPopup) { 11985 //incase the element is link type 11986 event.preventDefault(); 11987 event.stopPropagation(); 11988 DEARFLIP.openLightBox(element); 11989 } 11990 }); 11991 body.on('click', '.df-trigger', function (event) { 11992 var element = dflip_jQuery(this); 11993 var target = element.attr("df-trigger"); 11994 dflip_jQuery("[df-trigger-id=" + target + "]").trigger("click"); 11995 }); 11996 DEARFLIP.checkBrowserURLforDefaults(); 11997 DEARFLIP.parseCSSElements(); 11998 DEARFLIP.parseFallBack(); 11999 utils.detectHash(); 12000 DEARFLIP.parseNormalElements(); 12001 DEARFLIP.checkBrowserURLforPDF(true); 12002 DEARFLIP.openAttachmentLightBoxes(); 12003 DEARFLIP.executeCallback("afterDearFlipInit"); 12004}); 12005utils.finalizeOptions = function (options) { 12006 return updateOptions(options); 12007}; 12008ImageDocumentProvider.prototype.processAnnotations = function (pageNumber, element) { 12009 this.processCustomLinks(pageNumber, element); 12010}; 12011DEARFLIP.executeCallback("onDearFlipLoad"); 12012/* harmony default export */ var dflip = ((/* unused pure expression or super */ null && (DEARFLIP))); 12013}(); 12014/******/ })() 12015;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.