X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=_source%2Fplugins%2Ftable%2Fdialogs%2Ftable.js;h=55a45e1c15431cfb73bb5fe2f1bbed30648f0922;hb=e371ddf8abcb89013e20e6d0dd746adec344d0e5;hp=4675a0c6289f89ad0d218f392f8b8f5258cbbf1e;hpb=c6e377a02b54abc07129d72b632763c727476a15;p=ckeditor.git
diff --git a/_source/plugins/table/dialogs/table.js b/_source/plugins/table/dialogs/table.js
index 4675a0c..55a45e1 100644
--- a/_source/plugins/table/dialogs/table.js
+++ b/_source/plugins/table/dialogs/table.js
@@ -18,12 +18,62 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
function tableDialog( editor, command )
{
- var makeElement = function( name ){ return new CKEDITOR.dom.element( name, editor.document ); };
+ var makeElement = function( name )
+ {
+ return new CKEDITOR.dom.element( name, editor.document );
+ };
+
+ var dialogadvtab = editor.plugins.dialogadvtab;
return {
title : editor.lang.table.title,
minWidth : 310,
minHeight : CKEDITOR.env.ie ? 310 : 280,
+
+ onLoad : function()
+ {
+ var dialog = this,
+ isUpdating;
+
+ var styles = dialog.getContentElement( 'advanced', 'advStyles' );
+
+ if ( styles )
+ {
+ styles.on( 'change', function( evt )
+ {
+ if ( isUpdating )
+ return;
+
+ // Flag to avoid recursion.
+ isUpdating = 1;
+
+ // Synchronize width value.
+ var width = this.getStyle( 'width', '' ),
+ txtWidth = dialog.getContentElement( 'info', 'txtWidth' ),
+ cmbWidthType = dialog.getContentElement( 'info', 'cmbWidthType' ),
+ isPx = 1;
+
+ if ( width )
+ {
+ isPx = ( width.length < 3 || width.substr( width.length - 1 ) != '%' );
+ width = parseInt( width, 10 );
+ }
+
+ txtWidth && txtWidth.setValue( width );
+ cmbWidthType && cmbWidthType.setValue( isPx ? 'pixels' : 'percents' );
+
+ // Synchronize height value.
+ var height = this.getStyle( 'height', '' ),
+ txtHeight = dialog.getContentElement( 'info', 'txtHeight' );
+
+ height && ( height = parseInt( height, 10 ) );
+ txtHeight && txtHeight.setValue( height );
+
+ isUpdating = 0;
+ });
+ }
+ },
+
onShow : function()
{
// Detect if there's a selected table.
@@ -33,7 +83,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
var rowsInput = this.getContentElement( 'info', 'txtRows' ),
colsInput = this.getContentElement( 'info', 'txtCols' ),
- widthInput = this.getContentElement( 'info', 'txtWidth' );
+ widthInput = this.getContentElement( 'info', 'txtWidth' ),
+ heightInput = this.getContentElement( 'info', 'txtHeight' );
+
if ( command == 'tableProperties' )
{
if ( ( selectedTable = editor.getSelection().getSelectedElement() ) )
@@ -43,6 +95,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 );
}
@@ -65,6 +122,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
colsInput && colsInput.enable();
rowsInput && rowsInput.select();
}
+
+ // Call the onChange method for the widht and height fields so
+ // they get reflected into the Advanced tab.
+ widthInput && widthInput.onChange();
+ heightInput && heightInput.onChange();
},
onOk : function()
{
@@ -227,6 +289,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()
{
@@ -252,6 +315,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()
{
@@ -339,7 +403,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']
@@ -373,8 +437,35 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
id : 'txtWidth',
style : 'width:5em',
label : editor.lang.table.width,
- 'default' : 200,
+ 'default' : 500,
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( ' ' ) );
+ },
+
+ onChange : function()
+ {
+ var styles = this.getDialog().getContentElement( 'advanced', 'advStyles' );
+
+ if ( styles )
+ {
+ var value = this.getValue();
+
+ if ( value )
+ value += this.getDialog().getContentElement( 'info', 'cmbWidthType' ).getValue() == 'percents' ? '%' : 'px';
+
+ styles.updateStyle( 'width', value );
+ }
+ },
+
setup : function( selectedTable )
{
var widthMatch = widthPattern.exec( selectedTable.$.style.width );
@@ -388,7 +479,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
id : 'cmbWidthType',
type : 'select',
- label : ' ',
+ label : editor.lang.table.widthUnit,
+ labelStyle: 'visibility:hidden',
'default' : 'pixels',
items :
[
@@ -401,6 +493,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
if ( widthMatch )
this.setValue( widthMatch[2] == 'px' ? 'pixels' : 'percents' );
},
+ onChange : function()
+ {
+ this.getDialog().getContentElement( 'info', 'txtWidth' ).onChange();
+ },
commit : commitValue
}
]
@@ -417,6 +513,29 @@ 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( ' ' ) );
+ },
+
+ onChange : function()
+ {
+ var styles = this.getDialog().getContentElement( 'advanced', 'advStyles' );
+
+ if ( styles )
+ {
+ var value = this.getValue();
+ styles.updateStyle( 'height', value && ( value + 'px' ) );
+ }
+ },
+
setup : function( selectedTable )
{
var heightMatch = heightPattern.exec( selectedTable.$.style.height );
@@ -426,8 +545,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 + '
'
}
]
},
@@ -542,12 +662,15 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
if ( this.getValue() )
selectedTable.setAttribute( 'summary', this.getValue() );
+ else
+ selectedTable.removeAttribute( 'summary' );
}
}
]
}
]
- }
+ },
+ dialogadvtab && dialogadvtab.createAdvancedTab( editor )
]
};
}