Ticket #6010: 6010_1.patch
File 6010_1.patch, 2.6 KB (added by , 14 years ago) |
---|
-
_source/plugins/colorbutton/plugin.js
22 22 23 23 function addButton( name, type, title ) 24 24 { 25 var colorBoxId = CKEDITOR.tools.getNextId() + '_colorBox'; 25 26 editor.ui.add( name, CKEDITOR.UI_PANELBUTTON, 26 27 { 27 28 label : title, … … 39 40 { 40 41 block.autoSize = true; 41 42 block.element.addClass( 'cke_colorblock' ); 42 block.element.setHtml( renderColors( panel, type ) );43 block.element.setHtml( renderColors( panel, type, colorBoxId ) ); 43 44 // The block should not have scrollbars (#5933, #6056) 44 45 block.element.getDocument().getBody().setStyle( 'overflow', 'hidden' ); 45 46 … … 52 53 keys[ 38 ] = 'prev'; // ARROW-UP 53 54 keys[ CKEDITOR.SHIFT + 9 ] = 'prev'; // SHIFT + TAB 54 55 keys[ 32 ] = 'click'; // SPACE 56 }, 57 58 // The automatic colorbox should represent the real color (#6010) 59 onOpen : function() 60 { 61 var selection = editor.getSelection(), 62 block = selection && selection.getStartElement(), 63 color; 64 65 // Find the closest block element. 66 while ( block && !CKEDITOR.dtd.$block[ block.getName() ] ) 67 block = block.getParent(); 68 block = block || editor.document.getBody(); 69 70 // The background color might be transparent. In that case, look up the color in the DOM tree. 71 do 72 { 73 color = block && block.getComputedStyle( type == 'back' ? 'background-color' : 'color' ) || 'transparent'; 74 } 75 while ( type == 'back' && color == 'transparent' && ( block = block.getParent() ) ); 76 77 // The box should never be transparent. 78 if ( !color || color == 'transparent' ) 79 color = '#ffffff'; 80 81 this._.panel._.iframe.getFrameDocument().getById( colorBoxId ).setStyle( 'background-color', color ); 55 82 } 56 83 }); 57 84 } 58 85 59 86 60 function renderColors( panel, type )87 function renderColors( panel, type, colorBoxId ) 61 88 { 62 89 var output = [], 63 90 colors = config.colorButton_colors.split( ',' ), … … 121 148 '<table role="presentation" cellspacing=0 cellpadding=0 width="100%">' + 122 149 '<tr>' + 123 150 '<td>' + 124 '<span class="cke_colorbox" style="background-color:#000"></span>' +151 '<span class="cke_colorbox" id="', colorBoxId, '"></span>' + 125 152 '</td>' + 126 153 '<td colspan=7 align=center>', 127 154 lang.auto,