[BUGFIX] Incorrect behaviour of style selector in RTE
authorStanislas Rolland <typo3@sjbr.ca>
Wed, 24 Aug 2011 15:31:14 +0000 (11:31 -0400)
committerStanislas Rolland <typo3@sjbr.ca>
Tue, 30 Aug 2011 19:33:40 +0000 (21:33 +0200)
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: If81a43cb4768848863bfade78f661eba3331685d
Resolves: #27801
Releases: 4.4, 4.5, 4.6
Reviewed-on: http://review.typo3.org/4574
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockStyle/block-style.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/TextStyle/text-style.js

index 86a9181..f2bd716 100644 (file)
@@ -343,13 +343,15 @@ HTMLArea.BlockStyle = HTMLArea.Plugin.extend({
                                        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'));
        }
 });
index 54c902b..09731c3 100644 (file)
@@ -375,14 +375,16 @@ HTMLArea.TextStyle = HTMLArea.Plugin.extend({
                                        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 = HTMLArea.Plugin.extend({
                                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);
                }
        }
 });