feat(forums): emoji in post form

This commit is contained in:
OldHawk
2017-12-09 23:16:34 +08:00
parent 4195a6059a
commit 018bb33723
11 changed files with 284 additions and 26 deletions

View File

@@ -33,6 +33,24 @@
}
});
$('.autocomplete').textcomplete([
{ // emoji strategy
match: /\B:([\-+\w]*)$/,
search: function (term, callback) {
callback($.map(window.emojies, function (emoji) {
return emoji.indexOf(term) === 0 ? emoji : null;
}));
},
template: function (value) {
return '<img class="ac-emoji" src="/graphics/emojis/' + value + '.png" />' + '<span class="ac-emoji-text">' + value + '</span>';
},
replace: function (value) {
return ':' + value + ': ';
},
index: 1
}
]);
/**
* upToTop
*/
@@ -242,6 +260,24 @@
e.$options.hideable = false;
},
onShow: function (e) {
$('.md-input').textcomplete([
{ // emoji strategy
match: /\B:([\-+\w]*)$/,
search: function (term, callback) {
callback($.map(window.emojies, function (emoji) {
return emoji.indexOf(term) === 0 ? emoji : null;
}));
},
template: function (value) {
return '<img class="ac-emoji" src="/graphics/emojis/' + value + '.png" />' + '<span class="ac-emoji-text">' + value + '</span>';
},
replace: function (value) {
return ':' + value + ': ';
},
index: 1
}
]);
e.setContent(t.content);
angular.element($('.md-footer')).addClass('text-right');
@@ -304,6 +340,24 @@
e.$options.hideable = false;
},
onShow: function (e) {
$('.md-input').textcomplete([
{ // emoji strategy
match: /\B:([\-+\w]*)$/,
search: function (term, callback) {
callback($.map(window.emojies, function (emoji) {
return emoji.indexOf(term) === 0 ? emoji : null;
}));
},
template: function (value) {
return '<img class="ac-emoji" src="/graphics/emojis/' + value + '.png" />' + '<span class="ac-emoji-text">' + value + '</span>';
},
replace: function (value) {
return ':' + value + ': ';
},
index: 1
}
]);
e.setContent(r.content);
var ele = $('#' + e.$editor.attr('id') + ' .md-footer');
mtDebug.info(ele);