A tumblelog CMS built on AJAX, PHP and MySQL.

editor_plugin_src.js 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /**
  2. * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
  3. *
  4. * @author Moxiecode
  5. * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
  6. */
  7. /* Import plugin specific language pack */
  8. tinyMCE.importPluginLanguagePack('advlink');
  9. var TinyMCE_AdvancedLinkPlugin = {
  10. getInfo : function() {
  11. return {
  12. longname : 'Advanced link',
  13. author : 'Moxiecode Systems AB',
  14. authorurl : 'http://tinymce.moxiecode.com',
  15. infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advlink',
  16. version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
  17. };
  18. },
  19. initInstance : function(inst) {
  20. inst.addShortcut('ctrl', 'k', 'lang_advlink_desc', 'mceAdvLink');
  21. },
  22. getControlHTML : function(cn) {
  23. switch (cn) {
  24. case "link":
  25. return tinyMCE.getButtonHTML(cn, 'lang_link_desc', '{$themeurl}/images/link.gif', 'mceAdvLink');
  26. }
  27. return "";
  28. },
  29. execCommand : function(editor_id, element, command, user_interface, value) {
  30. switch (command) {
  31. case "mceAdvLink":
  32. var anySelection = false;
  33. var inst = tinyMCE.getInstanceById(editor_id);
  34. var focusElm = inst.getFocusElement();
  35. var selectedText = inst.selection.getSelectedText();
  36. if (tinyMCE.selectedElement)
  37. anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (selectedText && selectedText.length > 0);
  38. if (anySelection || (focusElm != null && focusElm.nodeName == "A")) {
  39. var template = new Array();
  40. template['file'] = '../../plugins/advlink/link.htm';
  41. template['width'] = 480;
  42. template['height'] = 400;
  43. // Language specific width and height addons
  44. template['width'] += tinyMCE.getLang('lang_advlink_delta_width', 0);
  45. template['height'] += tinyMCE.getLang('lang_advlink_delta_height', 0);
  46. tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"});
  47. }
  48. return true;
  49. }
  50. return false;
  51. },
  52. handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
  53. if (node == null)
  54. return;
  55. do {
  56. if (node.nodeName == "A" && tinyMCE.getAttrib(node, 'href') != "") {
  57. tinyMCE.switchClass(editor_id + '_advlink', 'mceButtonSelected');
  58. return true;
  59. }
  60. } while ((node = node.parentNode));
  61. if (any_selection) {
  62. tinyMCE.switchClass(editor_id + '_advlink', 'mceButtonNormal');
  63. return true;
  64. }
  65. tinyMCE.switchClass(editor_id + '_advlink', 'mceButtonDisabled');
  66. return true;
  67. }
  68. };
  69. tinyMCE.addPlugin("advlink", TinyMCE_AdvancedLinkPlugin);