@@ -32,7 +32,6 @@ function FileProgress(file, targetID) {
3232 var progressBarWrapper = $ ( "<div/>" ) ;
3333 progressBarWrapper . addClass ( "progress progress-striped" ) ;
3434
35-
3635 var progressBar = $ ( "<div/>" ) ;
3736 progressBar . addClass ( "progress-bar progress-bar-info" )
3837 . attr ( 'role' , 'progressbar' )
@@ -44,22 +43,18 @@ function FileProgress(file, targetID) {
4443 var progressBarPercent = $ ( '<span class=sr-only />' ) ;
4544 progressBarPercent . text ( fileSize ) ;
4645
47-
48- var progressCancel = $ ( '<a href=# />' ) ;
49- progressCancel . hide ( ) . addClass ( 'progressCancel' ) . text ( '' ) ;
50-
46+ var progressCancel = $ ( '<a href=javascript:; />' ) ;
47+ progressCancel . show ( ) . addClass ( 'progressCancel' ) . text ( '×' ) ;
5148
5249 progressBar . append ( progressBarPercent ) ;
5350 progressBarWrapper . append ( progressBar ) ;
5451 progressBarBox . append ( progressBarWrapper ) ;
5552 progressBarBox . append ( progressCancel ) ;
5653
57-
5854 var progressBarStatus = $ ( '<div class="status text-center"/>' ) ;
5955 progressBarBox . append ( progressBarStatus ) ;
6056 progressBarTd . append ( progressBarBox ) ;
6157
62-
6358 Wrappeer . append ( progressText ) ;
6459 Wrappeer . append ( progressSize ) ;
6560 Wrappeer . append ( progressBarTd ) ;
@@ -141,6 +136,7 @@ FileProgress.prototype.setProgress = function(percentage, speed, chunk_size) {
141136 if ( file . status !== plupload . DONE && percentage === 100 ) {
142137 percentage = 99 ;
143138 }
139+
144140 progressbar . attr ( 'aria-valuenow' , percentage ) . css ( 'width' , percentage + '%' ) ;
145141
146142 if ( chunk_size ) {
@@ -187,7 +183,8 @@ FileProgress.prototype.setProgress = function(percentage, speed, chunk_size) {
187183} ;
188184
189185FileProgress . prototype . setComplete = function ( up , info ) {
190- var td = this . fileProgressWrapper . find ( 'td:eq(2) .progress' ) ;
186+ var td = this . fileProgressWrapper . find ( 'td:eq(2)' ) ,
187+ tdProgress = td . find ( '.progress' ) ;
191188
192189 var res = $ . parseJSON ( info ) ;
193190 var url ;
@@ -203,7 +200,8 @@ FileProgress.prototype.setComplete = function(up, info) {
203200 "<div class=hash><strong>Hash:</strong>" + res . hash + "</div>" ;
204201 }
205202
206- td . html ( str ) . removeClass ( ) . next ( ) . next ( '.status' ) . hide ( ) ;
203+ tdProgress . html ( str ) . removeClass ( ) . next ( ) . next ( '.status' ) . hide ( ) ;
204+ td . find ( '.progressCancel' ) . hide ( ) ;
207205
208206 var progressNameTd = this . fileProgressWrapper . find ( '.progressName' ) ;
209207 var imageView = '?imageView2/1/w/100/h/100' ;
@@ -360,7 +358,9 @@ FileProgress.prototype.setCancelled = function(manual) {
360358 progressContainer += ' red' ;
361359 }
362360 this . fileProgressWrapper . attr ( 'class' , progressContainer ) ;
363- this . fileProgressWrapper . find ( 'td .progress .progress-bar-info' ) . css ( 'width' , 0 ) ;
361+ this . fileProgressWrapper . find ( 'td .progress' ) . remove ( ) ;
362+ this . fileProgressWrapper . find ( 'td:eq(2) .btn-default' ) . hide ( ) ;
363+ this . fileProgressWrapper . find ( 'td:eq(2) .progressCancel' ) . hide ( ) ;
364364} ;
365365
366366FileProgress . prototype . setStatus = function ( status , isUploading ) {
@@ -369,6 +369,21 @@ FileProgress.prototype.setStatus = function(status, isUploading) {
369369 }
370370} ;
371371
372+ // 绑定取消上传事件
373+ FileProgress . prototype . bindUploadCancel = function ( up ) {
374+ var self = this ;
375+ if ( up ) {
376+
377+ self . fileProgressWrapper . find ( 'td:eq(2) .progressCancel' ) . on ( 'click' , function ( ) {
378+ self . setCancelled ( false ) ;
379+ self . setStatus ( "取消上传" ) ;
380+ self . fileProgressWrapper . find ( '.status' ) . css ( 'left' , '0' ) ;
381+ up . removeFile ( self . file ) ;
382+ return true ;
383+ } ) ;
384+ }
385+
386+ } ;
372387
373388FileProgress . prototype . appear = function ( ) {
374389 if ( this . getTimer ( ) !== null ) {
0 commit comments