|
@@ -122,8 +122,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
});
|
|
|
exports.localized = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.mozL10n = exports.RendererType = exports.cloneObj = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined;
|
|
|
|
|
|
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
+
|
|
|
var _pdfjsLib = __w_pdfjs_require__(0);
|
|
|
|
|
|
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
+
|
|
|
var CSS_UNITS = 96.0 / 72.0;
|
|
|
var DEFAULT_SCALE_VALUE = 'auto';
|
|
|
var DEFAULT_SCALE = 1.0;
|
|
@@ -172,16 +176,17 @@ function getOutputScale(ctx) {
|
|
|
scaled: pixelRatio !== 1
|
|
|
};
|
|
|
}
|
|
|
-function scrollIntoView(element, spot, skipOverflowHiddenElements) {
|
|
|
+function scrollIntoView(element, spot) {
|
|
|
+ var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
|
+
|
|
|
var parent = element.offsetParent;
|
|
|
if (!parent) {
|
|
|
console.error('offsetParent is not set -- cannot scroll');
|
|
|
return;
|
|
|
}
|
|
|
- var checkOverflow = skipOverflowHiddenElements || false;
|
|
|
var offsetY = element.offsetTop + element.clientTop;
|
|
|
var offsetX = element.offsetLeft + element.clientLeft;
|
|
|
- while (parent.clientHeight === parent.scrollHeight || checkOverflow && getComputedStyle(parent).overflow === 'hidden') {
|
|
|
+ while (parent.clientHeight === parent.scrollHeight || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
|
|
|
if (parent.dataset._scaleY) {
|
|
|
offsetY /= parent.dataset._scaleY;
|
|
|
offsetX /= parent.dataset._scaleX;
|
|
@@ -231,7 +236,7 @@ function watchScroll(viewAreaElement, callback) {
|
|
|
}
|
|
|
function parseQueryString(query) {
|
|
|
var parts = query.split('&');
|
|
|
- var params = {};
|
|
|
+ var params = Object.create(null);
|
|
|
for (var i = 0, ii = parts.length; i < ii; ++i) {
|
|
|
var param = parts[i].split('=');
|
|
|
var key = param[0].toLowerCase();
|
|
@@ -290,7 +295,7 @@ function approximateFraction(x) {
|
|
|
b = q;
|
|
|
}
|
|
|
}
|
|
|
- var result;
|
|
|
+ var result = void 0;
|
|
|
if (x_ - a / b < c / d - x_) {
|
|
|
result = x_ === x ? [a, b] : [b, a];
|
|
|
} else {
|
|
@@ -302,7 +307,9 @@ function roundToDivide(x, div) {
|
|
|
var r = x % div;
|
|
|
return r === 0 ? x : Math.round(x - r + div);
|
|
|
}
|
|
|
-function getVisibleElements(scrollEl, views, sortByVisibility) {
|
|
|
+function getVisibleElements(scrollEl, views) {
|
|
|
+ var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
|
+
|
|
|
var top = scrollEl.scrollTop,
|
|
|
bottom = top + scrollEl.clientHeight;
|
|
|
var left = scrollEl.scrollLeft,
|
|
@@ -313,10 +320,14 @@ function getVisibleElements(scrollEl, views, sortByVisibility) {
|
|
|
return elementBottom > top;
|
|
|
}
|
|
|
var visible = [],
|
|
|
- view,
|
|
|
- element;
|
|
|
- var currentHeight, viewHeight, hiddenHeight, percentHeight;
|
|
|
- var currentWidth, viewWidth;
|
|
|
+ view = void 0,
|
|
|
+ element = void 0;
|
|
|
+ var currentHeight = void 0,
|
|
|
+ viewHeight = void 0,
|
|
|
+ hiddenHeight = void 0,
|
|
|
+ percentHeight = void 0;
|
|
|
+ var currentWidth = void 0,
|
|
|
+ viewWidth = void 0;
|
|
|
var firstVisibleElementInd = views.length === 0 ? 0 : binarySearchFirstItem(views, isElementBottomBelowViewTop);
|
|
|
for (var i = firstVisibleElementInd, ii = views.length; i < ii; i++) {
|
|
|
view = views[i];
|
|
@@ -358,8 +369,8 @@ function getVisibleElements(scrollEl, views, sortByVisibility) {
|
|
|
views: visible
|
|
|
};
|
|
|
}
|
|
|
-function noContextMenuHandler(e) {
|
|
|
- e.preventDefault();
|
|
|
+function noContextMenuHandler(evt) {
|
|
|
+ evt.preventDefault();
|
|
|
}
|
|
|
function isDataSchema(url) {
|
|
|
var i = 0,
|
|
@@ -385,7 +396,7 @@ function getPDFFileNameFromURL(url) {
|
|
|
if (suggestedFilename.indexOf('%') !== -1) {
|
|
|
try {
|
|
|
suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
|
|
|
- } catch (e) {}
|
|
|
+ } catch (ex) {}
|
|
|
}
|
|
|
}
|
|
|
return suggestedFilename || defaultFilename;
|
|
@@ -408,7 +419,7 @@ function normalizeWheelEventDelta(evt) {
|
|
|
return delta;
|
|
|
}
|
|
|
function cloneObj(obj) {
|
|
|
- var result = {};
|
|
|
+ var result = Object.create(null);
|
|
|
for (var i in obj) {
|
|
|
if (Object.prototype.hasOwnProperty.call(obj, i)) {
|
|
|
result[i] = obj[i];
|
|
@@ -419,30 +430,39 @@ function cloneObj(obj) {
|
|
|
var animationStarted = new Promise(function (resolve) {
|
|
|
window.requestAnimationFrame(resolve);
|
|
|
});
|
|
|
-var mozL10n;
|
|
|
+var mozL10n = void 0;
|
|
|
var localized = Promise.resolve();
|
|
|
-var EventBus = function EventBusClosure() {
|
|
|
+
|
|
|
+var EventBus = function () {
|
|
|
function EventBus() {
|
|
|
+ _classCallCheck(this, EventBus);
|
|
|
+
|
|
|
this._listeners = Object.create(null);
|
|
|
}
|
|
|
- EventBus.prototype = {
|
|
|
- on: function EventBus_on(eventName, listener) {
|
|
|
+
|
|
|
+ _createClass(EventBus, [{
|
|
|
+ key: 'on',
|
|
|
+ value: function on(eventName, listener) {
|
|
|
var eventListeners = this._listeners[eventName];
|
|
|
if (!eventListeners) {
|
|
|
eventListeners = [];
|
|
|
this._listeners[eventName] = eventListeners;
|
|
|
}
|
|
|
eventListeners.push(listener);
|
|
|
- },
|
|
|
- off: function EventBus_on(eventName, listener) {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'off',
|
|
|
+ value: function off(eventName, listener) {
|
|
|
var eventListeners = this._listeners[eventName];
|
|
|
- var i;
|
|
|
+ var i = void 0;
|
|
|
if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
|
|
|
return;
|
|
|
}
|
|
|
eventListeners.splice(i, 1);
|
|
|
- },
|
|
|
- dispatch: function EventBus_dispath(eventName) {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'dispatch',
|
|
|
+ value: function dispatch(eventName) {
|
|
|
var eventListeners = this._listeners[eventName];
|
|
|
if (!eventListeners || eventListeners.length === 0) {
|
|
|
return;
|
|
@@ -452,25 +472,37 @@ var EventBus = function EventBusClosure() {
|
|
|
listener.apply(null, args);
|
|
|
});
|
|
|
}
|
|
|
- };
|
|
|
+ }]);
|
|
|
+
|
|
|
return EventBus;
|
|
|
}();
|
|
|
-var ProgressBar = function ProgressBarClosure() {
|
|
|
- function clamp(v, min, max) {
|
|
|
- return Math.min(Math.max(v, min), max);
|
|
|
- }
|
|
|
- function ProgressBar(id, opts) {
|
|
|
+
|
|
|
+function clamp(v, min, max) {
|
|
|
+ return Math.min(Math.max(v, min), max);
|
|
|
+}
|
|
|
+
|
|
|
+var ProgressBar = function () {
|
|
|
+ function ProgressBar(id) {
|
|
|
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
|
+ height = _ref.height,
|
|
|
+ width = _ref.width,
|
|
|
+ units = _ref.units;
|
|
|
+
|
|
|
+ _classCallCheck(this, ProgressBar);
|
|
|
+
|
|
|
this.visible = true;
|
|
|
this.div = document.querySelector(id + ' .progress');
|
|
|
this.bar = this.div.parentNode;
|
|
|
- this.height = opts.height || 100;
|
|
|
- this.width = opts.width || 100;
|
|
|
- this.units = opts.units || '%';
|
|
|
+ this.height = height || 100;
|
|
|
+ this.width = width || 100;
|
|
|
+ this.units = units || '%';
|
|
|
this.div.style.height = this.height + this.units;
|
|
|
this.percent = 0;
|
|
|
}
|
|
|
- ProgressBar.prototype = {
|
|
|
- updateBar: function ProgressBar_updateBar() {
|
|
|
+
|
|
|
+ _createClass(ProgressBar, [{
|
|
|
+ key: '_updateBar',
|
|
|
+ value: function _updateBar() {
|
|
|
if (this._indeterminate) {
|
|
|
this.div.classList.add('indeterminate');
|
|
|
this.div.style.width = this.width + this.units;
|
|
@@ -479,33 +511,32 @@ var ProgressBar = function ProgressBarClosure() {
|
|
|
this.div.classList.remove('indeterminate');
|
|
|
var progressSize = this.width * this._percent / 100;
|
|
|
this.div.style.width = progressSize + this.units;
|
|
|
- },
|
|
|
- get percent() {
|
|
|
- return this._percent;
|
|
|
- },
|
|
|
- set percent(val) {
|
|
|
- this._indeterminate = isNaN(val);
|
|
|
- this._percent = clamp(val, 0, 100);
|
|
|
- this.updateBar();
|
|
|
- },
|
|
|
- setWidth: function ProgressBar_setWidth(viewer) {
|
|
|
- if (viewer) {
|
|
|
- var container = viewer.parentNode;
|
|
|
- var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
|
|
|
- if (scrollbarWidth > 0) {
|
|
|
- this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);');
|
|
|
- }
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'setWidth',
|
|
|
+ value: function setWidth(viewer) {
|
|
|
+ if (!viewer) {
|
|
|
+ return;
|
|
|
}
|
|
|
- },
|
|
|
- hide: function ProgressBar_hide() {
|
|
|
+ var container = viewer.parentNode;
|
|
|
+ var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
|
|
|
+ if (scrollbarWidth > 0) {
|
|
|
+ this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'hide',
|
|
|
+ value: function hide() {
|
|
|
if (!this.visible) {
|
|
|
return;
|
|
|
}
|
|
|
this.visible = false;
|
|
|
this.bar.classList.add('hidden');
|
|
|
document.body.classList.remove('loadingInProgress');
|
|
|
- },
|
|
|
- show: function ProgressBar_show() {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'show',
|
|
|
+ value: function show() {
|
|
|
if (this.visible) {
|
|
|
return;
|
|
|
}
|
|
@@ -513,9 +544,21 @@ var ProgressBar = function ProgressBarClosure() {
|
|
|
document.body.classList.add('loadingInProgress');
|
|
|
this.bar.classList.remove('hidden');
|
|
|
}
|
|
|
- };
|
|
|
+ }, {
|
|
|
+ key: 'percent',
|
|
|
+ get: function get() {
|
|
|
+ return this._percent;
|
|
|
+ },
|
|
|
+ set: function set(val) {
|
|
|
+ this._indeterminate = isNaN(val);
|
|
|
+ this._percent = clamp(val, 0, 100);
|
|
|
+ this._updateBar();
|
|
|
+ }
|
|
|
+ }]);
|
|
|
+
|
|
|
return ProgressBar;
|
|
|
}();
|
|
|
+
|
|
|
exports.CSS_UNITS = CSS_UNITS;
|
|
|
exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
|
|
|
exports.DEFAULT_SCALE = DEFAULT_SCALE;
|