-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframeless_window.js
61 lines (53 loc) · 1.81 KB
/
frameless_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
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");
document.getElementById("close-window-button").onclick = function() {
window.close();
}
updateContentStyle();
}