Mercurial > hg > orthanc
comparison OrthancExplorer/file-upload.js @ 57:4bc019d2f969 orthanc-renaming
renaming
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sun, 16 Sep 2012 09:22:48 +0200 |
parents | PalanthirExplorer/file-upload.js@33d67e1ab173 |
children | 79d259b86aa9 |
comparison
equal
deleted
inserted
replaced
56:088c4f23e2c8 | 57:4bc019d2f969 |
---|---|
1 var pendingUploads = []; | |
2 var currentUpload = 0; | |
3 var totalUpload = 0; | |
4 | |
5 $(document).ready(function() { | |
6 // Initialize the jQuery File Upload widget: | |
7 $('#fileupload').fileupload({ | |
8 //dataType: 'json', | |
9 //maxChunkSize: 500, | |
10 //sequentialUploads: true, | |
11 limitConcurrentUploads: 3, | |
12 add: function (e, data) { | |
13 pendingUploads.push(data); | |
14 } | |
15 }) | |
16 .bind('fileuploadstop', function(e, data) { | |
17 $('#upload-button').removeClass('ui-disabled'); | |
18 //$('#upload-abort').addClass('ui-disabled'); | |
19 $('#progress .bar').css('width', '100%'); | |
20 if ($('#progress .label').text() != 'Failure') | |
21 $('#progress .label').text('Done'); | |
22 }) | |
23 .bind('fileuploadfail', function(e, data) { | |
24 $('#progress .bar') | |
25 .css('width', '100%') | |
26 .css('background-color', 'red'); | |
27 $('#progress .label').text('Failure'); | |
28 }) | |
29 .bind('fileuploaddrop', function (e, data) { | |
30 var target = $('#upload-list'); | |
31 $.each(data.files, function (index, file) { | |
32 target.append('<li class="pending-file">' + file.name + '</li>'); | |
33 }); | |
34 target.listview('refresh'); | |
35 }) | |
36 .bind('fileuploadsend', function (e, data) { | |
37 // Update the progress bar. Note: for some weird reason, the | |
38 // "fileuploadprogressall" does not work under Firefox. | |
39 var progress = parseInt(currentUpload / totalUploads * 100, 10); | |
40 currentUpload += 1; | |
41 $('#progress .label').text('Uploading: ' + progress + '%'); | |
42 $('#progress .bar') | |
43 .css('width', progress + '%') | |
44 .css('background-color', 'green'); | |
45 }); | |
46 }); | |
47 | |
48 | |
49 | |
50 $('#upload').live('pageshow', function() { | |
51 $('#fileupload').fileupload('enable'); | |
52 }); | |
53 | |
54 $('#upload').live('pagehide', function() { | |
55 $('#fileupload').fileupload('disable'); | |
56 }); | |
57 | |
58 | |
59 $('#upload-button').live('click', function() { | |
60 var pu = pendingUploads; | |
61 pendingUploads = []; | |
62 | |
63 $('.pending-file').remove(); | |
64 $('#upload-list').listview('refresh'); | |
65 $('#progress .bar').css('width', '0%'); | |
66 $('#progress .label').text(''); | |
67 | |
68 currentUpload = 1; | |
69 totalUploads = pu.length + 1; | |
70 if (pu.length > 0) { | |
71 $('#upload-button').addClass('ui-disabled'); | |
72 //$('#upload-abort').removeClass('ui-disabled'); | |
73 } | |
74 | |
75 for (var i = 0; i < pu.length; i++) { | |
76 pu[i].submit(); | |
77 } | |
78 }); | |
79 | |
80 $('#upload-clear').live('click', function() { | |
81 pendingUploads = []; | |
82 $('.pending-file').remove(); | |
83 $('#upload-list').listview('refresh'); | |
84 }); | |
85 | |
86 /*$('#upload-abort').live('click', function() { | |
87 $('#fileupload').fileupload().abort(); | |
88 });*/ |