/static/scripts/tiny_mce/plugins/xhtmlxtras/editor_plugin_src.js

http://n23.googlecode.com/ · JavaScript · 134 lines · 111 code · 14 blank · 9 comment · 6 complexity · 204598d84c41cc2b255b6ab5a709ff0b MD5 · raw file

  1. /**
  2. * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
  3. *
  4. * @author Moxiecode
  5. * @copyright Copyright Š 2004-2008, Moxiecode Systems AB, All rights reserved.
  6. */
  7. (function() {
  8. tinymce.create('tinymce.plugins.XHTMLXtrasPlugin', {
  9. init : function(ed, url) {
  10. // Register commands
  11. ed.addCommand('mceCite', function() {
  12. ed.windowManager.open({
  13. file : url + '/cite.htm',
  14. width : 350 + parseInt(ed.getLang('xhtmlxtras.cite_delta_width', 0)),
  15. height : 250 + parseInt(ed.getLang('xhtmlxtras.cite_delta_height', 0)),
  16. inline : 1
  17. }, {
  18. plugin_url : url
  19. });
  20. });
  21. ed.addCommand('mceAcronym', function() {
  22. ed.windowManager.open({
  23. file : url + '/acronym.htm',
  24. width : 350 + parseInt(ed.getLang('xhtmlxtras.acronym_delta_width', 0)),
  25. height : 250 + parseInt(ed.getLang('xhtmlxtras.acronym_delta_width', 0)),
  26. inline : 1
  27. }, {
  28. plugin_url : url
  29. });
  30. });
  31. ed.addCommand('mceAbbr', function() {
  32. ed.windowManager.open({
  33. file : url + '/abbr.htm',
  34. width : 350 + parseInt(ed.getLang('xhtmlxtras.abbr_delta_width', 0)),
  35. height : 250 + parseInt(ed.getLang('xhtmlxtras.abbr_delta_width', 0)),
  36. inline : 1
  37. }, {
  38. plugin_url : url
  39. });
  40. });
  41. ed.addCommand('mceDel', function() {
  42. ed.windowManager.open({
  43. file : url + '/del.htm',
  44. width : 340 + parseInt(ed.getLang('xhtmlxtras.del_delta_width', 0)),
  45. height : 310 + parseInt(ed.getLang('xhtmlxtras.del_delta_width', 0)),
  46. inline : 1
  47. }, {
  48. plugin_url : url
  49. });
  50. });
  51. ed.addCommand('mceIns', function() {
  52. ed.windowManager.open({
  53. file : url + '/ins.htm',
  54. width : 340 + parseInt(ed.getLang('xhtmlxtras.ins_delta_width', 0)),
  55. height : 310 + parseInt(ed.getLang('xhtmlxtras.ins_delta_width', 0)),
  56. inline : 1
  57. }, {
  58. plugin_url : url
  59. });
  60. });
  61. ed.addCommand('mceAttributes', function() {
  62. ed.windowManager.open({
  63. file : url + '/attributes.htm',
  64. width : 380,
  65. height : 370,
  66. inline : 1
  67. }, {
  68. plugin_url : url
  69. });
  70. });
  71. // Register buttons
  72. ed.addButton('cite', {title : 'xhtmlxtras.cite_desc', cmd : 'mceCite'});
  73. ed.addButton('acronym', {title : 'xhtmlxtras.acronym_desc', cmd : 'mceAcronym'});
  74. ed.addButton('abbr', {title : 'xhtmlxtras.abbr_desc', cmd : 'mceAbbr'});
  75. ed.addButton('del', {title : 'xhtmlxtras.del_desc', cmd : 'mceDel'});
  76. ed.addButton('ins', {title : 'xhtmlxtras.ins_desc', cmd : 'mceIns'});
  77. ed.addButton('attribs', {title : 'xhtmlxtras.attribs_desc', cmd : 'mceAttributes'});
  78. if (tinymce.isIE) {
  79. function fix(ed, o) {
  80. if (o.set) {
  81. o.content = o.content.replace(/<abbr([^>]+)>/gi, '<html:abbr $1>');
  82. o.content = o.content.replace(/<\/abbr>/gi, '</html:abbr>');
  83. }
  84. };
  85. ed.onBeforeSetContent.add(fix);
  86. ed.onPostProcess.add(fix);
  87. }
  88. ed.onNodeChange.add(function(ed, cm, n, co) {
  89. n = ed.dom.getParent(n, 'CITE,ACRONYM,ABBR,DEL,INS');
  90. cm.setDisabled('cite', co);
  91. cm.setDisabled('acronym', co);
  92. cm.setDisabled('abbr', co);
  93. cm.setDisabled('del', co);
  94. cm.setDisabled('ins', co);
  95. cm.setDisabled('attribs', n && n.nodeName == 'BODY');
  96. if (n) {
  97. cm.setDisabled(n.nodeName.toLowerCase(), 0);
  98. cm.setActive(n.nodeName.toLowerCase(), 1);
  99. } else {
  100. cm.setActive('cite', 0);
  101. cm.setActive('acronym', 0);
  102. cm.setActive('abbr', 0);
  103. cm.setActive('del', 0);
  104. cm.setActive('ins', 0);
  105. }
  106. });
  107. },
  108. getInfo : function() {
  109. return {
  110. longname : 'XHTML Xtras Plugin',
  111. author : 'Moxiecode Systems AB',
  112. authorurl : 'http://tinymce.moxiecode.com',
  113. infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/xhtmlxtras',
  114. version : tinymce.majorVersion + "." + tinymce.minorVersion
  115. };
  116. }
  117. });
  118. // Register plugin
  119. tinymce.PluginManager.add('xhtmlxtras', tinymce.plugins.XHTMLXtrasPlugin);
  120. })();