X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Ftable%2Fdialogs%2Ftable.js;h=38652d4a4d75a9158bbf7ab702f7b9a318aba371;hb=8665a7c6c60586526e32e8941fe2896739b6ebfb;hp=461e36e64c7c0a96042d9f82a489b9f270a6e6f6;hpb=8761695d9b70afe75905deaac88f78c1f8aeb32d;p=ckeditor.git
diff --git a/_source/plugins/table/dialogs/table.js b/_source/plugins/table/dialogs/table.js
index 461e36e..38652d4 100644
--- a/_source/plugins/table/dialogs/table.js
+++ b/_source/plugins/table/dialogs/table.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
@@ -43,6 +43,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
}
else if ( ranges.length > 0 )
{
+ // Webkit could report the following range on cell selection (#4948):
+ //
]
+ if ( CKEDITOR.env.webkit )
+ ranges[ 0 ].shrink( CKEDITOR.NODE_ELEMENT );
+
var rangeRoot = ranges[0].getCommonAncestor( true );
selectedTable = rangeRoot.getAscendant( 'table', true );
}
@@ -68,6 +73,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
},
onOk : function()
{
+ if ( this._.selectedElement )
+ {
+ var selection = editor.getSelection(),
+ bms = editor.getSelection().createBookmarks();
+ }
+
var table = this._.selectedElement || makeElement( 'table' ),
me = this,
data = {};
@@ -148,7 +159,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
// Should we make all first cells in a row TH?
if ( !this.hasColumnHeaders && ( headers == 'col' || headers == 'both' ) )
{
- for( row = 0 ; row < table.$.rows.length ; row++ )
+ for ( row = 0 ; row < table.$.rows.length ; row++ )
{
newCell = new CKEDITOR.dom.element( table.$.rows[ row ].cells[ 0 ] );
newCell.renameNode( 'th' );
@@ -159,7 +170,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
// Should we make all first TH-cells in a row make TD? If 'yes' we do it the other way round :-)
if ( ( this.hasColumnHeaders ) && !( headers == 'col' || headers == 'both' ) )
{
- for( i = 0 ; i < table.$.rows.length ; i++ )
+ for ( i = 0 ; i < table.$.rows.length ; i++ )
{
row = new CKEDITOR.dom.element( table.$.rows[i] );
if ( row.getParent().getName() == 'tbody' )
@@ -174,22 +185,28 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
// Set the width and height.
var styles = [];
if ( info.txtHeight )
- styles.push( 'height:' + info.txtHeight + 'px' );
+ table.setStyle( 'height', CKEDITOR.tools.cssLength( info.txtHeight ) );
+ else
+ table.removeStyle( 'height' );
+
if ( info.txtWidth )
{
var type = info.cmbWidthType || 'pixels';
- styles.push( 'width:' + info.txtWidth + ( type == 'pixels' ? 'px' : '%' ) );
+ table.setStyle( 'width', info.txtWidth + ( type == 'pixels' ? 'px' : '%' ) );
}
- styles = styles.join( ';' );
- if ( styles )
- table.$.style.cssText = styles;
else
+ table.removeStyle( 'width' );
+
+ if ( !table.getAttribute( 'style' ) )
table.removeAttribute( 'style' );
}
// Insert the table element if we're creating one.
if ( !this._.selectedElement )
editor.insertElement( table );
+ // Properly restore the selection inside table. (#4822)
+ else
+ selection.selectBookmarks( bms );
return true;
},
@@ -327,7 +344,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
label : editor.lang.table.align,
items :
[
- [ editor.lang.table.alignNotSet , ''],
+ [ editor.lang.common.notSet , ''],
[ editor.lang.table.alignLeft , 'left'],
[ editor.lang.table.alignCenter , 'center'],
[ editor.lang.table.alignRight , 'right']
@@ -363,18 +380,33 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
label : editor.lang.table.width,
'default' : 200,
validate : CKEDITOR.dialog.validate['number']( editor.lang.table.invalidWidth ),
+
+ // Extra labelling of width unit type.
+ onLoad : function()
+ {
+ var widthType = this.getDialog().getContentElement( 'info', 'cmbWidthType' ),
+ labelElement = widthType.getElement(),
+ inputElement = this.getInputElement(),
+ ariaLabelledByAttr = inputElement.getAttribute( 'aria-labelledby' );
+
+ inputElement.setAttribute( 'aria-labelledby', [ ariaLabelledByAttr, labelElement.$.id ].join( ' ' ) );
+ },
+
setup : function( selectedTable )
{
var widthMatch = widthPattern.exec( selectedTable.$.style.width );
if ( widthMatch )
this.setValue( widthMatch[1] );
+ else
+ this.setValue( '' );
},
commit : commitValue
},
{
id : 'cmbWidthType',
type : 'select',
- label : ' ',
+ label : editor.lang.table.widthUnit,
+ labelStyle: 'visibility:hidden',
'default' : 'pixels',
items :
[
@@ -403,6 +435,18 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
label : editor.lang.table.height,
'default' : '',
validate : CKEDITOR.dialog.validate['number']( editor.lang.table.invalidHeight ),
+
+ // Extra labelling of height unit type.
+ onLoad : function()
+ {
+ var heightType = this.getDialog().getContentElement( 'info', 'htmlHeightType' ),
+ labelElement = heightType.getElement(),
+ inputElement = this.getInputElement(),
+ ariaLabelledByAttr = inputElement.getAttribute( 'aria-labelledby' );
+
+ inputElement.setAttribute( 'aria-labelledby', [ ariaLabelledByAttr, labelElement.$.id ].join( ' ' ) );
+ },
+
setup : function( selectedTable )
{
var heightMatch = heightPattern.exec( selectedTable.$.style.height );
@@ -412,8 +456,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
commit : commitValue
},
{
+ id : 'htmlHeightType',
type : 'html',
- html : '
' + editor.lang.table.widthPx
+ html : '
' + editor.lang.table.widthPx + '
'
}
]
},
@@ -528,6 +573,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
if ( this.getValue() )
selectedTable.setAttribute( 'summary', this.getValue() );
+ else
+ selectedTable.removeAttribute( 'summary' );
}
}
]