1 |
2
|
Manuela
|
/*
|
2 |
|
|
By Osvaldas Valutis, www.osvaldas.info
|
3 |
|
|
Available for use under the MIT License
|
4 |
|
|
*/
|
5 |
|
|
'use strict';
|
6 |
|
|
;( function ( document, window, index )
|
7 |
|
|
{
|
8 |
|
|
var inputs = document.querySelectorAll( '.inputfile' );
|
9 |
|
|
Array.prototype.forEach.call( inputs, function( input )
|
10 |
|
|
{
|
11 |
|
|
var label = input.nextElementSibling,
|
12 |
|
|
labelVal = label.innerHTML;
|
13 |
|
|
input.addEventListener( 'change', function( e )
|
14 |
|
|
{
|
15 |
|
|
var fileName = '';
|
16 |
|
|
if( this.files && this.files.length > 1 )
|
17 |
|
|
fileName = ( this.getAttribute( 'data-multiple-caption' ) || '' ).replace( '{count}', this.files.length );
|
18 |
|
|
else
|
19 |
|
|
fileName = e.target.value.split( '\\' ).pop();
|
20 |
|
|
if( fileName )
|
21 |
|
|
label.querySelector( 'span' ).innerHTML = fileName;
|
22 |
|
|
else
|
23 |
|
|
label.innerHTML = labelVal;
|
24 |
|
|
});
|
25 |
|
|
// Firefox bug fix
|
26 |
|
|
input.addEventListener( 'focus', function(){ input.classList.add( 'has-focus' ); });
|
27 |
|
|
input.addEventListener( 'blur', function(){ input.classList.remove( 'has-focus' ); });
|
28 |
|
|
});
|
29 |
|
|
}( document, window, 0 ));
|
30 |
|
|
|
31 |
|
|
/*
|
32 |
|
|
onchange=
|
33 |
|
|
document.upload.target.value.substr(6,100);
|
34 |
|
|
document.create.target.value = document.upload.target.value;
|
35 |
|
|
*/
|