-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
window.js
105 lines (91 loc) · 2.54 KB
/
window.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
document.addEventListener("click", (e) => {
function getCurrentWindow() {
return browser.windows.getCurrent();
}
if (e.target.id === "window-update-size_768") {
getCurrentWindow().then((currentWindow) => {
let updateInfo = {
width: 768,
height: 1024
};
browser.windows.update(currentWindow.id, updateInfo);
});
}
if (e.target.id === "window-update-minimize") {
getCurrentWindow().then((currentWindow) => {
let updateInfo = {
state: "minimized"
};
browser.windows.update(currentWindow.id, updateInfo);
});
}
else if (e.target.id === "window-create-normal") {
let createData = {};
let creating = browser.windows.create(createData);
creating.then(() => {
console.log("The normal window has been created");
});
}
else if (e.target.id === "window-create-incognito") {
let createData = {
incognito: true,
};
let creating = browser.windows.create(createData);
creating.then(() => {
console.log("The incognito window has been created");
});
}
else if (e.target.id === "window-create-panel") {
let createData = {
type: "panel",
};
let creating = browser.windows.create(createData);
creating.then(() => {
console.log("The panel has been created");
});
}
else if (e.target.id === "window-create-detached-panel") {
let createData = {
type: "detached_panel",
};
let creating = browser.windows.create(createData);
creating.then(() => {
console.log("The detached panel has been created");
});
}
else if (e.target.id === "window-create-popup") {
let createData = {
type: "popup",
};
let creating = browser.windows.create(createData);
creating.then(() => {
console.log("The popup has been created");
});
}
else if (e.target.id === "window-remove") {
getCurrentWindow().then((currentWindow) => {
browser.windows.remove(currentWindow.id);
});
}
else if (e.target.id === "window-resize-all") {
let gettingAll = browser.windows.getAll();
gettingAll.then((windows) => {
let updateInfo = {
width: 1024,
height: 768
};
for (let item of windows) {
browser.windows.update(item.id, updateInfo);
}
});
}
else if (e.target.id === "window-preface-title") {
getCurrentWindow().then((currentWindow) => {
let updateInfo = {
titlePreface: "Preface | "
}
browser.windows.update(currentWindow.id, updateInfo);
});
}
e.preventDefault();
});