-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions_window.js
92 lines (80 loc) · 2.75 KB
/
options_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
function updateCheckbox() {
var top_checkbox = document.getElementById("top-box");
var bottom_checkbox = document.getElementById("bottom-box");
var left_checkbox = document.getElementById("left-box");
var right_checkbox = document.getElementById("right-box");
if (top_checkbox.checked || bottom_checkbox.checked) {
left_checkbox.disabled = true;
right_checkbox.disabled = true;
} else if (left_checkbox.checked || right_checkbox.checked) {
top_checkbox.disabled = true;
bottom_checkbox.disabled = true;
} else {
left_checkbox.disabled = false;
right_checkbox.disabled = false;
top_checkbox.disabled = false;
bottom_checkbox.disabled = false;
}
}
function initCheckbox(checkboxId, titlebar_name, titlebar_icon_url, titlebar_text) {
var elem = document.getElementById(checkboxId);
if (!elem)
return;
elem.onclick = function() {
if (document.getElementById(checkboxId).checked)
addTitlebar(titlebar_name, titlebar_icon_url, titlebar_text);
else
removeTitlebar(titlebar_name);
focusTitlebars(true);
updateContentStyle();
updateCheckbox();
}
}
window.onfocus = function() {
console.log("focus");
focusTitlebars(true);
}
window.onblur = function() {
console.log("blur");
focusTitlebars(false);
}
window.onresize = function() {
updateContentStyle();
}
window.onload = function() {
initCheckbox("top-box", "top-titlebar", "top-titlebar.png", "Top Titlebar");
initCheckbox("bottom-box", "bottom-titlebar", "bottom-titlebar.png", "Bottom Titlebar");
initCheckbox("left-box", "left-titlebar", "left-titlebar.png", "Left Titlebar");
initCheckbox("right-box", "right-titlebar", "right-titlebar.png", "Right Titlebar");
var remote = require('remote');
var BrowserWindow = remote.require('browser-window');
var win = BrowserWindow.getFocusedWindow();
document.getElementById("close-window-button").onclick = function() {
win.close();
}
document.getElementById("minimize-window-button").onclick = function() {
win.minimize();
}
document.getElementById("maximize-window-button").onclick = function() {
win.maximize();
}
document.getElementById("unmaximize-window-button").onclick = function() {
win.unmaximize();
}
document.getElementById("toggle-window-button").onclick = function() {
win.setFullScreen(!(win.isFullScreen()));
}
document.getElementById("maxmin-window-button").onclick = function() {
win.isMaximized() ? win.unmaximize() : win.maximize();
}
document.getElementById("min").onclick = function() {
win.minimize();
}
document.getElementById("max").onclick = function() {
win.isMaximized() ? win.unmaximize() : win.maximize();
}
document.getElementById("exit").onclick = function() {
win.close();
}
updateContentStyle();
}