X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Ftabletools%2Fdialogs%2FtableCell.js;h=1393e2460bc9a55dc40375ed7aab027ed4d1042a;hb=c9fdde67e6384bd5a66adc2b3bba5c4ce9db56c7;hp=074ee83b19be3ffb402f7b52c37e8db59542c31d;hpb=059b4c2fef02528bf1af189f7996e80652faddfb;p=ckeditor.git diff --git a/_source/plugins/tabletools/dialogs/tableCell.js b/_source/plugins/tabletools/dialogs/tableCell.js index 074ee83..1393e24 100644 --- a/_source/plugins/tabletools/dialogs/tableCell.js +++ b/_source/plugins/tabletools/dialogs/tableCell.js @@ -5,18 +5,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license CKEDITOR.dialog.add( 'cellProperties', function( editor ) { - var langTable = editor.lang.table; - var langCell = langTable.cell; - var langCommon = editor.lang.common; - var validate = CKEDITOR.dialog.validate; - var widthPattern = /^(\d+(?:\.\d+)?)(px|%)$/, - heightPattern = /^(\d+(?:\.\d+)?)px$/; - var bind = CKEDITOR.tools.bind; - - function spacer() - { - return { type : 'html', html : ' ' }; - } + var langTable = editor.lang.table, + langCell = langTable.cell, + langCommon = editor.lang.common, + validate = CKEDITOR.dialog.validate, + widthPattern = /^(\d+(?:\.\d+)?)(px|%)$/, + heightPattern = /^(\d+(?:\.\d+)?)px$/, + bind = CKEDITOR.tools.bind, + spacer = { type : 'html', html : ' ' }; /** * @@ -28,22 +24,24 @@ CKEDITOR.dialog.add( 'cellProperties', function( editor ) var onOk = function() { releaseHandlers( this ); - callback( this ); + callback( this, this._.parentDialog ); + this._.parentDialog.changeFocus( true ); }; var onCancel = function() { releaseHandlers( this ); - }; - var bindToDialog = function( dialog ) - { - dialog.on( 'ok', onOk ); - dialog.on( 'cancel', onCancel ); + this._.parentDialog.changeFocus(); }; var releaseHandlers = function( dialog ) { dialog.removeListener( 'ok', onOk ); dialog.removeListener( 'cancel', onCancel ); }; + var bindToDialog = function( dialog ) + { + dialog.on( 'ok', onOk ); + dialog.on( 'cancel', onCancel ); + }; editor.execCommand( dialogName ); if ( editor._.storedDialogs.colordialog ) bindToDialog( editor._.storedDialogs.colordialog ); @@ -153,7 +151,7 @@ CKEDITOR.dialog.add( 'cellProperties', function( editor ) ], setup : function( selectedCell ) { - var widthMatch = widthPattern.exec( selectedCell.$.style.width ); + var widthMatch = widthPattern.exec( selectedCell.getStyle( 'width' ) || selectedCell.getAttribute( 'width' ) ); if ( widthMatch ) this.setValue( widthMatch[2] ); } @@ -212,7 +210,7 @@ CKEDITOR.dialog.add( 'cellProperties', function( editor ) } ] }, - spacer(), + spacer, { type : 'select', id : 'wordWrap', @@ -243,7 +241,7 @@ CKEDITOR.dialog.add( 'cellProperties', function( editor ) element.removeAttribute( 'noWrap' ); } }, - spacer(), + spacer, { type : 'select', id : 'hAlign', @@ -325,7 +323,7 @@ CKEDITOR.dialog.add( 'cellProperties', function( editor ) } ] }, - spacer(), + spacer, { type : 'vbox', padding : 0, @@ -352,7 +350,7 @@ CKEDITOR.dialog.add( 'cellProperties', function( editor ) selectedCell.renameNode( this.getValue() ); } }, - spacer(), + spacer, { type : 'text', id : 'rowSpan', @@ -399,7 +397,7 @@ CKEDITOR.dialog.add( 'cellProperties', function( editor ) selectedCell.removeAttribute( 'colSpan' ); } }, - spacer(), + spacer, { type : 'hbox', padding : 0, @@ -450,7 +448,7 @@ CKEDITOR.dialog.add( 'cellProperties', function( editor ) } ] }, - spacer(), + spacer, { type : 'hbox', padding : 0, @@ -515,9 +513,21 @@ CKEDITOR.dialog.add( 'cellProperties', function( editor ) }, onOk : function() { + var selection = this._.editor.getSelection(), + bookmarks = selection.createBookmarks(); + var cells = this.cells; for ( var i = 0 ; i < cells.length ; i++ ) this.commitContent( cells[ i ] ); + + selection.selectBookmarks( bookmarks ); + + // Force selectionChange event because of alignment style. + var firstElement = selection.getStartElement(); + var currentPath = new CKEDITOR.dom.elementPath( firstElement ); + + this._.editor._.selectionPreviousPath = currentPath; + this._.editor.fire( 'selectionChange', { selection : selection, path : currentPath, element : firstElement } ); } }; } );