JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.0.1
[ckeditor.git] / _source / plugins / tabletools / dialogs / tableCell.js
index ad03aa4..1491a24 100644 (file)
@@ -18,10 +18,63 @@ CKEDITOR.dialog.add( 'cellProperties', function( editor )
                        return { type : 'html', html : ' ' };\r
                }\r
 \r
+               /**\r
+                *\r
+                * @param dialogName\r
+                * @param callback [ childDialog ]\r
+                */\r
+               function getDialogValue( dialogName, callback )\r
+               {\r
+                       var onOk = function()\r
+                       {\r
+                               releaseHandlers( this );\r
+                               callback( this );\r
+                       };\r
+                       var onCancel = function()\r
+                       {\r
+                               releaseHandlers( this );\r
+                       };\r
+                       var bindToDialog = function( dialog )\r
+                       {\r
+                               dialog.on( 'ok', onOk );\r
+                               dialog.on( 'cancel', onCancel );\r
+                       };\r
+                       var releaseHandlers = function( dialog )\r
+                       {\r
+                               dialog.removeListener( 'ok', onOk );\r
+                               dialog.removeListener( 'cancel', onCancel );\r
+                       };\r
+                       editor.execCommand( dialogName );\r
+                       if ( editor._.storedDialogs.colordialog )\r
+                               bindToDialog( editor._.storedDialogs.colordialog );\r
+                       else\r
+                       {\r
+                               CKEDITOR.on( 'dialogDefinition', function( e )\r
+                               {\r
+                                       if ( e.data.name != dialogName )\r
+                                               return;\r
+\r
+                                       var definition = e.data.definition;\r
+\r
+                                       e.removeListener();\r
+                                       definition.onLoad = CKEDITOR.tools.override( definition.onLoad, function( orginal )\r
+                                       {\r
+                                               return function()\r
+                                               {\r
+                                                       bindToDialog( this );\r
+                                                       definition.onLoad = orginal;\r
+                                                       if ( typeof orginal == 'function' )\r
+                                                               orginal.call( this );\r
+                                               };\r
+                                       } );\r
+                               });\r
+                       }\r
+               }\r
+\r
                return {\r
                        title : langCell.title,\r
-                       minWidth : 480,\r
-                       minHeight : 140,\r
+                       minWidth : CKEDITOR.env.ie && CKEDITOR.env.quirks ? 550 : 480,\r
+                       minHeight : CKEDITOR.env.ie ? ( CKEDITOR.env.quirks ? 180 : 150 ) : 140,\r
                        contents : [\r
                                {\r
                                        id : 'info',\r
@@ -31,7 +84,7 @@ CKEDITOR.dialog.add( 'cellProperties', function( editor )
                                        [\r
                                                {\r
                                                        type : 'hbox',\r
-                                                       widths : [ '45%', '10%', '45%' ],\r
+                                                       widths : [ '40%', '5%', '40%' ],\r
                                                        children :\r
                                                        [\r
                                                                {\r
@@ -268,42 +321,91 @@ CKEDITOR.dialog.add( 'cellProperties', function( editor )
                                                                                },\r
                                                                                spacer(),\r
                                                                                {\r
-                                                                                       type : 'text',\r
-                                                                                       id : 'bgColor',\r
-                                                                                       label : langCell.bgColor,\r
-                                                                                       labelLayout : 'horizontal',\r
-                                                                                       widths : [ '50%', '50%' ],\r
-                                                                                       'default' : '',\r
-                                                                                       setup : function( selectedCell )\r
-                                                                                       {\r
-                                                                                               this.setValue( selectedCell.getAttribute( 'bgColor' ) || '' );\r
-                                                                                       },\r
-                                                                                       commit : function( selectedCell )\r
-                                                                                       {\r
-                                                                                               if ( this.getValue() )\r
-                                                                                                       selectedCell.setAttribute( 'bgColor', this.getValue() );\r
-                                                                                               else\r
-                                                                                                       selectedCell.removeAttribute( 'bgColor' );\r
-                                                                                       }\r
+                                                                                       type : 'hbox',\r
+                                                                                       padding : 0,\r
+                                                                                       widths : [ '80%', '20%' ],\r
+                                                                                       children :\r
+                                                                                       [\r
+                                                                                               {\r
+                                                                                                       type : 'text',\r
+                                                                                                       id : 'bgColor',\r
+                                                                                                       label : langCell.bgColor,\r
+                                                                                                       labelLayout : 'horizontal',\r
+                                                                                                       widths : [ '70%', '30%' ],\r
+                                                                                                       'default' : '',\r
+                                                                                                       setup : function( selectedCell )\r
+                                                                                                       {\r
+                                                                                                               this.setValue( selectedCell.getAttribute( 'bgColor' ) || '' );\r
+                                                                                                       },\r
+                                                                                                       commit : function( selectedCell )\r
+                                                                                                       {\r
+                                                                                                               if ( this.getValue() )\r
+                                                                                                                       selectedCell.setAttribute( 'bgColor', this.getValue() );\r
+                                                                                                               else\r
+                                                                                                                       selectedCell.removeAttribute( 'bgColor' );\r
+                                                                                                       }\r
+                                                                                               },\r
+                                                                                               {\r
+                                                                                                       type : 'button',\r
+                                                                                                       id : 'bgColorChoose',\r
+                                                                                                       label : langCell.chooseColor,\r
+                                                                                                       style : 'margin-left: 10px',\r
+                                                                                                       onClick : function()\r
+                                                                                                       {\r
+                                                                                                               var self = this;\r
+                                                                                                               getDialogValue( 'colordialog', function( colorDialog )\r
+                                                                                                               {\r
+                                                                                                                       self.getDialog().getContentElement( 'info', 'bgColor' ).setValue(\r
+                                                                                                                               colorDialog.getContentElement( 'picker', 'selectedColor' ).getValue()\r
+                                                                                                                       );\r
+                                                                                                               } );\r
+                                                                                                       }\r
+                                                                                               }\r
+                                                                                       ]\r
                                                                                },\r
+                                                                               spacer(),\r
                                                                                {\r
-                                                                                       type : 'text',\r
-                                                                                       id : 'borderColor',\r
-                                                                                       label : langCell.borderColor,\r
-                                                                                       labelLayout : 'horizontal',\r
-                                                                                       widths : [ '50%', '50%' ],\r
-                                                                                       'default' : '',\r
-                                                                                       setup : function( selectedCell )\r
-                                                                                       {\r
-                                                                                               this.setValue( selectedCell.getAttribute( 'borderColor' ) || '' );\r
-                                                                                       },\r
-                                                                                       commit : function( selectedCell )\r
-                                                                                       {\r
-                                                                                               if ( this.getValue() )\r
-                                                                                                       selectedCell.setAttribute( 'borderColor', this.getValue() );\r
-                                                                                               else\r
-                                                                                                       selectedCell.removeAttribute( 'borderColor' );\r
-                                                                                       }\r
+                                                                                       type : 'hbox',\r
+                                                                                       padding : 0,\r
+                                                                                       widths : [ '80%', '20%' ],\r
+                                                                                       children :\r
+                                                                                       [\r
+                                                                                               {\r
+                                                                                                       type : 'text',\r
+                                                                                                       id : 'borderColor',\r
+                                                                                                       label : langCell.borderColor,\r
+                                                                                                       labelLayout : 'horizontal',\r
+                                                                                                       widths : [ '70%', '30%' ],\r
+                                                                                                       'default' : '',\r
+                                                                                                       setup : function( selectedCell )\r
+                                                                                                       {\r
+                                                                                                               this.setValue( selectedCell.getStyle( 'border-color' ) || '' );\r
+                                                                                                       },\r
+                                                                                                       commit : function( selectedCell )\r
+                                                                                                       {\r
+                                                                                                               if ( this.getValue() )\r
+                                                                                                                       selectedCell.setStyle( 'border-color', this.getValue() );\r
+                                                                                                               else\r
+                                                                                                                       selectedCell.removeStyle( 'border-color' );\r
+                                                                                                       }\r
+                                                                                               },\r
+                                                                                               {\r
+                                                                                                       type : 'button',\r
+                                                                                                       id : 'borderColorChoose',\r
+                                                                                                       label : langCell.chooseColor,\r
+                                                                                                       style : 'margin-left: 10px',\r
+                                                                                                       onClick : function()\r
+                                                                                                       {\r
+                                                                                                               var self = this;\r
+                                                                                                               getDialogValue( 'colordialog', function( colorDialog )\r
+                                                                                                               {\r
+                                                                                                                       self.getDialog().getContentElement( 'info', 'borderColor' ).setValue(\r
+                                                                                                                               colorDialog.getContentElement( 'picker', 'selectedColor' ).getValue()\r
+                                                                                                                       );\r
+                                                                                                               } );\r
+                                                                                                       }\r
+                                                                                               }\r
+                                                                                       ]\r
                                                                                }\r
                                                                        ]\r
                                                                }\r