debian-mirror-gitlab/app/assets/javascripts/file_pickers.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
729 B
JavaScript
Raw Normal View History

2020-06-23 00:09:42 +05:30
export default function initFilePickers() {
const filePickers = document.querySelectorAll('.js-filepicker');
2021-03-08 18:12:59 +05:30
filePickers.forEach((filePicker) => {
2020-06-23 00:09:42 +05:30
const button = filePicker.querySelector('.js-filepicker-button');
button.addEventListener('click', () => {
const form = button.closest('form');
form.querySelector('.js-filepicker-input').click();
});
const input = filePicker.querySelector('.js-filepicker-input');
input.addEventListener('change', () => {
const form = input.closest('form');
const filename = input.value.replace(/^.*[\\\/]/, ''); // eslint-disable-line no-useless-escape
form.querySelector('.js-filepicker-filename').textContent = filename;
});
});
}