From 0d2b7a3b749c3e165aba24c682a60c5e13193ed8 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Mon, 3 Jun 2013 16:42:30 +0200 Subject: [PATCH] Fixes issues with attachment limits When having uploaded attachments, the input field/upload button is removed and recreated again to "reset" its `files` property which can't be directly reseted since its read-only. --- wcfsetup/install/files/js/WCF.Attachment.js | 17 ++++++----------- wcfsetup/install/files/js/WCF.js | 18 +++++++++++++++--- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.Attachment.js b/wcfsetup/install/files/js/WCF.Attachment.js index edc9f92090..5065da818b 100644 --- a/wcfsetup/install/files/js/WCF.Attachment.js +++ b/wcfsetup/install/files/js/WCF.Attachment.js @@ -75,11 +75,6 @@ WCF.Attachment.Upload = WCF.Upload.extend({ $innerError.html($errorMessage); - // reset value of file input (the 'files' prop is actually readonly!) - if (this._fileUpload) { - this._fileUpload.attr('value', ''); - } - return false; } @@ -94,15 +89,15 @@ WCF.Attachment.Upload = WCF.Upload.extend({ * @see WCF.Upload._upload() */ _upload: function() { - if (!this._validateLimit()) { - return false; + if (this._validateLimit()) { + this._super(); } - this._super(); - - // reset value of file input (the 'files' prop is actually readonly!) if (this._fileUpload) { - this._fileUpload.attr('value', ''); + // remove and re-create the upload button since the 'files' property + // of the input field is readonly thus it can't be reset + this._removeButton(); + this._createButton(); } }, diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 0c2031608c..715599cc2d 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -6457,13 +6457,13 @@ WCF.Upload = Class.extend({ */ _createButton: function() { if (this._supportsAJAXUpload) { - this._fileUpload = $(''); + this._fileUpload = $(''); this._fileUpload.change($.proxy(this._upload, this)); - var $button = $('

'+WCF.Language.get('wcf.global.button.upload')+'

'); + var $button = $('

' + WCF.Language.get('wcf.global.button.upload') + '

'); $button.prepend(this._fileUpload); } else { - var $button = $('

'+WCF.Language.get('wcf.global.button.upload')+'

'); + var $button = $('

' + WCF.Language.get('wcf.global.button.upload') + '

'); $button.click($.proxy(this._showOverlay, this)); } @@ -6479,6 +6479,18 @@ WCF.Upload = Class.extend({ this._buttonSelector.append(button); }, + /** + * Removes the upload button. + */ + _removeButton: function() { + var $selector = '.uploadButton'; + if (!this._supportsAJAXUpload) { + $selector = '.uploadFallbackButton'; + } + + this._buttonSelector.find($selector).remove(); + }, + /** * Callback for file uploads. */ -- 2.20.1