From: Matthias Schmidt Date: Mon, 3 Jun 2013 14:42:30 +0000 (+0200) Subject: Fixes issues with attachment limits X-Git-Tag: 2.0.0_Beta_3~18^2~4 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0d2b7a3b749c3e165aba24c682a60c5e13193ed8;p=GitHub%2FWoltLab%2FWCF.git 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. --- 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. */