eleven-8.x-1.0-beta5/eleven/templates/component/form/input-file/form-input-file.js
eleven/templates/component/form/input-file/form-input-file.js
(function () { var inputs = document.querySelectorAll( '.js-form-file' ); Array.prototype.forEach.call( inputs, function( input ) { var label = input.nextElementSibling, labelVal = label.innerHTML; input.addEventListener( 'change', function( e ) { var fileName = ''; if( this.files && this.files.length > 1 ) fileName = ( this.getAttribute( 'data-multiple-caption' ) || '' ).replace( '{count}', this.files.length ); else fileName = e.target.value.split( '\\' ).pop(); if( fileName ) // console.log('name ' + fileName) label.querySelector( 'span' ).innerHTML = fileName; else label.innerHTML = labelVal; }); }); })();