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