fckplugin.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Register the command.
  2. var FCKGlossary = function( name )
  3. {
  4. this.Name = name ;
  5. this.StyleName = '_FCK_Glossary' ;
  6. this.IsActive = false ;
  7. this.EditMode = FCK.EditMode;
  8. FCKStyles.AttachStyleStateChange( this.StyleName, this._OnStyleStateChange, this ) ;
  9. }
  10. FCKGlossary.prototype =
  11. {
  12. Execute : function()
  13. {
  14. FCKUndo.SaveUndoStep() ;
  15. if ( this.IsActive ) {
  16. FCKStyles.RemoveStyle(this.StyleName) ;
  17. }
  18. else {
  19. FCKStyles.ApplyStyle( this.StyleName ) ;
  20. }
  21. FCK.Focus() ;
  22. FCK.Events.FireEvent( 'OnSelectionChange' ) ;
  23. },
  24. GetState : function()
  25. {
  26. if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
  27. return FCK_TRISTATE_DISABLED ;
  28. return this.IsActive ? FCK_TRISTATE_ON : FCK_TRISTATE_OFF;
  29. },
  30. _OnStyleStateChange : function( styleName, isActive )
  31. {
  32. this.IsActive = isActive ;
  33. }
  34. };
  35. FCKCommands.RegisterCommand( 'Glossary' , new FCKGlossary( 'Glossary' ) ) ;
  36. /*FCKCommands.RegisterCommand( 'Glossary',
  37. new FCKCoreStyleCommand( 'Italic' )
  38. ) ;*/
  39. // Create and register the Audio toolbar button.
  40. var oGlossaryItem = new FCKToolbarButton( 'Glossary', FCKLang['GlossaryTitle'], null, null, null, null, null );
  41. oGlossaryItem.IconPath = FCKConfig.PluginsPath + 'glossary/glossary.gif' ;
  42. FCKToolbarItems.RegisterItem( 'Glossary', oGlossaryItem ) ;