Added delete button to edit overlay
authorAlexander Ebert <ebert@woltlab.com>
Tue, 13 Sep 2016 14:11:12 +0000 (16:11 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 13 Sep 2016 14:11:12 +0000 (16:11 +0200)
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Code.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Quote.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Spoiler.js

index c509424b09d480f6093e80086ed2d865d04bc1af..84f6289fcb6644674e2417855dd46ff351d74fec 100644 (file)
@@ -141,8 +141,29 @@ define(['EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util', 'Ui/Di
                        }
                },
                
+               _delete: function (event) {
+                       event.preventDefault();
+                       
+                       var caretEnd = this._pre.nextElementSibling || this._pre.previousElementSibling;
+                       if (caretEnd === null && this._pre.parentNode !== this._editor.core.editor()[0]) {
+                               caretEnd = this._pre.parentNode;
+                       }
+                       
+                       if (caretEnd === null) {
+                               this._editor.code.set('');
+                               this._editor.focus.end();
+                       }
+                       else {
+                               elRemove(this._pre);
+                               this._editor.caret.end(caretEnd);
+                       }
+                       
+                       UiDialog.close(this);
+               },
+               
                _dialogSetup: function() {
                        var id = 'redactor-code-' + this._elementId,
+                           idButtonDelete = id + '-button-delete',
                            idButtonSave = id + '-button-save',
                            idFile = id + '-file',
                            idHighlighter = id + '-highlighter',
@@ -157,6 +178,7 @@ define(['EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util', 'Ui/Di
                                        
                                        onSetup: (function() {
                                                elById(idButtonSave).addEventListener(WCF_CLICK_EVENT, this._save.bind(this));
+                                               elById(idButtonDelete).addEventListener(WCF_CLICK_EVENT, this._delete.bind(this));
                                                
                                                // set highlighters
                                                var highlighters = '<option value="">' + Language.get('wcf.editor.code.highlighter.detect') + '</option>';
@@ -224,6 +246,7 @@ define(['EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util', 'Ui/Di
                                + '</div>'
                                + '<div class="formSubmit">'
                                        + '<button id="' + idButtonSave + '" class="buttonPrimary">' + Language.get('wcf.global.button.save') + '</button>'
+                                       + '<button id="' + idButtonDelete + '">' + Language.get('wcf.global.button.delete') + '</button>'
                                + '</div>'
                        };
                }
index f073377e69877b87ad60d2d3f5ea030721a372b5..593ca463402c40e61dc6118512ea05c3bdca1eb8 100644 (file)
@@ -208,9 +208,30 @@ define(['Core', 'EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util'
                        }
                },
                
+               _delete: function (event) {
+                       event.preventDefault();
+                       
+                       var caretEnd = this._quote.nextElementSibling || this._quote.previousElementSibling;
+                       if (caretEnd === null && this._quote.parentNode !== this._editor.core.editor()[0]) {
+                               caretEnd = this._quote.parentNode;
+                       }
+                       
+                       if (caretEnd === null) {
+                               this._editor.code.set('');
+                               this._editor.focus.end();
+                       }
+                       else {
+                               elRemove(this._quote);
+                               this._editor.caret.end(caretEnd);
+                       }
+                       
+                       UiDialog.close(this);
+               },
+               
                _dialogSetup: function() {
                        var id = 'redactor-quote-' + this._elementId,
                            idAuthor = id + '-author',
+                           idButtonDelete = id + '-button-delete',
                            idButtonSave = id + '-button-save',
                            idUrl = id + '-url';
                        
@@ -223,6 +244,7 @@ define(['Core', 'EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util'
                                        
                                        onSetup: (function() {
                                                elById(idButtonSave).addEventListener(WCF_CLICK_EVENT, this._save.bind(this));
+                                               elById(idButtonDelete).addEventListener(WCF_CLICK_EVENT, this._delete.bind(this));
                                        }).bind(this),
                                        
                                        onShow: (function() {
@@ -249,6 +271,7 @@ define(['Core', 'EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util'
                                + '</div>'
                                + '<div class="formSubmit">'
                                        + '<button id="' + idButtonSave + '" class="buttonPrimary">' + Language.get('wcf.global.button.save') + '</button>'
+                                       + '<button id="' + idButtonDelete + '">' + Language.get('wcf.global.button.delete') + '</button>'
                                + '</div>'
                        };
                }
index 4b6b6d5a1425c52b8ca7405bc45855a42de17270..5f953f720348ee936ba56739c5994efdbec4617d 100644 (file)
@@ -126,8 +126,29 @@ define(['EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util', 'Ui/Di
                        }
                },
                
+               _delete: function (event) {
+                       event.preventDefault();
+                       
+                       var caretEnd = this._spoiler.nextElementSibling || this._spoiler.previousElementSibling;
+                       if (caretEnd === null && this._spoiler.parentNode !== this._editor.core.editor()[0]) {
+                               caretEnd = this._spoiler.parentNode;
+                       }
+                       
+                       if (caretEnd === null) {
+                               this._editor.code.set('');
+                               this._editor.focus.end();
+                       }
+                       else {
+                               elRemove(this._spoiler);
+                               this._editor.caret.end(caretEnd);
+                       }
+                       
+                       UiDialog.close(this);
+               },
+               
                _dialogSetup: function() {
                        var id = 'redactor-spoiler-' + this._elementId,
+                           idButtonDelete = id + '-button-delete',
                            idButtonSave = id + '-button-save',
                            idLabel = id + '-label';
                        
@@ -140,6 +161,7 @@ define(['EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util', 'Ui/Di
                                        
                                        onSetup: (function() {
                                                elById(idButtonSave).addEventListener(WCF_CLICK_EVENT, this._save.bind(this));
+                                               elById(idButtonDelete).addEventListener(WCF_CLICK_EVENT, this._delete.bind(this));
                                        }).bind(this),
                                        
                                        onShow: (function() {
@@ -159,6 +181,7 @@ define(['EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util', 'Ui/Di
                                + '</div>'
                                + '<div class="formSubmit">'
                                        + '<button id="' + idButtonSave + '" class="buttonPrimary">' + Language.get('wcf.global.button.save') + '</button>'
+                                       + '<button id="' + idButtonDelete + '">' + Language.get('wcf.global.button.delete') + '</button>'
                                + '</div>'
                        };
                }