Subversion-Projekte lars-tiefland.content-management

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

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