/wp-content/plugins/tinymce-advanced/mce/emoticons/plugin.js

https://bitbucket.org/carloskikea/helpet · JavaScript · 87 lines · 64 code · 13 blank · 10 comment · 1 complexity · 3cb32fb6da9c8b65dac6e8a695217870 MD5 · raw file

  1. /**
  2. * plugin.js (edited for WP)
  3. *
  4. * Copyright, Moxiecode Systems AB
  5. * Released under LGPL License.
  6. *
  7. * License: http://www.tinymce.com/license
  8. * Contributing: http://www.tinymce.com/contributing
  9. */
  10. /*global tinymce:true */
  11. tinymce.PluginManager.add('emoticons', function(editor, url) {
  12. var emoticons = [{
  13. smile: ':-)',
  14. razz: ':-P',
  15. cool: '8-)',
  16. wink: ';-)',
  17. biggrin: ':-D'
  18. },
  19. {
  20. twisted: ':twisted:',
  21. mrgreen: ':mrgreen:',
  22. lol: ':lol:',
  23. rolleyes: ':roll:',
  24. confused: ':-?'
  25. },
  26. {
  27. cry: ':cry:',
  28. surprised: ':-o',
  29. evil: ':evil:',
  30. neutral: ':-|',
  31. redface: ':oops:'
  32. },
  33. {
  34. mad: ':-x',
  35. eek: '8-O',
  36. sad: ':-(',
  37. arrow: ':arrow:',
  38. idea: ':idea:'
  39. }];
  40. function getHtml() {
  41. var emoticonsHtml;
  42. emoticonsHtml = '<table role="list" class="mce-grid">';
  43. tinymce.each(emoticons, function( row ) {
  44. emoticonsHtml += '<tr>';
  45. tinymce.each( row, function( icon, name ) {
  46. var emoticonUrl = url + '/img/icon_' + name + '.gif';
  47. emoticonsHtml += '<td><a href="#" data-mce-alt="' + icon + '" tabindex="-1" ' +
  48. 'role="option" aria-label="' + icon + '"><img src="' +
  49. emoticonUrl + '" style="width: 15px; height: 15px; padding: 3px;" role="presentation" alt="' + icon + '" /></a></td>';
  50. });
  51. emoticonsHtml += '</tr>';
  52. });
  53. emoticonsHtml += '</table>';
  54. return emoticonsHtml;
  55. }
  56. editor.addButton('emoticons', {
  57. type: 'panelbutton',
  58. panel: {
  59. role: 'application',
  60. autohide: true,
  61. html: getHtml,
  62. onclick: function(e) {
  63. var linkElm = editor.dom.getParent( e.target, 'a' );
  64. if ( linkElm ) {
  65. editor.insertContent(
  66. ' ' + linkElm.getAttribute('data-mce-alt') + ' '
  67. );
  68. this.hide();
  69. }
  70. }
  71. },
  72. tooltip: 'Emoticons'
  73. });
  74. });