/** * QCObjects Framework SDK * ________________ * * Author: Jean Machuca * * Cross Browser Javascript Framework for MVC Patterns * QCObjects is licensed under the MIT License * [LICENSE] (https://github.com/QCObjects/qcobjects-sdk/blob/main/LICENSE.txt) * * Copyright (C) 2015 Jean Machuca, * * Everyone is permitted to copy and distribute verbatim copies of this * license document, but changing it is not allowed. */ "use strict"; import { Package, Component, CONFIG, logger, componentsStack } from "qcobjects"; import { Resize, Fade } from "./org.qcobjects.effects"; type SplashScreenParams = { name:string; basePath: string; data:any; body:any; } type MainSplashComponent = { body: any; splashScreenComponent: any; shadowed: any; shadowRoot: any; // eslint-disable-next-line no-unused-vars addComponentHelper(arg0: () => void): unknown; name:string; _mainPosition: string; _mainOpacity: string; } export class SplashScreenComponent extends Component { _enabled_: boolean; _bgcolor: string; cached = false; shadowed = true; body: any; shadowRoot: any; constructor(component: SplashScreenParams) { component.name = (typeof component.name === "undefined") ? ("splashscreen") : (component.name); const isBrowser = typeof window !== "undefined" && typeof window.self !== "undefined" && window === window.self; const isStartURL = (location.hash === "" && location.pathname === "/" && location.search === "") || CONFIG.get("routingWay", "pathname") === "hash" && CONFIG.get("start_url", "/") === location.hash || CONFIG.get("routingWay", "pathname") === "pathname" && CONFIG.get("start_url", "/") === location.pathname || CONFIG.get("routingWay", "pathname") === "search" && CONFIG.get("start_url", "/") === location.search; const _enabled_ = isBrowser && isStartURL; if (_enabled_) { component.basePath = CONFIG.get("splashscreenBasePath", CONFIG.get("remoteSDKPath", "")); if (typeof component.data === "undefined") { component.data = {}; } component.data.basePath = component.basePath; } else { if (typeof component !== "undefined" && typeof component.body !== "undefined") { component.body.style.display = "none"; } } super(component); this._bgcolor = ""; this._enabled_ = _enabled_; if (this._enabled_) { const displayEffectDuration = 1000; const rawDuration = this.body?.getAttribute("duration"); const duration = rawDuration == null ? displayEffectDuration : parseInt(rawDuration.toString()); this._bgcolor = this.body?.style?.backgroundColor ?? ""; const _helper_ = () => { setTimeout(() => { if (!_helper_.executed) { const _componentRoot = (this.shadowed) ? (this.shadowRoot?.host as HTMLElement) : (this.body as HTMLElement); if (typeof componentsStack !== "undefined") { componentsStack.filter((c: MainSplashComponent) => c.body.hasAttribute("splashscreen")).map( (mainComponent: MainSplashComponent) => { logger.debug(`Splash Screen of Main Component: ${mainComponent.name}`); mainComponent.splashScreenComponent = this; const SplashScreenHandler = () => { if (!(SplashScreenHandler as any).executed) { const component = mainComponent.splashScreenComponent as SplashScreenComponent; const mainElement = (mainComponent.shadowed) ? (mainComponent.shadowRoot?.host as HTMLElement) : (mainComponent.body as HTMLElement); mainComponent._mainPosition = mainElement.style.position; if (typeof mainElement !== "undefined") { mainElement.style.position = "fixed"; } mainComponent._mainOpacity = mainElement.style.opacity; _componentRoot.style.width = "100%"; _componentRoot.style.height = "100%"; document.body.style.backgroundColor = "#111111"; mainElement.style.opacity = "0"; setTimeout(function () { if (typeof _componentRoot !== "undefined") { document.body.style.backgroundColor = component?._bgcolor; (_componentRoot as any).subelements("#slot-logo").map((slotlogo:any) => { slotlogo.style.display = "block"; slotlogo.style.transformOrigin = "center"; return (new Resize()).apply(slotlogo, 1, 0); }); (new Fade()).apply(_componentRoot, 1, 0); } }, (duration - displayEffectDuration)); setTimeout(function () { (new Fade()).apply(mainElement, 0, 1); mainElement.style.position = mainComponent._mainPosition; document.body.style.backgroundColor = component._bgcolor; if (_componentRoot.parentElement !== null) { _componentRoot.parentElement.remove(); } }, duration); } (SplashScreenHandler as any).executed = true; }; return mainComponent.addComponentHelper(SplashScreenHandler.bind(mainComponent)); } ); } _helper_.executed = true; } }); }; _helper_.executed = false; this.addComponentHelper(_helper_.bind(component)); } } } Package("org.qcobjects.components.base", [ SplashScreenComponent ]); export class VideoSplashScreenComponent extends SplashScreenComponent { cached = false; shadowed = true; tplsource = "inline"; template = `
`; constructor(o: SplashScreenParams) { o.name = "videosplashscreen"; super(o); } } export class CubeSplashScreenComponent extends SplashScreenComponent { cached = false; shadowed = true; tplsource = "inline"; template = `
`; constructor(o: SplashScreenParams) { o.name = "cubesplashscreen"; super(o); } } Package("org.qcobjects.components.splashscreen", [ SplashScreenComponent, VideoSplashScreenComponent, CubeSplashScreenComponent ]);