-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.custom-file-input.js
40 lines (37 loc) · 1.18 KB
/
jquery.custom-file-input.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
By Osvaldas Valutis, www.osvaldas.info
Available for use under the MIT License
*/
//
//'use strict';
//
//;( function( $, window, document, undefined )
////{
// $( '.inputfile' ).each( function()
// {
//// var $input = $( this ),
//// $label = $input.next( 'label' ),
//// labelVal = $label.html();
// $input=$("input");
$("input").on( 'change', function( e )
{
console.log("inside change input");
var $input =$(this ),
$label = $input.next( 'label' ),
labelVal = $label.html();
var fileName="Upload File";
if( this.files && this.files.length > 1 )
fileName = ( this.getAttribute( 'data-multiple-caption' ) || '' ).replace( '{count}', this.files.length );
else if( e.target.value )
fileName = e.target.value.split( '\\' ).pop();
if( fileName )
$label.html( fileName );
else
$label.html( labelVal );
});
// // Firefox bug fix
// $("input")
// .on( 'focus', function(){ $input.addClass( 'has-focus' ); })
// .on( 'blur', function(){ $input.removeClass( 'has-focus' ); });
// });
//})( jQuery, window, document );