1
|
$(function() {
|
2
|
// file upload
|
3
|
altair_form_file_upload.init();
|
4
|
});
|
5
|
|
6
|
|
7
|
altair_form_file_upload = {
|
8
|
init: function() {
|
9
|
|
10
|
var progressbar = $("#file_upload-progressbar"),
|
11
|
bar = progressbar.find('.uk-progress-bar'),
|
12
|
settings = {
|
13
|
action: '/', // Target url for the upload
|
14
|
allow : '*.(jpg|jpeg|gif|png)', // File filter
|
15
|
loadstart: function() {
|
16
|
bar.css("width", "0%").text("0%");
|
17
|
progressbar.removeClass("uk-hidden");
|
18
|
},
|
19
|
progress: function(percent) {
|
20
|
percent = Math.ceil(percent);
|
21
|
bar.css("width", percent+"%").text(percent+"%");
|
22
|
},
|
23
|
allcomplete: function(response,xhr) {
|
24
|
bar.css("width", "100%").text("100%");
|
25
|
setTimeout(function(){
|
26
|
progressbar.addClass("uk-hidden");
|
27
|
}, 250);
|
28
|
setTimeout(function() {
|
29
|
UIkit.notify({
|
30
|
message: "Upload Completed",
|
31
|
pos: 'top-right'
|
32
|
});
|
33
|
},280);
|
34
|
}
|
35
|
};
|
36
|
|
37
|
var select = UIkit.uploadSelect($("#file_upload-select"), settings),
|
38
|
drop = UIkit.uploadDrop($("#file_upload-drop"), settings);
|
39
|
}
|
40
|
};
|