|
4 | 4 | ref="container" |
5 | 5 | class="container" |
6 | 6 | :class="{ 'container-mimic-fullscreen': mimicFullscreen }"> |
| 7 | + |
7 | 8 | <k-button |
8 | | - class="btn" |
9 | 9 | v-if="supportsPDFs" |
| 10 | + class="btn" |
10 | 11 | :text="isFullscreen ? $tr('exitFullscreen') : $tr('enterFullscreen')" |
11 | | - @click="toggleFullScreen" |
12 | | - :primary="true"/> |
| 12 | + :primary="true" |
| 13 | + @click="toggleFullscreen" |
| 14 | + /> |
| 15 | + |
| 16 | + <template v-else> |
| 17 | + <p role="alert"> |
| 18 | + {{ $tr('pdfCompatibilityError') }} |
| 19 | + </p> |
| 20 | + <a :href="pdfURL"> |
| 21 | + {{ $tr('pdfDownloadLink')}} |
| 22 | + </a> |
| 23 | + </template> |
| 24 | + |
13 | 25 | <div ref="pdfcontainer" class="pdfcontainer"></div> |
| 26 | + |
14 | 27 | </div> |
15 | 28 |
|
16 | 29 | </template> |
|
21 | 34 | import PDFobject from 'pdfobject'; |
22 | 35 | import ScreenFull from 'screenfull'; |
23 | 36 | import kButton from 'kolibri.coreVue.components.kButton'; |
| 37 | +
|
| 38 | + const pdfObjectOptions = { |
| 39 | + fallbackLink: false, |
| 40 | + }; |
| 41 | +
|
24 | 42 | export default { |
| 43 | + $trs: { |
| 44 | + pdfCompatibilityError: 'Unable to display the document', |
| 45 | + pdfDownloadLink: 'Download the PDF file', |
| 46 | + exitFullscreen: 'Exit fullscreen', |
| 47 | + enterFullscreen: 'Enter fullscreen', |
| 48 | + }, |
| 49 | + name: 'pdfRender', |
25 | 50 | components: { kButton }, |
26 | 51 | props: ['defaultFile'], |
27 | 52 | data: () => ({ |
|
33 | 58 | fullscreenAllowed() { |
34 | 59 | return ScreenFull.enabled; |
35 | 60 | }, |
| 61 | + pdfURL() { |
| 62 | + return this.defaultFile.storage_url; |
| 63 | + }, |
36 | 64 | mimicFullscreen() { |
37 | 65 | return !this.fullscreenAllowed && this.isFullscreen; |
38 | 66 | }, |
|
53 | 81 | }, |
54 | 82 | }, |
55 | 83 | mounted() { |
56 | | - PDFobject.embed(this.defaultFile.storage_url, this.$refs.pdfcontainer); |
| 84 | + PDFobject.embed(this.pdfURL, this.$refs.pdfcontainer, pdfObjectOptions); |
57 | 85 | this.$emit('startTracking'); |
58 | 86 | const self = this; |
59 | 87 | this.timeout = setTimeout(() => { |
|
66 | 94 | } |
67 | 95 | this.$emit('stopTracking'); |
68 | 96 | }, |
69 | | - name: 'pdfRenderer', |
70 | | - $trs: { |
71 | | - exitFullscreen: 'Exit fullscreen', |
72 | | - enterFullscreen: 'Enter fullscreen', |
73 | | - }, |
74 | 97 | }; |
75 | 98 |
|
76 | 99 | </script> |
|
0 commit comments