5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 02:26:23 +00:00
panel/app/assets/javascripts/image_preview.js
2020-11-19 21:23:23 -03:00

11 lines
368 B
JavaScript

document.addEventListener('turbolinks:load', () => {
document.querySelectorAll('input[type=file]').forEach(file => {
if (!file.dataset.preview) return
file.addEventListener('change', event => {
if (file.files.length === 0) return
document.querySelector('#' + file.dataset.preview).src = window.URL.createObjectURL(file.files[0])
})
})
})