Improve notification test buttons
authorMatthias Schmidt <gravatronics@live.com>
Mon, 31 Jul 2017 13:33:05 +0000 (15:33 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 31 Jul 2017 13:33:05 +0000 (15:33 +0200)
See #2359

wcfsetup/install/files/acp/templates/devtoolsNotificationTest.tpl
wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Devtools/Notification/Test.js

index 1cdec09ebc2a4c14b8a2631bd051e67cd101d094..09acf84468888a774683097e6947f725de173dc2 100644 (file)
@@ -22,7 +22,7 @@
                        {foreach from=$eventList item=event}
                                <dt>{lang}wcf.user.notification.{$event->objectType}.{$event->eventName}{/lang}</dt>
                                <dd>
-                                       <a class="button small jsTestEventButton" data-event-id="{$event->eventID}" data-title="{lang}wcf.user.notification.{$event->objectType}.{$event->eventName}{/lang}">{lang}wcf.acp.devtools.notificationTest.button.test{/lang}</a>
+                                       <button class="small jsTestEventButton" data-event-id="{$event->eventID}" data-title="{lang}wcf.user.notification.{$event->objectType}.{$event->eventName}{/lang}">{lang}wcf.acp.devtools.notificationTest.button.test{/lang}</button>
                                </dd>
                        {/foreach}
                </dl>
 {/foreach}
 
 <script data-relocate="true">
-       require(['WoltLabSuite/Core/Acp/Ui/Devtools/Notification/Test'], function(AcpUiDevtoolsNotificationTest) {
+       require(['Language', 'WoltLabSuite/Core/Acp/Ui/Devtools/Notification/Test'], function(Language, AcpUiDevtoolsNotificationTest) {
+               Language.addObject({
+                       'wcf.acp.devtools.notificationTest.button.test': '{lang}wcf.acp.devtools.notificationTest.button.test{/lang}'
+               });
+               
                AcpUiDevtoolsNotificationTest.init();
        });
 </script>
index 75410234ac931f4f5bfd1b2345b1de4d78fc83da..445f8df36c3044822a95c7953be1e8ae882d3669 100644 (file)
@@ -6,7 +6,7 @@
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLabSuite/Core/Acp/Ui/Devtools/Project/QuickSetup
  */
-define(['Ajax', 'Dictionary', 'Ui/Dialog'], function(Ajax, Dictionary, UiDialog) {
+define(['Ajax', 'Dictionary', 'Language', 'Ui/Dialog'], function(Ajax, Dictionary, Language, UiDialog) {
        var _buttons = elByClass('jsTestEventButton');
        var _titles = new Dictionary();
        
@@ -63,6 +63,12 @@ define(['Ajax', 'Dictionary', 'Ui/Dialog'], function(Ajax, Dictionary, UiDialog)
                        });
                        
                        elById('notificationTestDialog').parentNode.scrollTop = 0;
+                       
+                       // restore buttons
+                       Array.prototype.forEach.call(_buttons, function(button) {
+                               button.innerHTML = Language.get('wcf.acp.devtools.notificationTest.button.test');
+                               button.disabled = false;
+                       });
                },
                
                /**
@@ -106,9 +112,17 @@ define(['Ajax', 'Dictionary', 'Ui/Dialog'], function(Ajax, Dictionary, UiDialog)
                 * @param       {Event}         event
                 */
                _test: function(event) {
+                       var button = event.currentTarget;
+                       
+                       button.innerHTML = '<span class="icon icon16 fa-spinner"></span>';
+                       
+                       Array.prototype.forEach.call(_buttons, function(button) {
+                               button.disabled = true;
+                       });
+                       
                        Ajax.api(this, {
                                parameters: {
-                                       eventID: elData(event.currentTarget, 'event-id')
+                                       eventID: elData(button, 'event-id')
                                }
                        });
                }