[BUGFIX] Incorrect behaviour of style selector in RTE
authorStanislas Rolland <typo3@sjbr.ca>
Wed, 24 Aug 2011 15:15:08 +0000 (11:15 -0400)
committerStanislas Rolland <typo3@sjbr.ca>
Tue, 30 Aug 2011 19:33:21 +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: 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
typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockStyle/block-style.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/TextStyle/text-style.js

index d587e1e..5fa0d4b 100644 (file)
@@ -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'));
        }
 });
index 2dccbbb..ca649f7 100644 (file)
@@ -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);
                }
        }
 });