adding all weblabels from weblabels.fsf.org
[weblabels.fsf.org.git] / www.fsf.org / 20131028 / files / plugins / plonelink / editor_plugin.js
1 /**
2 * Plone link plugin based on advlink plugin.
3 *
4 * @author Rob Gietema
5 */
6
7 (function() {
8 tinymce.create('tinymce.plugins.PloneLinkPlugin', {
9 init : function(ed, url) {
10 this.editor = ed;
11
12 // Register commands
13 ed.addCommand('mcePloneLink', function() {
14 var se = ed.selection;
15
16 // No selection and not in link
17 if (se.isCollapsed() && !ed.dom.getParent(se.getNode(), 'A'))
18 return;
19
20 ed.windowManager.open({
21 file : url + '/plonelink.htm',
22 width : 820 + parseInt(ed.getLang('plonelink.delta_width', 0)),
23 height : 540 + parseInt(ed.getLang('plonelink.delta_height', 0)),
24 inline : 1
25 }, {
26 plugin_url : url
27 });
28 });
29
30 // Register buttons
31 ed.addButton('link', {
32 title : 'advanced.link_desc',
33 cmd : 'mcePloneLink'
34 });
35
36 ed.addShortcut('ctrl+k', 'advanced.link_desc', 'mcePloneLink');
37
38 ed.onNodeChange.add(function(ed, cm, n, co) {
39 cm.setDisabled('link', co && n.nodeName != 'A');
40 cm.setActive('link', n.nodeName == 'A' && !n.name);
41 });
42 },
43
44 getInfo : function() {
45 return {
46 longname : 'Plone link',
47 author : 'Rob Gietema',
48 authorurl : 'http://plone.org',
49 infourl : 'http://plone.org/products/tinymce',
50 version : tinymce.majorVersion + "." + tinymce.minorVersion
51 };
52 }
53 });
54
55 // Register plugin
56 tinymce.PluginManager.add('plonelink', tinymce.plugins.PloneLinkPlugin);
57 })();