Misc popup refactoring/documentation

This commit is contained in:
hensm
2022-04-17 11:17:24 +01:00
parent 62d95df803
commit 3a488a6530
2 changed files with 49 additions and 70 deletions

View File

@@ -79,38 +79,6 @@ export function getMediaTypesForPageUrl(
return availableMediaTypes;
}
export interface WindowCenteredProps {
width: number;
height: number;
left: number;
top: number;
}
export function getWindowCenteredProps(
refWin: browser.windows.Window,
width: number,
height: number
): WindowCenteredProps {
if (
refWin.left === undefined ||
refWin.width === undefined ||
refWin.top === undefined ||
refWin.height === undefined
) {
throw logger.error("refWin missing positional attributes.");
}
const centerX = refWin.left + refWin.width / 2;
const centerY = refWin.top + refWin.height / 3;
return {
width,
height,
left: Math.floor(centerX - width / 2),
top: Math.floor(centerY - height / 2)
};
}
export function loadScript(
scriptUrl: string,
doc: Document = document