Editor plugin wysiwyg wordpress


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function swift_notice(seldata) {
  2. return '<p class="note"><span class="bg"> </span>'+ seldata + '</p>';
  3. }
  4. function swift_warning(seldata) {
  5. return '<p class="warning"><span class="bg"> </span>'+ seldata + '</p>';
  6. }
  7. function swift_question(seldata) {
  8. return '<p class="question"><span class="bg"> </span>'+ seldata + '</p>';
  9. }
  10. function swift_tip(seldata) {
  11. return '<p class="tip"><span class="bg"> </span>'+ seldata + '</p>';
  12. }
  13. function swift_button(seldata) {
  14. return '<div class="button">'+ seldata + '</div>';
  15. }
  16. function swift_download(seldata) {
  17. return '<div class="download"><span class="bg"> </span>'+ seldata + '</div>';
  18. }
  19.  
  20.  
  21. (function() {
  22. tinymce.create('tinymce.plugins.tinyplugin', {
  23.  
  24. init : function(ed, url){
  25. ed.addButton('note', {
  26. title : 'Insert a note',
  27. onclick : function() {
  28. var sel = ed.selection.getContent();
  29. ed.execCommand(
  30. 'mceInsertContent',
  31. false,
  32. swift_notice(sel)
  33. );
  34. },
  35. image: url + "/note.png"
  36. });
  37.  
  38. ed.addButton('tip', {
  39. title : 'Insert a Tip',
  40. onclick : function() {
  41. var sel = ed.selection.getContent();
  42. ed.execCommand(
  43. 'mceInsertContent',
  44. false,
  45. swift_tip(sel)
  46. );
  47. },
  48. image: url + "/tip.png"
  49. });
  50.  
  51. ed.addButton('warning', {
  52. title : 'Insert a Warning',
  53. onclick : function() {
  54. var sel = ed.selection.getContent();
  55. ed.execCommand(
  56. 'mceInsertContent',
  57. false,
  58. swift_warning(sel)
  59. );
  60. },
  61. image: url + "/warning.png"
  62. });
  63.  
  64.  
  65. ed.addButton('question', {
  66. title : 'Insert a question',
  67. onclick : function() {
  68. var sel = ed.selection.getContent();
  69. ed.execCommand(
  70. 'mceInsertContent',
  71. false,
  72. swift_question(sel)
  73. );
  74. },
  75. image: url + "/question.png"
  76. });
  77.  
  78. ed.addButton('button', {
  79. title : 'Insert a Button',
  80. onclick : function() {
  81. var sel = ed.selection.getContent();
  82. ed.execCommand(
  83. 'mceInsertContent',
  84. false,
  85. swift_button(sel)
  86. );
  87. },
  88. image: url + "/button.png"
  89. });
  90.  
  91. ed.addButton('download', {
  92. title : 'Insert a Download Button',
  93. onclick : function() {
  94. var sel = ed.selection.getContent();
  95. ed.execCommand(
  96. 'mceInsertContent',
  97. false,
  98. swift_download(sel)
  99. );
  100. },
  101. image: url + "/download.png"
  102. });
  103.  
  104.  
  105.  
  106. }
  107. });
  108.  
  109. tinymce.PluginManager.add('tinyplugin', tinymce.plugins.tinyplugin);
  110.  
  111. })();
  112.  
  113. jQuery(function() {
  114. jQuery( ".datepicker" ).datepicker({dateFormat: 'yy-mm-dd' });
  115. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.