From: Alexander Ebert Date: Thu, 29 May 2014 21:54:18 +0000 (+0200) Subject: Enabling indent/outdent within lists only X-Git-Tag: 2.1.0_Alpha_1~779^2~7 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=421890d7e1dd05e4a8777d1d1a87325223244812;p=GitHub%2FWoltLab%2FWCF.git Enabling indent/outdent within lists only --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js index 6c36e361d6..d1a894466d 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -51,15 +51,45 @@ RedactorPlugins.wmonkeypatch = { $mpModalInit.call(self, title, content, width, callback); }; + // handle indent/outdent + var $mpButtonActiveObserver = this.buttonActiveObserver; + this.buttonActiveObserver = function(e, btnName) { + self.mpButtonActiveObserver(e, btnName); + + $mpButtonActiveObserver.call(self, e, btnName); + }; + if (this.opts.activeButtons) { + this.$editor.off('mouseup.redactor keyup.redactor').on('mouseup.redactor keyup.redactor', $.proxy(this.buttonActiveObserver, this)); + } + this.$toolbar.find('a.re-indent, a.re-outdent').addClass('redactor_button_disabled'); + this.setOption('modalOpenedCallback', $.proxy(this.modalOpenedCallback, this)); this.modalTemplatesInit(); + + window.dtdesign = this; }, cleanRemoveSpaces: function(html, buffer) { return html; }, + /** + * Enable/Disable the 'Indent'/'Outdent' for lists/outside lists. + * + * @param object e + * @param string btnName + */ + mpButtonActiveObserver: function(e, btnName) { + var parent = this.getParent(); + if (parent !== false && $(parent).closest('ul', this.$editor.get()[0]).length != 0) { + this.$toolbar.find('a.re-indent, a.re-outdent').removeClass('redactor_button_disabled'); + } + else { + this.$toolbar.find('a.re-indent, a.re-outdent').addClass('redactor_button_disabled'); + } + }, + /** * Overwrites $.Redactor.inlineRemoveStyle() to drop empty elements. *