Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions unitylibs/scripts/transition-screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
loadImg,
loadArea,
getMatchedDomain,
getConfig,
} from './utils.js';

export default class TransitionScreen {
Expand Down Expand Up @@ -90,6 +91,25 @@ export default class TransitionScreen {
return splashScreenConfig.fragmentLink;
}

replaceDotMedia(area = document) {
const config = getConfig?.();
const contentRoot = config?.contentRoot ?? '';
if (!contentRoot) return;
const prefix = (config?.locale?.prefix ?? '').replace('/', '') ?? '';
const currUrl = new URL(window.location.href);
const pathSeg = currUrl.pathname.split('/').length;
if (area === document && ((prefix === '' && pathSeg >= 3) || (prefix !== '' && pathSeg >= 4))) return;
const resetAttributeBase = (tag, attr) => {
area.querySelectorAll(`${tag}[${attr}^="./media_"]`).forEach((el) => {
const value = el.getAttribute(attr);
if (!value) return;
el.setAttribute(attr, new URL(`${contentRoot}${value.substring(1)}`, window.location.href).href);
});
};
resetAttributeBase('img', 'src');
resetAttributeBase('source', 'srcset');
}

async loadSplashFragment() {
if (!this.workflowCfg.targetCfg.showSplashScreen) return;
const fragmentLink = this.getFragmentLink();
Expand All @@ -111,6 +131,7 @@ export default class TransitionScreen {
const sections = doc.querySelectorAll('body > div');
const f = createTag('div', { class: 'fragment splash-loader decorate', style: 'display: none', tabindex: '-1', role: 'dialog', 'aria-modal': 'true' });
if (this.workflowCfg.theme === 'dark') f.classList.add('dark');
if (getMatchedDomain(this.workflowCfg.targetCfg.domainMap) === 'acrobat') sections.forEach(sec => this.replaceDotMedia(sec))
f.append(...sections);
const splashDiv = document.querySelector(
this.workflowCfg.targetCfg.splashScreenConfig.splashScreenParent,
Expand Down
Loading