PageRenderTime 67ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/BlogEngine/BlogEngine.NET/editors/tiny_mce_3_4_3_1/plugins/example/editor_plugin_src.js

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