From 1cf023e4762c6024c36b05b3530ac56f06558de4 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Fri, 21 Jul 2017 12:55:36 +0200 Subject: [PATCH] Some fixes --- pages/profile/profile.pixy | 12 +++++++----- scripts/AnimeNotifier.ts | 5 ++++- scripts/Application.ts | 12 +++++++----- scripts/StatusMessage.ts | 7 +++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/pages/profile/profile.pixy b/pages/profile/profile.pixy index 85aff0e2..0226f6d9 100644 --- a/pages/profile/profile.pixy +++ b/pages/profile/profile.pixy @@ -55,11 +55,6 @@ component ProfileHeader(viewUser *arn.User, user *arn.User, uri string) button.profile-action.action(data-action="unfollowUser", data-trigger="click", data-api="/api/userfollows/" + user.ID + "/remove", data-view-user-id=viewUser.ID) Icon("user-times") span Unfollow - - if user.Role == "admin" || user.Role == "editor" - a.button.profile-action(href="/api/user/" + viewUser.ID) - Icon("search-plus") - span JSON ProfileNavigation(viewUser, uri) @@ -131,6 +126,13 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList, a.profile-watching-list-item.ajax(href=item.Anime().Link(), title=item.Anime().Title.Canonical + " (" + toString(item.Episodes) + " / " + arn.EpisodesToString(item.Anime().EpisodeCount) + ")") img.profile-watching-list-item-image.lazy(data-src=item.Anime().Image.Tiny, alt=item.Anime().Title.Canonical) + if user != nil && (user.Role == "admin" || user.Role == "editor") + .footer + .buttons + a.button.profile-action(href="/api/user/" + viewUser.ID, target="_blank", rel="noopener") + Icon("search-plus") + span JSON + //- .profile-category.mountable //- h3 //- a.ajax(href="/+" + viewUser.Nick + "/threads", title="View all threads") Threads diff --git a/scripts/AnimeNotifier.ts b/scripts/AnimeNotifier.ts index 22563390..db588825 100644 --- a/scripts/AnimeNotifier.ts +++ b/scripts/AnimeNotifier.ts @@ -68,6 +68,10 @@ export class AnimeNotifier { } init() { + // App init + this.app.init() + + // Event listeners document.addEventListener("readystatechange", this.onReadyStateChange.bind(this)) document.addEventListener("DOMContentLoaded", this.onContentLoaded.bind(this)) document.addEventListener("keydown", this.onKeyDown.bind(this), false) @@ -573,7 +577,6 @@ export class AnimeNotifier { return delay(300).then(() => { return request .then(html => this.app.setContent(html, true)) - .then(() => this.app.markActiveLinks()) .then(() => this.app.emit("DOMContentLoaded")) .then(() => this.loading(false)) .catch(console.error) diff --git a/scripts/Application.ts b/scripts/Application.ts index 9f86505a..3c16c134 100644 --- a/scripts/Application.ts +++ b/scripts/Application.ts @@ -23,9 +23,14 @@ export class Application { this.fadeOutClass = "fade-out" } + init() { + document.addEventListener("DOMContentLoaded", () => { + this.ajaxify() + this.markActiveLinks() + }) + } + run() { - this.ajaxify() - this.markActiveLinks() this.loading.classList.add(this.fadeOutClass) } @@ -118,9 +123,6 @@ export class Application { } else { this.content.innerHTML = html } - - this.ajaxify(this.content) - this.markActiveLinks(this.content) } markActiveLinks(element?: HTMLElement) { diff --git a/scripts/StatusMessage.ts b/scripts/StatusMessage.ts index 126e30c1..adc81497 100644 --- a/scripts/StatusMessage.ts +++ b/scripts/StatusMessage.ts @@ -26,12 +26,19 @@ export class StatusMessage { }) } + clearStyle() { + this.container.classList.remove("info-message") + this.container.classList.remove("error-message") + } + showError(message: string, duration?: number) { + this.clearStyle() this.show(message, duration || 4000) this.container.classList.add("error-message") } showInfo(message: string, duration?: number) { + this.clearStyle() this.show(message, duration || 2000) this.container.classList.add("info-message") }