js: reorganize Javascript file structure.

Move Javascript files from app/components/**/*.js back to app/javascript/src/javascripts/*.js.
This way Javascript files are in one place, which simplifies import paths and makes it
easier to see all Javascript at once.
This commit is contained in:
evazion
2022-02-08 13:43:50 -06:00
parent 37ad6f5a71
commit ef0d8151d8
11 changed files with 15 additions and 16 deletions

View File

@@ -0,0 +1,48 @@
import Utility from "./utility";
class ForumPostComponent {
static initialize() {
if ($("#c-forum-topics #a-show, #c-forum-posts #a-show").length) {
$(document).on("click.danbooru.forum_post", ".edit_forum_post_link", ForumPostComponent.showEditPostForm);
$(document).on("click.danbooru.forum_post", ".edit_forum_topic_link", ForumPostComponent.showEditTopicForm);
$(document).on("click.danbooru.forum_post", "#new-response-link", ForumPostComponent.showNewForumPostForm);
$(document).on("click.danbooru.forum_post", ".forum-post-copy-id", ForumPostComponent.copyID);
$(document).on("click.danbooru.forum_post", ".forum-post-copy-link", ForumPostComponent.copyLink);
}
}
static showNewForumPostForm(e) {
$("#topic-response").show();
$("#forum_post_body").get(0).scrollIntoView(false);
$("#forum_post_body").selectEnd();
e.preventDefault();
}
static showEditPostForm(e) {
$(this).closest(".forum-post").find(".edit_forum_post").show();
e.preventDefault();
}
static showEditTopicForm(e) {
$(this).closest(".forum-post").find(".edit_forum_topic").show();
e.preventDefault();
}
static async copyID(e) {
let id = $(this).closest(".forum-post").data("id");
let link = `forum #${id}`;
Utility.copyToClipboard(link);
e.preventDefault();
}
static async copyLink(e) {
let id = $(this).closest(".forum-post").data("id");
let link = `${window.location.origin}/forum_posts/${id}`;
Utility.copyToClipboard(link);
e.preventDefault();
}
}
$(document).ready(ForumPostComponent.initialize);
export default ForumPostComponent;