-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
60 lines (50 loc) · 1.86 KB
/
index.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* jQuery File Upload Plugin JS
* Copyright 2010, Sebastian Tschan
* Copyright 2017, Ambient Innovation GmbH
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*jslint nomen: true, regexp: true */
/*global $, window, blueimp */
$(function () {
'use strict';
// TODO: The usage of IDS in many places will let us only use one file uploader per screen
var fileuploadElement = $('#ai-fileupload');
// Initialize the jQuery File Upload widget:
// Uncomment the following to send cross-domain cookies:
fileuploadElement.fileupload({
// xhrFields: {withCredentials: true},
// url: 'server/php/'
});
// Enable iframe cross-domain access via redirect option:
fileuploadElement.fileupload(
'option',
'redirect',
window.location.href.replace(
/\/[^\/]*$/,
'/cors/result.html?%s'
)
);
// Load existing files:
fileuploadElement.addClass('fileupload-processing');
var content_type_id = $('#content_type_id').val();
var object_id = $('#object_id').val();
var exclude = $('#exclude_id').val();
exclude = exclude === "" ? "[]" : exclude;
if (content_type_id && object_id) {
$.ajax({
// Uncomment the following to send cross-domain cookies:
// xhrFields: {withCredentials: true},
// url: fileuploadElement.fileupload('option', 'url'),
url: '/upload/view/?content_type_id=' + content_type_id + '&object_id=' + object_id + '&exclude=' + exclude,
dataType: 'json',
context: fileuploadElement[0]
}).always(function () {
$(this).removeClass('fileupload-processing');
}).done(function (result) {
$(this).fileupload('option', 'done')
.call(this, $.Event('done'), {result: result});
});
}
});