[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 20:42:14 +0000 (21:42 +0100)
The language and font dropdowns need to initialized after their data
stores are loaded. The text indicator needs to be initialized after
the style sheets are loaded.

Change-Id: Iec14690d27ddf512d5f185387192bbb5667da15c
Resolves: #33637
Releases: 4.7
Reviewed-on: http://review.typo3.org/8814
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
typo3/sysext/rtehtmlarea/htmlarea/plugins/TextIndicator/text-indicator.js

index 929302d..b2fdab9 100644 (file)
@@ -124,9 +124,27 @@ HTMLArea.Language = Ext.extend(HTMLArea.Plugin, {
         * 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 = selection.isEmpty(),
+                                       ancestors = selection.getAllAncestors(),
+                                       endPointsInSameBlock = selection.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.document.styleSheets[0];
@@ -145,8 +163,6 @@ HTMLArea.Language = Ext.extend(HTMLArea.Plugin, {
                                }
                                return true;
                        }, this);
-                               // Monitor the combo's store being loaded
-                       select.mon(select.getStore(), 'load', function () { this.updateValue(select); }, this);
                }
        },
        /*
index 99e6a80..666cb37 100644 (file)
@@ -126,7 +126,13 @@ HTMLArea.SelectFont = Ext.extend(HTMLArea.Plugin, {
                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 = selection.isEmpty(),
+                                               ancestors = selection.getAllAncestors(),
+                                               endPointsInSameBlock = selection.endPointsInSameBlock();
+                                       this.onUpdateToolbar(select, this.getEditorMode(), selectionEmpty, ancestors, endPointsInSameBlock);
+                               }, this);
                        }
                }, this);       
        },
index 1b92523..2ade052 100644 (file)
@@ -59,7 +59,33 @@ HTMLArea.TextIndicator = Ext.extend(HTMLArea.Plugin, {
                this.registerText(textConfiguration);
                return true;
         },
-
+       /*
+        * This handler gets called when the editor is generated
+        */
+       onGenerate: function () {
+                       // Ensure text indicator is updated AFTER style sheets are loaded
+               var blockStylePlugin = this.getPluginInstance('BlockStyle');
+               if (blockStylePlugin && blockStylePlugin.blockStyles) {
+                               // Monitor css parsing being completed
+                       this.editor.iframe.mon(blockStylePlugin.blockStyles, 'HTMLAreaEventCssParsingComplete', this.onCssParsingComplete, this);
+               }
+               var textStylePlugin = this.getPluginInstance('TextStyle');
+               if (textStylePlugin && textStylePlugin.textStyles) {
+                               // Monitor css parsing being completed
+                       this.editor.iframe.mon(textStylePlugin.textStyles, 'HTMLAreaEventCssParsingComplete', this.onCssParsingComplete, this);
+               }
+       },
+       /*
+        * This handler gets called when parsing of css classes is completed
+        */
+       onCssParsingComplete: function () {
+               var button = this.getButton('TextIndicator'),
+                       selection = this.editor.getSelection(),
+                       selectionEmpty = selection.isEmpty(),
+                       ancestors = selection.getAllAncestors(),
+                       endPointsInSameBlock = selection.endPointsInSameBlock();
+               this.onUpdateToolbar(button, this.getEditorMode(), selectionEmpty, ancestors, endPointsInSameBlock);
+       },
        /*
         * This function gets called when the toolbar is updated
         */