123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- 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 = {}));
|