X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Ftable%2Fdialogs%2Ftable.js;h=ddd47f5f4256b25049a1c304fc86b9d9d6fb8317;hb=055b6b0792ce7dc53d47af606b367c04b927c2ab;hp=6a082d25236bdc5db6fef0253952c1f90607bb0f;hpb=7cd80714081a8ffdf4a1a8d2c72f120ed5ef3d6d;p=ckeditor.git diff --git a/_source/plugins/table/dialogs/table.js b/_source/plugins/table/dialogs/table.js index 6a082d2..ddd47f5 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' ) @@ -186,13 +197,16 @@ For licensing, see LICENSE.html or http://ckeditor.com/license else table.removeStyle( 'width' ); - if( !table.getAttribute( 'style' ) ) + 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; }, @@ -218,6 +232,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license id : 'txtRows', 'default' : 3, label : editor.lang.table.rows, + required : true, style : 'width:5em', validate : function() { @@ -243,6 +258,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license id : 'txtCols', 'default' : 2, label : editor.lang.table.columns, + required : true, style : 'width:5em', validate : function() { @@ -330,7 +346,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'] @@ -366,18 +382,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 : [ @@ -406,6 +437,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 ); @@ -415,8 +458,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 + '
' } ] }, @@ -531,6 +575,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { if ( this.getValue() ) selectedTable.setAttribute( 'summary', this.getValue() ); + else + selectedTable.removeAttribute( 'summary' ); } } ]