/*\r
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
},\r
onOk : function()\r
{\r
+ if ( this._.selectedElement )\r
+ {\r
+ var selection = editor.getSelection(),\r
+ bms = editor.getSelection().createBookmarks();\r
+ }\r
+\r
var table = this._.selectedElement || makeElement( 'table' ),\r
me = this,\r
data = {};\r
}\r
}\r
\r
- // Modify the table headers. Depends on havint rows and cols generated\r
+ // Modify the table headers. Depends on having rows and cols generated\r
// correctly so it can't be done in commit functions.\r
\r
// Should we make a <thead>?\r
if ( th.type == CKEDITOR.NODE_ELEMENT )\r
{\r
th.renameNode( 'th' );\r
- if ( !i )\r
- th.setAttribute( 'scope', 'col' );\r
+ th.setAttribute( 'scope', 'col' );\r
}\r
}\r
thead.append( theRow.remove() );\r
// Should we make all first cells in a row TH?\r
if ( !this.hasColumnHeaders && ( headers == 'col' || headers == 'both' ) )\r
{\r
- for( row = 0 ; row < table.$.rows.length ; row++ )\r
+ for ( row = 0 ; row < table.$.rows.length ; row++ )\r
{\r
newCell = new CKEDITOR.dom.element( table.$.rows[ row ].cells[ 0 ] );\r
newCell.renameNode( 'th' );\r
- newCell.setAttribute( 'scope', 'col' );\r
+ newCell.setAttribute( 'scope', 'row' );\r
}\r
}\r
\r
// Should we make all first TH-cells in a row make TD? If 'yes' we do it the other way round :-)\r
if ( ( this.hasColumnHeaders ) && !( headers == 'col' || headers == 'both' ) )\r
{\r
- for( i = 0 ; i < table.$.rows.length ; i++ )\r
+ for ( i = 0 ; i < table.$.rows.length ; i++ )\r
{\r
row = new CKEDITOR.dom.element( table.$.rows[i] );\r
if ( row.getParent().getName() == 'tbody' )\r
{\r
newCell = new CKEDITOR.dom.element( row.$.cells[0] );\r
- newCell.renameNode( 'td');\r
+ newCell.renameNode( 'td' );\r
newCell.removeAttribute( 'scope' );\r
}\r
}\r
// Set the width and height.\r
var styles = [];\r
if ( info.txtHeight )\r
- styles.push( 'height:' + info.txtHeight + 'px' );\r
+ table.setStyle( 'height', CKEDITOR.tools.cssLength( info.txtHeight ) );\r
+ else\r
+ table.removeStyle( 'height' );\r
+\r
if ( info.txtWidth )\r
{\r
var type = info.cmbWidthType || 'pixels';\r
- styles.push( 'width:' + info.txtWidth + ( type == 'pixels' ? 'px' : '%' ) );\r
+ table.setStyle( 'width', info.txtWidth + ( type == 'pixels' ? 'px' : '%' ) );\r
}\r
- styles = styles.join( ';' );\r
- if ( styles )\r
- table.$.style.cssText = styles;\r
else\r
+ table.removeStyle( 'width' );\r
+\r
+ if ( !table.getAttribute( 'style' ) )\r
table.removeAttribute( 'style' );\r
}\r
\r
// Insert the table element if we're creating one.\r
if ( !this._.selectedElement )\r
editor.insertElement( table );\r
+ // Properly restore the selection inside table. (#4822)\r
+ else\r
+ selection.selectBookmarks( bms );\r
\r
return true;\r
},\r
var widthMatch = widthPattern.exec( selectedTable.$.style.width );\r
if ( widthMatch )\r
this.setValue( widthMatch[1] );\r
+ else\r
+ this.setValue( '' );\r
},\r
commit : commitValue\r
},\r