PageRenderTime 20ms CodeModel.GetById 12ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/mod_base/lib/js/modules/tinymce3.4.3.2/plugins/zlink/editor_plugin.js

https://code.google.com/p/zotonic/
JavaScript | 54 lines | 40 code | 6 blank | 8 comment | 1 complexity | 048ae753ee331d36801fd918cd4dda3f MD5 | raw file
 1/**
 2 * Create internal links to zotonic pages in the body text, by using the typeahead.
 3 *
 4 * @author Arjan Scherpenisse <arjan@scherpenisse.net>
 5 * @copyright 2010 Arjan Scherpenisse <arjan@scherpenisse.net>
 6 */
 7
 8
 9(function() 
10{
11	var DOM = tinymce.DOM;
12
13	tinymce.create('tinymce.plugins.ZotonicLinkPlugin', 
14	{
15		init: function(ed, url) 
16		{
17			ed.addCommand('Z_Link', function() 
18			{
19                z_event('zlink');
20			});
21
22            window.z_zlink = function(url, title) {
23                //var html = id + "<b>{$selection}</b>";
24                if (ed.selection.getContent())
25                {
26                    ed.execCommand('mceInsertLink', false, {href: url, title: title});
27                }
28                else
29                {
30                    var html = "<a href=\"" + url + "\">" + title + "</a>";
31                    ed.execCommand('mceInsertContent', false, html);
32                }
33			};
34			ed.addButton('zlink', {
35				title: 'Add internal link',
36				cmd: 'Z_Link',
37				'class': 'mce_link'
38			});
39		},
40
41		getInfo : function() {
42			return {
43				longname : 'Zotonic Internal Link Plugin',
44				author : 'Arjan Scherpenisse',
45				authorurl : 'http://www.zotonic.com',
46				infourl : 'http://www.zotonic.com',
47				version : '0.1'
48			};
49		}
50	});
51
52	// Register plugin
53	tinymce.PluginManager.add('zlink', tinymce.plugins.ZotonicLinkPlugin);
54})();