mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-16 10:46:14 +01:00
feat: allow file uploads on mobile chat
closes https://github.com/NodeBB/NodeBB/issues/11217
This commit is contained in:
@@ -74,6 +74,7 @@ define('forum/chats', [
|
|||||||
dragDropAreaEl: $('.chats-full'),
|
dragDropAreaEl: $('.chats-full'),
|
||||||
pasteEl: $('[component="chat/input"]'),
|
pasteEl: $('[component="chat/input"]'),
|
||||||
uploadFormEl: $('[component="chat/upload"]'),
|
uploadFormEl: $('[component="chat/upload"]'),
|
||||||
|
uploadBtnEl: $('[component="chat/upload/button"]'),
|
||||||
inputEl: $('[component="chat/input"]'),
|
inputEl: $('[component="chat/input"]'),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -87,6 +88,7 @@ define('forum/chats', [
|
|||||||
dragDropAreaEl: options.dragDropAreaEl,
|
dragDropAreaEl: options.dragDropAreaEl,
|
||||||
pasteEl: options.pasteEl,
|
pasteEl: options.pasteEl,
|
||||||
uploadFormEl: options.uploadFormEl,
|
uploadFormEl: options.uploadFormEl,
|
||||||
|
uploadBtnEl: options.uploadBtnEl,
|
||||||
route: '/api/post/upload', // using same route as post uploads
|
route: '/api/post/upload', // using same route as post uploads
|
||||||
callback: function (uploads) {
|
callback: function (uploads) {
|
||||||
const inputEl = options.inputEl;
|
const inputEl = options.inputEl;
|
||||||
|
|||||||
@@ -304,6 +304,7 @@ define('chat', [
|
|||||||
dragDropAreaEl: chatModal.find('.modal-content'),
|
dragDropAreaEl: chatModal.find('.modal-content'),
|
||||||
pasteEl: chatModal,
|
pasteEl: chatModal,
|
||||||
uploadFormEl: chatModal.find('[component="chat/upload"]'),
|
uploadFormEl: chatModal.find('[component="chat/upload"]'),
|
||||||
|
uploadBtnEl: $('[component="chat/upload/button"]'),
|
||||||
inputEl: chatModal.find('[component="chat/input"]'),
|
inputEl: chatModal.find('[component="chat/input"]'),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,27 @@ define('uploadHelpers', ['alerts'], function (alerts) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.uploadBtnEl) {
|
||||||
|
const fileInput = formEl.find('input[name="files[]"]');
|
||||||
|
options.uploadBtnEl.on('click', function () {
|
||||||
|
fileInput.trigger('click');
|
||||||
|
});
|
||||||
|
fileInput.on('change', function (e) {
|
||||||
|
const files = (e.target || {}).files ||
|
||||||
|
($(this).val() ? [{ name: $(this).val(), type: utils.fileMimeType($(this).val()) }] : null);
|
||||||
|
if (files) {
|
||||||
|
uploadHelpers.ajaxSubmit({
|
||||||
|
uploadForm: formEl,
|
||||||
|
upload: {
|
||||||
|
files: files,
|
||||||
|
fileNames: Array.from(files).map(f => f.name),
|
||||||
|
},
|
||||||
|
callback: options.callback,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
uploadHelpers.handleDragDrop = function (options) {
|
uploadHelpers.handleDragDrop = function (options) {
|
||||||
|
|||||||
Reference in New Issue
Block a user