Built files from Bizgaze WebServer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

base.js 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. var Unibase;
  2. (function (Unibase) {
  3. let Apps;
  4. (function (Apps) {
  5. let Collaboration;
  6. (function (Collaboration) {
  7. let Components;
  8. (function (Components) {
  9. let PdfViewer;
  10. (function (PdfViewer) {
  11. class Base {
  12. constructor() {
  13. this.isFullscreen = false;
  14. }
  15. init(response) {
  16. this.result = response.result;
  17. this.documentGroup = this.result.DocumentGroup;
  18. this.documentFileName = this.result.DocumentFileName;
  19. this.documentFileId = this.result.DocumentFileId;
  20. this.filePath = this.result.DocumentFilePath;
  21. this.render();
  22. }
  23. unwireBootStrapKeyEvent() {
  24. let popup = document.body.getElementsByClassName('_bizgaze_popup_container');
  25. let events = $._data($(popup)[0], "events");
  26. if (events && events.keydown) {
  27. $(popup).off('keydown.dismiss.bs.modal', events.keydown[0].handler);
  28. }
  29. }
  30. render() {
  31. this.renderPopup();
  32. this.renderMenuBar();
  33. this.renderPdf();
  34. this.updateProps();
  35. this.refreshHeight();
  36. this.addEventListeners();
  37. this.unwireBootStrapKeyEvent();
  38. }
  39. addEventListeners() {
  40. this.fullscreenBtn.addEventListener('click', () => {
  41. this.openFullscreen();
  42. });
  43. this.popupElement.addEventListener('fullscreenchange', () => {
  44. setTimeout(() => {
  45. this.setHeigthOnFullscreenChange();
  46. }, 0);
  47. if (this.isFullscreen) {
  48. this.fullscreenBtn.classList.remove('biz-enterfullscreen');
  49. this.fullscreenBtn.classList.add('biz-exitfullscreen');
  50. this.isFullscreen = true;
  51. }
  52. else {
  53. this.fullscreenBtn.classList.remove('biz-exitfullscreen');
  54. this.fullscreenBtn.classList.add('biz-enterfullscreen');
  55. this.isFullscreen = false;
  56. }
  57. ;
  58. });
  59. document.addEventListener('fullscreenchange', () => {
  60. this.setHeigthOnFullscreenChange();
  61. });
  62. window.addEventListener('keyup', (e) => {
  63. if (e.keyCode == 122) {
  64. e.preventDefault();
  65. this.openFullscreen();
  66. this.setHeigthOnFullscreenChange();
  67. }
  68. });
  69. this.exitPdf.addEventListener('click', () => {
  70. this.closePopup();
  71. });
  72. }
  73. openFullscreen() {
  74. let elem = this.popupElement;
  75. if (!this.isFullscreen) {
  76. if (elem.requestFullscreen) {
  77. elem.requestFullscreen();
  78. }
  79. else if (elem.webkitRequestFullscreen) {
  80. elem.webkitRequestFullscreen();
  81. }
  82. else if (elem.msRequestFullscreen) {
  83. elem.msRequestFullscreen();
  84. }
  85. this.isFullscreen = true;
  86. }
  87. else {
  88. if (document.exitFullscreen) {
  89. document.exitFullscreen();
  90. }
  91. else if (document.webkitExitFullscreen) {
  92. document.webkitExitFullscreen();
  93. }
  94. else if (document.msExitFullscreen) {
  95. document.msExitFullscreen();
  96. }
  97. this.isFullscreen = false;
  98. }
  99. }
  100. setHeigthOnFullscreenChange() {
  101. var footerHeight = this.element.parentElement.nextElementSibling.offsetHeight;
  102. this.element.parentElement.style.height = window.innerHeight - footerHeight + 'px';
  103. this.pdfViewer.height = '100%';
  104. }
  105. renderPdf() {
  106. this.pdfViewer = new ej.pdfviewer.PdfViewer({
  107. created: this.pdfCreated.bind(this),
  108. documentPath: this.filePath,
  109. serviceUrl: 'http://localhost:3088/pdfviewer'
  110. });
  111. ej.pdfviewer.PdfViewer.Inject(ej.pdfviewer.TextSelection, ej.pdfviewer.TextSearch, ej.pdfviewer.Print, ej.pdfviewer.Navigation);
  112. this.pdfViewer.appendTo('#DocumentViewer');
  113. }
  114. updateProps() {
  115. this.popupElement = document.getElementsByClassName('_bizgaze_popup_container')[0];
  116. this.element = document.getElementById('DocumentViewer');
  117. this.fullscreenBtn = document.getElementsByClassName('biz-pdf-fullscreen-btn')[0];
  118. this.exitPdf = document.getElementsByClassName('biz-pdf-exitpdf-btn')[0];
  119. }
  120. pdfCreated() {
  121. var util = Unibase.Apps.Collaboration.Components.Common.Util.Instance();
  122. document.getElementById("DocumentViewer_zoomDropDownContainer").after(util.createElement('div', 'class', 'biz-pdf-fullscreen'));
  123. util.appendChildren('biz-pdf-fullscreen', 0, util.createElement('button', 'class', 'e-icons biz-pdf-fullscreen-btn biz-enterfullscreen'));
  124. document.getElementById("DocumentViewer_downloadContainer").after(util.createElement('div', 'class', 'biz-pdf-exitpdf'));
  125. util.appendChildren('biz-pdf-exitpdf', 0, util.createElement('button', 'class', 'e-icons biz-pdf-exitpdf-btn'));
  126. }
  127. actionComplete() {
  128. }
  129. closePopup() {
  130. Unibase.Apps.Collaboration.Components.DocConnector.Instance().closeDoc();
  131. var contId = $("._bizgaze_popup_container:visible").attr("id");
  132. $('#' + contId).modal('hide');
  133. $('#' + contId).remove();
  134. }
  135. refreshHeight() {
  136. var footerHeight = this.element.parentElement.nextElementSibling.offsetHeight;
  137. var rootHeight = this.element.parentElement.parentElement.offsetHeight;
  138. this.element.parentElement.style.height = (rootHeight - footerHeight) + 'px';
  139. }
  140. renderPopup() {
  141. Unibase.Apps.Collaboration.Components.Documents.Instance().loadForm(0, this.documentFileId, 0, null, this.documentGroup);
  142. }
  143. renderMenuBar() {
  144. }
  145. static Instance() {
  146. if (this.instance === undefined) {
  147. this.instance = new Base();
  148. }
  149. return this.instance;
  150. }
  151. }
  152. PdfViewer.Base = Base;
  153. })(PdfViewer = Components.PdfViewer || (Components.PdfViewer = {}));
  154. })(Components = Collaboration.Components || (Collaboration.Components = {}));
  155. })(Collaboration = Apps.Collaboration || (Apps.Collaboration = {}));
  156. })(Apps = Unibase.Apps || (Unibase.Apps = {}));
  157. })(Unibase || (Unibase = {}));