-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
58 lines (48 loc) · 977 Bytes
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* @copyright 2023 Chris Zuber <[email protected]>
*/
export function popup(url, {
name = '',
referrer = false,
opener = false,
height = null,
width = null,
x = null,
y = null,
resizable = true,
location = false,
scrollbars = true,
} = {}) {
let flags = [];
if (opener === false) {
flags.push('noopener');
}
if (referrer === false) {
flags.push('noreferrer');
}
// Some properties only apply to sized windows
if (Number.isInteger(width) || Number.isInteger(height)) {
if (Number.isInteger(height)) {
flags.push(`height=${height}`);
}
if (Number.isInteger(width)) {
flags.push(`width=${width}`);
}
if (Number.isInteger(x)) {
flags.push(`left=${x}`);
}
if (Number.isInteger(y)) {
flags.push(`top=${y}`);
}
if (resizable) {
flags.push('resiabled');
}
if (location) {
flags.push('location');
}
if (scrollbars) {
flags.push('scrollbars');
}
}
return window.open(url, name, flags.join(','));
}