source: main/waeup.kofa/trunk/layout/static/js/file-upload.js @ 16045

Last change on this file since 16045 was 11558, checked in by Henrik Bettermann, 10 years ago

File input fields brought into shape with Bootstrap 3. Technique adapted from http://labs.abeautifulsite.net/demos/bootstrap-file-inputs/.

File size: 586 bytes
RevLine 
[11558]1$(document)
2        .on('change', '.btn-file :file', function() {
3                var input = $(this),
4                numFiles = input.get(0).files ? input.get(0).files.length : 1,
5                label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
6                input.trigger('fileselect', [numFiles, label]);
7});
8
9$(document).ready( function() {
10        $('.btn-file :file').on('fileselect', function(event, numFiles, label) {
11
12                var input = $(this).parents('.input-group').find(':text'),
13                        log = numFiles > 1 ? numFiles + ' files selected' : label;
14
15                if( input.length ) {
16                        input.val(log);
17                } else {
18                        if( log ) alert(log);
19                }
20        });
21});
Note: See TracBrowser for help on using the repository browser.