1 | /*
|
---|
2 | Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
|
---|
3 | For licensing, see LICENSE.html or http://ckeditor.com/license
|
---|
4 | */
|
---|
5 |
|
---|
6 | CKEDITOR.dialog.add( 'uicolor', function( editor )
|
---|
7 | {
|
---|
8 | var dialog, picker, pickerContents,
|
---|
9 | // Actual UI color value.
|
---|
10 | uiColor = editor.getUiColor();
|
---|
11 |
|
---|
12 | function setNewPickerColor( color )
|
---|
13 | {
|
---|
14 | // Convert HEX representation to RGB, stripping # char.
|
---|
15 | if ( /^#/.test( color ) )
|
---|
16 | color = window.YAHOO.util.Color.hex2rgb( color.substr( 1 ) );
|
---|
17 | picker.setValue( color, true );
|
---|
18 | // Refresh picker UI.
|
---|
19 | picker.refresh( 'cke_uicolor_picker' );
|
---|
20 | }
|
---|
21 |
|
---|
22 | function setNewUiColor( color, force )
|
---|
23 | {
|
---|
24 | if ( force || dialog._.contents.tab1.livePeview.getValue() )
|
---|
25 | editor.setUiColor( color );
|
---|
26 | // Write new config string into textbox.
|
---|
27 | dialog._.contents.tab1.configBox.setValue(
|
---|
28 | 'config.uiColor = "#' + picker.get( "hex" ) + '"'
|
---|
29 | );
|
---|
30 | }
|
---|
31 |
|
---|
32 | pickerContents =
|
---|
33 | {
|
---|
34 | id : 'yuiColorPicker',
|
---|
35 | type : 'html',
|
---|
36 | html : "<div id='cke_uicolor_picker' style='width: 360px; height: 200px; position: relative;'></div>",
|
---|
37 | onLoad : function( event )
|
---|
38 | {
|
---|
39 | var url = CKEDITOR.getUrl(
|
---|
40 | '_source/' + // @Packager.RemoveLine
|
---|
41 | 'plugins/uicolor/yui/'
|
---|
42 | );
|
---|
43 |
|
---|
44 | // Create new color picker widget.
|
---|
45 | picker = new window.YAHOO.widget.ColorPicker( "cke_uicolor_picker",
|
---|
46 | {
|
---|
47 | showhsvcontrols : true,
|
---|
48 | showhexcontrols : true,
|
---|
49 | images :
|
---|
50 | {
|
---|
51 | PICKER_THUMB : url + "assets/picker_thumb.png",
|
---|
52 | HUE_THUMB : url + "assets/hue_thumb.png"
|
---|
53 | }
|
---|
54 | });
|
---|
55 |
|
---|
56 | // Set actual UI color to the picker.
|
---|
57 | if ( uiColor )
|
---|
58 | setNewPickerColor( uiColor );
|
---|
59 |
|
---|
60 | // Subscribe to the rgbChange event.
|
---|
61 | picker.on( "rgbChange", function()
|
---|
62 | {
|
---|
63 | // Reset predefined box.
|
---|
64 | dialog._.contents.tab1.predefined.setValue( '' );
|
---|
65 | setNewUiColor( '#' + picker.get( 'hex' ) );
|
---|
66 | });
|
---|
67 |
|
---|
68 | // Fix input class names.
|
---|
69 | var inputs = new CKEDITOR.dom.nodeList( picker.getElementsByTagName( 'input' ) );
|
---|
70 | for ( var i = 0; i < inputs.count() ; i++ )
|
---|
71 | inputs.getItem( i ).addClass( 'cke_dialog_ui_input_text' );
|
---|
72 | }
|
---|
73 | };
|
---|
74 |
|
---|
75 | var skipPreviewChange = true;
|
---|
76 |
|
---|
77 | return {
|
---|
78 | title : editor.lang.uicolor.title,
|
---|
79 | minWidth : 360,
|
---|
80 | minHeight : 320,
|
---|
81 | onLoad : function()
|
---|
82 | {
|
---|
83 | dialog = this;
|
---|
84 | this.setupContent();
|
---|
85 |
|
---|
86 | // #3808
|
---|
87 | if ( CKEDITOR.env.ie7Compat )
|
---|
88 | dialog.parts.contents.setStyle( 'overflow', 'hidden' );
|
---|
89 | },
|
---|
90 | contents : [
|
---|
91 | {
|
---|
92 | id : 'tab1',
|
---|
93 | label : '',
|
---|
94 | title : '',
|
---|
95 | expand : true,
|
---|
96 | padding : 0,
|
---|
97 | elements : [
|
---|
98 | pickerContents,
|
---|
99 | {
|
---|
100 | id : 'tab1',
|
---|
101 | type : 'vbox',
|
---|
102 | children :
|
---|
103 | [
|
---|
104 | {
|
---|
105 | id : 'livePeview',
|
---|
106 | type : 'checkbox',
|
---|
107 | label : editor.lang.uicolor.preview,
|
---|
108 | 'default' : 1,
|
---|
109 | onLoad : function()
|
---|
110 | {
|
---|
111 | skipPreviewChange = true;
|
---|
112 | },
|
---|
113 | onChange : function()
|
---|
114 | {
|
---|
115 | if ( skipPreviewChange )
|
---|
116 | return;
|
---|
117 | var on = this.getValue(),
|
---|
118 | color = on ? '#' + picker.get( 'hex' ) : uiColor;
|
---|
119 | setNewUiColor( color, true );
|
---|
120 | }
|
---|
121 | },
|
---|
122 | {
|
---|
123 | type : 'hbox',
|
---|
124 | children :
|
---|
125 | [
|
---|
126 | {
|
---|
127 | id : 'predefined',
|
---|
128 | type : 'select',
|
---|
129 | 'default' : '',
|
---|
130 | label : editor.lang.uicolor.predefined,
|
---|
131 | items :
|
---|
132 | [
|
---|
133 | [ '' ],
|
---|
134 | [ 'Light blue', '#9AB8F3' ],
|
---|
135 | [ 'Sand', '#D2B48C' ],
|
---|
136 | [ 'Metallic', '#949AAA' ],
|
---|
137 | [ 'Purple', '#C2A3C7' ],
|
---|
138 | [ 'Olive', '#A2C980' ],
|
---|
139 | [ 'Happy green', '#9BD446' ],
|
---|
140 | [ 'Jezebel Blue', '#14B8C4' ],
|
---|
141 | [ 'Burn', '#FF893A' ],
|
---|
142 | [ 'Easy red', '#FF6969' ],
|
---|
143 | [ 'Pisces 3', '#48B4F2' ],
|
---|
144 | [ 'Aquarius 5', '#487ED4' ],
|
---|
145 | [ 'Absinthe', '#A8CF76' ],
|
---|
146 | [ 'Scrambled Egg', '#C7A622' ],
|
---|
147 | [ 'Hello monday', '#8E8D80' ],
|
---|
148 | [ 'Lovely sunshine', '#F1E8B1' ],
|
---|
149 | [ 'Recycled air', '#B3C593' ],
|
---|
150 | [ 'Down', '#BCBCA4' ],
|
---|
151 | [ 'Mark Twain', '#CFE91D' ],
|
---|
152 | [ 'Specks of dust', '#D1B596' ],
|
---|
153 | [ 'Lollipop', '#F6CE23' ]
|
---|
154 | ],
|
---|
155 | onChange : function()
|
---|
156 | {
|
---|
157 | var color = this.getValue();
|
---|
158 | if ( color )
|
---|
159 | {
|
---|
160 | setNewPickerColor( color );
|
---|
161 | setNewUiColor( color );
|
---|
162 | // Refresh predefined preview box.
|
---|
163 | CKEDITOR.document.getById( 'predefinedPreview' ).setStyle( 'background', color );
|
---|
164 | }
|
---|
165 | else
|
---|
166 | CKEDITOR.document.getById( 'predefinedPreview' ).setStyle( 'background', '' );
|
---|
167 | },
|
---|
168 | onShow : function()
|
---|
169 | {
|
---|
170 | var color = editor.getUiColor();
|
---|
171 | if ( color )
|
---|
172 | this.setValue( color );
|
---|
173 | }
|
---|
174 | },
|
---|
175 | {
|
---|
176 | id : 'predefinedPreview',
|
---|
177 | type : 'html',
|
---|
178 | html : '<div id="cke_uicolor_preview" style="border: 1px solid black; padding: 3px; width: 30px;">' +
|
---|
179 | '<div id="predefinedPreview" style="width: 30px; height: 30px;"> </div>' +
|
---|
180 | '</div>'
|
---|
181 | }
|
---|
182 | ]
|
---|
183 | },
|
---|
184 | {
|
---|
185 | id : 'configBox',
|
---|
186 | type : 'text',
|
---|
187 | label : editor.lang.uicolor.config,
|
---|
188 | onShow : function()
|
---|
189 | {
|
---|
190 | var color = editor.getUiColor();
|
---|
191 | if ( color )
|
---|
192 | this.setValue(
|
---|
193 | 'config.uiColor = "' + color + '"'
|
---|
194 | );
|
---|
195 | }
|
---|
196 | }
|
---|
197 | ]
|
---|
198 | }
|
---|
199 | ]
|
---|
200 | }
|
---|
201 | ],
|
---|
202 | buttons : [ CKEDITOR.dialog.okButton ]
|
---|
203 | };
|
---|
204 | } );
|
---|