ngx-extended-pdf-viewer
Version:
<p> <a href="https://www.npmjs.com/package/ngx-extended-pdf-viewer"> <img src="https://img.shields.io/npm/dm/ngx-extended-pdf-viewer.svg?style=flat" alt="downloads"> </a> <a href="https://badge.fury.io/js/ngx-extended-pdf-viewer"> <img src="
882 lines (879 loc) • 219 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common')) :
typeof define === 'function' && define.amd ? define('ngx-extended-pdf-viewer', ['exports', '@angular/core', '@angular/common'], factory) :
(factory((global['ngx-extended-pdf-viewer'] = {}),global.ng.core,global.ng.common));
}(this, (function (exports,i0,common) { 'use strict';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NgxExtendedPdfViewerComponent = /** @class */ (function () {
function NgxExtendedPdfViewerComponent() {
this.resizeTimeout = null;
/**
* Number of milliseconds to wait between initializing the PDF viewer and loading the PDF file.
* Most users can let this parameter safely at it's default value of zero.
* Set this to 1000 or higher if you run into timing problems (typically caused by loading the locale files
* after the PDF files, so they are not available when the PDF viewer is initialized).
*/
this.delayFirstView = 0;
this.primaryMenuVisible = true;
this.minHeight = undefined;
this._height = '100%';
/**
* If this flag is true, this components adds a link to the locale assets. The pdf viewer
* sees this link and uses it to load the locale files automatically.
* @param useBrowserLocale boolean
*/
this.useBrowserLocale = false;
this.backgroundColor = '#e8e8eb';
/**
* Allows the user to define the name of the file after clicking "download"
*/
this.filenameForDownload = 'document.pdf';
/**
* Override the default locale. This must be the complete locale name, such as "es-ES". The string is allowed to be all lowercase.
*/
this.language = undefined;
/**
* By default, listening to the URL is deactivated because often the anchor tag is used for the Angular router
*/
this.listenToURL = false;
/**
* Navigate to a certain "named destination"
*/
this.nameddest = undefined;
/**
* allows you to pass a password to read password-protected files
*/
this.password = undefined;
this._showSidebarButton = true;
this.viewerPositionTop = '32px';
/**
* If [showSideBarButton]="true", do you want the sidebar to be shown by default ([showSidebarOnLoad])="true")
* or not? By default, this flag is undefined, telling the PDF viewer to use the last setting used with this particular
* document, or to hide the sidebar if the document is opened for the first time.
*/
this.showSidebarOnLoad = undefined;
this.showFindButton = true;
this.showPagingButtons = true;
this.showZoomButtons = true;
this.showPresentationModeButton = false;
this.showOpenFileButton = true;
this.showPrintButton = true;
this.showDownloadButton = true;
this.showBookmarkButton = true;
this.showSecondaryToolbarButton = true;
this.showRotateButton = true;
this.showSelectToolButton = true;
this.handTool = false;
this.showHandToolButton = true;
this.showScrollingButton = true;
this.showSpreadButton = true;
this.showPropertiesButton = true;
this.spreadChange = new i0.EventEmitter();
this.page = undefined;
this.pageChange = new i0.EventEmitter();
this.pagesLoaded = new i0.EventEmitter();
this.pageRendered = new i0.EventEmitter();
/**
* Legal values: undefined, 'auto', 'page-actual', 'page_fit', 'page-width', or '50' (or any other percentage)
*/
this.zoom = undefined;
this.zoomChange = new i0.EventEmitter();
/**
* This attributes allows you to increase the size of the UI elements so you can use them on small mobile devices.
* This attribute is a string with a percent character at the end (e.g. "150%").
*/
this._mobileFriendlyZoom = '100%';
this.toolbarWidth = '100%';
// dirty IE11 hack - temporary solution
this.findbarTop = undefined;
// dirty IE11 hack - temporary solution
this.findbarLeft = undefined;
// dirty IE11 hack - temporary solution
this.secondaryToolbarRight = undefined;
this._top = undefined;
}
Object.defineProperty(NgxExtendedPdfViewerComponent.prototype, "src", {
set: /**
* @param {?} url
* @return {?}
*/ function (url) {
if (url instanceof Uint8Array) {
this._src = (( /** @type {?} */(url))).buffer;
}
else if (url instanceof Blob) {
this._src = URL.createObjectURL(url);
}
else if (typeof url === 'string') {
this._src = url;
if (url.length > 980) {
// minimal length of a base64 encoded PDF
if (url.length % 4 === 0) {
if (/^[a-zA-Z\d\/+]+={0,2}$/.test(url)) {
console.warn('The URL looks like a base64 encoded string. If so, please use the attribute base64 instead of src');
}
}
}
}
else {
this._src = url;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgxExtendedPdfViewerComponent.prototype, "base64Src", {
set: /**
* @param {?} base64
* @return {?}
*/ function (base64) {
/** @type {?} */
var binary_string = window.atob(base64);
/** @type {?} */
var len = binary_string.length;
/** @type {?} */
var bytes = new Uint8Array(len);
for (var i = 0; i < len; i++) {
bytes[i] = binary_string.charCodeAt(i);
}
this.src = bytes.buffer;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgxExtendedPdfViewerComponent.prototype, "height", {
get: /**
* @return {?}
*/ function () {
return this._height;
},
set: /**
* @param {?} h
* @return {?}
*/ function (h) {
var _this = this;
this.minHeight = undefined;
if (h) {
this._height = h;
}
else {
this.height = '100%';
}
setTimeout(( /**
* @return {?}
*/function () {
_this.checkHeight();
}));
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgxExtendedPdfViewerComponent.prototype, "showSidebarButton", {
get: /**
* @return {?}
*/ function () {
return this._showSidebarButton;
},
set: /**
* @param {?} show
* @return {?}
*/ function (show) {
this._showSidebarButton = show;
/** @type {?} */
var isIE = /msie\s|trident\//i.test(window.navigator.userAgent);
/** @type {?} */
var factor = 1;
if (isIE) {
factor = Number((this._mobileFriendlyZoom || '100').replace('%', '')) / 100;
}
if (this._showSidebarButton) {
this.findbarLeft = (68 * factor).toString() + 'px';
}
else {
this.findbarLeft = '0px';
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgxExtendedPdfViewerComponent.prototype, "mobileFriendlyZoom", {
get: /**
* @return {?}
*/ function () {
return this._mobileFriendlyZoom;
},
/*
* This attributes allows you to increase the size of the UI elements so you can use them on small mobile devices.
* This attribute is a string with a percent character at the end (e.g. "150%").*/
set: /*
* This attributes allows you to increase the size of the UI elements so you can use them on small mobile devices.
* This attribute is a string with a percent character at the end (e.g. "150%").*/
/**
* @param {?} zoom
* @return {?}
*/
function (zoom) {
// tslint:disable-next-line:triple-equals - the type conversion is intended
if (zoom == 'true') {
zoom = '150%';
// tslint:disable-next-line:triple-equals - the type conversion is intended
}
else if (zoom == 'false') {
zoom = '100%';
}
this._mobileFriendlyZoom = zoom;
/** @type {?} */
var isIE = /msie\s|trident\//i.test(window.navigator.userAgent);
/** @type {?} */
var factor = 1;
if (isIE) {
factor = Number((zoom || '100').replace('%', '')) / 100;
}
if (this.showSidebarButton) {
this.findbarLeft = (68 * factor).toString() + 'px';
}
else {
this.findbarLeft = '0px';
}
if (isIE) {
// dirty, temporary hack
this.toolbarWidth = (100 / factor).toString() + '%';
this.findbarTop = (32 * factor).toString() + 'px';
this.secondaryToolbarRight = (252 * (factor - 1)).toString() + 'px';
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgxExtendedPdfViewerComponent.prototype, "mobileZoom", {
/** Deprecated. Please use [mobileFriendlyZoom] instead.
* This attributes allows you to increase the size of the UI elements so you can use them on small mobile devices.
* This attribute is a string with a percent character at the end (e.g. "150%").*/
set: /**
* Deprecated. Please use [mobileFriendlyZoom] instead.
* This attributes allows you to increase the size of the UI elements so you can use them on small mobile devices.
* This attribute is a string with a percent character at the end (e.g. "150%").
* @param {?} mobileFriendlyZoom
* @return {?}
*/ function (mobileFriendlyZoom) {
this.mobileFriendlyZoom = mobileFriendlyZoom;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgxExtendedPdfViewerComponent.prototype, "sidebarPositionTop", {
get: /**
* @return {?}
*/ function () {
if (this._top) {
return this._top;
}
if (this.mobileFriendlyZoom) {
if (this.mobileFriendlyZoom.endsWith('%')) {
/** @type {?} */
var zoom = Number(this.mobileFriendlyZoom.substring(0, this.mobileFriendlyZoom.length - 1));
return (0.32 * zoom).toString() + 'px';
}
if (this.mobileFriendlyZoom.endsWith('px')) {
return this.mobileFriendlyZoom;
}
}
return '32px';
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
NgxExtendedPdfViewerComponent.prototype.calcViewerPositionTop = /**
* @return {?}
*/
function () {
if (this._top) {
this.viewerPositionTop = this._top;
return;
}
if (this.mobileFriendlyZoom) {
if (this.mobileFriendlyZoom.endsWith('%')) {
/** @type {?} */
var zoom = Number(this.mobileFriendlyZoom.substring(0, this.mobileFriendlyZoom.length - 1));
if (!this.isPrimaryMenuVisible()) {
this.viewerPositionTop = '0';
}
else {
this.viewerPositionTop = (1 + 0.32 * zoom).toString() + 'px';
}
return;
}
if (this.mobileFriendlyZoom.endsWith('px')) {
this.viewerPositionTop = this.mobileFriendlyZoom;
return;
}
}
if (this.isPrimaryMenuVisible()) {
this.viewerPositionTop = '32px';
}
else {
this.viewerPositionTop = '0';
}
};
/**
* @return {?}
*/
NgxExtendedPdfViewerComponent.prototype.emitZoomChange = /**
* @return {?}
*/
function () {
/** @type {?} */
var selectedIndex = this.sizeSelector.nativeElement.selectedIndex;
if (selectedIndex) {
/** @type {?} */
var s = ( /** @type {?} */(this.sizeSelector.nativeElement.options[selectedIndex]));
/** @type {?} */
var value = s.label;
if (value.endsWith('%')) {
value = Number(value.replace('%', ''));
}
else {
value = s.value;
}
this.zoomChange.emit(value);
}
};
/**
* @return {?}
*/
NgxExtendedPdfViewerComponent.prototype.emitZoomChangeAfterDelay = /**
* @return {?}
*/
function () {
var _this = this;
setTimeout(( /**
* @return {?}
*/function () {
_this.emitZoomChange();
}), 10);
};
/**
* @return {?}
*/
NgxExtendedPdfViewerComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
/** @type {?} */
var callback = ( /**
* @param {?} e
* @return {?}
*/function (e) {
document.removeEventListener('localized', callback);
_this.initTimeout = setTimeout(( /**
* @return {?}
*/function () {
_this.openPDF();
}), _this.delayFirstView);
});
document.addEventListener('localized', callback);
if (NgxExtendedPdfViewerComponent.ngxExtendedPdfViewerInitialized) {
console.error("You're trying to open two instances of the PDF viewer. Most likely, this will result in errors.");
}
document.addEventListener('webviewerloaded', ( /**
* @return {?}
*/function () {
_this.overrideDefaultSettings();
}));
setTimeout(( /**
* @return {?}
*/function () {
// This initializes the webviewer, the file may be passed in to it to initialize the viewer with a pdf directly
_this.primaryMenuVisible = true;
if (!_this.isSecondaryMenuVisible()) {
_this.showSecondaryToolbarButton = false;
}
if (!_this.showSecondaryToolbarButton) {
if (!_this.isPrimaryMenuVisible()) {
_this.primaryMenuVisible = false;
}
}
_this.calcViewerPositionTop();
(( /** @type {?} */(window))).webViewerLoad();
(( /** @type {?} */(window))).PDFViewerApplication.appConfig.defaultUrl = ''; // IE bugfix
(( /** @type {?} */(window))).PDFViewerApplicationOptions.set('locale', _this.language);
(( /** @type {?} */(window))).PDFViewerApplication.isViewerEmbedded = true;
_this.overrideDefaultSettings();
/** @type {?} */
var pc = document.getElementById('printContainer');
if (pc) {
document.getElementsByTagName('body')[0].appendChild(pc);
}
}), 0);
};
/**
* @return {?}
*/
NgxExtendedPdfViewerComponent.prototype.checkHeight = /**
* @return {?}
*/
function () {
/** @type {?} */
var container = document.getElementsByClassName('zoom')[0];
if (container.clientHeight === 0 && this._height.includes('%')) {
/** @type {?} */
var available = window.innerHeight;
/** @type {?} */
var rect = container.getBoundingClientRect();
/** @type {?} */
var top_1 = rect.top;
/** @type {?} */
var mh = available - top_1;
/** @type {?} */
var factor = Number(this._height.replace('%', ''));
mh = (mh * factor) / 100;
if (mh > 100) {
this.minHeight = mh + 'px';
}
else {
this.minHeight = '100px';
}
}
};
/**
* @return {?}
*/
NgxExtendedPdfViewerComponent.prototype.onPageChange = /**
* @return {?}
*/
function () {
var _this = this;
setTimeout(( /**
* @return {?}
*/function () {
/** @type {?} */
var inputField = ( /** @type {?} */(document.getElementById('pageNumber')));
/** @type {?} */
var page = Number(inputField.value);
if (isNaN(page)) {
page = undefined;
}
_this.pageChange.emit(page);
}));
};
/**
* @param {?} newSpread
* @return {?}
*/
NgxExtendedPdfViewerComponent.prototype.onSpreadChange = /**
* @param {?} newSpread
* @return {?}
*/
function (newSpread) {
this.spreadChange.emit(newSpread);
};
/**
* @private
* @return {?}
*/
NgxExtendedPdfViewerComponent.prototype.overrideDefaultSettings = /**
* @private
* @return {?}
*/
function () {
(( /** @type {?} */(window))).PDFViewerApplication.overrideHistory = {};
if ((( /** @type {?} */(window))).PDFViewerApplication.appConfig) {
(( /** @type {?} */(window))).PDFViewerApplication.appConfig.filenameForDownload = this.filenameForDownload;
}
else {
(( /** @type {?} */(window))).PDFViewerApplicationOptions.set('filenameForDownload', this.filenameForDownload);
}
if (this.showSidebarButton) {
if (this.showSidebarOnLoad !== undefined) {
(( /** @type {?} */(window))).PDFViewerApplication.sidebarViewOnLoad = this.showSidebarOnLoad ? 1 : 0;
if ((( /** @type {?} */(window))).PDFViewerApplication.appConfig) {
(( /** @type {?} */(window))).PDFViewerApplication.appConfig.sidebarViewOnLoad = this.showSidebarOnLoad ? 1 : 0;
}
(( /** @type {?} */(window))).PDFViewerApplication.overrideHistory.sidebarViewOnLoad = this.showSidebarOnLoad ? 1 : 0;
}
}
else {
(( /** @type {?} */(window))).PDFViewerApplication.sidebarViewOnLoad = 0;
if ((( /** @type {?} */(window))).PDFViewerApplication.appConfig) {
(( /** @type {?} */(window))).PDFViewerApplication.appConfig.sidebarViewOnLoad = 0;
}
(( /** @type {?} */(window))).PDFViewerApplication.overrideHistory.sidebarViewOnLoad = 0;
}
if (this.spread === 'even') {
(( /** @type {?} */(window))).PDFViewerApplicationOptions.set('spreadModeOnLoad', 2);
if ((( /** @type {?} */(window))).PDFViewerApplication.pdfViewer) {
(( /** @type {?} */(window))).PDFViewerApplication.pdfViewer.spreadMode = 2;
}
this.onSpreadChange('even');
}
else if (this.spread === 'odd') {
(( /** @type {?} */(window))).PDFViewerApplicationOptions.set('spreadModeOnLoad', 1);
if ((( /** @type {?} */(window))).PDFViewerApplication.pdfViewer) {
(( /** @type {?} */(window))).PDFViewerApplication.pdfViewer.spreadMode = 1;
}
this.onSpreadChange('odd');
}
else {
(( /** @type {?} */(window))).PDFViewerApplicationOptions.set('spreadModeOnLoad', 0);
if ((( /** @type {?} */(window))).PDFViewerApplication.pdfViewer) {
(( /** @type {?} */(window))).PDFViewerApplication.pdfViewer.spreadMode = 0;
}
this.onSpreadChange('off');
}
};
/**
* @private
* @return {?}
*/
NgxExtendedPdfViewerComponent.prototype.openPDF = /**
* @private
* @return {?}
*/
function () {
var _this = this;
NgxExtendedPdfViewerComponent.ngxExtendedPdfViewerInitialized = true;
this.onResize();
if (!this.listenToURL) {
(( /** @type {?} */(window))).PDFViewerApplication.pdfLinkService.setHash = ( /**
* @return {?}
*/function () { });
}
this.initTimeout = null;
(( /** @type {?} */(window))).PDFViewerApplication.eventBus.on('pagesloaded', ( /**
* @param {?} x
* @return {?}
*/function (x) {
_this.pagesLoaded.emit(x);
if (_this.nameddest) {
(( /** @type {?} */(window))).PDFViewerApplication.pdfLinkService.navigateTo(_this.nameddest);
}
_this.overrideDefaultSettings();
_this.setZoom();
}));
(( /** @type {?} */(window))).PDFViewerApplication.eventBus.on('pagerendered', ( /**
* @param {?} x
* @return {?}
*/function (x) {
_this.pageRendered.emit(x);
}));
this.checkHeight();
// open a file in the viewer
if (!!this._src) {
/** @type {?} */
var options = {
password: this.password
};
(( /** @type {?} */(window))).PDFViewerApplication.open(this._src, options);
}
setTimeout(( /**
* @return {?}
*/function () {
if (_this.page) {
(( /** @type {?} */(window))).PDFViewerApplication.page = _this.page;
}
}), 100);
};
/**
* @return {?}
*/
NgxExtendedPdfViewerComponent.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
NgxExtendedPdfViewerComponent.ngxExtendedPdfViewerInitialized = false;
if (this.initTimeout) {
clearTimeout(this.initTimeout);
this.initTimeout = undefined;
}
/** @type {?} */
var app = (( /** @type {?} */(window))).PDFViewerApplication;
if (app) {
app.cleanup();
app.close();
if (app._boundEvents) {
app.unbindWindowEvents();
}
/** @type {?} */
var bus = ( /** @type {?} */(app.eventBus));
if (bus) {
app.unbindEvents();
for (var key in bus._listeners) {
if (bus._listeners[key]) {
bus._listeners[key] = undefined;
}
}
}
app.eventBus = null;
}
/** @type {?} */
var body = document.getElementsByTagName('body');
if (body[0]) {
/** @type {?} */
var topLevelElements = body[0].children;
for (var i = topLevelElements.length - 1; i >= 0; i--) {
/** @type {?} */
var e = topLevelElements.item(i);
if (e && e.id === 'printContainer') {
body[0].removeChild(e);
}
else if (e && e.id === 'fileInput') {
body[0].removeChild(e);
}
}
}
};
/**
* @private
* @return {?}
*/
NgxExtendedPdfViewerComponent.prototype.isSecondaryMenuVisible = /**
* @private
* @return {?}
*/
function () {
/** @type {?} */
var visible = this.showHandToolButton ||
this.showPagingButtons ||
this.showPropertiesButton ||
this.showRotateButton ||
this.showScrollingButton ||
this.showRotateButton ||
this.showSpreadButton ||
this.showSelectToolButton;
if (visible) {
return true;
}
return false;
};
/**
* @private
* @return {?}
*/
NgxExtendedPdfViewerComponent.prototype.isPrimaryMenuVisible = /**
* @private
* @return {?}
*/
function () {
/** @type {?} */
var visible = this.showBookmarkButton ||
this.showDownloadButton ||
this.showFindButton ||
this.showOpenFileButton ||
this.showPagingButtons ||
this.showPresentationModeButton ||
this.showPrintButton ||
this.showPropertiesButton ||
this.showSidebarButton ||
this.showSecondaryToolbarButton ||
this.showZoomButtons;
if (visible) {
return true;
}
return false;
};
/**
* @param {?} changes
* @return {?}
*/
NgxExtendedPdfViewerComponent.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
if (NgxExtendedPdfViewerComponent.ngxExtendedPdfViewerInitialized) {
if ('src' in changes) {
if (!!this._src) {
this.overrideDefaultSettings();
(( /** @type {?} */(window))).PDFViewerApplication.open(this._src);
}
}
if ('zoom' in changes) {
this.setZoom();
}
if ('handTool' in changes) {
if (this.handTool) {
/** @type {?} */
var menu = document.getElementsByClassName('handTool');
if (menu && menu[0]) {
(( /** @type {?} */(menu[0]))).click();
}
}
else {
/** @type {?} */
var menu = document.getElementsByClassName('selectTool');
if (menu && menu[0]) {
(( /** @type {?} */(menu[0]))).click();
}
}
}
if ('page' in changes) {
if (this.page) {
(( /** @type {?} */(window))).PDFViewerApplication.page = this.page;
}
}
if ('filenameForDownload' in changes) {
(( /** @type {?} */(window))).PDFViewerApplication.appConfig.filenameForDownload = this.filenameForDownload;
}
if ('nameddest' in changes) {
if (this.nameddest) {
(( /** @type {?} */(window))).PDFViewerApplication.pdfLinkService.navigateTo(this.nameddest);
}
}
if ('spread' in changes) {
if (this.spread === 'even') {
(( /** @type {?} */(window))).PDFViewerApplication.spreadModeOnLoad = 2;
(( /** @type {?} */(window))).PDFViewerApplication.pdfViewer.spreadMode = 2;
this.onSpreadChange('even');
}
else if (this.spread === 'odd') {
(( /** @type {?} */(window))).PDFViewerApplication.spreadModeOnLoad = 1;
(( /** @type {?} */(window))).PDFViewerApplication.pdfViewer.spreadMode = 1;
this.onSpreadChange('odd');
}
else {
(( /** @type {?} */(window))).PDFViewerApplication.spreadModeOnLoad = 0;
(( /** @type {?} */(window))).PDFViewerApplication.pdfViewer.spreadMode = 0;
this.onSpreadChange('off');
}
}
this.primaryMenuVisible = true;
if (!this.isSecondaryMenuVisible()) {
this.showSecondaryToolbarButton = false;
}
if (!this.showSecondaryToolbarButton) {
if (!this.isPrimaryMenuVisible()) {
this.primaryMenuVisible = false;
}
}
this.calcViewerPositionTop();
}
};
/**
* @private
* @return {?}
*/
NgxExtendedPdfViewerComponent.prototype.setZoom = /**
* @private
* @return {?}
*/
function () {
/** @type {?} */
var zoomAsNumber = this.zoom;
if (String(zoomAsNumber).endsWith('%')) {
zoomAsNumber = Number(String(zoomAsNumber).replace('%', '')) / 100;
}
else if (!isNaN(Number(zoomAsNumber))) {
zoomAsNumber = Number(zoomAsNumber) / 100;
}
(( /** @type {?} */(window))).PDFViewerApplication.pdfViewer.currentScaleValue = zoomAsNumber;
};
/**
* @return {?}
*/
NgxExtendedPdfViewerComponent.prototype.onResize = /**
* @return {?}
*/
function () {
clearTimeout(this.resizeTimeout);
this.resizeTimeout = setTimeout(this.doResize, 100);
};
/**
* @private
* @return {?}
*/
NgxExtendedPdfViewerComponent.prototype.doResize = /**
* @private
* @return {?}
*/
function () {
/** @type {?} */
var pdfViewer = document.getElementsByClassName('html');
if (pdfViewer && pdfViewer.length > 0) {
/** @type {?} */
var toolbar_1 = pdfViewer[0].getElementsByClassName('toolbar');
if (toolbar_1 && toolbar_1.length > 0) {
/** @type {?} */
var width = toolbar_1[0].clientWidth;
if (window.innerWidth - width > 50) {
/** @type {?} */
var mediumElements = toolbar_1[0].getElementsByClassName('hiddenMediumView');
for (var i = 0; i < mediumElements.length; i++) {
/** @type {?} */
var elt = ( /** @type {?} */(mediumElements[i]));
if (width < 650) {
elt.classList.add('hidden');
}
else {
elt.classList.remove('hidden');
}
}
/** @type {?} */
var smallElements = toolbar_1[0].getElementsByClassName('hiddenSmallView');
for (var i = 0; i < smallElements.length; i++) {
/** @type {?} */
var elt = ( /** @type {?} */(smallElements[i]));
if (width < 590) {
elt.classList.add('hidden');
}
else {
elt.classList.remove('hidden');
}
}
/** @type {?} */
var tinyElement = document.getElementById('scaleSelectContainer');
/** @type {?} */
var tiny = ( /** @type {?} */(tinyElement));
if (width < 485) {
// not perfect, but good first approximation
tiny.classList.add('hidden');
}
else {
tiny.classList.remove('hidden');
}
}
}
/* TODO: this is the complete list of items to consider:
@media all and (max-width: 700px) {
#outerContainer .hiddenMediumView {
display: none;
}
#outerContainer .visibleMediumView {
display: inherit;
}
}
@media all and (max-width: 640px) {
.hiddenSmallView, .hiddenSmallView * {
display: none;
}
.visibleSmallView {
display: inherit;
}
.toolbarButtonSpacer {
width: 0;
}
html[dir='ltr'] .findbar {
left: 38px;
}
html[dir='rtl'] .findbar {
right: 38px;
}
}
@media all and (max-width: 535px) {
#scaleSelectContainer {
display: none;
}
}
*/
}
};
NgxExtendedPdfViewerComponent.ngxExtendedPdfViewerInitialized = false;
NgxExtendedPdfViewerComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'ngx-extended-pdf-viewer',
template: "<link\n *ngIf=\"useBrowserLocale\"\n rel=\"resource\"\n type=\"application/l10n\"\n href=\"assets/locale/locale.properties\"\n/>\n<div class=\"zoom\" [style.height]=\"height\" [style.minHeight]=\"minHeight\">\n <div class=\"html\">\n <div\n tabindex=\"1\"\n class=\"loadingInProgress body\"\n [style.backgroundColor]=\"backgroundColor\"\n >\n <div id=\"outerContainer\">\n <div id=\"sidebarContainer\" [style.top]=\"sidebarPositionTop\">\n <div\n id=\"additionalSidebarContainer\"\n [class.hidden]=\"!showSidebarButton\"\n >\n <div id=\"toolbarSidebar\">\n <div class=\"splitToolbarButton toggled\">\n <button\n id=\"viewThumbnail\"\n class=\"toolbarButton toggled\"\n title=\"Show Thumbnails\"\n tabindex=\"2\"\n data-l10n-id=\"thumbs\"\n >\n <span data-l10n-id=\"thumbs_label\">Thumbnails</span>\n </button>\n <button\n id=\"viewOutline\"\n class=\"toolbarButton\"\n title=\"Show Document Outline (double-click to expand/collapse all items)\"\n tabindex=\"3\"\n data-l10n-id=\"document_outline\"\n >\n <span data-l10n-id=\"document_outline_label\"\n >Document Outline</span\n >\n </button>\n <button\n id=\"viewAttachments\"\n class=\"toolbarButton\"\n title=\"Show Attachments\"\n tabindex=\"4\"\n data-l10n-id=\"attachments\"\n >\n <span data-l10n-id=\"attachments_label\">Attachments</span>\n </button>\n </div>\n </div>\n </div>\n <div id=\"sidebarContent\">\n <div id=\"thumbnailView\"></div>\n <div id=\"outlineView\" class=\"hidden\"></div>\n <div id=\"attachmentsView\" class=\"hidden\"></div>\n </div>\n <div id=\"sidebarResizer\" class=\"hidden\"></div>\n </div>\n <!-- sidebarContainer -->\n\n <div id=\"mainContainer\">\n <div\n class=\"findbar hidden doorHanger\"\n id=\"findbar\"\n [style.zoom]=\"mobileFriendlyZoom\"\n [style.top]=\"findbarTop\"\n [style.left]=\"findbarLeft\"\n >\n <div id=\"findbarInputContainer\">\n <input\n autocomplete=\"search-input-field\"\n id=\"findInput\"\n class=\"toolbarField\"\n title=\"Find\"\n placeholder=\"Find in document\u2026\"\n tabindex=\"91\"\n data-l10n-id=\"find_input\"\n name=\"search-input-field\"\n />\n <div class=\"splitToolbarButton\">\n <button\n id=\"findPrevious\"\n class=\"toolbarButton findPrevious\"\n title=\"Find the previous occurrence of the phrase\"\n tabindex=\"92\"\n data-l10n-id=\"find_previous\"\n >\n <span data-l10n-id=\"find_previous_label\">Previous</span>\n </button>\n <div class=\"splitToolbarButtonSeparator\"></div>\n <button\n id=\"findNext\"\n class=\"toolbarButton findNext\"\n title=\"Find the next occurrence of the phrase\"\n tabindex=\"93\"\n data-l10n-id=\"find_next\"\n >\n <span data-l10n-id=\"find_next_label\">Next</span>\n </button>\n </div>\n </div>\n\n <div id=\"findbarOptionsOneContainer\">\n <input\n type=\"checkbox\"\n id=\"findHighlightAll\"\n class=\"toolbarField\"\n tabindex=\"94\"\n />\n <label\n for=\"findHighlightAll\"\n class=\"toolbarLabel\"\n data-l10n-id=\"find_highlight\"\n >Highlight all</label\n >\n <input\n type=\"checkbox\"\n id=\"findMatchCase\"\n class=\"toolbarField\"\n tabindex=\"95\"\n />\n <label\n for=\"findMatchCase\"\n class=\"toolbarLabel\"\n data-l10n-id=\"find_match_case_label\"\n >Match case</label\n >\n </div>\n <div id=\"findbarOptionsTwoContainer\">\n <input\n type=\"checkbox\"\n id=\"findEntireWord\"\n class=\"toolbarField\"\n tabindex=\"96\"\n />\n <label\n for=\"findEntireWord\"\n class=\"toolbarLabel\"\n data-l10n-id=\"find_entire_word_label\"\n >Whole words</label\n >\n <span id=\"findResultsCount\" class=\"toolbarLabel hidden\"></span>\n </div>\n\n <div id=\"findbarMessageContainer\">\n <span id=\"findMsg\" class=\"toolbarLabel\"></span>\n </div>\n </div>\n <!-- findbar -->\n\n <div\n id=\"secondaryToolbar\"\n class=\"secondaryToolbar hidden doorHangerRight\"\n [style.zoom]=\"mobileFriendlyZoom\"\n [style.top]=\"findbarTop\"\n [style.right]=\"secondaryToolbarRight\"\n >\n <div id=\"secondaryToolbarButtonContainer\">\n <button\n id=\"secondaryPresentationMode\"\n class=\"secondaryToolbarButton presentationMode visibleLargeView\"\n title=\"Switch to Presentation Mode\"\n tabindex=\"51\"\n data-l10n-id=\"presentation_mode\"\n >\n <span data-l10n-id=\"presentation_mode_label\"\n >Presentation Mode</span\n >\n </button>\n\n <button\n id=\"secondaryOpenFile\"\n class=\"secondaryToolbarButton openFile visibleLargeView\"\n title=\"Open File\"\n tabindex=\"52\"\n data-l10n-id=\"open_file\"\n >\n <span data-l10n-id=\"open_file_label\">Open</span>\n </button>\n\n <button\n id=\"secondaryPrint\"\n class=\"secondaryToolbarButton print visibleMediumView\"\n title=\"Print\"\n tabindex=\"53\"\n data-l10n-id=\"print\"\n >\n <span data-l10n-id=\"print_label\">Print</span>\n </button>\n\n <button\n id=\"secondaryDownload\"\n class=\"secondaryToolbarButton download visibleMediumView\"\n title=\"Download\"\n tabindex=\"54\"\n data-l10n-id=\"download\"\n >\n <span data-l10n-id=\"download_label\">Download</span>\n </button>\n\n <a\n href=\"#\"\n id=\"secondaryViewBookmark\"\n class=\"secondaryToolbarButton bookmark visibleSmallView\"\n title=\"Current view (copy or open in new window)\"\n tabindex=\"55\"\n data-l10n-id=\"bookmark\"\n >\n <span data-l10n-id=\"bookmark_label\">Current View</span>\n </a>\n\n <div class=\"horizontalToolbarSeparator visibleLargeView\"></div>\n\n <button\n [class.hidden]=\"!showPagingButtons\"\n id=\"firstPage\"\n class=\"secondaryToolbarButton firstPage\"\n title=\"Go to First Page\"\n tabindex=\"56\"\n data-l10n-id=\"first_page\"\n >\n <span data-l10n-id=\"first_page_label\">Go to First Page</span>\n </button>\n <button\n [class.hidden]=\"!showPagingButtons\"\n id=\"lastPage\"\n class=\"secondaryToolbarButton lastPage\"\n title=\"Go to Last Page\"\n tabindex=\"57\"\n data-l10n-id=\"last_page\"\n >\n <span data-l10n-id=\"last_page_label\">Go to Last Page</span>\n </button>\n\n <div\n [class.hidden]=\"!showRotateButton\"\n class=\"horizontalToolbarSeparator\"\n ></div>\n\n <button\n [class.hidden]=\"!showRotateButton\"\n id=\"pageRotateCw\"\n class=\"secondaryToolbarButton rotateCw\"\n title=\"Rotate Clockwise\"\n tabindex=\"58\"\n data-l10n-id=\"page_rotate_cw\"\n >\n <span data-l10n-id=\"page_rotate_cw_label\"\n >Rotate Clockwise</span\n >\n </button>\n <button\n [class.hidden]=\"!showRotateButton\"\n id=\"pageRotateCcw\"\n class=\"secondaryToolbarButton rotateCcw\"\n title=\"Rotate Counterclockwise\"\n tabindex=\"59\"\n data-l10n-id=\"page_rotate_ccw\"\n >\n <span data-l10n-id=\"page_rotate_ccw_label\"\n >Rotate Counterclockwise</span\n >\n </button>\n\n <div class=\"horizontalToolbarSeparator\"></div>\n\n <button\n [class.hidden]=\"!showSelectToolButton\"\n id=\"cursorSelectTool\"\n class=\"secondaryToolbarButton selectTool toggled\"\n title=\"Enable Text Selection Tool\"\n tabindex=\"60\"\n data-l10n-id=\"cursor_text_select_tool\"\n >\n <span data-l10n-id=\"cursor_text_select_tool_label\"\n >Text Selection Tool</span\n >\n </button>\n <button\n [class.hidden]=\"!showHandToolButton\"\n id=\"cursorHandTool\"\n class=\"secondaryToolbarButton handTool\"\n title=\"Enable Hand Tool\"\n tabindex=\"61\"\n data-l10n-id=\"cursor_hand_tool\"\n >\n <span data-l10n-id=\"cursor_hand_tool_label\">Hand Tool</span>\n </button>\n\n <div\n [class.hidden]=\"!showScrollingButton\"\n class=\"horizontalToolbarSeparator\"\n ></div>\n\n <button\n [class.hidden]=\"!showScrollingButton\"\n id=\"scrollVertical\"\n class=\"secondaryToolbarButton scrollVertical toggled\"\n title=\"Use Vertical Scrolling\"\n tabindex=\"62\"\n data-l10n-id=\"scroll_vertical\"\n >\n <span data-l10n-id=\"scroll_vertical_label\"\n >Vertical Scrolling</span\n >\n </button>\n <button\n [class.hidden]=\"!showScrollingButton\"\n id=\"scrollHorizontal\"\n class=\"secondaryToolbarButton scrollHorizontal\"\n title=\"Use Horizontal Scrolling\"\n tabindex=\"63\"\n data-l10n-id=\"scroll_hori