X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fshowborders%2Fplugin.js;h=e7e9eecfb321a62961ae712febe66fcdc80a6283;hb=055b6b0792ce7dc53d47af606b367c04b927c2ab;hp=4fc46b6b7f3f51fd55ed8c2a9bfc9a63a395a70b;hpb=c6e377a02b54abc07129d72b632763c727476a15;p=ckeditor.git diff --git a/_source/plugins/showborders/plugin.js b/_source/plugins/showborders/plugin.js index 4fc46b6..e7e9eec 100644 --- a/_source/plugins/showborders/plugin.js +++ b/_source/plugins/showborders/plugin.js @@ -83,6 +83,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( command.state != CKEDITOR.TRISTATE_DISABLED ) command.refresh( editor ); }); + + editor.on( 'removeFormatCleanup', function( evt ) + { + var element = evt.data; + if ( editor.getCommand( 'showborders' ).state == CKEDITOR.TRISTATE_ON && + element.is( 'table' ) && ( !element.hasAttribute( 'border' ) || parseInt( element.getAttribute( 'border' ), 10 ) <= 0 ) ) + element.addClass( showBorderClassName ); + }); }, afterInit : function( editor ) @@ -129,36 +137,33 @@ For licensing, see LICENSE.html or http://ckeditor.com/license } } ); } + } + }); - // Table dialog must be aware of it. - CKEDITOR.on( 'dialogDefinition', function( ev ) - { - if ( ev.editor != editor ) - return; + // Table dialog must be aware of it. + CKEDITOR.on( 'dialogDefinition', function( ev ) + { + var dialogName = ev.data.name; - var dialogName = ev.data.name; + if ( dialogName == 'table' || dialogName == 'tableProperties' ) + { + var dialogDefinition = ev.data.definition, + infoTab = dialogDefinition.getContents( 'info' ), + borderField = infoTab.get( 'txtBorder' ), + originalCommit = borderField.commit; - if ( dialogName == 'table' || dialogName == 'tableProperties' ) + borderField.commit = CKEDITOR.tools.override( originalCommit, function( org ) + { + return function( data, selectedTable ) { - var dialogDefinition = ev.data.definition, - infoTab = dialogDefinition.getContents( 'info' ), - borderField = infoTab.get( 'txtBorder' ), - originalCommit = borderField.commit; - - borderField.commit = CKEDITOR.tools.override( originalCommit, function( org ) - { - return function( data, selectedTable ) - { - org.apply( this, arguments ); - var value = parseInt( this.getValue(), 10 ); - selectedTable[ ( !value || value <= 0 ) ? 'addClass' : 'removeClass' ]( showBorderClassName ); - }; - } ); - } - }); + org.apply( this, arguments ); + var value = parseInt( this.getValue(), 10 ); + selectedTable[ ( !value || value <= 0 ) ? 'addClass' : 'removeClass' ]( showBorderClassName ); + }; + } ); } - }); + } )(); /**