| 4 |
lars |
1 |
/*
|
|
|
2 |
* jQuery File Upload Plugin JS Example 5.0.2
|
|
|
3 |
* https://github.com/blueimp/jQuery-File-Upload
|
|
|
4 |
*
|
|
|
5 |
* Copyright 2010, Sebastian Tschan
|
|
|
6 |
* https://blueimp.net
|
|
|
7 |
*
|
|
|
8 |
* Licensed under the MIT license:
|
|
|
9 |
* http://creativecommons.org/licenses/MIT/
|
|
|
10 |
*/
|
|
|
11 |
|
|
|
12 |
/*jslint nomen: true */
|
|
|
13 |
/*global $ */
|
|
|
14 |
|
|
|
15 |
$(function () {
|
|
|
16 |
'use strict';
|
|
|
17 |
|
|
|
18 |
// Initialize the jQuery File Upload widget:
|
|
|
19 |
$('#fileupload').fileupload();
|
|
|
20 |
|
|
|
21 |
// Load existing files:
|
|
|
22 |
$.getJSON($('#fileupload form').prop('action'), $('#fileupload form').serializeArray(), function (files) {
|
|
|
23 |
var fu = $('#fileupload').data('fileupload');
|
|
|
24 |
fu._adjustMaxNumberOfFiles(-files.length);
|
|
|
25 |
fu._renderDownload(files)
|
|
|
26 |
.appendTo($('#fileupload .files'))
|
|
|
27 |
.fadeIn(function () {
|
|
|
28 |
// Fix for IE7 and lower:
|
|
|
29 |
$(this).show();
|
|
|
30 |
});
|
|
|
31 |
});
|
|
|
32 |
|
|
|
33 |
// Open download dialogs via iframes,
|
|
|
34 |
// to prevent aborting current uploads:
|
|
|
35 |
$('#fileupload .files a:not([target^=_blank])').on('click', function (e) {
|
|
|
36 |
e.preventDefault();
|
|
|
37 |
$('<iframe style="display:none;"></iframe>')
|
|
|
38 |
.prop('src', this.href)
|
|
|
39 |
.appendTo('body');
|
|
|
40 |
});
|
|
|
41 |
|
|
|
42 |
});
|