152d955cab4dd3f53eb31cd01112efad391be5a7.svn-base
6.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.skins.add( 'kama', (function()
{
var uiColorStylesheetId = 'cke_ui_color';
return {
editor : { css : [ 'editor.css' ] },
dialog : { css : [ 'dialog.css' ] },
richcombo : { canGroup: false },
templates : { css : [ 'templates.css' ] },
margins : [ 0, 0, 0, 0 ],
init : function( editor )
{
if ( editor.config.width && !isNaN( editor.config.width ) )
editor.config.width -= 12;
var uiColorMenus = [];
var uiColorRegex = /\$color/g;
var uiColorMenuCss = "/* UI Color Support */\
.cke_skin_kama .cke_menuitem .cke_icon_wrapper\
{\
background-color: $color !important;\
border-color: $color !important;\
}\
\
.cke_skin_kama .cke_menuitem a:hover .cke_icon_wrapper,\
.cke_skin_kama .cke_menuitem a:focus .cke_icon_wrapper,\
.cke_skin_kama .cke_menuitem a:active .cke_icon_wrapper\
{\
background-color: $color !important;\
border-color: $color !important;\
}\
\
.cke_skin_kama .cke_menuitem a:hover .cke_label,\
.cke_skin_kama .cke_menuitem a:focus .cke_label,\
.cke_skin_kama .cke_menuitem a:active .cke_label\
{\
background-color: $color !important;\
}\
\
.cke_skin_kama .cke_menuitem a.cke_disabled:hover .cke_label,\
.cke_skin_kama .cke_menuitem a.cke_disabled:focus .cke_label,\
.cke_skin_kama .cke_menuitem a.cke_disabled:active .cke_label\
{\
background-color: transparent !important;\
}\
\
.cke_skin_kama .cke_menuitem a.cke_disabled:hover .cke_icon_wrapper,\
.cke_skin_kama .cke_menuitem a.cke_disabled:focus .cke_icon_wrapper,\
.cke_skin_kama .cke_menuitem a.cke_disabled:active .cke_icon_wrapper\
{\
background-color: $color !important;\
border-color: $color !important;\
}\
\
.cke_skin_kama .cke_menuitem a.cke_disabled .cke_icon_wrapper\
{\
background-color: $color !important;\
border-color: $color !important;\
}\
\
.cke_skin_kama .cke_menuseparator\
{\
background-color: $color !important;\
}\
\
.cke_skin_kama .cke_menuitem a:hover,\
.cke_skin_kama .cke_menuitem a:focus,\
.cke_skin_kama .cke_menuitem a:active\
{\
background-color: $color !important;\
}";
// We have to split CSS declarations for webkit.
if ( CKEDITOR.env.webkit )
{
uiColorMenuCss = uiColorMenuCss.split( '}' ).slice( 0, -1 );
for ( var i = 0 ; i < uiColorMenuCss.length ; i++ )
uiColorMenuCss[ i ] = uiColorMenuCss[ i ].split( '{' );
}
function getStylesheet( document )
{
var node = document.getById( uiColorStylesheetId );
if ( !node )
{
node = document.getHead().append( 'style' );
node.setAttribute( "id", uiColorStylesheetId );
node.setAttribute( "type", "text/css" );
}
return node;
}
function updateStylesheets( styleNodes, styleContent, replace )
{
var r, i, content;
for ( var id = 0 ; id < styleNodes.length ; id++ )
{
if ( CKEDITOR.env.webkit )
{
for ( i = 0 ; i < styleContent.length ; i++ )
{
content = styleContent[ i ][ 1 ];
for ( r = 0 ; r < replace.length ; r++ )
content = content.replace( replace[ r ][ 0 ], replace[ r ][ 1 ] );
styleNodes[ id ].$.sheet.addRule( styleContent[ i ][ 0 ], content );
}
}
else
{
content = styleContent;
for ( r = 0 ; r < replace.length ; r++ )
content = content.replace( replace[ r ][ 0 ], replace[ r ][ 1 ] );
if ( CKEDITOR.env.ie )
styleNodes[ id ].$.styleSheet.cssText += content;
else
styleNodes[ id ].$.innerHTML += content;
}
}
}
var uiColorRegexp = /\$color/g;
CKEDITOR.tools.extend( editor,
{
uiColor: null,
getUiColor : function()
{
return this.uiColor;
},
setUiColor : function( color )
{
var cssContent,
uiStyle = getStylesheet( CKEDITOR.document ),
cssId = '.' + editor.id;
var cssSelectors =
[
cssId + " .cke_wrapper",
cssId + "_dialog .cke_dialog_contents",
cssId + "_dialog a.cke_dialog_tab",
cssId + "_dialog .cke_dialog_footer"
].join( ',' );
var cssProperties = "background-color: $color !important;";
if ( CKEDITOR.env.webkit )
cssContent = [ [ cssSelectors, cssProperties ] ];
else
cssContent = cssSelectors + '{' + cssProperties + '}';
return ( this.setUiColor =
function( color )
{
var replace = [ [ uiColorRegexp, color ] ];
editor.uiColor = color;
// Update general style.
updateStylesheets( [ uiStyle ], cssContent, replace );
// Update menu styles.
updateStylesheets( uiColorMenus, uiColorMenuCss, replace );
})( color );
}
});
editor.on( 'menuShow', function( event )
{
var panel = event.data[ 0 ];
var iframe = panel.element.getElementsByTag( 'iframe' ).getItem( 0 ).getFrameDocument();
// Add stylesheet if missing.
if ( !iframe.getById( 'cke_ui_color' ) )
{
var node = getStylesheet( iframe );
uiColorMenus.push( node );
var color = editor.getUiColor();
// Set uiColor for new menu.
if ( color )
updateStylesheets( [ node ], uiColorMenuCss, [ [ uiColorRegexp, color ] ] );
}
});
// Apply UI color if specified in config.
if ( editor.config.uiColor )
editor.setUiColor( editor.config.uiColor );
}
};
})() );
(function()
{
CKEDITOR.dialog ? dialogSetup() : CKEDITOR.on( 'dialogPluginReady', dialogSetup );
function dialogSetup()
{
CKEDITOR.dialog.on( 'resize', function( evt )
{
var data = evt.data,
width = data.width,
height = data.height,
dialog = data.dialog,
contents = dialog.parts.contents;
if ( data.skin != 'kama' )
return;
contents.setStyles(
{
width : width + 'px',
height : height + 'px'
});
});
}
})();
/**
* The base user interface color to be used by the editor. Not all skins are
* compatible with this setting.
* @name CKEDITOR.config.uiColor
* @type String
* @default '' (empty)
* @example
* // Using a color code.
* config.uiColor = '#AADC6E';
* @example
* // Using an HTML color name.
* config.uiColor = 'Gold';
*/