From c4943abe7348f30ffce36213e07ba2d0b63a3d8b Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 26 Aug 2014 21:32:03 +0200 Subject: [PATCH] Added button highlighting for subscript/superscript --- .../3rdParty/redactor/plugins/wmonkeypatch.js | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js index d10659901c..7ecc8bc22c 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -149,26 +149,23 @@ RedactorPlugins.wmonkeypatch = { var parent = this.getParent(); parent = (parent === false) ? null : $(parent); - if (parent && 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'); - } - - if (parent && parent.closest('inline.inlineCode', this.$editor.get()[0]).length != 0) { - this.$toolbar.find('a.re-__wcf_tt').addClass('redactor_act'); - } - else { - this.$toolbar.find('a.re-__wcf_tt').removeClass('redactor_act'); - } + var self = this; + var $editor = this.$editor.get()[0]; + var $toggleButtons = function(searchFor, buttonSelector, inverse, className) { + var $buttons = self.$toolbar.find(buttonSelector); + if (parent && parent.closest(searchFor, $editor).length != 0) { + $buttons[(inverse ? 'removeClass' : 'addClass')](className); + } + else { + $buttons[(inverse ? 'addClass' : 'removeClass')](className); + } + }; - if (parent && parent.closest('blockquote.quoteBox', this.$editor.get()[0]).length != 0) { - this.$toolbar.find('a.re-__wcf_quote').addClass('redactor_button_disabled'); - } - else if (this.opts.visual) { - this.$toolbar.find('a.re-__wcf_quote').removeClass('redactor_button_disabled'); - } + $toggleButtons('ul', 'a.re-indent, a.re-outdent', true, 'redactor_button_disabled'); + $toggleButtons('inline.inlineCode', 'a.re-__wcf_tt', false, 'redactor_act'); + $toggleButtons('blockquote.quoteBox', 'a.re-__wcf_quote', false, 'redactor_button_disabled'); + $toggleButtons('sub', 'a.re-subscript', false, 'redactor_act'); + $toggleButtons('sup', 'a.re-superscript', false, 'redactor_act'); }, /** -- 2.20.1