mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-24 16:53:17 +00:00
Add commentform.js
This commit is contained in:
parent
9238dbf9b3
commit
5f40f39435
1 changed files with 25 additions and 0 deletions
25
resources/assets/js/components/commentform.js
vendored
Normal file
25
resources/assets/js/components/commentform.js
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
$('.comment-form').submit(function(e, data) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
let el = $(this);
|
||||||
|
let id = el.data('id');
|
||||||
|
let commentform = el.find('input[name="comment"]');
|
||||||
|
let commenttext = commentform.val();
|
||||||
|
let item = {item: id, comment: commenttext};
|
||||||
|
try {
|
||||||
|
axios.post('/i/comment', item);
|
||||||
|
var comments = el.parent().parent().find('.comments');
|
||||||
|
var comment = '<p class="mb-0"><span class="font-weight-bold pr-1">' + pixelfed.user.username + '</span><span class="comment-text">'+ commenttext + '</span></p>';
|
||||||
|
comments.prepend(comment);
|
||||||
|
|
||||||
|
commentform.val('');
|
||||||
|
commentform.blur();
|
||||||
|
return true;
|
||||||
|
} catch(e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
Loading…
Reference in a new issue