annotate WebContent/jscripts/tiny_mce/plugins/example/editor_plugin_src.js @ 8:11baadcdd2c8

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