--- /dev/null
+/*\r
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
+For licensing, see LICENSE.html or http://ckeditor.com/license\r
+*/\r
+\r
+CKEDITOR.dialog.add( 'uicolor', function( editor )\r
+{\r
+ var dialog, picker, pickerContents,\r
+ // Actual UI color value.\r
+ uiColor = editor.getUiColor();\r
+\r
+ function setNewPickerColor( color )\r
+ {\r
+ // Convert HEX representation to RGB, stripping # char.\r
+ if ( /^#/.test( color ) )\r
+ color = window.YAHOO.util.Color.hex2rgb( color.substr( 1 ) );\r
+ picker.setValue( color, true );\r
+ // Refresh picker UI.\r
+ picker.refresh( 'cke_uicolor_picker' );\r
+ }\r
+\r
+ function setNewUiColor( color, force )\r
+ {\r
+ if ( force || dialog._.contents.tab1.livePeview.getValue() )\r
+ editor.setUiColor( color );\r
+ // Write new config string into textbox.\r
+ dialog._.contents.tab1.configBox.setValue(\r
+ 'config.uiColor = "#' + picker.get( "hex" ) + '"'\r
+ );\r
+ }\r
+\r
+ pickerContents =\r
+ {\r
+ id : 'yuiColorPicker',\r
+ type : 'html',\r
+ html : "<div id='cke_uicolor_picker' style='width: 360px; height: 200px; position: relative;'></div>",\r
+ onLoad : function( event )\r
+ {\r
+ var url = CKEDITOR.getUrl(\r
+ 'plugins/uicolor/yui/'\r
+ );\r
+\r
+ // Create new color picker widget.\r
+ picker = new window.YAHOO.widget.ColorPicker( "cke_uicolor_picker",\r
+ {\r
+ showhsvcontrols : true,\r
+ showhexcontrols : true,\r
+ images :\r
+ {\r
+ PICKER_THUMB : url + "assets/picker_thumb.png",\r
+ HUE_THUMB : url + "assets/hue_thumb.png"\r
+ }\r
+ });\r
+\r
+ // Set actual UI color to the picker.\r
+ if ( uiColor )\r
+ setNewPickerColor( uiColor );\r
+\r
+ // Subscribe to the rgbChange event.\r
+ picker.on( "rgbChange", function()\r
+ {\r
+ // Reset predefined box.\r
+ dialog._.contents.tab1.predefined.setValue( '' );\r
+ setNewUiColor( '#' + picker.get( 'hex' ) );\r
+ });\r
+\r
+ // Fix input class names.\r
+ var inputs = new CKEDITOR.dom.nodeList( picker.getElementsByTagName( 'input' ) );\r
+ for ( var i = 0; i < inputs.count() ; i++ )\r
+ inputs.getItem( i ).addClass( 'cke_dialog_ui_input_text' );\r
+ }\r
+ };\r
+\r
+ var skipPreviewChange = true;\r
+\r
+ return {\r
+ title : editor.lang.uicolor.title,\r
+ minWidth : 360,\r
+ minHeight : 320,\r
+ onLoad : function()\r
+ {\r
+ dialog = this;\r
+ this.setupContent();\r
+\r
+ // #3808\r
+ if ( CKEDITOR.env.ie7Compat )\r
+ dialog.parts.contents.setStyle( 'overflow', 'hidden' );\r
+ },\r
+ contents : [\r
+ {\r
+ id : 'tab1',\r
+ label : '',\r
+ title : '',\r
+ expand : true,\r
+ padding : 0,\r
+ elements : [\r
+ pickerContents,\r
+ {\r
+ id : 'tab1',\r
+ type : 'vbox',\r
+ children :\r
+ [\r
+ {\r
+ id : 'livePeview',\r
+ type : 'checkbox',\r
+ label : editor.lang.uicolor.preview,\r
+ 'default' : 1,\r
+ onLoad : function()\r
+ {\r
+ skipPreviewChange = true;\r
+ },\r
+ onChange : function()\r
+ {\r
+ if ( skipPreviewChange )\r
+ return;\r
+ var on = this.getValue(),\r
+ color = on ? '#' + picker.get( 'hex' ) : uiColor;\r
+ setNewUiColor( color, true );\r
+ }\r
+ },\r
+ {\r
+ type : 'hbox',\r
+ children :\r
+ [\r
+ {\r
+ id : 'predefined',\r
+ type : 'select',\r
+ 'default' : '',\r
+ label : editor.lang.uicolor.predefined,\r
+ items :\r
+ [\r
+ [ '' ],\r
+ [ 'Light blue', '#9AB8F3' ],\r
+ [ 'Sand', '#D2B48C' ],\r
+ [ 'Metallic', '#949AAA' ],\r
+ [ 'Purple', '#C2A3C7' ],\r
+ [ 'Olive', '#A2C980' ],\r
+ [ 'Happy green', '#9BD446' ],\r
+ [ 'Jezebel Blue', '#14B8C4' ],\r
+ [ 'Burn', '#FF893A' ],\r
+ [ 'Easy red', '#FF6969' ],\r
+ [ 'Pisces 3', '#48B4F2' ],\r
+ [ 'Aquarius 5', '#487ED4' ],\r
+ [ 'Absinthe', '#A8CF76' ],\r
+ [ 'Scrambled Egg', '#C7A622' ],\r
+ [ 'Hello monday', '#8E8D80' ],\r
+ [ 'Lovely sunshine', '#F1E8B1' ],\r
+ [ 'Recycled air', '#B3C593' ],\r
+ [ 'Down', '#BCBCA4' ],\r
+ [ 'Mark Twain', '#CFE91D' ],\r
+ [ 'Specks of dust', '#D1B596' ],\r
+ [ 'Lollipop', '#F6CE23' ]\r
+ ],\r
+ onChange : function()\r
+ {\r
+ var color = this.getValue();\r
+ if ( color )\r
+ {\r
+ setNewPickerColor( color );\r
+ setNewUiColor( color );\r
+ // Refresh predefined preview box.\r
+ CKEDITOR.document.getById( 'predefinedPreview' ).setStyle( 'background', color );\r
+ }\r
+ else\r
+ CKEDITOR.document.getById( 'predefinedPreview' ).setStyle( 'background', '' );\r
+ },\r
+ onShow : function()\r
+ {\r
+ var color = editor.getUiColor();\r
+ if ( color )\r
+ this.setValue( color );\r
+ }\r
+ },\r
+ {\r
+ id : 'predefinedPreview',\r
+ type : 'html',\r
+ html : '<div id="cke_uicolor_preview" style="border: 1px solid black; padding: 3px; width: 30px;">' +\r
+ '<div id="predefinedPreview" style="width: 30px; height: 30px;"> </div>' +\r
+ '</div>'\r
+ }\r
+ ]\r
+ },\r
+ {\r
+ id : 'configBox',\r
+ type : 'text',\r
+ label : editor.lang.uicolor.config,\r
+ onShow : function()\r
+ {\r
+ var color = editor.getUiColor();\r
+ if ( color )\r
+ this.setValue(\r
+ 'config.uiColor = "' + color + '"'\r
+ );\r
+ }\r
+ }\r
+ ]\r
+ }\r
+ ]\r
+ }\r
+ ],\r
+ buttons : [ CKEDITOR.dialog.okButton ]\r
+ };\r
+} );\r