import Component from "@glimmer/component"; import { tracked } from "@glimmer/tracking"; import { on } from "@ember/modifier"; import { action } from "@ember/object"; import didInsert from "@ember/render-modifiers/modifiers/did-insert"; import { service } from "@ember/service"; import { eq } from "truth-helpers"; import DButton from "discourse/components/d-button"; import concatClass from "discourse/helpers/concat-class"; import { ajax } from "discourse/lib/ajax"; import { popupAjaxError } from "discourse/lib/ajax-error"; import ActivityCalendar from "discourse/plugins/discourse-rewind/discourse/components/reports/activity-calendar"; import BestPosts from "discourse/plugins/discourse-rewind/discourse/components/reports/best-posts"; import BestTopics from "discourse/plugins/discourse-rewind/discourse/components/reports/best-topics"; import FavoriteCategories from "discourse/plugins/discourse-rewind/discourse/components/reports/favorite-categories"; import FavoriteTags from "discourse/plugins/discourse-rewind/discourse/components/reports/favorite-tags"; import FBFF from "discourse/plugins/discourse-rewind/discourse/components/reports/fbff"; import RewindHeader from "discourse/plugins/discourse-rewind/discourse/components/reports/header"; import Reactions from "discourse/plugins/discourse-rewind/discourse/components/reports/reactions"; import ReadingTime from "discourse/plugins/discourse-rewind/discourse/components/reports/reading-time"; import TopWords from "discourse/plugins/discourse-rewind/discourse/components/reports/top-words"; export default class Rewind extends Component { @service siteSettings; @tracked rewind = []; @tracked fullScreen = true; @tracked loadingRewind = false; @action registerScrollWrapper(element) { this.scrollWrapper = element; } @action async loadRewind() { try { this.loadingRewind = true; this.rewind = await ajax("/rewinds"); } catch (e) { popupAjaxError(e); } finally { this.loadingRewind = false; } } @action toggleFullScreen() { this.fullScreen = !this.fullScreen; } @action handleEscape(event) { if (this.fullScreen && event.key === "Escape") { this.fullScreen = false; } } @action handleScroll({ target }) { let children = this.rewindContainer.getElementsByClassName("parallax-bg"); for (let i = 0; i < children.length; i++) { children[i].style.transform = `translateY(-${ (target.scrollTop * (i + 1)) / 5 }px)`; } } @action registerRewindContainer(element) { this.rewindContainer = element; } }