/* * slide.ts * Copyright (C) 2024 veypi * 2024-10-22 17:57 * Distributed under terms of the GPL license. */ import b from './build' import bus from '../bus' import account from './account' import cfg from '../cfg' /* mask slide header body main footer * * */ export default class { mask: HTMLElement slide: HTMLElement header: HTMLElement body: HTMLElement main: HTMLElement footer: HTMLElement constructor() { this.header = b({ class: 'voa-slide-header voa-animate-slow', }) this.footer = b({ class: 'voa-slide-footer', innerHtml: 'logout', onclick: () => { bus.emit('logout') } }) this.main = b({ class: 'voa-slide-main', children: [ account, b({ class: 'voa-sm-separate' }) ], onclick: () => { console.log(cfg) cfg.user.phone = new Date().toLocaleString() } }) this.body = b({ class: 'voa-slide-body voa-animate-slow', style: 'animation-delay: 300ms', children: [this.main, this.footer] }) this.slide = b({ id: 'voa-slide', class: 'voa-slide', children: [this.header, this.body] }) this.mask = b({ class: 'voa-slide-mask', style: 'visibility: hidden', children: [this.slide], onclick: (e: MouseEvent) => { if (e.target === e.currentTarget) { this.hide() } } }) document.body.appendChild(this.mask) } show() { this.mask.style.visibility = 'visible' this.header.classList.add('voa-slidein-right') this.body.classList.add('voa-slidein-up') } hide() { this.mask.style.visibility = 'hidden' this.header.classList.remove('voa-slidein-right') this.body.classList.remove('voa-slidein-up') } }