From: Alexander Ebert Date: Tue, 13 Sep 2016 14:11:12 +0000 (+0200) Subject: Added delete button to edit overlay X-Git-Tag: 3.0.0_Beta_1~185 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c536f83ba68f6456c9bcb86ce4c82a4fde4571a8;p=GitHub%2FWoltLab%2FWCF.git Added delete button to edit overlay --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Code.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Code.js index c509424b09..84f6289fcb 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Code.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Code.js @@ -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 = ''; @@ -224,6 +246,7 @@ define(['EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util', 'Ui/Di + '' + '
' + '' + + '' + '
' }; } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Quote.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Quote.js index f073377e69..593ca46340 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Quote.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Quote.js @@ -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' + '' + '
' + '' + + '' + '
' }; } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Spoiler.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Spoiler.js index 4b6b6d5a14..5f953f7203 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Spoiler.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Spoiler.js @@ -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 + '' + '
' + '' + + '' + '
' }; }