Disable the search for updates buttons while active
authorAlexander Ebert <ebert@woltlab.com>
Wed, 19 Aug 2020 08:40:47 +0000 (10:40 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 19 Aug 2020 08:40:47 +0000 (10:40 +0200)
wcfsetup/install/files/acp/js/WCF.ACP.js

index 6318fe7bbe4e39f688cbc2d5b1abf20e5363d566..8b25007f8ede4ba20025ec3461828f35bacad7d6 100644 (file)
@@ -978,6 +978,9 @@ WCF.ACP.Package.Update.Manager = Class.extend({
  * @param      boolean         bindOnExistingButtons
  */
 WCF.ACP.Package.Update.Search = Class.extend({
+       /** @var {Element} */
+       _button: null,
+       
        /**
         * dialog overlay
         * @var jQuery
@@ -987,24 +990,31 @@ WCF.ACP.Package.Update.Search = Class.extend({
        /**
         * Initializes the WCF.ACP.Package.SearchForUpdates class.
         * 
-        * @param       boolean         bindOnExistingButtons
+        * @param       {boolean}               bindOnExistingButtons
         */
        init: function(bindOnExistingButtons) {
                this._dialog = null;
                
-               if (bindOnExistingButtons === true) {
-                       $('.jsButtonSearchForUpdates').click($.proxy(this._click, this));
-               }
-               else {
-                       var $button = $('<li><a class="button jsButtonSearchForUpdates"><span class="icon icon16 fa-refresh"></span> <span>' + WCF.Language.get('wcf.acp.package.searchForUpdates') + '</span></a></li>');
-                       $button.click(this._click.bind(this)).prependTo($('.contentHeaderNavigation > ul'));
+               if (!bindOnExistingButtons === true) {
+                       $('<li><a href="#" class="button jsButtonSearchForUpdates"><span class="icon icon16 fa-refresh"></span> <span>' + WCF.Language.get('wcf.acp.package.searchForUpdates') + '</span></a></li>').prependTo($('.contentHeaderNavigation > ul'));
                }
+               
+               this._button = elBySel('.jsButtonSearchForUpdates');
+               if (this._button) this._button.addEventListener('click', this._click.bind(this));
        },
        
        /**
         * Handles clicks on the search button.
         */
-       _click: function() {
+       _click: function(event) {
+               event.preventDefault();
+               
+               if (this._button.classList.contains('disabled')) {
+                       return;
+               }
+               
+               this._button.classList.add('disabled');
+               
                if (this._dialog === null) {
                        new WCF.Action.Proxy({
                                autoSend: true,
@@ -1044,6 +1054,8 @@ WCF.ACP.Package.Update.Search = Class.extend({
                        this._dialog.wcfDialog({
                                title: WCF.Language.get('wcf.acp.package.searchForUpdates')
                        });
+                       
+                       this._button.classList.remove('disabled');
                }
        }
 });