JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.1
[ckeditor.git] / _source / plugins / table / dialogs / table.js
1 /*\r
2 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license\r
4 */\r
5 \r
6 (function()\r
7 {\r
8         var widthPattern = /^(\d+(?:\.\d+)?)(px|%)$/,\r
9                 heightPattern = /^(\d+(?:\.\d+)?)px$/;\r
10 \r
11         var commitValue = function( data )\r
12         {\r
13                 var id = this.id;\r
14                 if ( !data.info )\r
15                         data.info = {};\r
16                 data.info[id] = this.getValue();\r
17         };\r
18 \r
19         function tableDialog( editor, command )\r
20         {\r
21                 var makeElement = function( name ){ return new CKEDITOR.dom.element( name, editor.document ); };\r
22 \r
23                 return {\r
24                         title : editor.lang.table.title,\r
25                         minWidth : 310,\r
26                         minHeight : CKEDITOR.env.ie ? 310 : 280,\r
27                         onShow : function()\r
28                         {\r
29                                 // Detect if there's a selected table.\r
30                                 var selection = editor.getSelection(),\r
31                                         ranges = selection.getRanges(),\r
32                                         selectedTable = null;\r
33 \r
34                                 var rowsInput = this.getContentElement( 'info', 'txtRows' ),\r
35                                         colsInput = this.getContentElement( 'info', 'txtCols' ),\r
36                                         widthInput = this.getContentElement( 'info', 'txtWidth' );\r
37                                 if ( command == 'tableProperties' )\r
38                                 {\r
39                                         if ( ( selectedTable = editor.getSelection().getSelectedElement() ) )\r
40                                         {\r
41                                                 if ( selectedTable.getName() != 'table' )\r
42                                                         selectedTable = null;\r
43                                         }\r
44                                         else if ( ranges.length > 0 )\r
45                                         {\r
46                                                 var rangeRoot = ranges[0].getCommonAncestor( true );\r
47                                                 selectedTable = rangeRoot.getAscendant( 'table', true );\r
48                                         }\r
49 \r
50                                         // Save a reference to the selected table, and push a new set of default values.\r
51                                         this._.selectedElement = selectedTable;\r
52                                 }\r
53 \r
54                                 // Enable, disable and select the row, cols, width fields.\r
55                                 if ( selectedTable )\r
56                                 {\r
57                                         this.setupContent( selectedTable );\r
58                                         rowsInput && rowsInput.disable();\r
59                                         colsInput && colsInput.disable();\r
60                                         widthInput && widthInput.select();\r
61                                 }\r
62                                 else\r
63                                 {\r
64                                         rowsInput && rowsInput.enable();\r
65                                         colsInput && colsInput.enable();\r
66                                         rowsInput && rowsInput.select();\r
67                                 }\r
68                         },\r
69                         onOk : function()\r
70                         {\r
71                                 if ( this._.selectedElement )\r
72                                 {\r
73                                         var selection = editor.getSelection(),\r
74                                                 bms = editor.getSelection().createBookmarks();\r
75                                 }\r
76 \r
77                                 var table = this._.selectedElement || makeElement( 'table' ),\r
78                                         me = this,\r
79                                         data = {};\r
80 \r
81                                 this.commitContent( data, table );\r
82 \r
83                                 if ( data.info )\r
84                                 {\r
85                                         var info = data.info;\r
86 \r
87                                         // Generate the rows and cols.\r
88                                         if ( !this._.selectedElement )\r
89                                         {\r
90                                                 var tbody = table.append( makeElement( 'tbody' ) ),\r
91                                                         rows = parseInt( info.txtRows, 10 ) || 0,\r
92                                                         cols = parseInt( info.txtCols, 10 ) || 0;\r
93 \r
94                                                 for ( var i = 0 ; i < rows ; i++ )\r
95                                                 {\r
96                                                         var row = tbody.append( makeElement( 'tr' ) );\r
97                                                         for ( var j = 0 ; j < cols ; j++ )\r
98                                                         {\r
99                                                                 var cell = row.append( makeElement( 'td' ) );\r
100                                                                 if ( !CKEDITOR.env.ie )\r
101                                                                         cell.append( makeElement( 'br' ) );\r
102                                                         }\r
103                                                 }\r
104                                         }\r
105 \r
106                                         // Modify the table headers. Depends on having rows and cols generated\r
107                                         // correctly so it can't be done in commit functions.\r
108 \r
109                                         // Should we make a <thead>?\r
110                                         var headers = info.selHeaders;\r
111                                         if ( !table.$.tHead && ( headers == 'row' || headers == 'both' ) )\r
112                                         {\r
113                                                 var thead = new CKEDITOR.dom.element( table.$.createTHead() );\r
114                                                 tbody = table.getElementsByTag( 'tbody' ).getItem( 0 );\r
115                                                 var theRow = tbody.getElementsByTag( 'tr' ).getItem( 0 );\r
116 \r
117                                                 // Change TD to TH:\r
118                                                 for ( i = 0 ; i < theRow.getChildCount() ; i++ )\r
119                                                 {\r
120                                                         var th = theRow.getChild( i );\r
121                                                         if ( th.type == CKEDITOR.NODE_ELEMENT )\r
122                                                         {\r
123                                                                 th.renameNode( 'th' );\r
124                                                                 th.setAttribute( 'scope', 'col' );\r
125                                                         }\r
126                                                 }\r
127                                                 thead.append( theRow.remove() );\r
128                                         }\r
129 \r
130                                         if ( table.$.tHead !== null && !( headers == 'row' || headers == 'both' ) )\r
131                                         {\r
132                                                 // Move the row out of the THead and put it in the TBody:\r
133                                                 thead = new CKEDITOR.dom.element( table.$.tHead );\r
134                                                 tbody = table.getElementsByTag( 'tbody' ).getItem( 0 );\r
135 \r
136                                                 var previousFirstRow = tbody.getFirst();\r
137                                                 while ( thead.getChildCount() > 0 )\r
138                                                 {\r
139                                                         theRow = thead.getFirst();\r
140                                                         for ( i = 0; i < theRow.getChildCount() ; i++ )\r
141                                                         {\r
142                                                                 var newCell = theRow.getChild( i );\r
143                                                                 if ( newCell.type == CKEDITOR.NODE_ELEMENT )\r
144                                                                 {\r
145                                                                         newCell.renameNode( 'td' );\r
146                                                                         newCell.removeAttribute( 'scope' );\r
147                                                                 }\r
148                                                         }\r
149                                                         theRow.insertBefore( previousFirstRow );\r
150                                                 }\r
151                                                 thead.remove();\r
152                                         }\r
153 \r
154                                         // Should we make all first cells in a row TH?\r
155                                         if ( !this.hasColumnHeaders && ( headers == 'col' || headers == 'both' ) )\r
156                                         {\r
157                                                 for( row = 0 ; row < table.$.rows.length ; row++ )\r
158                                                 {\r
159                                                         newCell = new CKEDITOR.dom.element( table.$.rows[ row ].cells[ 0 ] );\r
160                                                         newCell.renameNode( 'th' );\r
161                                                         newCell.setAttribute( 'scope', 'row' );\r
162                                                 }\r
163                                         }\r
164 \r
165                                         // Should we make all first TH-cells in a row make TD? If 'yes' we do it the other way round :-)\r
166                                         if ( ( this.hasColumnHeaders ) && !( headers == 'col' || headers == 'both' ) )\r
167                                         {\r
168                                                 for( i = 0 ; i < table.$.rows.length ; i++ )\r
169                                                 {\r
170                                                         row = new CKEDITOR.dom.element( table.$.rows[i] );\r
171                                                         if ( row.getParent().getName() == 'tbody' )\r
172                                                         {\r
173                                                                 newCell = new CKEDITOR.dom.element( row.$.cells[0] );\r
174                                                                 newCell.renameNode( 'td' );\r
175                                                                 newCell.removeAttribute( 'scope' );\r
176                                                         }\r
177                                                 }\r
178                                         }\r
179 \r
180                                         // Set the width and height.\r
181                                         var styles = [];\r
182                                         if ( info.txtHeight )\r
183                                                 table.setStyle( 'height', CKEDITOR.tools.cssLength( info.txtHeight ) );\r
184                                         else\r
185                                                 table.removeStyle( 'height' );\r
186 \r
187                                         if ( info.txtWidth )\r
188                                         {\r
189                                                 var type = info.cmbWidthType || 'pixels';\r
190                                                 table.setStyle( 'width', info.txtWidth + ( type == 'pixels' ? 'px' : '%' ) );\r
191                                         }\r
192                                         else\r
193                                                 table.removeStyle( 'width' );\r
194 \r
195                                         if( !table.getAttribute( 'style' ) )\r
196                                                 table.removeAttribute( 'style' );\r
197                                 }\r
198 \r
199                                 // Insert the table element if we're creating one.\r
200                                 if ( !this._.selectedElement )\r
201                                         editor.insertElement( table );\r
202                                 // Properly restore the selection inside table. (#4822)\r
203                                 else\r
204                                         selection.selectBookmarks( bms );\r
205 \r
206                                 return true;\r
207                         },\r
208                         contents : [\r
209                                 {\r
210                                         id : 'info',\r
211                                         label : editor.lang.table.title,\r
212                                         elements :\r
213                                         [\r
214                                                 {\r
215                                                         type : 'hbox',\r
216                                                         widths : [ null, null ],\r
217                                                         styles : [ 'vertical-align:top' ],\r
218                                                         children :\r
219                                                         [\r
220                                                                 {\r
221                                                                         type : 'vbox',\r
222                                                                         padding : 0,\r
223                                                                         children :\r
224                                                                         [\r
225                                                                                 {\r
226                                                                                         type : 'text',\r
227                                                                                         id : 'txtRows',\r
228                                                                                         'default' : 3,\r
229                                                                                         label : editor.lang.table.rows,\r
230                                                                                         style : 'width:5em',\r
231                                                                                         validate : function()\r
232                                                                                         {\r
233                                                                                                 var pass = true,\r
234                                                                                                         value = this.getValue();\r
235                                                                                                 pass = pass && CKEDITOR.dialog.validate.integer()( value )\r
236                                                                                                         && value > 0;\r
237                                                                                                 if ( !pass )\r
238                                                                                                 {\r
239                                                                                                         alert( editor.lang.table.invalidRows );\r
240                                                                                                         this.select();\r
241                                                                                                 }\r
242                                                                                                 return pass;\r
243                                                                                         },\r
244                                                                                         setup : function( selectedElement )\r
245                                                                                         {\r
246                                                                                                 this.setValue( selectedElement.$.rows.length );\r
247                                                                                         },\r
248                                                                                         commit : commitValue\r
249                                                                                 },\r
250                                                                                 {\r
251                                                                                         type : 'text',\r
252                                                                                         id : 'txtCols',\r
253                                                                                         'default' : 2,\r
254                                                                                         label : editor.lang.table.columns,\r
255                                                                                         style : 'width:5em',\r
256                                                                                         validate : function()\r
257                                                                                         {\r
258                                                                                                 var pass = true,\r
259                                                                                                         value = this.getValue();\r
260                                                                                                 pass = pass && CKEDITOR.dialog.validate.integer()( value )\r
261                                                                                                         && value > 0;\r
262                                                                                                 if ( !pass )\r
263                                                                                                 {\r
264                                                                                                         alert( editor.lang.table.invalidCols );\r
265                                                                                                         this.select();\r
266                                                                                                 }\r
267                                                                                                 return pass;\r
268                                                                                         },\r
269                                                                                         setup : function( selectedTable )\r
270                                                                                         {\r
271                                                                                                 this.setValue( selectedTable.$.rows[0].cells.length);\r
272                                                                                         },\r
273                                                                                         commit : commitValue\r
274                                                                                 },\r
275                                                                                 {\r
276                                                                                         type : 'html',\r
277                                                                                         html : '&nbsp;'\r
278                                                                                 },\r
279                                                                                 {\r
280                                                                                         type : 'select',\r
281                                                                                         id : 'selHeaders',\r
282                                                                                         'default' : '',\r
283                                                                                         label : editor.lang.table.headers,\r
284                                                                                         items :\r
285                                                                                         [\r
286                                                                                                 [ editor.lang.table.headersNone, '' ],\r
287                                                                                                 [ editor.lang.table.headersRow, 'row' ],\r
288                                                                                                 [ editor.lang.table.headersColumn, 'col' ],\r
289                                                                                                 [ editor.lang.table.headersBoth, 'both' ]\r
290                                                                                         ],\r
291                                                                                         setup : function( selectedTable )\r
292                                                                                         {\r
293                                                                                                 // Fill in the headers field.\r
294                                                                                                 var dialog = this.getDialog();\r
295                                                                                                 dialog.hasColumnHeaders = true;\r
296 \r
297                                                                                                 // Check if all the first cells in every row are TH\r
298                                                                                                 for ( var row = 0 ; row < selectedTable.$.rows.length ; row++ )\r
299                                                                                                 {\r
300                                                                                                         // If just one cell isn't a TH then it isn't a header column\r
301                                                                                                         if ( selectedTable.$.rows[row].cells[0].nodeName.toLowerCase() != 'th' )\r
302                                                                                                         {\r
303                                                                                                                 dialog.hasColumnHeaders = false;\r
304                                                                                                                 break;\r
305                                                                                                         }\r
306                                                                                                 }\r
307 \r
308                                                                                                 // Check if the table contains <thead>.\r
309                                                                                                 if ( ( selectedTable.$.tHead !== null) )\r
310                                                                                                         this.setValue( dialog.hasColumnHeaders ? 'both' : 'row' );\r
311                                                                                                 else\r
312                                                                                                         this.setValue( dialog.hasColumnHeaders ? 'col' : '' );\r
313                                                                                         },\r
314                                                                                         commit : commitValue\r
315                                                                                 },\r
316                                                                                 {\r
317                                                                                         type : 'text',\r
318                                                                                         id : 'txtBorder',\r
319                                                                                         'default' : 1,\r
320                                                                                         label : editor.lang.table.border,\r
321                                                                                         style : 'width:3em',\r
322                                                                                         validate : CKEDITOR.dialog.validate['number']( editor.lang.table.invalidBorder ),\r
323                                                                                         setup : function( selectedTable )\r
324                                                                                         {\r
325                                                                                                 this.setValue( selectedTable.getAttribute( 'border' ) || '' );\r
326                                                                                         },\r
327                                                                                         commit : function( data, selectedTable )\r
328                                                                                         {\r
329                                                                                                 if ( this.getValue() )\r
330                                                                                                         selectedTable.setAttribute( 'border', this.getValue() );\r
331                                                                                                 else\r
332                                                                                                         selectedTable.removeAttribute( 'border' );\r
333                                                                                         }\r
334                                                                                 },\r
335                                                                                 {\r
336                                                                                         id : 'cmbAlign',\r
337                                                                                         type : 'select',\r
338                                                                                         'default' : '',\r
339                                                                                         label : editor.lang.table.align,\r
340                                                                                         items :\r
341                                                                                         [\r
342                                                                                                 [ editor.lang.table.alignNotSet , ''],\r
343                                                                                                 [ editor.lang.table.alignLeft , 'left'],\r
344                                                                                                 [ editor.lang.table.alignCenter , 'center'],\r
345                                                                                                 [ editor.lang.table.alignRight , 'right']\r
346                                                                                         ],\r
347                                                                                         setup : function( selectedTable )\r
348                                                                                         {\r
349                                                                                                 this.setValue( selectedTable.getAttribute( 'align' ) || '' );\r
350                                                                                         },\r
351                                                                                         commit : function( data, selectedTable )\r
352                                                                                         {\r
353                                                                                                 if ( this.getValue() )\r
354                                                                                                         selectedTable.setAttribute( 'align', this.getValue() );\r
355                                                                                                 else\r
356                                                                                                         selectedTable.removeAttribute( 'align' );\r
357                                                                                         }\r
358                                                                                 }\r
359                                                                         ]\r
360                                                                 },\r
361                                                                 {\r
362                                                                         type : 'vbox',\r
363                                                                         padding : 0,\r
364                                                                         children :\r
365                                                                         [\r
366                                                                                 {\r
367                                                                                         type : 'hbox',\r
368                                                                                         widths : [ '5em' ],\r
369                                                                                         children :\r
370                                                                                         [\r
371                                                                                                 {\r
372                                                                                                         type : 'text',\r
373                                                                                                         id : 'txtWidth',\r
374                                                                                                         style : 'width:5em',\r
375                                                                                                         label : editor.lang.table.width,\r
376                                                                                                         'default' : 200,\r
377                                                                                                         validate : CKEDITOR.dialog.validate['number']( editor.lang.table.invalidWidth ),\r
378                                                                                                         setup : function( selectedTable )\r
379                                                                                                         {\r
380                                                                                                                 var widthMatch = widthPattern.exec( selectedTable.$.style.width );\r
381                                                                                                                 if ( widthMatch )\r
382                                                                                                                         this.setValue( widthMatch[1] );\r
383                                                                                                         },\r
384                                                                                                         commit : commitValue\r
385                                                                                                 },\r
386                                                                                                 {\r
387                                                                                                         id : 'cmbWidthType',\r
388                                                                                                         type : 'select',\r
389                                                                                                         label : '&nbsp;',\r
390                                                                                                         'default' : 'pixels',\r
391                                                                                                         items :\r
392                                                                                                         [\r
393                                                                                                                 [ editor.lang.table.widthPx , 'pixels'],\r
394                                                                                                                 [ editor.lang.table.widthPc , 'percents']\r
395                                                                                                         ],\r
396                                                                                                         setup : function( selectedTable )\r
397                                                                                                         {\r
398                                                                                                                 var widthMatch = widthPattern.exec( selectedTable.$.style.width );\r
399                                                                                                                 if ( widthMatch )\r
400                                                                                                                         this.setValue( widthMatch[2] == 'px' ? 'pixels' : 'percents' );\r
401                                                                                                         },\r
402                                                                                                         commit : commitValue\r
403                                                                                                 }\r
404                                                                                         ]\r
405                                                                                 },\r
406                                                                                 {\r
407                                                                                         type : 'hbox',\r
408                                                                                         widths : [ '5em' ],\r
409                                                                                         children :\r
410                                                                                         [\r
411                                                                                                 {\r
412                                                                                                         type : 'text',\r
413                                                                                                         id : 'txtHeight',\r
414                                                                                                         style : 'width:5em',\r
415                                                                                                         label : editor.lang.table.height,\r
416                                                                                                         'default' : '',\r
417                                                                                                         validate : CKEDITOR.dialog.validate['number']( editor.lang.table.invalidHeight ),\r
418                                                                                                         setup : function( selectedTable )\r
419                                                                                                         {\r
420                                                                                                                 var heightMatch = heightPattern.exec( selectedTable.$.style.height );\r
421                                                                                                                 if ( heightMatch )\r
422                                                                                                                         this.setValue( heightMatch[1] );\r
423                                                                                                         },\r
424                                                                                                         commit : commitValue\r
425                                                                                                 },\r
426                                                                                                 {\r
427                                                                                                         type : 'html',\r
428                                                                                                         html : '<br />' + editor.lang.table.widthPx\r
429                                                                                                 }\r
430                                                                                         ]\r
431                                                                                 },\r
432                                                                                 {\r
433                                                                                         type : 'html',\r
434                                                                                         html : '&nbsp;'\r
435                                                                                 },\r
436                                                                                 {\r
437                                                                                         type : 'text',\r
438                                                                                         id : 'txtCellSpace',\r
439                                                                                         style : 'width:3em',\r
440                                                                                         label : editor.lang.table.cellSpace,\r
441                                                                                         'default' : 1,\r
442                                                                                         validate : CKEDITOR.dialog.validate['number']( editor.lang.table.invalidCellSpacing ),\r
443                                                                                         setup : function( selectedTable )\r
444                                                                                         {\r
445                                                                                                 this.setValue( selectedTable.getAttribute( 'cellSpacing' ) || '' );\r
446                                                                                         },\r
447                                                                                         commit : function( data, selectedTable )\r
448                                                                                         {\r
449                                                                                                 if ( this.getValue() )\r
450                                                                                                         selectedTable.setAttribute( 'cellSpacing', this.getValue() );\r
451                                                                                                 else\r
452                                                                                                         selectedTable.removeAttribute( 'cellSpacing' );\r
453                                                                                         }\r
454                                                                                 },\r
455                                                                                 {\r
456                                                                                         type : 'text',\r
457                                                                                         id : 'txtCellPad',\r
458                                                                                         style : 'width:3em',\r
459                                                                                         label : editor.lang.table.cellPad,\r
460                                                                                         'default' : 1,\r
461                                                                                         validate : CKEDITOR.dialog.validate['number']( editor.lang.table.invalidCellPadding ),\r
462                                                                                         setup : function( selectedTable )\r
463                                                                                         {\r
464                                                                                                 this.setValue( selectedTable.getAttribute( 'cellPadding' ) || '' );\r
465                                                                                         },\r
466                                                                                         commit : function( data, selectedTable )\r
467                                                                                         {\r
468                                                                                                 if ( this.getValue() )\r
469                                                                                                         selectedTable.setAttribute( 'cellPadding', this.getValue() );\r
470                                                                                                 else\r
471                                                                                                         selectedTable.removeAttribute( 'cellPadding' );\r
472                                                                                         }\r
473                                                                                 }\r
474                                                                         ]\r
475                                                                 }\r
476                                                         ]\r
477                                                 },\r
478                                                 {\r
479                                                         type : 'html',\r
480                                                         align : 'right',\r
481                                                         html : ''\r
482                                                 },\r
483                                                 {\r
484                                                         type : 'vbox',\r
485                                                         padding : 0,\r
486                                                         children :\r
487                                                         [\r
488                                                                 {\r
489                                                                         type : 'text',\r
490                                                                         id : 'txtCaption',\r
491                                                                         label : editor.lang.table.caption,\r
492                                                                         setup : function( selectedTable )\r
493                                                                         {\r
494                                                                                 var nodeList = selectedTable.getElementsByTag( 'caption' );\r
495                                                                                 if ( nodeList.count() > 0 )\r
496                                                                                 {\r
497                                                                                         var caption = nodeList.getItem( 0 );\r
498                                                                                         caption = ( caption.getChild( 0 ) && caption.getChild( 0 ).getText() ) || '';\r
499                                                                                         caption = CKEDITOR.tools.trim( caption );\r
500                                                                                         this.setValue( caption );\r
501                                                                                 }\r
502                                                                         },\r
503                                                                         commit : function( data, table )\r
504                                                                         {\r
505                                                                                 var caption = this.getValue(),\r
506                                                                                         captionElement = table.getElementsByTag( 'caption' );\r
507                                                                                 if ( caption )\r
508                                                                                 {\r
509                                                                                         if ( captionElement.count() > 0 )\r
510                                                                                         {\r
511                                                                                                 captionElement = captionElement.getItem( 0 );\r
512                                                                                                 captionElement.setHtml( '' );\r
513                                                                                         }\r
514                                                                                         else\r
515                                                                                         {\r
516                                                                                                 captionElement = new CKEDITOR.dom.element( 'caption', editor.document );\r
517                                                                                                 if ( table.getChildCount() )\r
518                                                                                                         captionElement.insertBefore( table.getFirst() );\r
519                                                                                                 else\r
520                                                                                                         captionElement.appendTo( table );\r
521                                                                                         }\r
522                                                                                         captionElement.append( new CKEDITOR.dom.text( caption, editor.document ) );\r
523                                                                                 }\r
524                                                                                 else if ( captionElement.count() > 0 )\r
525                                                                                 {\r
526                                                                                         for ( var i = captionElement.count() - 1 ; i >= 0 ; i-- )\r
527                                                                                                 captionElement.getItem( i ).remove();\r
528                                                                                 }\r
529                                                                         }\r
530                                                                 },\r
531                                                                 {\r
532                                                                         type : 'text',\r
533                                                                         id : 'txtSummary',\r
534                                                                         label : editor.lang.table.summary,\r
535                                                                         setup : function( selectedTable )\r
536                                                                         {\r
537                                                                                 this.setValue( selectedTable.getAttribute( 'summary' ) || '' );\r
538                                                                         },\r
539                                                                         commit : function( data, selectedTable )\r
540                                                                         {\r
541                                                                                 if ( this.getValue() )\r
542                                                                                         selectedTable.setAttribute( 'summary', this.getValue() );\r
543                                                                         }\r
544                                                                 }\r
545                                                         ]\r
546                                                 }\r
547                                         ]\r
548                                 }\r
549                         ]\r
550                 };\r
551         }\r
552 \r
553         CKEDITOR.dialog.add( 'table', function( editor )\r
554                 {\r
555                         return tableDialog( editor, 'table' );\r
556                 } );\r
557         CKEDITOR.dialog.add( 'tableProperties', function( editor )\r
558                 {\r
559                         return tableDialog( editor, 'tableProperties' );\r
560                 } );\r
561 })();\r