123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- 'use strict';
- var CustomStyle = (function CustomStyleClosure() {
-
-
-
-
- var prefixes = ['ms', 'Moz', 'Webkit', 'O'];
- var _cache = { };
- function CustomStyle() {
- }
- CustomStyle.getProp = function get(propName, element) {
-
- if (arguments.length == 1 && typeof _cache[propName] == 'string') {
- return _cache[propName];
- }
- element = element || document.documentElement;
- var style = element.style, prefixed, uPropName;
-
- if (typeof style[propName] == 'string') {
- return (_cache[propName] = propName);
- }
-
- uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
-
- for (var i = 0, l = prefixes.length; i < l; i++) {
- prefixed = prefixes[i] + uPropName;
- if (typeof style[prefixed] == 'string') {
- return (_cache[propName] = prefixed);
- }
- }
-
- return (_cache[propName] = 'undefined');
- };
- CustomStyle.setProp = function set(propName, element, str) {
- var prop = this.getProp(propName);
- if (prop != 'undefined')
- element.style[prop] = str;
- };
- return CustomStyle;
- })();
- function getFileName(url) {
- var anchor = url.indexOf('#');
- var query = url.indexOf('?');
- var end = Math.min(
- anchor > 0 ? anchor : url.length,
- query > 0 ? query : url.length);
- return url.substring(url.lastIndexOf('/', end) + 1, end);
- }
- function getOutputScale(ctx) {
- var devicePixelRatio = window.devicePixelRatio || 1;
- var backingStoreRatio = ctx.webkitBackingStorePixelRatio ||
- ctx.mozBackingStorePixelRatio ||
- ctx.msBackingStorePixelRatio ||
- ctx.oBackingStorePixelRatio ||
- ctx.backingStorePixelRatio || 1;
- var pixelRatio = devicePixelRatio / backingStoreRatio;
- return {
- sx: pixelRatio,
- sy: pixelRatio,
- scaled: pixelRatio != 1
- };
- }
- function scrollIntoView(element, spot) {
-
-
-
- var parent = element.offsetParent;
- var offsetY = element.offsetTop + element.clientTop;
- var offsetX = element.offsetLeft + element.clientLeft;
- if (!parent) {
- console.error('offsetParent is not set -- cannot scroll');
- return;
- }
- while (parent.clientHeight === parent.scrollHeight) {
- if (parent.dataset._scaleY) {
- offsetY /= parent.dataset._scaleY;
- offsetX /= parent.dataset._scaleX;
- }
- offsetY += parent.offsetTop;
- offsetX += parent.offsetLeft;
- parent = parent.offsetParent;
- if (!parent) {
- return;
- }
- }
- if (spot) {
- if (spot.top !== undefined) {
- offsetY += spot.top;
- }
- if (spot.left !== undefined) {
- offsetX += spot.left;
- parent.scrollLeft = offsetX;
- }
- }
- parent.scrollTop = offsetY;
- }
- function noContextMenuHandler(e) {
- e.preventDefault();
- }
- function getPDFFileNameFromURL(url) {
- var reURI = /^(?:([^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
-
-
- var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
- var splitURI = reURI.exec(url);
- var suggestedFilename = reFilename.exec(splitURI[1]) ||
- reFilename.exec(splitURI[2]) ||
- reFilename.exec(splitURI[3]);
- if (suggestedFilename) {
- suggestedFilename = suggestedFilename[0];
- if (suggestedFilename.indexOf('%') != -1) {
-
- try {
- suggestedFilename =
- reFilename.exec(decodeURIComponent(suggestedFilename))[0];
- } catch(e) {
-
-
- }
- }
- }
- return suggestedFilename || 'document.pdf';
- }
- var ProgressBar = (function ProgressBarClosure() {
- function clamp(v, min, max) {
- return Math.min(Math.max(v, min), max);
- }
- function ProgressBar(id, opts) {
-
- 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.div.style.height = this.height + this.units;
- this.percent = 0;
- }
- ProgressBar.prototype = {
- updateBar: function ProgressBar_updateBar() {
- if (this._indeterminate) {
- this.div.classList.add('indeterminate');
- this.div.style.width = this.width + this.units;
- return;
- }
- 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);');
- }
- }
- },
- hide: function ProgressBar_hide() {
- this.bar.classList.add('hidden');
- this.bar.removeAttribute('style');
- }
- };
- return ProgressBar;
- })();
- var Cache = function cacheCache(size) {
- var data = [];
- this.push = function cachePush(view) {
- var i = data.indexOf(view);
- if (i >= 0)
- data.splice(i);
- data.push(view);
- if (data.length > size)
- data.shift().destroy();
- };
- };
- var isLocalStorageEnabled = (function isLocalStorageEnabledClosure() {
-
-
-
- try {
- return ('localStorage' in window && window['localStorage'] !== null &&
- localStorage);
- } catch (e) {
- return false;
- }
- })();
|