[3019] | 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.skins.add( 'kama', (function()
|
---|
| 7 | {
|
---|
| 8 | var preload = [];
|
---|
| 9 |
|
---|
| 10 | if ( CKEDITOR.env.ie && CKEDITOR.env.version < 7 )
|
---|
| 11 | {
|
---|
| 12 | // For IE6, we need to preload some images, otherwhise they will be
|
---|
| 13 | // downloaded several times (CSS background bug).
|
---|
| 14 | preload.push( 'icons.png', 'images/sprites_ie6.png', 'images/dialog_sides.gif' );
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | return {
|
---|
| 18 | preload : preload,
|
---|
| 19 | editor : { css : [ 'editor.css' ] },
|
---|
| 20 | dialog : { css : [ 'dialog.css' ] },
|
---|
| 21 | templates : { css : [ 'templates.css' ] },
|
---|
| 22 | margins : [ 0, 0, 0, 0 ],
|
---|
| 23 | init : function( editor )
|
---|
| 24 | {
|
---|
| 25 | if ( editor.config.width && !isNaN( editor.config.width ) )
|
---|
| 26 | editor.config.width -= 12;
|
---|
| 27 |
|
---|
| 28 | var uiColorMenus = [];
|
---|
| 29 | var uiColorRegex = /\$color/g;
|
---|
| 30 | var uiColorMenuCss = "/* UI Color Support */\
|
---|
| 31 | .cke_skin_kama .cke_menuitem .cke_icon_wrapper\
|
---|
| 32 | {\
|
---|
| 33 | background-color: $color !important;\
|
---|
| 34 | border-color: $color !important;\
|
---|
| 35 | }\
|
---|
| 36 | \
|
---|
| 37 | .cke_skin_kama .cke_menuitem a:hover .cke_icon_wrapper,\
|
---|
| 38 | .cke_skin_kama .cke_menuitem a:focus .cke_icon_wrapper,\
|
---|
| 39 | .cke_skin_kama .cke_menuitem a:active .cke_icon_wrapper\
|
---|
| 40 | {\
|
---|
| 41 | background-color: $color !important;\
|
---|
| 42 | border-color: $color !important;\
|
---|
| 43 | }\
|
---|
| 44 | \
|
---|
| 45 | .cke_skin_kama .cke_menuitem a:hover .cke_label,\
|
---|
| 46 | .cke_skin_kama .cke_menuitem a:focus .cke_label,\
|
---|
| 47 | .cke_skin_kama .cke_menuitem a:active .cke_label\
|
---|
| 48 | {\
|
---|
| 49 | background-color: $color !important;\
|
---|
| 50 | }\
|
---|
| 51 | \
|
---|
| 52 | .cke_skin_kama .cke_menuitem a.cke_disabled:hover .cke_label,\
|
---|
| 53 | .cke_skin_kama .cke_menuitem a.cke_disabled:focus .cke_label,\
|
---|
| 54 | .cke_skin_kama .cke_menuitem a.cke_disabled:active .cke_label\
|
---|
| 55 | {\
|
---|
| 56 | background-color: transparent !important;\
|
---|
| 57 | }\
|
---|
| 58 | \
|
---|
| 59 | .cke_skin_kama .cke_menuitem a.cke_disabled:hover .cke_icon_wrapper,\
|
---|
| 60 | .cke_skin_kama .cke_menuitem a.cke_disabled:focus .cke_icon_wrapper,\
|
---|
| 61 | .cke_skin_kama .cke_menuitem a.cke_disabled:active .cke_icon_wrapper\
|
---|
| 62 | {\
|
---|
| 63 | background-color: $color !important;\
|
---|
| 64 | border-color: $color !important;\
|
---|
| 65 | }\
|
---|
| 66 | \
|
---|
| 67 | .cke_skin_kama .cke_menuitem a.cke_disabled .cke_icon_wrapper\
|
---|
| 68 | {\
|
---|
| 69 | background-color: $color !important;\
|
---|
| 70 | border-color: $color !important;\
|
---|
| 71 | }\
|
---|
| 72 | \
|
---|
| 73 | .cke_skin_kama .cke_menuseparator\
|
---|
| 74 | {\
|
---|
| 75 | background-color: $color !important;\
|
---|
| 76 | }\
|
---|
| 77 | \
|
---|
| 78 | .cke_skin_kama .cke_menuitem a:hover,\
|
---|
| 79 | .cke_skin_kama .cke_menuitem a:focus,\
|
---|
| 80 | .cke_skin_kama .cke_menuitem a:active\
|
---|
| 81 | {\
|
---|
| 82 | background-color: $color !important;\
|
---|
| 83 | }";
|
---|
| 84 | // We have to split CSS declarations for webkit.
|
---|
| 85 | if ( CKEDITOR.env.webkit )
|
---|
| 86 | {
|
---|
| 87 | uiColorMenuCss = uiColorMenuCss.split( '}' ).slice( 0, -1 );
|
---|
| 88 | for ( var i = 0 ; i < uiColorMenuCss.length ; i++ )
|
---|
| 89 | uiColorMenuCss[ i ] = uiColorMenuCss[ i ].split( '{' );
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | function addStylesheet( document )
|
---|
| 93 | {
|
---|
| 94 | var node = document.getHead().append( 'style' );
|
---|
| 95 | node.setAttribute( "id", "cke_ui_color" );
|
---|
| 96 | node.setAttribute( "type", "text/css" );
|
---|
| 97 |
|
---|
| 98 | return node;
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | function updateStylesheets( styleNodes, styleContent, replace )
|
---|
| 102 | {
|
---|
| 103 | var r, i, content;
|
---|
| 104 | for ( var id = 0 ; id < styleNodes.length ; id++ )
|
---|
| 105 | {
|
---|
| 106 | if ( CKEDITOR.env.webkit )
|
---|
| 107 | {
|
---|
| 108 | // Truncate manually.
|
---|
| 109 | for ( i = 0 ; i < styleNodes[ id ].$.sheet.rules.length ; i++ )
|
---|
| 110 | styleNodes[ id ].$.sheet.removeRule( i );
|
---|
| 111 |
|
---|
| 112 | for ( i = 0 ; i < styleContent.length ; i++ )
|
---|
| 113 | {
|
---|
| 114 | content = styleContent[ i ][ 1 ];
|
---|
| 115 | for ( r = 0 ; r < replace.length ; r++ )
|
---|
| 116 | content = content.replace( replace[ r ][ 0 ], replace[ r ][ 1 ] );
|
---|
| 117 |
|
---|
| 118 | styleNodes[ id ].$.sheet.addRule( styleContent[ i ][ 0 ], content );
|
---|
| 119 | }
|
---|
| 120 | }
|
---|
| 121 | else
|
---|
| 122 | {
|
---|
| 123 | content = styleContent;
|
---|
| 124 | for ( r = 0 ; r < replace.length ; r++ )
|
---|
| 125 | content = content.replace( replace[ r ][ 0 ], replace[ r ][ 1 ] );
|
---|
| 126 |
|
---|
| 127 | if ( CKEDITOR.env.ie )
|
---|
| 128 | styleNodes[ id ].$.styleSheet.cssText = content;
|
---|
| 129 | else
|
---|
| 130 | styleNodes[ id ].setHtml( content );
|
---|
| 131 | }
|
---|
| 132 | }
|
---|
| 133 | }
|
---|
| 134 |
|
---|
| 135 | var uiColorRegexp = /\$color/g;
|
---|
| 136 |
|
---|
| 137 | CKEDITOR.tools.extend( editor,
|
---|
| 138 | {
|
---|
| 139 | uiColor: null,
|
---|
| 140 |
|
---|
| 141 | getUiColor : function()
|
---|
| 142 | {
|
---|
| 143 | return this.uiColor;
|
---|
| 144 | },
|
---|
| 145 |
|
---|
| 146 | setUiColor : function( color )
|
---|
| 147 | {
|
---|
| 148 | var cssContent,
|
---|
| 149 | uiStyle = addStylesheet( CKEDITOR.document ),
|
---|
| 150 | cssId = '#cke_' + editor.name.replace('.', '\\.');
|
---|
| 151 |
|
---|
| 152 | var cssSelectors =
|
---|
| 153 | [
|
---|
| 154 | cssId + " .cke_wrapper",
|
---|
| 155 | cssId + "_dialog .cke_dialog_contents",
|
---|
| 156 | cssId + "_dialog a.cke_dialog_tab",
|
---|
| 157 | cssId + "_dialog .cke_dialog_footer"
|
---|
| 158 | ].join( ',' );
|
---|
| 159 | var cssProperties = "background-color: $color !important;";
|
---|
| 160 |
|
---|
| 161 | if ( CKEDITOR.env.webkit )
|
---|
| 162 | cssContent = [ [ cssSelectors, cssProperties ] ];
|
---|
| 163 | else
|
---|
| 164 | cssContent = cssSelectors + '{' + cssProperties + '}';
|
---|
| 165 |
|
---|
| 166 | return ( this.setUiColor =
|
---|
| 167 | function( color )
|
---|
| 168 | {
|
---|
| 169 | var replace = [ [ uiColorRegexp, color ] ];
|
---|
| 170 | editor.uiColor = color;
|
---|
| 171 |
|
---|
| 172 | // Update general style.
|
---|
| 173 | updateStylesheets( [ uiStyle ], cssContent, replace );
|
---|
| 174 |
|
---|
| 175 | // Update menu styles.
|
---|
| 176 | updateStylesheets( uiColorMenus, uiColorMenuCss, replace );
|
---|
| 177 | })( color );
|
---|
| 178 | }
|
---|
| 179 | });
|
---|
| 180 |
|
---|
| 181 | editor.on( 'menuShow', function( event )
|
---|
| 182 | {
|
---|
| 183 | var panel = event.data[ 0 ];
|
---|
| 184 | var iframe = panel.element.getElementsByTag( 'iframe' ).getItem( 0 ).getFrameDocument();
|
---|
| 185 |
|
---|
| 186 | // Add stylesheet if missing.
|
---|
| 187 | if ( !iframe.getById( 'cke_ui_color' ) )
|
---|
| 188 | {
|
---|
| 189 | var node = addStylesheet( iframe );
|
---|
| 190 | uiColorMenus.push( node );
|
---|
| 191 |
|
---|
| 192 | var color = editor.getUiColor();
|
---|
| 193 | // Set uiColor for new menu.
|
---|
| 194 | if ( color )
|
---|
| 195 | updateStylesheets( [ node ], uiColorMenuCss, [ [ uiColorRegexp, color ] ] );
|
---|
| 196 | }
|
---|
| 197 | });
|
---|
| 198 |
|
---|
| 199 | // Apply UI color if specified in config.
|
---|
| 200 | if ( editor.config.uiColor )
|
---|
| 201 | editor.setUiColor( editor.config.uiColor );
|
---|
| 202 | }
|
---|
| 203 | };
|
---|
| 204 | })() );
|
---|
| 205 |
|
---|
| 206 | if ( CKEDITOR.dialog )
|
---|
| 207 | {
|
---|
| 208 | CKEDITOR.dialog.on( 'resize', function( evt )
|
---|
| 209 | {
|
---|
| 210 | var data = evt.data,
|
---|
| 211 | width = data.width,
|
---|
| 212 | height = data.height,
|
---|
| 213 | dialog = data.dialog,
|
---|
| 214 | contents = dialog.parts.contents,
|
---|
| 215 | standardsMode = !CKEDITOR.env.quirks;
|
---|
| 216 |
|
---|
| 217 | if ( data.skin != 'kama' )
|
---|
| 218 | return;
|
---|
| 219 |
|
---|
| 220 | contents.setStyles(
|
---|
| 221 | ( CKEDITOR.env.ie || ( CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 ) ) ? // IE && FF2
|
---|
| 222 | {
|
---|
| 223 | width : width + 'px',
|
---|
| 224 | height : height + 'px'
|
---|
| 225 | }
|
---|
| 226 | :
|
---|
| 227 | {
|
---|
| 228 | // To avoid having scrollbars in the dialogs, we're
|
---|
| 229 | // (for now) using the "min-xxx" properties, for
|
---|
| 230 | // browsers which well support it (#3878).
|
---|
| 231 | 'min-width' : width + 'px',
|
---|
| 232 | 'min-height' : height + 'px'
|
---|
| 233 | });
|
---|
| 234 |
|
---|
| 235 | if ( !CKEDITOR.env.ie )
|
---|
| 236 | return;
|
---|
| 237 |
|
---|
| 238 | // Fix the size of the elements which have flexible lengths.
|
---|
| 239 | setTimeout( function()
|
---|
| 240 | {
|
---|
| 241 | var body = contents.getParent(),
|
---|
| 242 | innerDialog = body.getParent();
|
---|
| 243 |
|
---|
| 244 | // tc
|
---|
| 245 | var el = innerDialog.getChild( 2 );
|
---|
| 246 | el.setStyle( 'width', ( body.$.offsetWidth ) + 'px' );
|
---|
| 247 |
|
---|
| 248 | // bc
|
---|
| 249 | el = innerDialog.getChild( 7 );
|
---|
| 250 | el.setStyle( 'width', ( body.$.offsetWidth - 28 ) + 'px' );
|
---|
| 251 |
|
---|
| 252 | // ml
|
---|
| 253 | el = innerDialog.getChild( 4 );
|
---|
| 254 | el.setStyle( 'height', ( body.$.offsetHeight - 31 - 14 ) + 'px' );
|
---|
| 255 |
|
---|
| 256 | // mr
|
---|
| 257 | el = innerDialog.getChild( 5 );
|
---|
| 258 | el.setStyle( 'height', ( body.$.offsetHeight - 31 - 14 ) + 'px' );
|
---|
| 259 | },
|
---|
| 260 | 100 );
|
---|
| 261 | });
|
---|
| 262 | }
|
---|
| 263 |
|
---|
| 264 | /**
|
---|
| 265 | * The base user interface color to be used by the editor. Not all skins are
|
---|
| 266 | * compatible with this setting.
|
---|
| 267 | * @name CKEDITOR.config.uiColor
|
---|
| 268 | * @type String
|
---|
| 269 | * @default '' (empty)
|
---|
| 270 | * @example
|
---|
| 271 | * // Using a color code.
|
---|
| 272 | * config.uiColor = '#AADC6E';
|
---|
| 273 | * @example
|
---|
| 274 | * // Using an HTML color name.
|
---|
| 275 | * config.uiColor = 'Gold';
|
---|
| 276 | */
|
---|