|
1 /** |
|
2 * plugin.js |
|
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 |
|
11 /*global tinymce:true */ |
|
12 |
|
13 tinymce.PluginManager.add('emoticons', function(editor, url) { |
|
14 var emoticons = [ |
|
15 ["cool", "cry", "embarassed", "foot-in-mouth"], |
|
16 ["frown", "innocent", "kiss", "laughing"], |
|
17 ["money-mouth", "sealed", "smile", "surprised"], |
|
18 ["tongue-out", "undecided", "wink", "yell"] |
|
19 ]; |
|
20 |
|
21 function getHtml() { |
|
22 var emoticonsHtml; |
|
23 |
|
24 emoticonsHtml = '<table role="list" class="mce-grid">'; |
|
25 |
|
26 tinymce.each(emoticons, function(row) { |
|
27 emoticonsHtml += '<tr>'; |
|
28 |
|
29 tinymce.each(row, function(icon) { |
|
30 var emoticonUrl = url + '/img/smiley-' + icon + '.gif'; |
|
31 |
|
32 emoticonsHtml += '<td><a href="#" data-mce-url="' + emoticonUrl + '" data-mce-alt="' + icon + '" tabindex="-1" ' + |
|
33 'role="option" aria-label="' + icon + '"><img src="' + |
|
34 emoticonUrl + '" style="width: 18px; height: 18px" role="presentation" /></a></td>'; |
|
35 }); |
|
36 |
|
37 emoticonsHtml += '</tr>'; |
|
38 }); |
|
39 |
|
40 emoticonsHtml += '</table>'; |
|
41 |
|
42 return emoticonsHtml; |
|
43 } |
|
44 |
|
45 editor.addButton('emoticons', { |
|
46 type: 'panelbutton', |
|
47 panel: { |
|
48 role: 'application', |
|
49 autohide: true, |
|
50 html: getHtml, |
|
51 onclick: function(e) { |
|
52 var linkElm = editor.dom.getParent(e.target, 'a'); |
|
53 |
|
54 if (linkElm) { |
|
55 editor.insertContent( |
|
56 '<img src="' + linkElm.getAttribute('data-mce-url') + '" alt="' + linkElm.getAttribute('data-mce-alt') + '" />' |
|
57 ); |
|
58 |
|
59 this.hide(); |
|
60 } |
|
61 } |
|
62 }, |
|
63 tooltip: 'Emoticons' |
|
64 }); |
|
65 }); |