Fixed "Insert All" button being always visible
authorAlexander Ebert <ebert@woltlab.com>
Sun, 25 May 2014 11:17:36 +0000 (13:17 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 25 May 2014 11:17:36 +0000 (13:17 +0200)
wcfsetup/install/files/js/WCF.Attachment.js

index 0dc4e26521970e11ca1ba96dd5927dba6c9c9591..5c4c5f68f6ff30ea1b441766aaa24e07e1909296 100644 (file)
@@ -64,8 +64,12 @@ WCF.Attachment.Upload = WCF.Upload.extend({
                
                this._makeSortable();
                
-               this._insertAllButton = $('<p class="button">' + WCF.Language.get('wcf.attachment.insertAll') + '</p>').appendTo(this._buttonSelector);
+               this._insertAllButton = $('<p class="button">' + WCF.Language.get('wcf.attachment.insertAll') + '</p>').hide().appendTo(this._buttonSelector);
                this._insertAllButton.click($.proxy(this._insertAll, this));
+               
+               if (this._fileListSelector.children('li:not(.uploadFailed)').length) {
+                       this._insertAllButton.show();
+               }
        },
        
        /**
@@ -107,6 +111,10 @@ WCF.Attachment.Upload = WCF.Upload.extend({
                if ($target.is('li.box48') && $target.parent().wcfIdentify() === this._fileListSelector.wcfIdentify()) {
                        this._buttonSelector.next('small.innerError').remove();
                }
+               
+               if (!this._fileListSelector.children('li:not(.uploadFailed)').length) {
+                       this._insertAllButton.hide();
+               }
        },
        
        /**
@@ -243,6 +251,13 @@ WCF.Attachment.Upload = WCF.Upload.extend({
                
                this._makeSortable();
                
+               if (this._fileListSelector.children('li:not(.uploadFailed)').length) {
+                       this._insertAllButton.show();
+               }
+               else {
+                       this._insertAllButton.hide();
+               }
+               
                WCF.DOMNodeInsertedHandler.execute();
        },