A tumblelog CMS built on AJAX, PHP and MySQL.

editor_plugin_src.js 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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('advhr');
  9. var TinyMCE_AdvancedHRPlugin = {
  10. getInfo : function() {
  11. return {
  12. longname : 'Advanced HR',
  13. author : 'Moxiecode Systems AB',
  14. authorurl : 'http://tinymce.moxiecode.com',
  15. infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advhr',
  16. version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
  17. }
  18. },
  19. getControlHTML : function(cn) {
  20. switch (cn) {
  21. case "advhr":
  22. return tinyMCE.getButtonHTML(cn, 'lang_insert_advhr_desc', '{$pluginurl}/images/advhr.gif', 'mceAdvancedHr');
  23. }
  24. return "";
  25. },
  26. /**
  27. * Executes the mceAdvanceHr command.
  28. */
  29. execCommand : function(editor_id, element, command, user_interface, value) {
  30. // Handle commands
  31. switch (command) {
  32. case "mceAdvancedHr":
  33. var template = new Array();
  34. template['file'] = '../../plugins/advhr/rule.htm'; // Relative to theme
  35. template['width'] = 250;
  36. template['height'] = 160;
  37. template['width'] += tinyMCE.getLang('lang_advhr_delta_width', 0);
  38. template['height'] += tinyMCE.getLang('lang_advhr_delta_height', 0);
  39. var size = "", width = "", noshade = "";
  40. if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "hr") {
  41. tinyMCE.hrElement = tinyMCE.selectedElement;
  42. if (tinyMCE.hrElement) {
  43. size = tinyMCE.hrElement.getAttribute('size') ? tinyMCE.hrElement.getAttribute('size') : "";
  44. width = tinyMCE.hrElement.getAttribute('width') ? tinyMCE.hrElement.getAttribute('width') : "";
  45. noshade = tinyMCE.hrElement.getAttribute('noshade') ? tinyMCE.hrElement.getAttribute('noshade') : "";
  46. }
  47. tinyMCE.openWindow(template, {editor_id : editor_id, size : size, width : width, noshade : noshade, mceDo : 'update'});
  48. } else {
  49. if (tinyMCE.isMSIE) {
  50. tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false,'<hr />');
  51. } else {
  52. tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", size : size, width : width, noshade : noshade, mceDo : 'insert'});
  53. }
  54. }
  55. return true;
  56. }
  57. // Pass to next handler in chain
  58. return false;
  59. },
  60. handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
  61. if (node == null)
  62. return;
  63. do {
  64. if (node.nodeName == "HR") {
  65. tinyMCE.switchClass(editor_id + '_advhr', 'mceButtonSelected');
  66. return true;
  67. }
  68. } while ((node = node.parentNode));
  69. tinyMCE.switchClass(editor_id + '_advhr', 'mceButtonNormal');
  70. return true;
  71. }
  72. };
  73. tinyMCE.addPlugin("advhr", TinyMCE_AdvancedHRPlugin);