Add cancel button for guest comment dialog
authorMatthias Schmidt <gravatronics@live.com>
Thu, 21 Dec 2017 08:41:41 +0000 (09:41 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 21 Dec 2017 08:42:28 +0000 (09:42 +0100)
See #2502

com.woltlab.wcf/templates/commentAddGuestDialog.tpl
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Comment/Add.js

index a2da40c3d21c0f191b98bbe7ca5e1f9aced3b565..e1a16a1658c212fb20de37f30297e5d5adb6dd1b 100644 (file)
@@ -22,4 +22,5 @@
 
 <div class="formSubmit">
        <input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s">
+       <button data-type="cancel">{lang}wcf.global.button.cancel{/lang}</button>
 </div>
index 35a666eccbdf7f852d6ae998e99d0bb8ffb413c4..7c4293c6c3123f1c4e065dfbf02ce57e56acf7b6 100644 (file)
@@ -35,7 +35,8 @@ function(
                        _insertMessage: function() {},
                        _ajaxSuccess: function() {},
                        _ajaxFailure: function() {},
-                       _ajaxSetup: function() {}
+                       _ajaxSetup: function() {},
+                       _cancelGuestDialog: function() {}
                };
                return Fake;
        }
@@ -318,6 +319,7 @@ function(
                                
                                var dialog = UiDialog.getDialog('jsDialogGuestComment');
                                elBySel('input[type=submit]', dialog.content).addEventListener(WCF_CLICK_EVENT, this._submitGuestDialog.bind(this));
+                               elBySel('button[data-type="cancel"]', dialog.content).addEventListener(WCF_CLICK_EVENT, this._cancelGuestDialog.bind(this));
                                elBySel('input[type=text]', dialog.content).addEventListener('keypress', this._submitGuestDialog.bind(this));
                        }
                        else {
@@ -358,6 +360,15 @@ function(
                                },
                                silent: true
                        };
+               },
+               
+               /**
+                * Cancels the guest dialog and restores the comment editor.
+                */
+               _cancelGuestDialog: function() {
+                       UiDialog.close('jsDialogGuestComment');
+                       
+                       this._hideLoadingOverlay();
                }
        };