|
4 | 4 | /** |
5 | 5 | * Add inline attachment at position as image |
6 | 6 | * AddOn for editor.js |
| 7 | + * |
| 8 | + * @param string fileUrl Image file URL |
7 | 9 | */ |
8 | 10 | function imcgerAttachImage(fileUrl) { |
9 | 11 | insert_text('[img]' + fileUrl + '[/img]'); |
|
14 | 16 | * Remove attachment in preview when insert as img BBcode in message |
15 | 17 | * AddOn for editor.js |
16 | 18 | * |
17 | | - * @var array notDisplayedAttachments Attachments that insert in the message |
18 | | - * @var array notDisplayAttachmentBox Don't show any attachment |
| 19 | + * @var array notDisplayedAttachments Attachments that insert in the message |
| 20 | + * @var bool notDisplayAttachmentBox Don't show any attachment |
19 | 21 | */ |
20 | 22 | function imcgerShowAttachImage() { |
| 23 | + const notDisplayedAttachments = {{ IUL_NOT_DISPLAYED_ATTACHMENTS }}, |
| 24 | + notDisplayAttachmentBox = {{ IUL_NOT_DISPLAY_ATTACHMENTBOX }}; |
| 25 | + |
21 | 26 | // Return when no attachments present |
22 | 27 | if (typeof notDisplayAttachmentBox == 'undefined' || notDisplayAttachmentBox && !notDisplayedAttachments.length) { |
23 | 28 | return; |
24 | 29 | } |
25 | 30 |
|
26 | 31 | if (notDisplayAttachmentBox) { |
| 32 | + // Hide attachment box |
27 | 33 | document.getElementsByClassName('attachbox')[0].style.display = 'none'; |
28 | 34 | } else { |
29 | 35 | let attachments = document.querySelectorAll(".attachbox .thumbnail"); |
30 | | - |
| 36 | + // Hide attachments that present in array |
31 | 37 | attachments.forEach((attachment) => { |
32 | 38 | let link = attachment.getElementsByTagName('a')[0].getAttribute("href"); |
| 39 | + |
33 | 40 | if (notDisplayedAttachments.includes(link.match('id=([0-9]+)')[1])) { |
34 | 41 | attachment.parentElement.style.display = 'none'; |
35 | 42 | } |
36 | 43 | }); |
37 | 44 | } |
38 | 45 | } |
39 | | -// When load the document, update AttatmentBox in preview |
| 46 | +// When load the document, update AttachmentBox in preview |
40 | 47 | document.addEventListener ("DOMContentLoaded", () => {imcgerShowAttachImage();}); |
41 | 48 |
|
42 | 49 | (function($) { // Avoid conflicts with other libraries |
|
93 | 100 | */ |
94 | 101 | phpbb.plupload.imcgerUpdateRow = function() { |
95 | 102 | $('.file-name.ellipsis-text a').each(function() { |
96 | | - const allowedExt = [{{ IUL_ALLOWED_IMAGES }}]; |
| 103 | + const allowedExt = {{ IUL_ALLOWED_IMAGES }}; |
97 | 104 | let link = $(this), |
98 | 105 | imgUrl = $(this).attr('href'), |
99 | 106 | real_filename = $(this).html(), |
|
136 | 143 | /** |
137 | 144 | * Update the relevant elements and hidden data for an attachment. |
138 | 145 | * |
139 | | - * @param {int} index The index from phpbb.plupload.ids of the attachment to edit. |
140 | | - * @param {array} downloadUrl Optional array of download urls to update. |
| 146 | + * @param int index The index from phpbb.plupload.ids of the attachment to edit. |
| 147 | + * @param array downloadUrl Optional array of download urls to update. |
141 | 148 | */ |
142 | 149 | phpbb.plupload.updateRow = function(index, downloadUrl) { |
143 | | - const allowedExt = [{{ IUL_ALLOWED_IMAGES }}]; |
| 150 | + const allowedExt = {{ IUL_ALLOWED_IMAGES }}; |
144 | 151 | let attach = phpbb.plupload.data[index], |
145 | 152 | row = $('[data-attach-id="' + attach.attach_id + '"]'), |
146 | 153 | filenameArray = attach.real_filename.split('.'), |
|
0 commit comments