|
|
|
@ -52,20 +52,17 @@ RocketChat.messageBox.actions.add('Add_files_from', 'Computer', { |
|
|
|
|
condition: () => RocketChat.settings.get('FileUpload_Enabled'), |
|
|
|
|
action({event}) { |
|
|
|
|
event.preventDefault(); |
|
|
|
|
const input = document.createElement('input'); |
|
|
|
|
input.style.display = 'none'; |
|
|
|
|
input.type = 'file'; |
|
|
|
|
input.setAttribute('multiple', 'multiple'); |
|
|
|
|
document.body.appendChild(input); |
|
|
|
|
|
|
|
|
|
input.click(); |
|
|
|
|
const $input = $(document.createElement('input')); |
|
|
|
|
$input.css('display', 'none'); |
|
|
|
|
$input.attr({ |
|
|
|
|
id: 'fileupload-input', |
|
|
|
|
type: 'file', |
|
|
|
|
multiple: 'multiple' |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Simple hack for cordova aka codegueira
|
|
|
|
|
if (typeof device !== 'undefined' && device.platform && device.platform.toLocaleLowerCase() === 'ios') { |
|
|
|
|
input.click(); |
|
|
|
|
} |
|
|
|
|
$(document.body).append($input); |
|
|
|
|
|
|
|
|
|
input.addEventListener('change', function(e) { |
|
|
|
|
$input.one('change', function(e) { |
|
|
|
|
const filesToUpload = [...e.target.files].map(file => { |
|
|
|
|
Object.defineProperty(file, 'type', { |
|
|
|
|
value: mime.lookup(file.name) |
|
|
|
@ -76,9 +73,15 @@ RocketChat.messageBox.actions.add('Add_files_from', 'Computer', { |
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
|
fileUpload(filesToUpload); |
|
|
|
|
}, {once: true}); |
|
|
|
|
$input.remove(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$input.click(); |
|
|
|
|
|
|
|
|
|
input.remove(); |
|
|
|
|
// Simple hack for cordova aka codegueira
|
|
|
|
|
if ((typeof device !== 'undefined' && device.platform && device.platform.toLocaleLowerCase() === 'ios') || navigator.userAgent.match(/(iPad|iPhone|iPod)/g)) { |
|
|
|
|
$input.click(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|