/static/scripts/tiny_mce/plugins/example/editor_plugin_src.js

http://n23.googlecode.com/ · JavaScript · 81 lines · 39 code · 7 blank · 35 comment · 1 complexity · b31b675b93ff4a5a670f562860dadb1b MD5 · raw file

  1. /**
  2. * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
  3. *
  4. * @author Moxiecode
  5. * @copyright Copyright Š 2004-2008, Moxiecode Systems AB, All rights reserved.
  6. */
  7. (function() {
  8. // Load plugin specific language pack
  9. tinymce.PluginManager.requireLangPack('example');
  10. tinymce.create('tinymce.plugins.ExamplePlugin', {
  11. /**
  12. * Initializes the plugin, this will be executed after the plugin has been created.
  13. * This call is done before the editor instance has finished it's initialization so use the onInit event
  14. * of the editor instance to intercept that event.
  15. *
  16. * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
  17. * @param {string} url Absolute URL to where the plugin is located.
  18. */
  19. init : function(ed, url) {
  20. // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
  21. ed.addCommand('mceExample', function() {
  22. ed.windowManager.open({
  23. file : url + '/dialog.htm',
  24. width : 320 + parseInt(ed.getLang('example.delta_width', 0)),
  25. height : 120 + parseInt(ed.getLang('example.delta_height', 0)),
  26. inline : 1
  27. }, {
  28. plugin_url : url, // Plugin absolute URL
  29. some_custom_arg : 'custom arg' // Custom argument
  30. });
  31. });
  32. // Register example button
  33. ed.addButton('example', {
  34. title : 'example.desc',
  35. cmd : 'mceExample',
  36. image : url + '/img/example.gif'
  37. });
  38. // Add a node change handler, selects the button in the UI when a image is selected
  39. ed.onNodeChange.add(function(ed, cm, n) {
  40. cm.setActive('example', n.nodeName == 'IMG');
  41. });
  42. },
  43. /**
  44. * Creates control instances based in the incomming name. This method is normally not
  45. * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
  46. * but you sometimes need to create more complex controls like listboxes, split buttons etc then this
  47. * method can be used to create those.
  48. *
  49. * @param {String} n Name of the control to create.
  50. * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
  51. * @return {tinymce.ui.Control} New control instance or null if no control was created.
  52. */
  53. createControl : function(n, cm) {
  54. return null;
  55. },
  56. /**
  57. * Returns information about the plugin as a name/value array.
  58. * The current keys are longname, author, authorurl, infourl and version.
  59. *
  60. * @return {Object} Name/value array containing information about the plugin.
  61. */
  62. getInfo : function() {
  63. return {
  64. longname : 'Example plugin',
  65. author : 'Some author',
  66. authorurl : 'http://tinymce.moxiecode.com',
  67. infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/example',
  68. version : "1.0"
  69. };
  70. }
  71. });
  72. // Register plugin
  73. tinymce.PluginManager.add('example', tinymce.plugins.ExamplePlugin);
  74. })();