From 092f3ff9c6b42b5549fd0310903839cc29cbba89 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Mon, 25 Feb 2008 21:56:33 +0000 Subject: [PATCH] Removed Wiki.js.Upload_pulldown.shutdown() "force" flag as it's redundant if this.uploading is set accordingly. Make IE 6 and 7 actually stop uploading a file when the cancel button is clicked. Ignoring blank filename renames. --- static/js/Wiki.js | 25 +++++++++++++++++-------- view/Progress_bar.py | 2 +- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/static/js/Wiki.js b/static/js/Wiki.js index 025e116..c45fb0a 100644 --- a/static/js/Wiki.js +++ b/static/js/Wiki.js @@ -2344,7 +2344,7 @@ Upload_pulldown.prototype.upload_complete = function () { this.link.href = "/files/download?file_id=" + this.file_id new File_link_pulldown( this.wiki, this.notebook_id, this.invoker, this.editor, this.link ); - this.shutdown( true ); + this.shutdown(); } Upload_pulldown.prototype.update_position = function ( anchor, relative_to ) { @@ -2352,28 +2352,37 @@ Upload_pulldown.prototype.update_position = function ( anchor, relative_to ) { } Upload_pulldown.prototype.cancel_due_to_click = function () { + this.uploading = false; this.wiki.display_message( "The file upload has been cancelled." ) - this.shutdown( true ); + this.shutdown(); } Upload_pulldown.prototype.cancel_due_to_quota = function () { + this.uploading = false; + this.shutdown(); + this.wiki.display_error( "That file is too large for your available storage space. Before uploading, please delete some notes or files, empty the trash, or", [ createDOM( "a", { "href": "/upgrade" }, "upgrade" ), " your account." ] ); - - this.shutdown( true ); } Upload_pulldown.prototype.cancel_due_to_error = function ( message ) { + this.uploading = false; this.wiki.display_error( message ) - this.shutdown( true ); + this.shutdown(); } -Upload_pulldown.prototype.shutdown = function ( force ) { - if ( this.uploading && !force ) +Upload_pulldown.prototype.shutdown = function () { + if ( this.uploading ) return; + // in Internet Explorer, the upload won't actually cancel without an explicit Stop command + if ( !this.iframe.contentDocument && this.iframe.contentWindow ) { + this.iframe.contentWindow.document.execCommand( 'Stop' ); + this.progress_iframe.contentWindow.document.execCommand( 'Stop' ); + } + Pulldown.prototype.shutdown.call( this ); if ( this.link ) this.link.pulldown = null; @@ -2450,7 +2459,7 @@ File_link_pulldown.prototype.filename_field_focused = function ( event ) { File_link_pulldown.prototype.filename_field_changed = function ( event ) { // if the filename is actually unchanged, then bail var filename = strip( this.filename_field.value ); - if ( filename == this.previous_filename ) + if ( filename == "" || filename == this.previous_filename ) return; var title = link_title( this.link ); diff --git a/view/Progress_bar.py b/view/Progress_bar.py index 89a42d6..037954b 100644 --- a/view/Progress_bar.py +++ b/view/Progress_bar.py @@ -35,7 +35,7 @@ def stream_progress( uploading_file, filename, fraction_reported ): %s - + 0%%