-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautotoggle-ui.js
50 lines (40 loc) · 1.34 KB
/
autotoggle-ui.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
// Autohide UI
vivaldi.jdhooks.onUIReady(function () {
var uiActions = vivaldi.jdhooks.require('_UIActions');
var header = document.getElementById("header");
var body = document.getElementsByTagName("body")[0];
var footer = document.getElementById("footer");
var webview = document.getElementById("webview-container");
var size = {
body: 0
}
var isAddressVisible = !document.getElementsByClassName("address-off").length;
var isFooterVisible = !footer.classList.contains("disabled");
if (!isFooterVisible)
uiActions.toggleFooter();
if (!isAddressVisible)
uiActions.toggleAddressBar();
var isVisible = isAddressVisible;
function toggleUI() {
uiActions.toggleUI();
isVisible = !isVisible;
}
webview.addEventListener("mouseover", function () {
webview.over = true;
window.setTimeout(function () {
if (isVisible && webview.over) {
toggleUI();
}
}, 1000);
});
webview.addEventListener("mouseout", function () {
webview.over = false;
});
body.addEventListener("mousemove", function (e) {
var y = e.clientY;
if ((y <= header.clientHeight + 8 && !isVisible)
|| (y >= body.clientHeight - 8 && !isVisible))
toggleUI();
});
toggleUI();
});