[BUGFIX] htmlArea RTE: Text indicator refers to deleted color conversion function...
authorstan <typo3@sjbr.ca>
Fri, 8 Jul 2011 15:34:32 +0000 (11:34 -0400)
committerStanislas Rolland <typo3@sjbr.ca>
Fri, 8 Jul 2011 15:40:04 +0000 (17:40 +0200)
The function aliases were deleted as part of TYPO3 4.6 cleanup.

Change-Id: I5f386cbd1c7e32e46440b4621fc9279ba1aa7cf8
Resolves: #27994
Related: #25093
Releases: 4.6
Reviewed-on: http://review.typo3.org/3154
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
typo3/sysext/rtehtmlarea/htmlarea/plugins/TextIndicator/text-indicator.js

index 54d6e1c..01b4675 100644 (file)
@@ -66,31 +66,35 @@ HTMLArea.TextIndicator = Ext.extend(HTMLArea.Plugin, {
        onUpdateToolbar: function (button, mode, selectionEmpty, ancestors) {
                var editor = this.editor;
                if (mode === 'wysiwyg' && editor.isEditable()) {
-                       var doc = editor._doc;
+                       var doc = editor.document;
+                       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.util.Color.colorToRgb(doc.queryCommandValue((Ext.isIE || Ext.isWebKit) ? 'BackColor' : 'HiliteColor'));
+                               style.color = HTMLArea.util.Color.colorToRgb(doc.queryCommandValue('ForeColor'));
+                               style.fontFamily = doc.queryCommandValue('FontName');
                        } catch (e) { }
+                               // queryCommandValue does not work in Gecko
+                       if (Ext.isGecko) {
+                               var computedStyle = editor._iframe.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);
                }
        }
 });