var $file = $('.form__input-file');
$file.on('change', function(event){
var $this = $(this),
$label = $this.next('label'),
$labelText = $label.find('span'),
labelDefault = $labelText.text();
var fileName = $this.val().split( '\\' ).pop();
if( fileName ){
$labelText.text(fileName);
}else{
$labelText.text(labelDefault);
}
});
document.addEventListener('click', function(e) {
const el = document.getElementById(e.target.dataset.id);
if (el) {
el.checked = !el.checked;
}
});
const buttons = document.querySelectorAll('[data-id]');
const onClick = e => checkboxes[e.target.dataset.id].checked ^= 1;
const checkboxes = Array
.from(buttons, n => n.dataset.id)
.reduce((acc, n) => (acc[n] = document.querySelector(`#${n}`), acc), {});
buttons.forEach(n => n.addEventListener('click', onClick));