Ticket #4048: 4048_2.patch

File 4048_2.patch, 7.1 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, stringMap )
     102                        {
     103                                for ( var id in uiColorMenus )
    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                                                for ( var i in styleContent )
    106108                                                {
    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 );
     109                                                        var content = uiColorMenuCss[ i ][ 1 ];
    115110
    116                                                         if ( CKEDITOR.env.ie )
    117                                                                 uiStyle.$.styleSheet.cssText = css;
    118                                                         else
    119                                                                 uiStyle.setHtml( css );
     111                                                        for ( var s in stringMap )
     112                                                                // IE doesn't support global replace in string object.
     113                                                                while ( content.indexOf( s ) > -1 )
     114                                                                        content = content.replace( s, stringMap[ s ] );
     115
     116                                                        uiColorMenus[ id ].$.sheet.addRule( uiColorMenuCss[ i ][ 0 ], content );
    120117                                                }
    121                                         })( color );
     118                                        }
     119                                        else
     120                                        {
     121                                                for ( var s in stringMap )
     122                                                        // IE doesn't support global replace in string object.
     123                                                        while ( styleContent.indexOf( s ) > -1 )
     124                                                                styleContent = styleContent.replace( s, stringMap[ s ] );
     125
     126                                                if ( CKEDITOR.env.ie )
     127                                                        uiColorMenus[ id ].$.styleSheet.cssText = styleContent;
     128                                                else
     129                                                        uiColorMenus[ id ].setHtml( styleContent );
     130                                        }
     131                                }
    122132                        }
    123133
    124134                        CKEDITOR.tools.extend( editor,
     
    132142
    133143                                setUiColor : function( color )
    134144                                {
    135                                         var uiStyle = CKEDITOR.document.getHead().append('style'),
     145                                        var uiStyle = addStylesheet( CKEDITOR.document ),
    136146                                                cssId = '#cke_' + editor.name.replace('.', '\\.');
    137147
    138148                                        var cssSelectors =
     
    144154                                                ].join( ',' );
    145155                                        var cssProperties = "background-color: $color !important;";
    146156
    147                                         uiStyle.setAttribute("type", "text/css");
    148 
    149157                                        return ( this.setUiColor =
    150158                                                function( color )
    151159                                                {
     
    159167                                                        else
    160168                                                                uiStyle.setHtml( cssSelectors + '{' + css + '}' );
    161169
    162                                                         menuSetUiColor( color );
     170                                                        // Update menu styles.
     171                                                        updateStylesheets( uiColorMenus, uiColorMenuCss, { '$color': editor.getUiColor() } );
    163172                                                })( color );
    164173                                }
    165174                        });
    166175
    167                         // If the "menu" plugin is loaded, register the listeners.
    168                         if ( CKEDITOR.menu )
     176                        editor.on( 'menuShow', function( event )
    169177                        {
    170                                 var old = CKEDITOR.menu.prototype.show;
     178                                var panel = event.data[ 0 ];
     179                                var iframe = panel.element.getElementsByTag( 'iframe' ).getItem( 0 ).getFrameDocument();
    171180
    172                                 CKEDITOR.menu.prototype.show = function()
     181                                // Add stylesheet if missing.
     182                                if ( !iframe.getById( 'cke_ui_color' ) )
    173183                                {
    174                                         old.apply( this, arguments );
     184                                        var node = addStylesheet( iframe );
     185                                        uiColorMenus.push( node );
    175186
    176                                         if ( !menuHead && editor == this.editor )
    177                                         {
    178                                                 // Save reference.
    179                                                 menuHead = this._.element.getDocument().getHead();
    180                                                 menuSetUiColor( editor.getUiColor() );
    181                                         }
    182                                 };
    183                         }
     187                                        var color = editor.getUiColor();
     188                                        // Set uiColor for new menu.
     189                                        if ( color )
     190                                                updateStylesheets( [ node ], uiColorMenuCss, { '$color': color } );
     191                                }
     192                        });
    184193
    185194                        // Apply UI color if specified in config.
    186195                        if ( editor.config.uiColor )
    187196                                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 //                      }
    217197                }
    218198        };
    219199})() );
  • 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