916b5d200a6a693b2cea84139830dd3cdbb65bc6
2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
6 CKEDITOR
.dialog
.add( 'uicolor', function( editor
)
8 var dialog
, picker
, pickerContents
,
9 // Actual UI color value.
10 uiColor
= editor
.getUiColor(),
11 pickerId
= 'cke_uicolor_picker' + CKEDITOR
.tools
.getNextNumber();
13 function setNewPickerColor( color
)
15 // Convert HEX representation to RGB, stripping # char.
16 if ( /^#/.test( color
) )
17 color
= window
.YAHOO
.util
.Color
.hex2rgb( color
.substr( 1 ) );
18 picker
.setValue( color
, true );
20 picker
.refresh( pickerId
);
23 function setNewUiColor( color
, force
)
25 if ( force
|| dialog
._
.contents
.tab1
.livePeview
.getValue() )
26 editor
.setUiColor( color
);
27 // Write new config string into textbox.
28 dialog
._
.contents
.tab1
.configBox
.setValue(
29 'config.uiColor = "#' + picker
.get( "hex" ) + '"'
35 id
: 'yuiColorPicker',
37 html
: "<div id='" + pickerId
+ "' class='cke_uicolor_picker' style='width: 360px; height: 200px; position: relative;'></div>",
38 onLoad : function( event
)
40 var url
= CKEDITOR
.getUrl(
41 '_source/' + // @Packager.RemoveLine
42 'plugins/uicolor/yui/'
45 // Create new color picker widget.
46 picker
= new window
.YAHOO
.widget
.ColorPicker( pickerId
,
48 showhsvcontrols
: true,
49 showhexcontrols
: true,
52 PICKER_THUMB
: url
+ "assets/picker_thumb.png",
53 HUE_THUMB
: url
+ "assets/hue_thumb.png"
57 // Set actual UI color to the picker.
59 setNewPickerColor( uiColor
);
61 // Subscribe to the rgbChange event.
62 picker
.on( "rgbChange", function()
64 // Reset predefined box.
65 dialog
._
.contents
.tab1
.predefined
.setValue( '' );
66 setNewUiColor( '#' + picker
.get( 'hex' ) );
69 // Fix input class names.
70 var inputs
= new CKEDITOR
.dom
.nodeList( picker
.getElementsByTagName( 'input' ) );
71 for ( var i
= 0; i
< inputs
.count() ; i
++ )
72 inputs
.getItem( i
).addClass( 'cke_dialog_ui_input_text' );
76 var skipPreviewChange
= true;
79 title
: editor
.lang
.uicolor
.title
,
88 if ( CKEDITOR
.env
.ie7Compat
)
89 dialog
.parts
.contents
.setStyle( 'overflow', 'hidden' );
108 label
: editor
.lang
.uicolor
.preview
,
112 skipPreviewChange
= true;
114 onChange : function()
116 if ( skipPreviewChange
)
118 var on
= this.getValue(),
119 color
= on
? '#' + picker
.get( 'hex' ) : uiColor
;
120 setNewUiColor( color
, true );
131 label
: editor
.lang
.uicolor
.predefined
,
135 [ 'Light blue', '#9AB8F3' ],
136 [ 'Sand', '#D2B48C' ],
137 [ 'Metallic', '#949AAA' ],
138 [ 'Purple', '#C2A3C7' ],
139 [ 'Olive', '#A2C980' ],
140 [ 'Happy green', '#9BD446' ],
141 [ 'Jezebel Blue', '#14B8C4' ],
142 [ 'Burn', '#FF893A' ],
143 [ 'Easy red', '#FF6969' ],
144 [ 'Pisces 3', '#48B4F2' ],
145 [ 'Aquarius 5', '#487ED4' ],
146 [ 'Absinthe', '#A8CF76' ],
147 [ 'Scrambled Egg', '#C7A622' ],
148 [ 'Hello monday', '#8E8D80' ],
149 [ 'Lovely sunshine', '#F1E8B1' ],
150 [ 'Recycled air', '#B3C593' ],
151 [ 'Down', '#BCBCA4' ],
152 [ 'Mark Twain', '#CFE91D' ],
153 [ 'Specks of dust', '#D1B596' ],
154 [ 'Lollipop', '#F6CE23' ]
156 onChange : function()
158 var color
= this.getValue();
161 setNewPickerColor( color
);
162 setNewUiColor( color
);
163 // Refresh predefined preview box.
164 CKEDITOR
.document
.getById( 'predefinedPreview' ).setStyle( 'background', color
);
167 CKEDITOR
.document
.getById( 'predefinedPreview' ).setStyle( 'background', '' );
171 var color
= editor
.getUiColor();
173 this.setValue( color
);
177 id
: 'predefinedPreview',
179 html
: '<div id="cke_uicolor_preview" style="border: 1px solid black; padding: 3px; width: 30px;">' +
180 '<div id="predefinedPreview" style="width: 30px; height: 30px;"> </div>' +
188 label
: editor
.lang
.uicolor
.config
,
191 var color
= editor
.getUiColor();
194 'config.uiColor = "' + color
+ '"'
203 buttons
: [ CKEDITOR
.dialog
.okButton
]