Ticket #4048: 4048_3.patch

File 4048_3.patch, 7.7 KB (added by Tobiasz Cudnik, 14 years ago)
  • _source/plugins/menu/plugin.js

     
    232232                                        this.parent._.panel.showAsChild( panel, this.id, offsetParent, corner, offsetX, offsetY );
    233233                                else
    234234                                        panel.showBlock( this.id, offsetParent, corner, offsetX, offsetY );
     235                               
     236                                editor.fire( 'menuShow', [ panel ] );
    235237                        },
    236238
    237239                        hide : function()
  • _source/skins/kama/skin.js

     
    2525                        if ( editor.config.width && !isNaN( editor.config.width ) )
    2626                                editor.config.width -= 12;
    2727
    28                         var menuHead;
    29                         function menuSetUiColor( color )
    30                         {
    31                                 if ( !menuHead )
    32                                         return null;
    33 
    34                                 var uiStyle = menuHead.append('style');
    35 
    36                                 var cssSrc = "/* UI Color Support */\
     28                        var uiColorMenus = [];
     29                        var uiColorRegex = /\$color/g;
     30                        var uiColorMenuCss = "/* UI Color Support */\
    3731.cke_skin_kama .cke_menuitem .cke_icon_wrapper\
    3832{\
    3933        background-color: $color !important;\
     
    8781{\
    8882        background-color: $color !important;\
    8983}";
     84                        // We have to split CSS declarations for webkit.
     85                        if ( CKEDITOR.env.webkit )
     86                        {
     87                                uiColorMenuCss = uiColorMenuCss.split( '}' ).slice( 0, -1 );
     88                                for ( var i in uiColorMenuCss )
     89                                                uiColorMenuCss[ i ] = uiColorMenuCss[ i ].split( '{' );
     90                        }
    9091
    91                                 uiStyle.setAttribute( "type", "text/css" );
    92                                 var regex = /\$color/g;
    93 
    94                                 // We have to split CSS declarations for webkit.
    95                                 if ( CKEDITOR.env.webkit )
     92                        function addStylesheet( document )
     93                        {
     94                                var node = document.getHead().append( 'style' );
     95                                node.setAttribute( "id", "cke_ui_color" );
     96                                node.setAttribute( "type", "text/css" );
     97                               
     98                                return node;
     99                        }
     100                       
     101                        function updateStylesheets( styleNodes, styleContent, replace )
     102                        {
     103                                for ( var id in styleNodes )
    96104                                {
    97                                         cssSrc = cssSrc.split( '}' ).slice( 0, -1 );
    98                                         for ( var i in cssSrc )
    99                                                         cssSrc[ i ] = cssSrc[ i ].split( '{' );
    100                                 }
    101 
    102                                 return ( menuSetUiColor =
    103                                         function( color )
     105                                        if ( CKEDITOR.env.webkit )
    104106                                        {
    105                                                 if ( CKEDITOR.env.webkit )
     107                                                // Truncate manually.
     108                                                for ( var i = 0 ; i < styleNodes[ id ].$.sheet.rules.length ; i++ )
     109                                                        styleNodes[ id ].$.sheet.removeRule( i );
     110
     111                                                for ( var i in styleContent )
    106112                                                {
    107                                                         for ( var i in cssSrc )
    108                                                                 uiStyle.$.sheet.addRule(
    109                                                                         cssSrc[ i ][ 0 ], cssSrc[ i ][ 1 ].replace( regex, color )
    110                                                                 );
    111                                                 }
    112                                                 else
    113                                                 {
    114                                                         var css = cssSrc.replace( regex, color );
     113                                                        var content = styleContent[ i ][ 1 ];
     114                                                        for ( var r in replace )
     115                                                                content = content.replace( replace[ r ][ 0 ], replace[ r ][ 1 ] );
    115116
    116                                                         if ( CKEDITOR.env.ie )
    117                                                                 uiStyle.$.styleSheet.cssText = css;
    118                                                         else
    119                                                                 uiStyle.setHtml( css );
     117                                                        styleNodes[ id ].$.sheet.addRule( styleContent[ i ][ 0 ], content );
    120118                                                }
    121                                         })( color );
     119                                        }
     120                                        else
     121                                        {
     122                                                var content = styleContent;
     123                                                for ( var r in replace )
     124                                                        content = content.replace( replace[ r ][ 0 ], replace[ r ][ 1 ] );
     125
     126                                                if ( CKEDITOR.env.ie )
     127                                                        styleNodes[ id ].$.styleSheet.cssText = content;
     128                                                else
     129                                                        styleNodes[ id ].setHtml( content );
     130                                        }
     131                                }
    122132                        }
    123133
     134                        var uiColorRegexp = /\$color/g;
     135
    124136                        CKEDITOR.tools.extend( editor,
    125137                        {
    126138                                uiColor: null,
     
    132144
    133145                                setUiColor : function( color )
    134146                                {
    135                                         var uiStyle = CKEDITOR.document.getHead().append('style'),
     147                                        var uiStyle = addStylesheet( CKEDITOR.document ),
    136148                                                cssId = '#cke_' + editor.name.replace('.', '\\.');
    137149
    138150                                        var cssSelectors =
     
    144156                                                ].join( ',' );
    145157                                        var cssProperties = "background-color: $color !important;";
    146158
    147                                         uiStyle.setAttribute("type", "text/css");
     159                                        if ( CKEDITOR.env.webkit )
     160                                                var cssContent = [ [ cssSelectors, cssProperties ] ];
     161                                        else
     162                                                var cssContent = cssSelectors + '{' + cssProperties + '}';
    148163
    149164                                        return ( this.setUiColor =
    150165                                                function( color )
    151166                                                {
    152                                                         var css = cssProperties.replace( '$color', color );
     167                                                        var replace = [ [ uiColorRegexp, color ] ];
    153168                                                        editor.uiColor = color;
    154169
    155                                                         if ( CKEDITOR.env.ie )
    156                                                                 uiStyle.$.styleSheet.cssText = cssSelectors + '{' + css + '}';
    157                                                         else if ( CKEDITOR.env.webkit )
    158                                                                 uiStyle.$.sheet.addRule( cssSelectors, css );
    159                                                         else
    160                                                                 uiStyle.setHtml( cssSelectors + '{' + css + '}' );
     170                                                        // Update general style.
     171                                                        updateStylesheets( [ uiStyle ], cssContent, replace );
    161172
    162                                                         menuSetUiColor( color );
     173                                                        // Update menu styles.
     174                                                        updateStylesheets( uiColorMenus, uiColorMenuCss, replace );
    163175                                                })( color );
    164176                                }
    165177                        });
    166178
    167                         // If the "menu" plugin is loaded, register the listeners.
    168                         if ( CKEDITOR.menu )
     179                        editor.on( 'menuShow', function( event )
    169180                        {
    170                                 var old = CKEDITOR.menu.prototype.show;
     181                                var panel = event.data[ 0 ];
     182                                var iframe = panel.element.getElementsByTag( 'iframe' ).getItem( 0 ).getFrameDocument();
    171183
    172                                 CKEDITOR.menu.prototype.show = function()
     184                                // Add stylesheet if missing.
     185                                if ( !iframe.getById( 'cke_ui_color' ) )
    173186                                {
    174                                         old.apply( this, arguments );
     187                                        var node = addStylesheet( iframe );
     188                                        uiColorMenus.push( node );
    175189
    176                                         if ( !menuHead && editor == this.editor )
    177                                         {
    178                                                 // Save reference.
    179                                                 menuHead = this._.element.getDocument().getHead();
    180                                                 menuSetUiColor( editor.getUiColor() );
    181                                         }
    182                                 };
    183                         }
     190                                        var color = editor.getUiColor();
     191                                        // Set uiColor for new menu.
     192                                        if ( color )
     193                                                updateStylesheets( [ node ], uiColorMenuCss, [ [ uiColorRegexp, color ] ] );
     194                                }
     195                        });
    184196
    185197                        // Apply UI color if specified in config.
    186198                        if ( editor.config.uiColor )
    187199                                editor.setUiColor( editor.config.uiColor );
    188 
    189                         // Fix editor's width. HPadding and 100% width iframe issue.
    190 //                      if ( CKEDITOR.env.ie && CKEDITOR.env.quirks )
    191 //                      {
    192 //                              editor.on( 'mode', function( event )
    193 //                              {
    194 //                                      var container = editor.getResizable();
    195 //                                      editor.resize( container.$.offsetWidth-10, container.$.offsetHeight );
    196 //                                      event.removeListener();
    197 //                              });
    198 //                      }
    199 
    200 //                      if ( CKEDITOR.env.ie && ( CKEDITOR.env.quirks || CKEDITOR.env.version < 7 ) )
    201 //                      {
    202 //                              editor.on( 'themeLoaded', function( event )
    203 //                              {
    204 //                                      var toolbars = editor.container.getChild( [0, 0, 0, 0, 0, 0, 0] ).getChildren();
    205 //                                      for ( var i = 0 ; i < toolbars.count() ; i++ )
    206 //                                      {
    207 //                                              var toolbar = toolbars.getItem( i );
    208 
    209 //                                              var last = toolbar.getLast();
    210 //                                              if ( !last || !last.getPrevious().hasClass( 'cke_rcombo' ) )
    211 //                                                      continue;
    212 //
    213 //                                              last.addClass( 'cke_toolbar_end_last' );
    214 //                                      }
    215 //                              });
    216 //                      }
    217200                }
    218201        };
    219202})() );
  • CHANGES.html

     
    4747                <li><a href="http://dev.fckeditor.net/ticket/3898">#3898</a> : Added validation for URL presentance in Image dialog.</li>
    4848                <li><a href="http://dev.fckeditor.net/ticket/3528">#3528</a> : Fixed Context Menu issue when triggered using Shift+F10.</li>
    4949                <li><a href="http://dev.fckeditor.net/ticket/4028">#4028</a> : Maximize control's tool tip was wrong once it is maximized.</li>
     50                <li><a href="http://dev.fckeditor.net/ticket/4048">#4048</a> : Context submenu was lacking uiColor.</li>
    5051        </ul>
    5152        <h3>
    5253                CKEditor 3.0</h3>
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy