Skip to content

Commit 7c87fba

Browse files
committed
Merge branch 't/12440'
2 parents 12f0de3 + 6c5453a commit 7c87fba

File tree

3 files changed

+70
-18
lines changed

3 files changed

+70
-18
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CKEditor 4 Changelog
55

66
Other Changes:
77

8+
* [#12440](http://dev.ckeditor.com/ticket/12440): Added the [`config.colorButton_enableAutomatic`](http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-colorButton_enableAutomatic) option to allow hiding the "Automatic" option in the color picker.
89
* [#13756](http://dev.ckeditor.com/ticket/13756): Fixed: Context menus are cut-off in Microsoft Edge.
910
* [#12707](http://dev.ckeditor.com/ticket/12707): Fixed: The order of table elements does not meet the HTML specification.
1011

plugins/colorbutton/plugin.js

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ CKEDITOR.plugins.add( 'colorbutton', {
9191
if ( !color || color == 'transparent' )
9292
color = '#ffffff';
9393

94-
this._.panel._.iframe.getFrameDocument().getById( colorBoxId ).setStyle( 'background-color', color );
94+
if ( config.colorButton_enableAutomatic !== false ) {
95+
this._.panel._.iframe.getFrameDocument().getById( colorBoxId ).setStyle( 'background-color', color );
96+
}
9597

9698
return color;
9799
}
@@ -153,22 +155,24 @@ CKEDITOR.plugins.add( 'colorbutton', {
153155
editor.fire( 'saveSnapshot' );
154156
} );
155157

156-
// Render the "Automatic" button.
157-
output.push( '<a class="cke_colorauto" _cke_focus=1 hidefocus=true' +
158-
' title="', lang.auto, '"' +
159-
' onclick="CKEDITOR.tools.callFunction(', clickFn, ',null,\'', type, '\');return false;"' +
160-
' href="javascript:void(\'', lang.auto, '\')"' +
161-
' role="option" aria-posinset="1" aria-setsize="', total, '">' +
162-
'<table role="presentation" cellspacing=0 cellpadding=0 width="100%">' +
163-
'<tr>' +
164-
'<td>' +
165-
'<span class="cke_colorbox" id="', colorBoxId, '"></span>' +
166-
'</td>' +
167-
'<td colspan=7 align=center>', lang.auto, '</td>' +
168-
'</tr>' +
169-
'</table>' +
170-
'</a>' +
171-
'<table role="presentation" cellspacing=0 cellpadding=0 width="100%">' );
158+
if ( config.colorButton_enableAutomatic !== false ) {
159+
// Render the "Automatic" button.
160+
output.push( '<a class="cke_colorauto" _cke_focus=1 hidefocus=true' +
161+
' title="', lang.auto, '"' +
162+
' onclick="CKEDITOR.tools.callFunction(', clickFn, ',null,\'', type, '\');return false;"' +
163+
' href="javascript:void(\'', lang.auto, '\')"' +
164+
' role="option" aria-posinset="1" aria-setsize="', total, '">' +
165+
'<table role="presentation" cellspacing=0 cellpadding=0 width="100%">' +
166+
'<tr>' +
167+
'<td>' +
168+
'<span class="cke_colorbox" id="', colorBoxId, '"></span>' +
169+
'</td>' +
170+
'<td colspan=7 align=center>', lang.auto, '</td>' +
171+
'</tr>' +
172+
'</table>' +
173+
'</a>' );
174+
}
175+
output.push( '<table role="presentation" cellspacing=0 cellpadding=0 width="100%">' );
172176

173177
// Render the color boxes.
174178
for ( var i = 0; i < colors.length; i++ ) {
@@ -299,3 +303,12 @@ CKEDITOR.config.colorButton_backStyle = {
299303
element: 'span',
300304
styles: { 'background-color': '#(color)' }
301305
};
306+
307+
/**
308+
* Whether to enable the **Automatic** button in the color selectors.
309+
*
310+
* config.colorButton_enableAutomatic = false;
311+
*
312+
* @cfg {Boolean} [colorButton_enableAutomatic=true]
313+
* @member CKEDITOR.config
314+
*/

tests/plugins/colorbutton/colorbutton.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,44 @@
3636
} );
3737

3838
wait();
39+
},
40+
41+
'test enableAutomatic=true option': function() {
42+
bender.editorBot.create( {
43+
name: 'editor1',
44+
config: {
45+
colorButton_enableAutomatic: true
46+
}
47+
}, function( bot ) {
48+
var editor = bot.editor,
49+
txtColorBtn = editor.ui.get( 'TextColor' ),
50+
bgColorBtn = editor.ui.get( 'BGColor' );
51+
52+
txtColorBtn.click( editor );
53+
assert.areEqual( 1, txtColorBtn._.panel.getBlock( txtColorBtn._.id ).element.find( '.cke_colorauto' ).count(), 'Automatic button should be visible.' );
54+
55+
bgColorBtn.click( editor );
56+
assert.areEqual( 1, bgColorBtn._.panel.getBlock( bgColorBtn._.id ).element.find( '.cke_colorauto' ).count(), 'Automatic button should be visible.' );
57+
} );
58+
},
59+
60+
'test enableAutomatic=false option': function() {
61+
bender.editorBot.create( {
62+
name: 'editor2',
63+
config: {
64+
colorButton_enableAutomatic: false
65+
}
66+
}, function( bot ) {
67+
var editor = bot.editor,
68+
txtColorBtn = editor.ui.get( 'TextColor' ),
69+
bgColorBtn = editor.ui.get( 'BGColor' );
70+
71+
txtColorBtn.click( editor );
72+
assert.areEqual( 0, txtColorBtn._.panel.getBlock( txtColorBtn._.id ).element.find( '.cke_colorauto' ).count(), 'Automatic button should not be visible.' );
73+
74+
bgColorBtn.click( editor );
75+
assert.areEqual( 0, bgColorBtn._.panel.getBlock( bgColorBtn._.id ).element.find( '.cke_colorauto' ).count(), 'Automatic button should not be visible.' );
76+
} );
3977
}
4078
} );
41-
} )();
79+
} )();

0 commit comments

Comments
 (0)