Added show more button to profile tags

This commit is contained in:
2018-11-14 21:16:29 +09:00
parent 7c958e6b17
commit 9ca6fd744f
6 changed files with 86 additions and 52 deletions

View File

@ -1,17 +0,0 @@
import AnimeNotifier from "../AnimeNotifier"
// Follow user
export function followUser(arn: AnimeNotifier, elem: HTMLElement) {
return arn.post(elem.dataset.api)
.then(() => arn.reloadContent())
.then(() => arn.statusMessage.showInfo("You are now following " + document.getElementById("nick").textContent + "."))
.catch(err => arn.statusMessage.showError(err))
}
// Unfollow user
export function unfollowUser(arn: AnimeNotifier, elem: HTMLElement) {
return arn.post(elem.dataset.api)
.then(() => arn.reloadContent())
.then(() => arn.statusMessage.showInfo("You stopped following " + document.getElementById("nick").textContent + "."))
.catch(err => arn.statusMessage.showError(err))
}

35
scripts/Actions/User.ts Normal file
View File

@ -0,0 +1,35 @@
import AnimeNotifier from "../AnimeNotifier"
import Diff from "scripts/Diff";
// Follow user
export async function followUser(arn: AnimeNotifier, element: HTMLElement) {
try {
await arn.post(element.dataset.api)
await arn.reloadContent()
arn.statusMessage.showInfo("You are now following " + document.getElementById("nick").textContent + ".")
} catch(err) {
arn.statusMessage.showError(err)
}
}
// Unfollow user
export async function unfollowUser(arn: AnimeNotifier, element: HTMLElement) {
try {
await arn.post(element.dataset.api)
await arn.reloadContent()
arn.statusMessage.showInfo("You stopped following " + document.getElementById("nick").textContent + ".")
} catch(err) {
arn.statusMessage.showError(err)
}
}
// Show more
export function showMore(arn: AnimeNotifier, showMoreElement: HTMLElement) {
const elements = [...document.getElementsByClassName("show-more")]
for(let element of elements) {
Diff.mutations.queue(() => element.classList.remove("show-more"))
}
Diff.mutations.queue(() => showMoreElement.classList.add("show-more"))
}

View File

@ -4,7 +4,7 @@ export * from "./AnimeList"
export * from "./Diff"
export * from "./Editor"
export * from "./Explore"
export * from "./FollowUser"
export * from "./User"
export * from "./Forum"
export * from "./InfiniteScroller"
export * from "./Install"