2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
6 CKEDITOR
.skins
.add( 'kama', (function()
8 var uiColorStylesheetId
= 'cke_ui_color';
11 editor
: { css
: [ 'editor.css' ] },
12 dialog
: { css
: [ 'dialog.css' ] },
13 richcombo
: { canGroup
: false },
14 templates
: { css
: [ 'templates.css' ] },
15 margins
: [ 0, 0, 0, 0 ],
16 init : function( editor
)
18 if ( editor
.config
.width
&& !isNaN( editor
.config
.width
) )
19 editor
.config
.width
-= 12;
21 var uiColorMenus
= [];
22 var uiColorRegex
= /\$color/g;
23 var uiColorMenuCss
= "/* UI Color Support */\
24 .cke_skin_kama .cke_menuitem .cke_icon_wrapper\
26 background-color: $color !important;\
27 border-color: $color !important;\
30 .cke_skin_kama .cke_menuitem a:hover .cke_icon_wrapper,\
31 .cke_skin_kama .cke_menuitem a:focus .cke_icon_wrapper,\
32 .cke_skin_kama .cke_menuitem a:active .cke_icon_wrapper\
34 background-color: $color !important;\
35 border-color: $color !important;\
38 .cke_skin_kama .cke_menuitem a:hover .cke_label,\
39 .cke_skin_kama .cke_menuitem a:focus .cke_label,\
40 .cke_skin_kama .cke_menuitem a:active .cke_label\
42 background-color: $color !important;\
45 .cke_skin_kama .cke_menuitem a.cke_disabled:hover .cke_label,\
46 .cke_skin_kama .cke_menuitem a.cke_disabled:focus .cke_label,\
47 .cke_skin_kama .cke_menuitem a.cke_disabled:active .cke_label\
49 background-color: transparent !important;\
52 .cke_skin_kama .cke_menuitem a.cke_disabled:hover .cke_icon_wrapper,\
53 .cke_skin_kama .cke_menuitem a.cke_disabled:focus .cke_icon_wrapper,\
54 .cke_skin_kama .cke_menuitem a.cke_disabled:active .cke_icon_wrapper\
56 background-color: $color !important;\
57 border-color: $color !important;\
60 .cke_skin_kama .cke_menuitem a.cke_disabled .cke_icon_wrapper\
62 background-color: $color !important;\
63 border-color: $color !important;\
66 .cke_skin_kama .cke_menuseparator\
68 background-color: $color !important;\
71 .cke_skin_kama .cke_menuitem a:hover,\
72 .cke_skin_kama .cke_menuitem a:focus,\
73 .cke_skin_kama .cke_menuitem a:active\
75 background-color: $color !important;\
77 // We have to split CSS declarations for webkit.
78 if ( CKEDITOR
.env
.webkit
)
80 uiColorMenuCss
= uiColorMenuCss
.split( '}' ).slice( 0, -1 );
81 for ( var i
= 0 ; i
< uiColorMenuCss
.length
; i
++ )
82 uiColorMenuCss
[ i
] = uiColorMenuCss
[ i
].split( '{' );
85 function getStylesheet( document
)
87 var node
= document
.getById( uiColorStylesheetId
);
90 node
= document
.getHead().append( 'style' );
91 node
.setAttribute( "id", uiColorStylesheetId
);
92 node
.setAttribute( "type", "text/css" );
97 function updateStylesheets( styleNodes
, styleContent
, replace
)
100 for ( var id
= 0 ; id
< styleNodes
.length
; id
++ )
102 if ( CKEDITOR
.env
.webkit
)
104 for ( i
= 0 ; i
< styleContent
.length
; i
++ )
106 content
= styleContent
[ i
][ 1 ];
107 for ( r
= 0 ; r
< replace
.length
; r
++ )
108 content
= content
.replace( replace
[ r
][ 0 ], replace
[ r
][ 1 ] );
110 styleNodes
[ id
].$.sheet
.addRule( styleContent
[ i
][ 0 ], content
);
115 content
= styleContent
;
116 for ( r
= 0 ; r
< replace
.length
; r
++ )
117 content
= content
.replace( replace
[ r
][ 0 ], replace
[ r
][ 1 ] );
119 if ( CKEDITOR
.env
.ie
)
120 styleNodes
[ id
].$.styleSheet
.cssText
+= content
;
122 styleNodes
[ id
].$.innerHTML
+= content
;
127 var uiColorRegexp
= /\$color/g;
129 CKEDITOR
.tools
.extend( editor
,
133 getUiColor : function()
138 setUiColor : function( color
)
141 uiStyle
= getStylesheet( CKEDITOR
.document
),
142 cssId
= '.' + editor
.id
;
146 cssId
+ " .cke_wrapper",
147 cssId
+ "_dialog .cke_dialog_contents",
148 cssId
+ "_dialog a.cke_dialog_tab",
149 cssId
+ "_dialog .cke_dialog_footer"
151 var cssProperties
= "background-color: $color !important;";
153 if ( CKEDITOR
.env
.webkit
)
154 cssContent
= [ [ cssSelectors
, cssProperties
] ];
156 cssContent
= cssSelectors
+ '{' + cssProperties
+ '}';
158 return ( this.setUiColor
=
161 var replace
= [ [ uiColorRegexp
, color
] ];
162 editor
.uiColor
= color
;
164 // Update general style.
165 updateStylesheets( [ uiStyle
], cssContent
, replace
);
167 // Update menu styles.
168 updateStylesheets( uiColorMenus
, uiColorMenuCss
, replace
);
173 editor
.on( 'menuShow', function( event
)
175 var panel
= event
.data
[ 0 ];
176 var iframe
= panel
.element
.getElementsByTag( 'iframe' ).getItem( 0 ).getFrameDocument();
178 // Add stylesheet if missing.
179 if ( !iframe
.getById( 'cke_ui_color' ) )
181 var node
= getStylesheet( iframe
);
182 uiColorMenus
.push( node
);
184 var color
= editor
.getUiColor();
185 // Set uiColor for new menu.
187 updateStylesheets( [ node
], uiColorMenuCss
, [ [ uiColorRegexp
, color
] ] );
191 // Apply UI color if specified in config.
192 if ( editor
.config
.uiColor
)
193 editor
.setUiColor( editor
.config
.uiColor
);
200 CKEDITOR
.dialog
? dialogSetup() : CKEDITOR
.on( 'dialogPluginReady', dialogSetup
);
202 function dialogSetup()
204 CKEDITOR
.dialog
.on( 'resize', function( evt
)
208 height
= data
.height
,
209 dialog
= data
.dialog
,
210 contents
= dialog
.parts
.contents
;
212 if ( data
.skin
!= 'kama' )
217 width
: width
+ 'px',
218 height
: height
+ 'px'
225 * The base user interface color to be used by the editor. Not all skins are
226 * compatible with this setting.
227 * @name CKEDITOR.config.uiColor
229 * @default '' (empty)
231 * // Using a color code.
232 * config.uiColor = '#AADC6E';
234 * // Using an HTML color name.
235 * config.uiColor = 'Gold';