var Unibase; (function (Unibase) { let Apps; (function (Apps) { let Collaboration; (function (Collaboration) { let Components; (function (Components) { let PdfViewer; (function (PdfViewer) { class Base { constructor() { this.isFullscreen = false; } init(response) { this.result = response.result; this.documentGroup = this.result.DocumentGroup; this.documentFileName = this.result.DocumentFileName; this.documentFileId = this.result.DocumentFileId; this.filePath = this.result.DocumentFilePath; this.render(); } unwireBootStrapKeyEvent() { let popup = document.body.getElementsByClassName('_bizgaze_popup_container'); let events = $._data($(popup)[0], "events"); if (events && events.keydown) { $(popup).off('keydown.dismiss.bs.modal', events.keydown[0].handler); } } render() { this.renderPopup(); this.renderMenuBar(); this.renderPdf(); this.updateProps(); this.refreshHeight(); this.addEventListeners(); this.unwireBootStrapKeyEvent(); } addEventListeners() { this.fullscreenBtn.addEventListener('click', () => { this.openFullscreen(); }); this.popupElement.addEventListener('fullscreenchange', () => { setTimeout(() => { this.setHeigthOnFullscreenChange(); }, 0); if (this.isFullscreen) { this.fullscreenBtn.classList.remove('biz-enterfullscreen'); this.fullscreenBtn.classList.add('biz-exitfullscreen'); this.isFullscreen = true; } else { this.fullscreenBtn.classList.remove('biz-exitfullscreen'); this.fullscreenBtn.classList.add('biz-enterfullscreen'); this.isFullscreen = false; } ; }); document.addEventListener('fullscreenchange', () => { this.setHeigthOnFullscreenChange(); }); window.addEventListener('keyup', (e) => { if (e.keyCode == 122) { e.preventDefault(); this.openFullscreen(); this.setHeigthOnFullscreenChange(); } }); this.exitPdf.addEventListener('click', () => { this.closePopup(); }); } openFullscreen() { let elem = this.popupElement; if (!this.isFullscreen) { if (elem.requestFullscreen) { elem.requestFullscreen(); } else if (elem.webkitRequestFullscreen) { elem.webkitRequestFullscreen(); } else if (elem.msRequestFullscreen) { elem.msRequestFullscreen(); } this.isFullscreen = true; } else { if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.webkitExitFullscreen) { document.webkitExitFullscreen(); } else if (document.msExitFullscreen) { document.msExitFullscreen(); } this.isFullscreen = false; } } setHeigthOnFullscreenChange() { var footerHeight = this.element.parentElement.nextElementSibling.offsetHeight; this.element.parentElement.style.height = window.innerHeight - footerHeight + 'px'; this.pdfViewer.height = '100%'; } renderPdf() { this.pdfViewer = new ej.pdfviewer.PdfViewer({ created: this.pdfCreated.bind(this), documentPath: this.filePath, serviceUrl: 'http://localhost:3088/pdfviewer' }); ej.pdfviewer.PdfViewer.Inject(ej.pdfviewer.TextSelection, ej.pdfviewer.TextSearch, ej.pdfviewer.Print, ej.pdfviewer.Navigation); this.pdfViewer.appendTo('#DocumentViewer'); } updateProps() { this.popupElement = document.getElementsByClassName('_bizgaze_popup_container')[0]; this.element = document.getElementById('DocumentViewer'); this.fullscreenBtn = document.getElementsByClassName('biz-pdf-fullscreen-btn')[0]; this.exitPdf = document.getElementsByClassName('biz-pdf-exitpdf-btn')[0]; } pdfCreated() { var util = Unibase.Apps.Collaboration.Components.Common.Util.Instance(); document.getElementById("DocumentViewer_zoomDropDownContainer").after(util.createElement('div', 'class', 'biz-pdf-fullscreen')); util.appendChildren('biz-pdf-fullscreen', 0, util.createElement('button', 'class', 'e-icons biz-pdf-fullscreen-btn biz-enterfullscreen')); document.getElementById("DocumentViewer_downloadContainer").after(util.createElement('div', 'class', 'biz-pdf-exitpdf')); util.appendChildren('biz-pdf-exitpdf', 0, util.createElement('button', 'class', 'e-icons biz-pdf-exitpdf-btn')); } actionComplete() { } closePopup() { Unibase.Apps.Collaboration.Components.DocConnector.Instance().closeDoc(); var contId = $("._bizgaze_popup_container:visible").attr("id"); $('#' + contId).modal('hide'); $('#' + contId).remove(); } refreshHeight() { var footerHeight = this.element.parentElement.nextElementSibling.offsetHeight; var rootHeight = this.element.parentElement.parentElement.offsetHeight; this.element.parentElement.style.height = (rootHeight - footerHeight) + 'px'; } renderPopup() { Unibase.Apps.Collaboration.Components.Documents.Instance().loadForm(0, this.documentFileId, 0, null, this.documentGroup); } renderMenuBar() { } static Instance() { if (this.instance === undefined) { this.instance = new Base(); } return this.instance; } } PdfViewer.Base = Base; })(PdfViewer = Components.PdfViewer || (Components.PdfViewer = {})); })(Components = Collaboration.Components || (Collaboration.Components = {})); })(Collaboration = Apps.Collaboration || (Apps.Collaboration = {})); })(Apps = Unibase.Apps || (Unibase.Apps = {})); })(Unibase || (Unibase = {}));