root / src / gr / grnet / pithos / web / public / application.js @ 2f807846
History | View | Annotate | Download (2.4 kB)
1 |
/*
|
---|---|
2 |
* jQuery File Upload Plugin JS Example 6.0.3
|
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://www.opensource.org/licenses/MIT
|
10 |
*/
|
11 |
|
12 |
/*jslint nomen: true, unparam: true, regexp: true */
|
13 |
/*global $, window, document */
|
14 |
|
15 |
$(function () { |
16 |
'use strict';
|
17 |
|
18 |
// Initialize the jQuery File Upload widget:
|
19 |
$('#fileupload').fileupload(); |
20 |
|
21 |
if (window.location.hostname === 'blueimp.github.com') { |
22 |
// Demo settings:
|
23 |
$('#fileupload').prop( |
24 |
'action',
|
25 |
'//jquery-file-upload.appspot.com'
|
26 |
); |
27 |
$('#fileupload').fileupload('option', { |
28 |
maxFileSize: 5000000, |
29 |
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i |
30 |
}); |
31 |
} else {
|
32 |
// Load existing files:
|
33 |
$.getJSON($('#fileupload').prop('action'), function (files) { |
34 |
var fu = $('#fileupload').data('fileupload'), |
35 |
template; |
36 |
fu._adjustMaxNumberOfFiles(-files.length); |
37 |
template = fu._renderDownload(files) |
38 |
.appendTo($('#fileupload .files')); |
39 |
// Force reflow:
|
40 |
fu._reflow = fu._transition && template.length && |
41 |
template[0].offsetWidth;
|
42 |
template.addClass('in');
|
43 |
}); |
44 |
} |
45 |
|
46 |
// Enable iframe cross-domain access via redirect page:
|
47 |
var redirectPage = window.location.href.replace(
|
48 |
/\/[^\/]*$/,
|
49 |
'/cors/result.html?%s'
|
50 |
); |
51 |
$('#fileupload').bind('fileuploadsend', function (e, data) { |
52 |
if (data.dataType.substr(0, 6) === 'iframe') { |
53 |
var target = $('<a/>').prop('href', data.url)[0]; |
54 |
if (window.location.host !== target.host) {
|
55 |
data.formData.push({ |
56 |
name: 'redirect', |
57 |
value: redirectPage
|
58 |
}); |
59 |
} |
60 |
} |
61 |
}); |
62 |
|
63 |
// Open download dialogs via iframes,
|
64 |
// to prevent aborting current uploads:
|
65 |
$('#fileupload .files').delegate( |
66 |
'a:not([rel^=gallery])',
|
67 |
'click',
|
68 |
function (e) {
|
69 |
e.preventDefault(); |
70 |
$('<iframe style="display:none;"></iframe>') |
71 |
.prop('src', this.href) |
72 |
.appendTo(document.body); |
73 |
} |
74 |
); |
75 |
|
76 |
// Initialize the Bootstrap Image Gallery plugin:
|
77 |
$('#fileupload .files').imagegallery(); |
78 |
|
79 |
}); |