mirror of
https://github.com/openvk/openvk
synced 2024-11-11 09:29:29 +03:00
89bcd89cb3
Now it can be used after textarea initialization (fixes #391) and is capable of replacing pervious mention (if it is located at the start of le string, otherwise it prepends mention)
13 lines
734 B
JavaScript
13 lines
734 B
JavaScript
u(".comment-reply").on("click", function(e) {
|
|
let comment = u(e.target).closest(".post");
|
|
let authorId = comment.data("owner-id");
|
|
let authorNm = u(".post-author > a > b", comment.first()).text().trim();
|
|
let fromGroup = Boolean(comment.data("from-group"));
|
|
let postId = comment.data("post-id");
|
|
let inputbox = postId == null ? u("#write textarea") : u("#wall-post-input" + (postId || ""));
|
|
let mention = ("[" + (fromGroup ? "club" : "id") + authorId + "|" + authorNm + "], ");
|
|
|
|
// Substitute pervious mention if present, prepend otherwise
|
|
inputbox.nodes[0].value = s.nodes[0].value.replace(/(^\[([A-Za-z0-9]+)\|([\p{L} 0-9@]+)\], |^)/u, mention);
|
|
inputbox.trigger("focusin");
|
|
});
|