[BUGFIX] RTE: Some toolbar elements may not be correctly initialized
authorStanislas Rolland <typo3@sjbr.ca>
Thu, 2 Feb 2012 18:05:33 +0000 (13:05 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Thu, 2 Feb 2012 21:13:06 +0000 (22:13 +0100)
The language and font dropdowns need to initialized after their data
stores are loaded.

Change-Id: If34a6c03628ce277e4fa567fb34b0db8bcc428b4
Resolves: #33637
Releases: 4.5
Reviewed-on: http://review.typo3.org/8815
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
typo3/sysext/rtehtmlarea/htmlarea/plugins/Language/language.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/SelectFont/select-font.js

index 54f1d6c..717dc0f 100644 (file)
@@ -132,9 +132,27 @@ HTMLArea.Language = HTMLArea.Plugin.extend({
         * This function gets called when the editor is generated
         */
        onGenerate: function () {
-                       // Add rules to the stylesheet for language mark highlighting
-                       // Model: body.htmlarea-show-language-marks *[lang=en]:before { content: "en: "; }
-                       // Works in IE8, but not in earlier versions of IE
+               var select = this.getButton('Language');
+               if (select.getStore().getCount() > 1) {
+                       this.addLanguageMarkingRules();
+               } else {
+                               // Monitor the language combo's store being loaded
+                       select.mon(select.getStore(), 'load', function () {
+                               this.addLanguageMarkingRules();
+                               var selection = this.editor._getSelection(),
+                                       selectionEmpty = this.editor._selectionEmpty(selection),
+                                       ancestors = this.editor.getAllAncestors(),
+                                       endPointsInSameBlock = this.editor.endPointsInSameBlock();
+                               this.onUpdateToolbar(select, this.getEditorMode(), selectionEmpty, ancestors, endPointsInSameBlock);
+                       }, this);
+               }
+       },
+       /*
+        * This function adds rules to the stylesheet for language mark highlighting
+        * Model: body.htmlarea-show-language-marks *[lang=en]:before { content: "en: "; }
+        * Works in IE8, but not in earlier versions of IE
+        */
+       addLanguageMarkingRules: function () {
                var select = this.getButton('Language');
                if (select) {
                        var styleSheet = this.editor._doc.styleSheets[0];
@@ -153,8 +171,6 @@ HTMLArea.Language = HTMLArea.Plugin.extend({
                                }
                                return true;
                        }, this);
-                               // Monitor the combo's store being loaded
-                       select.mon(select.getStore(), 'load', function () { this.updateValue(select); }, this);
                }
        },
        /*
index 1df4021..7a11bf7 100644 (file)
@@ -131,7 +131,13 @@ HTMLArea.SelectFont = HTMLArea.Plugin.extend({
                Ext.each(this.dropDownList, function (dropDown) {
                        var select = this.getButton(dropDown[0]);
                        if (select) {
-                               select.mon(select.getStore(), 'load', function () { select.setValue('none'); });
+                               select.mon(select.getStore(), 'load', function () {
+                                       var selection = this.editor._getSelection(),
+                                               selectionEmpty = this.editor._selectionEmpty(selection),
+                                               ancestors = this.editor.getAllAncestors(),
+                                               endPointsInSameBlock = this.editor.endPointsInSameBlock();
+                                       this.onUpdateToolbar(select, this.getEditorMode(), selectionEmpty, ancestors, endPointsInSameBlock);
+                               }, this);
                        }
                }, this);
        },