2024-08-13 09:26:23 +02:00
|
|
|
import { t, Trans } from '@lingui/macro';
|
|
|
|
|
2022-12-16 06:27:04 +01:00
|
|
|
export default function openCompose(opts) {
|
2024-06-14 02:34:50 +02:00
|
|
|
const url = URL.parse('/compose/', window.location);
|
2022-12-13 14:54:16 +01:00
|
|
|
const { width: screenWidth, height: screenHeight } = window.screen;
|
|
|
|
const left = Math.max(0, (screenWidth - 600) / 2);
|
|
|
|
const top = Math.max(0, (screenHeight - 450) / 2);
|
|
|
|
const width = Math.min(screenWidth, 600);
|
|
|
|
const height = Math.min(screenHeight, 450);
|
2023-09-03 13:44:26 +02:00
|
|
|
const winUID = opts?.uid || Math.random();
|
2022-12-13 14:54:16 +01:00
|
|
|
const newWin = window.open(
|
|
|
|
url,
|
2023-01-11 16:23:49 +01:00
|
|
|
'compose' + winUID,
|
2022-12-13 14:54:16 +01:00
|
|
|
`width=${width},height=${height},left=${left},top=${top}`,
|
|
|
|
);
|
|
|
|
|
|
|
|
if (newWin) {
|
2023-02-05 17:17:19 +01:00
|
|
|
// if (masto) {
|
|
|
|
// newWin.masto = masto;
|
|
|
|
// }
|
2022-12-13 14:54:16 +01:00
|
|
|
|
|
|
|
newWin.__COMPOSE__ = opts;
|
2023-11-05 10:41:29 +01:00
|
|
|
} else {
|
2024-08-13 09:26:23 +02:00
|
|
|
alert(t`Looks like your browser is blocking popups.`);
|
2022-12-13 14:54:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return newWin;
|
2022-12-16 06:27:04 +01:00
|
|
|
}
|