Skip to content

Commit 7e2379b

Browse files
committed
Merge pull request #81 from meilixie/js-sdk-upload-cancel
Js sdk upload cancel
2 parents 22b7730 + 58149c4 commit 7e2379b

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

demo/js/main.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,11 @@ $(function() {
4444
if (up.runtime === 'html5' && chunk_size) {
4545
progress.setChunkProgess(chunk_size);
4646
}
47-
progress.bindUploadCancel(up);
4847
},
4948
'UploadProgress': function(up, file) {
5049
var progress = new FileProgress(file, 'fsUploadProgress');
5150
var chunk_size = plupload.parseSize(this.getOption('chunk_size'));
5251
progress.setProgress(file.percent + "%", file.speed, chunk_size);
53-
progress.bindUploadCancel(up);
54-
5552
},
5653
'UploadComplete': function() {
5754
$('#success').show();

demo/js/ui.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,13 @@ FileProgress.prototype.setChunkProgess = function(chunk_size) {
115115
col.append(progressBarWrapper);
116116
progressBarChunk.append(col);
117117
}
118-
this.fileProgressWrapper.find('td>div').append(viewProgess);
119118

119+
if(!this.fileProgressWrapper.find('td:eq(2) .btn-default').length){
120+
this.fileProgressWrapper.find('td>div').append(viewProgess);
121+
}
120122
progressBarChunkTr.hide().find('td').append(progressBarChunk);
121-
122123
progressBarChunkTr.insertAfter(this.fileProgressWrapper);
124+
123125
};
124126

125127
FileProgress.prototype.setProgress = function(percentage, speed, chunk_size) {
@@ -131,6 +133,9 @@ FileProgress.prototype.setProgress = function(percentage, speed, chunk_size) {
131133
var size = plupload.formatSize(uploaded).toUpperCase();
132134
var formatSpeed = plupload.formatSize(speed).toUpperCase();
133135
var progressbar = this.fileProgressWrapper.find('td .progress').find('.progress-bar-info');
136+
if (this.fileProgressWrapper.find('.status').text() === '取消上传'){
137+
return;
138+
}
134139
this.fileProgressWrapper.find('.status').text("已上传: " + size + " 上传速度: " + formatSpeed + "/s");
135140
percentage = parseInt(percentage, 10);
136141
if (file.status !== plupload.DONE && percentage === 100) {
@@ -373,13 +378,11 @@ FileProgress.prototype.setStatus = function(status, isUploading) {
373378
FileProgress.prototype.bindUploadCancel = function(up) {
374379
var self = this;
375380
if (up) {
376-
377381
self.fileProgressWrapper.find('td:eq(2) .progressCancel').on('click', function(){
378382
self.setCancelled(false);
379383
self.setStatus("取消上传");
380384
self.fileProgressWrapper.find('.status').css('left', '0');
381385
up.removeFile(self.file);
382-
return true;
383386
});
384387
}
385388

0 commit comments

Comments
 (0)