[BUGFIX] RTE Text indicator does not work in Firefox in TYPO3 4.5
authorStanislas Rolland <typo3@sjbr.ca>
Thu, 2 Feb 2012 21:35:37 +0000 (16:35 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Thu, 2 Feb 2012 21:36:56 +0000 (22:36 +0100)
Solution: Backport logic from master (4.7).

Change-Id: Idf129efb55bc12ec8c2fe17ef931c0027ae08c69
Fixes: #33642
Releases: 4.5
Reviewed-on: http://review.typo3.org/8816
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
typo3/sysext/rtehtmlarea/htmlarea/plugins/TextIndicator/text-indicator.js

index 610d0d5..9dd5855 100644 (file)
@@ -74,30 +74,34 @@ HTMLArea.TextIndicator = HTMLArea.Plugin.extend({
                var editor = this.editor;
                if (mode === 'wysiwyg' && editor.isEditable()) {
                        var doc = editor._doc;
+                       var style = {
+                               fontWeight: 'normal',
+                               fontStyle: 'normal'
+                       };
                        try {
-                               var style = {
-                                       backgroundColor: HTMLArea._makeColor(doc.queryCommandValue((Ext.isIE || Ext.isWebKit) ? 'BackColor' : 'HiliteColor')),
-                                       color: HTMLArea._makeColor(doc.queryCommandValue('ForeColor')),
-                                       fontFamily: doc.queryCommandValue('FontName'),
-                                       fontWeight: 'normal',
-                                       fontStyle: 'normal'
-                               };
-                                       // Mozilla
-                               if (/transparent/i.test(style.backgroundColor)) {
-                                       style.backgroundColor = HTMLArea._makeColor(doc.queryCommandValue('BackColor'));
-                               }
-                               try {
-                                       style.fontWeight = doc.queryCommandState('Bold') ? 'bold' : 'normal';
-                               } catch(e) {
-                                       style.fontWeight = 'normal';
-                               }
-                               try {
-                                       style.fontStyle = doc.queryCommandState('Italic') ? 'italic' : 'normal';
-                               } catch(e) {
-                                       style.fontStyle = 'normal';
-                               }
-                               button.getEl().setStyle(style);
+                                       //  Note: IE always reports FFFFFF as background color
+                               style.backgroundColor = HTMLArea._makeColor(doc.queryCommandValue((Ext.isIE || Ext.isWebKit) ? 'BackColor' : 'HiliteColor'));
+                               style.color = HTMLArea._makeColor(doc.queryCommandValue('ForeColor'));
+                               style.fontFamily = doc.queryCommandValue('FontName');
                        } catch (e) { }
+                               // queryCommandValue does not work in Gecko
+                       if (Ext.isGecko) {
+                               var computedStyle = editor.iframe.getEl().dom.contentWindow.getComputedStyle(editor.getParentElement(), null);
+                               style.color = computedStyle.getPropertyValue('color');
+                               style.backgroundColor = computedStyle.getPropertyValue('background-color');
+                               style.fontFamily = computedStyle.getPropertyValue('font-family');
+                       }
+                       try {
+                               style.fontWeight = doc.queryCommandState('Bold') ? 'bold' : 'normal';
+                       } catch(e) {
+                               style.fontWeight = 'normal';
+                       }
+                       try {
+                               style.fontStyle = doc.queryCommandState('Italic') ? 'italic' : 'normal';
+                       } catch(e) {
+                               style.fontStyle = 'normal';
+                       }
+                       button.getEl().setStyle(style);
                }
        }
 });