/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. (function()
  8. {
  9. var DOM = tinymce.DOM;
  10. tinymce.create('tinymce.plugins.ZotonicLinkPlugin',
  11. {
  12. init: function(ed, url)
  13. {
  14. ed.addCommand('Z_Link', function()
  15. {
  16. z_event('zlink');
  17. });
  18. window.z_zlink = function(url, title) {
  19. //var html = id + "<b>{$selection}</b>";
  20. if (ed.selection.getContent())
  21. {
  22. ed.execCommand('mceInsertLink', false, {href: url, title: title});
  23. }
  24. else
  25. {
  26. var html = "<a href=\"" + url + "\">" + title + "</a>";
  27. ed.execCommand('mceInsertContent', false, html);
  28. }
  29. };
  30. ed.addButton('zlink', {
  31. title: 'Add internal link',
  32. cmd: 'Z_Link',
  33. 'class': 'mce_link'
  34. });
  35. },
  36. getInfo : function() {
  37. return {
  38. longname : 'Zotonic Internal Link Plugin',
  39. author : 'Arjan Scherpenisse',
  40. authorurl : 'http://www.zotonic.com',
  41. infourl : 'http://www.zotonic.com',
  42. version : '0.1'
  43. };
  44. }
  45. });
  46. // Register plugin
  47. tinymce.PluginManager.add('zlink', tinymce.plugins.ZotonicLinkPlugin);
  48. })();