From ad0ab9e75c59c1cd806158cc70bbbe4abae791ec Mon Sep 17 00:00:00 2001 From: Stanislas Rolland Date: Wed, 24 Aug 2011 11:15:08 -0400 Subject: [PATCH] [BUGFIX] Incorrect behaviour of style selector in RTE When all classes allowed on an element have been assigned to a single element, the block/text style selector becomes disabled. It is then not possible to remove the assigned classes from this element. Change-Id: Ifc5ca8e4fc07c8627a07fe94854ceda056b2e557 Resolves: #27801 Releases: 4.4, 4.5, 4.6 Reviewed-on: http://review.typo3.org/4572 Reviewed-by: Stanislas Rolland Tested-by: Stanislas Rolland --- .../htmlarea/plugins/BlockStyle/block-style.js | 6 ++++-- .../rtehtmlarea/htmlarea/plugins/TextStyle/text-style.js | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockStyle/block-style.js b/typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockStyle/block-style.js index d587e1e6af7f..5fa0d4b0d749 100644 --- a/typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockStyle/block-style.js +++ b/typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockStyle/block-style.js @@ -346,13 +346,15 @@ HTMLArea.BlockStyle = Ext.extend(HTMLArea.Plugin, { store.getAt(0).set('text', this.localize('Remove style')); } } + // Remove already assigned classes from the dropDown box + var classNamesString = ',' + classNames.join(',') + ','; store.each(function (option) { - if (store.indexOf(option) != index && (',' + classNames.join(',') + ',').indexOf(',' + option.get('value') + ',') != -1) { + if (classNamesString.indexOf(',' + option.get('value') + ',') != -1) { store.removeAt(store.indexOf(option)); } return true; }); } - dropDown.setDisabled(!(store.getCount()>1)); + dropDown.setDisabled(!store.getCount() || (store.getCount() == 1 && dropDown.getValue() == 'none')); } }); diff --git a/typo3/sysext/rtehtmlarea/htmlarea/plugins/TextStyle/text-style.js b/typo3/sysext/rtehtmlarea/htmlarea/plugins/TextStyle/text-style.js index 2dccbbb8a272..ca649f747bd6 100644 --- a/typo3/sysext/rtehtmlarea/htmlarea/plugins/TextStyle/text-style.js +++ b/typo3/sysext/rtehtmlarea/htmlarea/plugins/TextStyle/text-style.js @@ -375,14 +375,16 @@ HTMLArea.TextStyle = Ext.extend(HTMLArea.Plugin, { store.getAt(0).set('text', this.localize('Remove style')); } } + // Remove already assigned classes from the dropDown box + var classNamesString = ',' + classNames.join(',') + ','; store.each(function (option) { - if (("," + classNames.join(",") + ",").indexOf("," + option.get('value') + ",") != -1 && store.indexOf(option) != index) { + if (classNamesString.indexOf("," + option.get('value') + ",") != -1) { store.removeAt(store.indexOf(option)); } return true; }); } - dropDown.setDisabled(!(store.getCount()>1)); + dropDown.setDisabled(!store.getCount() || (store.getCount() == 1 && dropDown.getValue() == 'none')); }, /* * This function updates the current value of the dropdown list @@ -396,7 +398,7 @@ HTMLArea.TextStyle = Ext.extend(HTMLArea.Plugin, { this.setSelectedOption(dropDown, classNames); } var store = dropDown.getStore(); - dropDown.setDisabled(!(store.getCount()>1) || disabled); + dropDown.setDisabled(!store.getCount() || (store.getCount() == 1 && dropDown.getValue() == 'none') || disabled); } } }); -- 2.20.1