UNPKG

1.61 kBJavaScriptView Raw
1/* eslint-disable prefer-arrow-callback, func-names, strict, no-var */
2/* eslint-disable vars-on-top, no-plusplus, no-bitwise, no-multi-assign */
3/* eslint-disable no-nested-ternary, no-labels, no-restricted-syntax */
4/* eslint-disable no-continue, import/no-amd, import/no-dynamic-require */
5/* eslint-disable prefer-template, global-require */
6
7define('admin/plugins/emoji', [], function () {
8 $('#save').on('click', function () {
9 var settings = {
10 parseAscii: !!$('#emoji-parseAscii').prop('checked'),
11 parseNative: !!$('#emoji-parseNative').prop('checked'),
12 customFirst: !!$('#emoji-customFirst').prop('checked'),
13 };
14 $.get(window.config.relative_path + '/api/admin/plugins/emoji/save', { settings: JSON.stringify(settings) }, function () {
15 window.app.alertSuccess();
16 });
17 });
18
19 $('#build').on('click', function () {
20 $.get(window.config.relative_path + '/api/admin/plugins/emoji/build', function () {
21 window.app.alertSuccess();
22 });
23 });
24
25 require.config({
26 shim: {
27 preact: {
28 exports: 'preact',
29 },
30 },
31 });
32
33 var addedStyle = false;
34 $('#edit').click(function () {
35 require(['custom-emoji'], function (customEmoji) {
36 customEmoji.init(document.getElementById('editModalBody'), function () {
37 $('#editModal').modal({
38 backdrop: false,
39 show: true,
40 });
41 });
42 });
43 if (!addedStyle) {
44 addedStyle = true;
45 $('head').append(
46 '<style>@import "' + window.config.relative_path + '/plugins/nodebb-plugin-emoji/emoji/styles.css";</style>'
47 );
48 }
49 });
50});