X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fbutton%2Fplugin.js;h=c0c8208b5c2a1c80cc7e2a46faec4a7eefd4c56c;hb=614511639979907ceb0da3614122a4d8eb963ad4;hp=f16e192aac50194667cdfaa9beaf7850c4d1aac5;hpb=055b6b0792ce7dc53d47af606b367c04b927c2ab;p=ckeditor.git diff --git a/_source/plugins/button/plugin.js b/_source/plugins/button/plugin.js index f16e192..c0c8208 100644 --- a/_source/plugins/button/plugin.js +++ b/_source/plugins/button/plugin.js @@ -70,7 +70,7 @@ CKEDITOR.ui.button.prototype = render : function( editor, output ) { var env = CKEDITOR.env, - id = this._.id = 'cke_' + CKEDITOR.tools.getNextNumber(), + id = this._.id = CKEDITOR.tools.getNextId(), classes = '', command = this.command, // Get the command name. clickFn, @@ -98,11 +98,22 @@ CKEDITOR.ui.button.prototype = instance.index = index = CKEDITOR.ui.button._.instances.push( instance ) - 1; + // Indicate a mode sensitive button. if ( this.modes ) { + var modeStates = {}; + editor.on( 'beforeModeUnload', function() + { + modeStates[ editor.mode ] = this._.state; + }, this ); + editor.on( 'mode', function() { - this.setState( this.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED ); + var mode = editor.mode; + // Restore saved button state. + this.setState( this.modes[ mode ] ? + modeStates[ mode ] != undefined ? modeStates[ mode ] : + CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED ); }, this); } else if ( command )