-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathpopup.js
More file actions
29 lines (25 loc) · 785 Bytes
/
popup.js
File metadata and controls
29 lines (25 loc) · 785 Bytes
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
module.exports = {
/**
* Opens a centered popup with the specified URL
* @param {String} url
* @param {Number} width
* @param {Number} height
* @return {Window} A reference to the popup
*/
open (url, width, height) {
const options = {};
let stringOptions;
if (!window) return;
options.location = 1;
options.width = width;
options.height = height;
options.left = window.screenX + (window.outerWidth - width) / 2;
options.top = window.screenY + (window.outerHeight - height) / 2;
options.toolbar = 'no';
options.scrollbars = 'yes';
stringOptions = Object.keys(options).map((key) => {
return `${key}=${options[key]}`;
}).join(', ');
return window.open(url, options.name, stringOptions);
}
};