fckplugin.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. ImgMap plugin for FCKeditor
  3. version 0.4 14/12/2007
  4. See docs/install.html
  5. */
  6. imgmapCommand_GetState = function() {
  7. if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
  8. return FCK_TRISTATE_DISABLED;
  9. var oImage = FCK.Selection.GetSelectedElement() ;
  10. if ( oImage && oImage.tagName == 'IMG' )
  11. {
  12. if ( !FCK.IsRealImage( oImage ) )
  13. {
  14. return FCK_TRISTATE_DISABLED ;
  15. }
  16. // Does it has an assigned map?
  17. if (oImage.getAttribute( 'usemap' ))
  18. return FCK_TRISTATE_ON;
  19. // Plain image
  20. return FCK_TRISTATE_OFF;
  21. }
  22. // No image selected
  23. return FCK_TRISTATE_DISABLED;
  24. }
  25. /*
  26. FCKCommands.RegisterCommand( 'imgmapPopup',
  27. new FCKDialogCommand( FCKLang.imgmapDlgName, FCKLang.imgmapDlgTitle, FCKPlugins.Items['imgmap'].Path + 'popup.html', 700, 620, imgmapCommand_GetState ) ) ;
  28. */
  29. FCKCommands.RegisterCommand( 'imgmapPopup',
  30. new FCKDialogCommand( FCKLang.imgmapDlgName, FCKLang.imgmapDlgTitle, FCKPlugins.Items['imgmap'].Path + 'popup.html', 750, 580, imgmapCommand_GetState ) ) ;
  31. // create imgmap toolbar button.
  32. var imgmapButton = new FCKToolbarButton('imgmapPopup', FCKLang.imgmapBtn, null, null, false, true);
  33. // Use the proper icon according to the skin:
  34. if ( /\/editor\/skins\/(.*)\//.test(FCKConfig.SkinPath) )
  35. imgmapButton.IconPath = FCKPlugins.Items['imgmap'].Path + 'images/icon_' + RegExp.$1 + '.gif';
  36. else
  37. imgmapButton.IconPath = FCKPlugins.Items['imgmap'].Path + 'images/editor_icon.gif';
  38. FCKToolbarItems.RegisterItem('imgmapPopup', imgmapButton);
  39. // register new contextmenu
  40. FCK.ContextMenu.RegisterListener({
  41. AddItems : function( menu, tag, tagName ) {
  42. // under what circumstances do we display this option
  43. if ( FCK.IsRealImage( tag ) )
  44. {
  45. // when the option is displayed, show a separator the command
  46. //menu.AddSeparator();
  47. // the command needs the registered command name, the title for the context menu, and the icon path
  48. menu.AddItem('imgmapPopup', FCKLang.imgmapDlgTitle, imgmapButton.IconPath);
  49. }
  50. }
  51. });