summaryrefslogblamecommitdiffstats
path: root/script/fileselect.js
blob: 13711fd5efaf035398a9ec0a96192a7a3903e654 (plain) (tree)
1
2
3
4
5
6
7
8
9








                                                                                

                                                                              

                                       
                 





                                                            
$(document).on('change', '.btn-file :file', function() {
	var input = $(this);
	var numFiles = input.get(0).files ? input.get(0).files.length : 1;
	var label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
	input.trigger('fileselect', [numFiles, label]);
});

$(document).ready(function() {
	$('.btn-file :file').on('fileselect', function(event, numFiles, label) {
		var input = $(this).parents('.upload-ex').find(':text');
		var log = numFiles > 1 ? numFiles + ' files selected' : label;
		if (input.length) {
			input.val(log);
		}
	});
});

$('.upload-ex :text').click(function () {
	$(this).parents('.upload-ex').find(':file').click();
});