1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-22 06:39:43 +02:00
documize/gui/public/tinymce/plugins/emoticons/plugin.js

88 lines
2.2 KiB
JavaScript
Raw Normal View History

2017-12-09 12:42:35 +00:00
(function () {
2018-01-19 11:36:38 +00:00
var emoticons = (function () {
'use strict';
var PluginManager = tinymce.util.Tools.resolve('tinymce.PluginManager');
var Tools = tinymce.util.Tools.resolve('tinymce.util.Tools');
var emoticons = [
[
'cool',
'cry',
'embarassed',
'foot-in-mouth'
],
[
'frown',
'innocent',
'kiss',
'laughing'
],
[
'money-mouth',
'sealed',
'smile',
'surprised'
],
[
'tongue-out',
'undecided',
'wink',
'yell'
]
];
var getHtml = function (pluginUrl) {
var emoticonsHtml;
emoticonsHtml = '<table role="list" class="mce-grid">';
Tools.each(emoticons, function (row) {
emoticonsHtml += '<tr>';
Tools.each(row, function (icon) {
var emoticonUrl = pluginUrl + '/img/smiley-' + icon + '.gif';
emoticonsHtml += '<td><a href="#" data-mce-url="' + emoticonUrl + '" data-mce-alt="' + icon + '" tabindex="-1" ' + 'role="option" aria-label="' + icon + '"><img src="' + emoticonUrl + '" style="width: 18px; height: 18px" role="presentation" /></a></td>';
2017-12-09 12:42:35 +00:00
});
2018-01-19 11:36:38 +00:00
emoticonsHtml += '</tr>';
});
emoticonsHtml += '</table>';
return emoticonsHtml;
};
var $_7qwqiva7jcg89c7z = { getHtml: getHtml };
2017-12-09 12:42:35 +00:00
2018-01-19 11:36:38 +00:00
var insertEmoticon = function (editor, src, alt) {
editor.insertContent(editor.dom.createHTML('img', {
src: src,
alt: alt
}));
};
var register = function (editor, pluginUrl) {
var panelHtml = $_7qwqiva7jcg89c7z.getHtml(pluginUrl);
editor.addButton('emoticons', {
type: 'panelbutton',
panel: {
role: 'application',
autohide: true,
html: panelHtml,
onclick: function (e) {
var linkElm = editor.dom.getParent(e.target, 'a');
if (linkElm) {
insertEmoticon(editor, linkElm.getAttribute('data-mce-url'), linkElm.getAttribute('data-mce-alt'));
this.hide();
2017-12-09 12:42:35 +00:00
}
2018-01-19 11:36:38 +00:00
}
},
tooltip: 'Emoticons'
});
};
var $_5wph89a6jcg89c7y = { register: register };
2017-12-09 12:42:35 +00:00
2018-01-19 11:36:38 +00:00
PluginManager.add('emoticons', function (editor, pluginUrl) {
$_5wph89a6jcg89c7y.register(editor, pluginUrl);
});
var Plugin = function () {
};
2017-12-09 12:42:35 +00:00
2018-01-19 11:36:38 +00:00
return Plugin;
2017-12-09 12:42:35 +00:00
2018-01-19 11:36:38 +00:00
}());
})()