@jsenv/plugin-toolbar 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/toolbar.css +683 -7
- package/dist/js/toolbar_core.js +1792 -8
- package/dist/js/toolbar_injector.js +4 -2
- package/dist/jsenv_plugin_toolbar.js +6 -3
- package/package.json +1 -1
- package/dist/css/document_execution_indicator.css +0 -87
- package/dist/css/globals.css +0 -75
- package/dist/css/server_indicator.css +0 -83
- package/dist/css/theme_light.css +0 -110
- package/dist/css/toolbar_menu_overflow.css +0 -59
- package/dist/css/toolbar_settings.css +0 -202
- package/dist/css/tooltips.css +0 -67
- package/dist/js/animation.js +0 -282
- package/dist/js/animation_actions.js +0 -7
- package/dist/js/animation_effects.js +0 -10
- package/dist/js/animation_signals.js +0 -4
- package/dist/js/changes_actions.js +0 -7
- package/dist/js/changes_indicator.js +0 -57
- package/dist/js/changes_signals.js +0 -2
- package/dist/js/document_execution_indicator.js +0 -62
- package/dist/js/document_index_link.js +0 -4
- package/dist/js/dom.js +0 -48
- package/dist/js/execution_actions.js +0 -46
- package/dist/js/execution_effects.js +0 -16
- package/dist/js/execution_signals.js +0 -17
- package/dist/js/hooks.mjs +0 -185
- package/dist/js/iframe_to_parent_href.js +0 -10
- package/dist/js/notification_actions.js +0 -60
- package/dist/js/notification_context.js +0 -1
- package/dist/js/notification_effects.js +0 -9
- package/dist/js/notification_signals.js +0 -5
- package/dist/js/parent_window_actions.js +0 -39
- package/dist/js/parent_window_context.js +0 -6
- package/dist/js/parent_window_effects.js +0 -15
- package/dist/js/parent_window_signals.js +0 -25
- package/dist/js/preact.mjs +0 -316
- package/dist/js/responsive.js +0 -104
- package/dist/js/server_actions.js +0 -7
- package/dist/js/server_effects.js +0 -9
- package/dist/js/server_indicator.js +0 -52
- package/dist/js/server_signals.js +0 -10
- package/dist/js/settings_actions.js +0 -7
- package/dist/js/settings_signals.js +0 -2
- package/dist/js/signals-core.mjs +0 -339
- package/dist/js/signals.mjs +0 -202
- package/dist/js/theme_actions.js +0 -7
- package/dist/js/theme_effects.js +0 -6
- package/dist/js/theme_signals.js +0 -4
- package/dist/js/toolbar_animation_setting.js +0 -21
- package/dist/js/toolbar_autoreload_setting.js +0 -67
- package/dist/js/toolbar_close_button.js +0 -14
- package/dist/js/toolbar_menu_overflow.js +0 -81
- package/dist/js/toolbar_notification_setting.js +0 -72
- package/dist/js/toolbar_open_actions.js +0 -7
- package/dist/js/toolbar_open_effects.js +0 -4
- package/dist/js/toolbar_open_signals.js +0 -4
- package/dist/js/toolbar_opening.js +0 -65
- package/dist/js/toolbar_overlay.js +0 -69
- package/dist/js/toolbar_settings.js +0 -44
- package/dist/js/toolbar_state_context.js +0 -1
- package/dist/js/toolbar_state_effects.js +0 -8
- package/dist/js/toolbar_state_signals.js +0 -17
- package/dist/js/toolbar_theme_setting.js +0 -13
- package/dist/js/toolbar_ui.js +0 -20
- package/dist/js/tooltip_actions.js +0 -6
- package/dist/js/variant.js +0 -53
package/dist/js/signals.mjs
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { Component as t, options as i } from "./preact.mjs";
|
|
2
|
-
import { useMemo as e, useRef as n, useEffect as o } from "./hooks.mjs";
|
|
3
|
-
import { Signal as r, computed as f, signal as l, effect as s } from "./signals-core.mjs";
|
|
4
|
-
export { Signal, batch, computed, effect, signal } from "./signals-core.mjs";
|
|
5
|
-
function c(t, e) {
|
|
6
|
-
i[t] = e.bind(null, i[t] || (() => {}));
|
|
7
|
-
}
|
|
8
|
-
let u, a;
|
|
9
|
-
function d(t) {
|
|
10
|
-
if (a) a();
|
|
11
|
-
a = t && t.S();
|
|
12
|
-
}
|
|
13
|
-
function p({
|
|
14
|
-
data: t
|
|
15
|
-
}) {
|
|
16
|
-
const i = useSignal(t);
|
|
17
|
-
i.value = t;
|
|
18
|
-
const n = e(() => {
|
|
19
|
-
let t = this.__v;
|
|
20
|
-
while (t = t.__) if (t.__c) {
|
|
21
|
-
t.__c.__$f |= 4;
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
this.__$u.c = () => {
|
|
25
|
-
this.base.data = n.peek();
|
|
26
|
-
};
|
|
27
|
-
return f(() => {
|
|
28
|
-
let t = i.value.value;
|
|
29
|
-
return 0 === t ? 0 : !0 === t ? "" : t || "";
|
|
30
|
-
});
|
|
31
|
-
}, []);
|
|
32
|
-
return n.value;
|
|
33
|
-
}
|
|
34
|
-
p.displayName = "_st";
|
|
35
|
-
Object.defineProperties(r.prototype, {
|
|
36
|
-
constructor: {
|
|
37
|
-
configurable: !0
|
|
38
|
-
},
|
|
39
|
-
type: {
|
|
40
|
-
configurable: !0,
|
|
41
|
-
value: p
|
|
42
|
-
},
|
|
43
|
-
props: {
|
|
44
|
-
configurable: !0,
|
|
45
|
-
get() {
|
|
46
|
-
return {
|
|
47
|
-
data: this
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
__b: {
|
|
52
|
-
configurable: !0,
|
|
53
|
-
value: 1
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
c("__b", (t, i) => {
|
|
57
|
-
if ("string" == typeof i.type) {
|
|
58
|
-
let t,
|
|
59
|
-
e = i.props;
|
|
60
|
-
for (let n in e) {
|
|
61
|
-
if ("children" === n) continue;
|
|
62
|
-
let o = e[n];
|
|
63
|
-
if (o instanceof r) {
|
|
64
|
-
if (!t) i.__np = t = {};
|
|
65
|
-
t[n] = o;
|
|
66
|
-
e[n] = o.peek();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
t(i);
|
|
71
|
-
});
|
|
72
|
-
c("__r", (t, i) => {
|
|
73
|
-
d();
|
|
74
|
-
let e,
|
|
75
|
-
n = i.__c;
|
|
76
|
-
if (n) {
|
|
77
|
-
n.__$f &= -2;
|
|
78
|
-
e = n.__$u;
|
|
79
|
-
if (void 0 === e) n.__$u = e = function (t) {
|
|
80
|
-
let i;
|
|
81
|
-
s(function () {
|
|
82
|
-
i = this;
|
|
83
|
-
});
|
|
84
|
-
i.c = () => {
|
|
85
|
-
n.__$f |= 1;
|
|
86
|
-
n.setState({});
|
|
87
|
-
};
|
|
88
|
-
return i;
|
|
89
|
-
}();
|
|
90
|
-
}
|
|
91
|
-
u = n;
|
|
92
|
-
d(e);
|
|
93
|
-
t(i);
|
|
94
|
-
});
|
|
95
|
-
c("__e", (t, i, e, n) => {
|
|
96
|
-
d();
|
|
97
|
-
u = void 0;
|
|
98
|
-
t(i, e, n);
|
|
99
|
-
});
|
|
100
|
-
c("diffed", (t, i) => {
|
|
101
|
-
d();
|
|
102
|
-
u = void 0;
|
|
103
|
-
let e;
|
|
104
|
-
if ("string" == typeof i.type && (e = i.__e)) {
|
|
105
|
-
let t = i.__np,
|
|
106
|
-
n = i.props;
|
|
107
|
-
if (t) {
|
|
108
|
-
let i = e.U;
|
|
109
|
-
if (i) for (let e in i) {
|
|
110
|
-
let n = i[e];
|
|
111
|
-
if (void 0 !== n && !(e in t)) {
|
|
112
|
-
n.d();
|
|
113
|
-
i[e] = void 0;
|
|
114
|
-
}
|
|
115
|
-
} else {
|
|
116
|
-
i = {};
|
|
117
|
-
e.U = i;
|
|
118
|
-
}
|
|
119
|
-
for (let o in t) {
|
|
120
|
-
let r = i[o],
|
|
121
|
-
f = t[o];
|
|
122
|
-
if (void 0 === r) {
|
|
123
|
-
r = h(e, o, f, n);
|
|
124
|
-
i[o] = r;
|
|
125
|
-
} else r.o(f, n);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
t(i);
|
|
130
|
-
});
|
|
131
|
-
function h(t, i, e, n) {
|
|
132
|
-
const o = i in t && void 0 === t.ownerSVGElement,
|
|
133
|
-
r = l(e);
|
|
134
|
-
return {
|
|
135
|
-
o: (t, i) => {
|
|
136
|
-
r.value = t;
|
|
137
|
-
n = i;
|
|
138
|
-
},
|
|
139
|
-
d: s(() => {
|
|
140
|
-
const e = r.value.value;
|
|
141
|
-
if (n[i] !== e) {
|
|
142
|
-
n[i] = e;
|
|
143
|
-
if (o) t[i] = e;else if (e) t.setAttribute(i, e);else t.removeAttribute(i);
|
|
144
|
-
}
|
|
145
|
-
})
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
c("unmount", (t, i) => {
|
|
149
|
-
if ("string" == typeof i.type) {
|
|
150
|
-
let t = i.__e;
|
|
151
|
-
if (t) {
|
|
152
|
-
const i = t.U;
|
|
153
|
-
if (i) {
|
|
154
|
-
t.U = void 0;
|
|
155
|
-
for (let t in i) {
|
|
156
|
-
let e = i[t];
|
|
157
|
-
if (e) e.d();
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
} else {
|
|
162
|
-
let t = i.__c;
|
|
163
|
-
if (t) {
|
|
164
|
-
const i = t.__$u;
|
|
165
|
-
if (i) {
|
|
166
|
-
t.__$u = void 0;
|
|
167
|
-
i.d();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
t(i);
|
|
172
|
-
});
|
|
173
|
-
c("__h", (t, i, e, n) => {
|
|
174
|
-
if (n < 3) i.__$f |= 2;
|
|
175
|
-
t(i, e, n);
|
|
176
|
-
});
|
|
177
|
-
t.prototype.shouldComponentUpdate = function (t, i) {
|
|
178
|
-
const e = this.__$u;
|
|
179
|
-
if (!(e && void 0 !== e.s || 4 & this.__$f)) return !0;
|
|
180
|
-
if (3 & this.__$f) return !0;
|
|
181
|
-
for (let t in i) return !0;
|
|
182
|
-
for (let i in t) if ("__source" !== i && t[i] !== this.props[i]) return !0;
|
|
183
|
-
for (let i in this.props) if (!(i in t)) return !0;
|
|
184
|
-
return !1;
|
|
185
|
-
};
|
|
186
|
-
function useSignal(t) {
|
|
187
|
-
return e(() => l(t), []);
|
|
188
|
-
}
|
|
189
|
-
function useComputed(t) {
|
|
190
|
-
const i = n(t);
|
|
191
|
-
i.current = t;
|
|
192
|
-
u.__$f |= 4;
|
|
193
|
-
return e(() => f(() => i.current()), []);
|
|
194
|
-
}
|
|
195
|
-
function useSignalEffect(t) {
|
|
196
|
-
const i = n(t);
|
|
197
|
-
i.current = t;
|
|
198
|
-
o(() => s(() => {
|
|
199
|
-
i.current();
|
|
200
|
-
}), []);
|
|
201
|
-
}
|
|
202
|
-
export { useComputed, useSignal, useSignalEffect };
|
package/dist/js/theme_actions.js
DELETED
package/dist/js/theme_effects.js
DELETED
package/dist/js/theme_signals.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { signal } from "./signals.mjs";
|
|
2
|
-
import { paramsFromParentWindow } from "./parent_window_context.js";
|
|
3
|
-
import { stateFromLocalStorage } from "./toolbar_state_context.js";
|
|
4
|
-
export const themeSignal = signal(typeof stateFromLocalStorage.theme === "string" ? stateFromLocalStorage.theme : typeof paramsFromParentWindow.theme === "string" ? paramsFromParentWindow.theme : "dark");
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { effect } from "./signals.mjs";
|
|
2
|
-
import { animationsEnabledSignal } from "./animation_signals.js";
|
|
3
|
-
import { enableAnimations, disableAnimations } from "./animation_actions.js";
|
|
4
|
-
export const renderToolbarAnimationSetting = () => {
|
|
5
|
-
const animCheckbox = document.querySelector("#toggle_anims");
|
|
6
|
-
effect(() => {
|
|
7
|
-
const animationsEnabled = animationsEnabledSignal.value;
|
|
8
|
-
animCheckbox.checked = animationsEnabled;
|
|
9
|
-
});
|
|
10
|
-
animCheckbox.onchange = () => {
|
|
11
|
-
if (animCheckbox.checked) {
|
|
12
|
-
enableAnimations();
|
|
13
|
-
} else {
|
|
14
|
-
disableAnimations();
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
// enable toolbar transition only after first render
|
|
18
|
-
setTimeout(() => {
|
|
19
|
-
document.querySelector("#toolbar").setAttribute("data-animate", "");
|
|
20
|
-
});
|
|
21
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { effect } from "./signals.mjs";
|
|
2
|
-
import { autoreloadEnabledSignal } from "./parent_window_signals.js";
|
|
3
|
-
import { disableAutoreload, enableAutoreload } from "./parent_window_actions.js";
|
|
4
|
-
export const renderToolbarAutoreloadSetting = () => {
|
|
5
|
-
const parentWindowReloader = window.parent.__reloader__;
|
|
6
|
-
if (!parentWindowReloader) {
|
|
7
|
-
disableAutoreloadSetting();
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const autoreloadCheckbox = document.querySelector("#toggle_autoreload");
|
|
11
|
-
effect(() => {
|
|
12
|
-
const autoreloadEnabled = autoreloadEnabledSignal.value;
|
|
13
|
-
if (autoreloadEnabled) {
|
|
14
|
-
autoreloadCheckbox.checked = true;
|
|
15
|
-
} else {
|
|
16
|
-
autoreloadCheckbox.checked = false;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
autoreloadCheckbox.onchange = () => {
|
|
20
|
-
if (autoreloadCheckbox.checked) {
|
|
21
|
-
enableAutoreload();
|
|
22
|
-
} else {
|
|
23
|
-
disableAutoreload();
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
const disableAutoreloadSetting = () => {
|
|
28
|
-
document.querySelector(".settings_autoreload").setAttribute("data-disabled", "true");
|
|
29
|
-
document.querySelector(".settings_autoreload").setAttribute("title", `Autoreload not enabled on server`);
|
|
30
|
-
document.querySelector("#toggle_autoreload").disabled = true;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// const changeLink = variantNode.querySelector(".eventsource-changes-link")
|
|
34
|
-
// changeLink.innerHTML = reloadMessageCount
|
|
35
|
-
// changeLink.onclick = () => {
|
|
36
|
-
// console.log(reloadMessages)
|
|
37
|
-
// // eslint-disable-next-line no-alert
|
|
38
|
-
// window.parent.alert(JSON.stringify(reloadMessages, null, " "))
|
|
39
|
-
// }
|
|
40
|
-
|
|
41
|
-
// const someFailed = reloadMessages.some((m) => m.status === "failed")
|
|
42
|
-
// const somePending = reloadMessages.some((m) => m.status === "pending")
|
|
43
|
-
// const applyLink = variantNode.querySelector(".eventsource-reload-link")
|
|
44
|
-
// applyLink.innerHTML = someFailed
|
|
45
|
-
// ? "failed"
|
|
46
|
-
// : somePending
|
|
47
|
-
// ? "applying..."
|
|
48
|
-
// : "apply changes"
|
|
49
|
-
// applyLink.onclick = someFailed
|
|
50
|
-
// ? () => {
|
|
51
|
-
// parentEventSourceClient.applyReloadMessageEffects()
|
|
52
|
-
// }
|
|
53
|
-
// : somePending
|
|
54
|
-
// ? () => {}
|
|
55
|
-
// : () => {
|
|
56
|
-
// parentEventSourceClient.applyReloadMessageEffects()
|
|
57
|
-
// }
|
|
58
|
-
|
|
59
|
-
// parentEventSourceClient.reloadMessagesSignal.onchange = () => {
|
|
60
|
-
// updateEventSourceIndicator()
|
|
61
|
-
// }
|
|
62
|
-
// const autoreloadCheckbox = document.querySelector("#toggle-autoreload")
|
|
63
|
-
// autoreloadCheckbox.checked = parentEventSourceClient.isAutoreloadEnabled()
|
|
64
|
-
// autoreloadCheckbox.onchange = () => {
|
|
65
|
-
// parentEventSourceClient.setAutoreloadPreference(autoreloadCheckbox.checked)
|
|
66
|
-
// updateEventSourceIndicator()
|
|
67
|
-
// }
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { openedSignal } from "./toolbar_open_signals.js";
|
|
2
|
-
import { openToolbar, closeToolbar } from "./toolbar_open_actions.js";
|
|
3
|
-
export const renderToolbarCloseButton = () => {
|
|
4
|
-
// if user click enter or space quickly while closing toolbar
|
|
5
|
-
// it will cancel the closing
|
|
6
|
-
// that's why I used toggleToolbar and not hideToolbar
|
|
7
|
-
document.querySelector("#toolbar_close_button").onclick = () => {
|
|
8
|
-
if (openedSignal.value) {
|
|
9
|
-
closeToolbar();
|
|
10
|
-
} else {
|
|
11
|
-
openToolbar();
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { closeAllTooltips } from "./tooltip_actions.js";
|
|
2
|
-
import { forceHideElement, removeForceHideElement, deactivateToolbarSection } from "./dom.js";
|
|
3
|
-
import { createHorizontalBreakpoint } from "./responsive.js";
|
|
4
|
-
const WINDOW_SMALL_WIDTH = 420;
|
|
5
|
-
export const initToolbarMenuOverflow = () => {
|
|
6
|
-
// apply responsive design on toolbar icons if needed + add listener on resize screen
|
|
7
|
-
// ideally we should listen breakpoint once, for now restore toolbar
|
|
8
|
-
const overflowMenuBreakpoint = createHorizontalBreakpoint(WINDOW_SMALL_WIDTH);
|
|
9
|
-
const handleOverflowMenuBreakpoint = () => {
|
|
10
|
-
responsiveToolbar(overflowMenuBreakpoint);
|
|
11
|
-
};
|
|
12
|
-
handleOverflowMenuBreakpoint();
|
|
13
|
-
overflowMenuBreakpoint.changed.listen(handleOverflowMenuBreakpoint);
|
|
14
|
-
document.querySelector("#menu_overflow_button").onclick = () => {
|
|
15
|
-
if (overflowMenuIsOpened()) {
|
|
16
|
-
closeOverflowMenu();
|
|
17
|
-
} else {
|
|
18
|
-
openOverflowMenu();
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
const responsiveToolbar = overflowMenuBreakpoint => {
|
|
23
|
-
// close all tooltips in case opened
|
|
24
|
-
closeAllTooltips();
|
|
25
|
-
// close settings box in case opened
|
|
26
|
-
deactivateToolbarSection(document.querySelector("#settings"));
|
|
27
|
-
if (overflowMenuBreakpoint.isBelow()) {
|
|
28
|
-
enableOverflow();
|
|
29
|
-
} else {
|
|
30
|
-
disableOverflow();
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
let moves = [];
|
|
34
|
-
const enableOverflow = () => {
|
|
35
|
-
// move elements from toolbar to overflow menu
|
|
36
|
-
const responsiveToolbarElements = document.querySelectorAll("[data-responsive-toolbar-element]");
|
|
37
|
-
const overflowMenu = document.querySelector("#menu_overflow");
|
|
38
|
-
|
|
39
|
-
// keep a placeholder element to know where to move them back
|
|
40
|
-
moves = Array.from(responsiveToolbarElements).map(element => {
|
|
41
|
-
const placeholder = document.createElement("div");
|
|
42
|
-
placeholder.style.display = "none";
|
|
43
|
-
placeholder.setAttribute("data-placeholder", "");
|
|
44
|
-
element.parentNode.replaceChild(placeholder, element);
|
|
45
|
-
overflowMenu.appendChild(element);
|
|
46
|
-
return {
|
|
47
|
-
element,
|
|
48
|
-
placeholder
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
document.querySelector("#toolbar").setAttribute("data-menu-overflow-enabled", "");
|
|
52
|
-
removeForceHideElement(document.querySelector("#menu_overflow_button"));
|
|
53
|
-
};
|
|
54
|
-
const disableOverflow = () => {
|
|
55
|
-
// close overflow menu in case it's open & unselect toggleOverflowMenu button in case it's selected
|
|
56
|
-
closeOverflowMenu();
|
|
57
|
-
deactivateToolbarSection(document.querySelector("#menu_overflow"));
|
|
58
|
-
moves.forEach(({
|
|
59
|
-
element,
|
|
60
|
-
placeholder
|
|
61
|
-
}) => {
|
|
62
|
-
placeholder.parentNode.replaceChild(element, placeholder);
|
|
63
|
-
});
|
|
64
|
-
moves = [];
|
|
65
|
-
document.querySelector("#toolbar").removeAttribute("data-menu-overflow-enabled");
|
|
66
|
-
forceHideElement(document.querySelector("#menu_overflow_button"));
|
|
67
|
-
};
|
|
68
|
-
const overflowMenuIsOpened = () => {
|
|
69
|
-
const toolbar = document.querySelector("#toolbar");
|
|
70
|
-
return toolbar.hasAttribute("data-menu-overflow-opened");
|
|
71
|
-
};
|
|
72
|
-
const openOverflowMenu = () => {
|
|
73
|
-
const toolbar = document.querySelector("#toolbar");
|
|
74
|
-
document.querySelector("#menu_overflow").setAttribute("data-animate", "");
|
|
75
|
-
toolbar.setAttribute("data-menu-overflow-opened", "");
|
|
76
|
-
};
|
|
77
|
-
const closeOverflowMenu = () => {
|
|
78
|
-
const toolbar = document.querySelector("#toolbar");
|
|
79
|
-
toolbar.removeAttribute("data-menu-overflow-opened");
|
|
80
|
-
document.querySelector("#menu_overflow").removeAttribute("data-animate");
|
|
81
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { effect } from "./signals.mjs";
|
|
2
|
-
import { notificationsEnabledSignal, notificationPermissionSignal } from "./notification_signals.js";
|
|
3
|
-
import { notificationAPIDetected } from "./notification_context.js";
|
|
4
|
-
import { enableNotifications, disableNotifications, requestPermission } from "./notification_actions.js";
|
|
5
|
-
import { enableVariant } from "./variant.js";
|
|
6
|
-
const notifCheckbox = document.querySelector("#toggle_notifs");
|
|
7
|
-
export const renderToolbarNotificationSetting = () => {
|
|
8
|
-
effect(() => {
|
|
9
|
-
const notificationsEnabled = notificationsEnabledSignal.value;
|
|
10
|
-
notifCheckbox.checked = notificationsEnabled;
|
|
11
|
-
});
|
|
12
|
-
effect(() => {
|
|
13
|
-
const notificationPermission = notificationPermissionSignal.value;
|
|
14
|
-
if (!notificationAPIDetected) {
|
|
15
|
-
applyNotificationNotAvailableEffects();
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (notificationPermission === "default") {
|
|
19
|
-
applyNotificationDefaultEffects();
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (notificationPermission === "denied") {
|
|
23
|
-
applyNotificationDeniedEffects();
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
if (notificationPermission === "granted") {
|
|
27
|
-
applyNotificationGrantedEffects();
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
const applyNotificationNotAvailableEffects = () => {
|
|
33
|
-
const notifSetting = document.querySelector(".settings_notification");
|
|
34
|
-
notifSetting.setAttribute("data-disabled", "true");
|
|
35
|
-
notifSetting.setAttribute("title", `Notification not available in the browser`);
|
|
36
|
-
notifCheckbox.disabled = true;
|
|
37
|
-
};
|
|
38
|
-
const applyNotificationDefaultEffects = () => {
|
|
39
|
-
applyNotificationNOTGrantedEffects();
|
|
40
|
-
const notifSetting = document.querySelector(".settings_notification");
|
|
41
|
-
notifSetting.removeAttribute("data-disabled");
|
|
42
|
-
notifSetting.removeAttribute("title");
|
|
43
|
-
};
|
|
44
|
-
const applyNotificationDeniedEffects = () => {
|
|
45
|
-
applyNotificationNOTGrantedEffects();
|
|
46
|
-
const notifSetting = document.querySelector(".settings_notification");
|
|
47
|
-
notifSetting.setAttribute("data-disabled", "true");
|
|
48
|
-
notifSetting.setAttribute("title", `Notification denied`);
|
|
49
|
-
};
|
|
50
|
-
const applyNotificationGrantedEffects = () => {
|
|
51
|
-
enableVariant(document.querySelector(".notification_text"), {
|
|
52
|
-
notif_granted: "yes"
|
|
53
|
-
});
|
|
54
|
-
notifCheckbox.disabled = false;
|
|
55
|
-
notifCheckbox.onchange = () => {
|
|
56
|
-
if (notifCheckbox.checked) {
|
|
57
|
-
enableNotifications();
|
|
58
|
-
} else {
|
|
59
|
-
disableNotifications();
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
const applyNotificationNOTGrantedEffects = () => {
|
|
64
|
-
enableVariant(document.querySelector(".notification_text"), {
|
|
65
|
-
notif_granted: "no"
|
|
66
|
-
});
|
|
67
|
-
notifCheckbox.disabled = true;
|
|
68
|
-
notifCheckbox.checked = false;
|
|
69
|
-
document.querySelector("a.request_notification_permission").onclick = () => {
|
|
70
|
-
requestPermission();
|
|
71
|
-
};
|
|
72
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { signal } from "./signals.mjs";
|
|
2
|
-
import { paramsFromParentWindow } from "./parent_window_context.js";
|
|
3
|
-
import { stateFromLocalStorage } from "./toolbar_state_context.js";
|
|
4
|
-
export const openedSignal = signal(typeof stateFromLocalStorage.opened === "boolean" ? stateFromLocalStorage.opened : typeof paramsFromParentWindow.opened === "boolean" ? paramsFromParentWindow.opened : false);
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { effect } from "./signals.mjs";
|
|
2
|
-
import { closeAllTooltips } from "./tooltip_actions.js";
|
|
3
|
-
import { animationsEnabledSignal } from "./animation_signals.js";
|
|
4
|
-
import { openedSignal } from "./toolbar_open_signals.js";
|
|
5
|
-
import { getToolbarIframe, setStyles } from "./dom.js";
|
|
6
|
-
import { startJavaScriptAnimation } from "./animation.js";
|
|
7
|
-
export const initToolbarOpening = () => {
|
|
8
|
-
effect(() => {
|
|
9
|
-
const opened = openedSignal.value;
|
|
10
|
-
if (opened) {
|
|
11
|
-
showToolbar();
|
|
12
|
-
} else {
|
|
13
|
-
hideToolbar();
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
let restoreToolbarIframeParentStyles = () => {};
|
|
18
|
-
let restoreToolbarIframeStyles = () => {};
|
|
19
|
-
const hideToolbar = () => {
|
|
20
|
-
closeAllTooltips();
|
|
21
|
-
restoreToolbarIframeParentStyles();
|
|
22
|
-
restoreToolbarIframeStyles();
|
|
23
|
-
document.documentElement.removeAttribute("data-toolbar-visible");
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
// (by the way it might be cool to have the toolbar auto show when)
|
|
27
|
-
// it has something to say (being disconnected from server)
|
|
28
|
-
const showToolbar = () => {
|
|
29
|
-
const animationsEnabled = animationsEnabledSignal.peek();
|
|
30
|
-
document.documentElement.setAttribute("data-toolbar-visible", "");
|
|
31
|
-
const toolbarIframe = getToolbarIframe();
|
|
32
|
-
const toolbarIframeParent = toolbarIframe.parentNode;
|
|
33
|
-
const parentWindow = window.parent;
|
|
34
|
-
const parentDocumentElement = parentWindow.document.compatMode === "CSS1Compat" ? parentWindow.document.documentElement : parentWindow.document.body;
|
|
35
|
-
const scrollYMax = parentDocumentElement.scrollHeight - parentWindow.innerHeight;
|
|
36
|
-
const scrollY = parentDocumentElement.scrollTop;
|
|
37
|
-
const scrollYRemaining = scrollYMax - scrollY;
|
|
38
|
-
setStyles(toolbarIframeParent, {
|
|
39
|
-
"transition-property": "padding-bottom",
|
|
40
|
-
"transition-duration": animationsEnabled ? "300ms" : "0s"
|
|
41
|
-
});
|
|
42
|
-
// maybe we should use js animation here because we would not conflict with css
|
|
43
|
-
restoreToolbarIframeParentStyles = setStyles(toolbarIframeParent, {
|
|
44
|
-
"scroll-padding-bottom": "40px",
|
|
45
|
-
// same here we should add 40px
|
|
46
|
-
"padding-bottom": "40px" // if there is already one we should add 40px
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
restoreToolbarIframeStyles = setStyles(toolbarIframe, {
|
|
50
|
-
height: "40px",
|
|
51
|
-
visibility: "visible"
|
|
52
|
-
});
|
|
53
|
-
if (scrollYRemaining < 40 && scrollYMax > 0) {
|
|
54
|
-
const scrollEnd = scrollY + 40;
|
|
55
|
-
startJavaScriptAnimation({
|
|
56
|
-
duration: 300,
|
|
57
|
-
onProgress: ({
|
|
58
|
-
progress
|
|
59
|
-
}) => {
|
|
60
|
-
const value = scrollY + (scrollEnd - scrollY) * progress;
|
|
61
|
-
parentDocumentElement.scrollTop = value;
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { effect } from "./signals.mjs";
|
|
2
|
-
import { openedSignal } from "./toolbar_open_signals.js";
|
|
3
|
-
import { settingsOpenedSignal } from "./settings_signals.js";
|
|
4
|
-
import { closeSettings } from "./settings_actions.js";
|
|
5
|
-
import { closeAllTooltips } from "./tooltip_actions.js";
|
|
6
|
-
import { executionTooltipOpenedSignal } from "./execution_signals.js";
|
|
7
|
-
import { changesTooltipOpenedSignal } from "./changes_signals.js";
|
|
8
|
-
import { serverTooltipOpenedSignal } from "./server_signals.js";
|
|
9
|
-
import { getToolbarIframe, setStyles } from "./dom.js";
|
|
10
|
-
export const renderToolbarOverlay = () => {
|
|
11
|
-
const toolbarOverlay = document.querySelector("#toolbar_overlay");
|
|
12
|
-
toolbarOverlay.onclick = () => {
|
|
13
|
-
closeAllTooltips();
|
|
14
|
-
closeSettings();
|
|
15
|
-
};
|
|
16
|
-
effect(() => {
|
|
17
|
-
if (!window.parent) {
|
|
18
|
-
// can happen while parent iframe reloads
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const opened = openedSignal.value;
|
|
22
|
-
const settingsOpened = settingsOpenedSignal.value;
|
|
23
|
-
const executionTooltipOpened = executionTooltipOpenedSignal.value;
|
|
24
|
-
const changesTooltipOpened = changesTooltipOpenedSignal.value;
|
|
25
|
-
const serverTooltipOpened = serverTooltipOpenedSignal.value;
|
|
26
|
-
if (!opened) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (settingsOpened || executionTooltipOpened || changesTooltipOpened || serverTooltipOpened) {
|
|
30
|
-
enableIframeOverflowOnParentWindow();
|
|
31
|
-
} else {
|
|
32
|
-
disableIframeOverflowOnParentWindow();
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
const enableIframeOverflowOnParentWindow = () => {
|
|
37
|
-
const iframe = getToolbarIframe();
|
|
38
|
-
const transitionDuration = iframe.style.transitionDuration;
|
|
39
|
-
setStyles(iframe, {
|
|
40
|
-
"height": "100%",
|
|
41
|
-
// we don't want to animate height transition
|
|
42
|
-
// but if it was enabled, we'll restore it afterwards
|
|
43
|
-
"transition-duration": "0ms"
|
|
44
|
-
});
|
|
45
|
-
if (transitionDuration) {
|
|
46
|
-
setTimeout(() => {
|
|
47
|
-
setStyles(iframe, {
|
|
48
|
-
"transition-duration": transitionDuration
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const disableIframeOverflowOnParentWindow = () => {
|
|
54
|
-
const iframe = getToolbarIframe();
|
|
55
|
-
const transitionDuration = iframe.style.transitionDuration;
|
|
56
|
-
setStyles(iframe, {
|
|
57
|
-
"height": "40px",
|
|
58
|
-
// we don't want to animate height transition
|
|
59
|
-
// but if it was enabled, we'll restore it afterwards
|
|
60
|
-
"transition-duration": "0ms"
|
|
61
|
-
});
|
|
62
|
-
if (transitionDuration) {
|
|
63
|
-
setTimeout(() => {
|
|
64
|
-
setStyles(iframe, {
|
|
65
|
-
"transition-duration": transitionDuration
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { effect } from "./signals.mjs";
|
|
2
|
-
import { settingsOpenedSignal } from "./settings_signals.js";
|
|
3
|
-
import { openSettings, closeSettings } from "./settings_actions.js";
|
|
4
|
-
import { enableVariant } from "./variant.js";
|
|
5
|
-
import { activateToolbarSection, deactivateToolbarSection } from "./dom.js";
|
|
6
|
-
import { renderToolbarAutoreloadSetting } from "./toolbar_autoreload_setting.js";
|
|
7
|
-
import { renderToolbarAnimationSetting } from "./toolbar_animation_setting.js";
|
|
8
|
-
import { renderToolbarNotificationSetting } from "./toolbar_notification_setting.js";
|
|
9
|
-
import { renderToolbarThemeSetting } from "./toolbar_theme_setting.js";
|
|
10
|
-
export const renderToolbarSettings = () => {
|
|
11
|
-
document.querySelector("#settings_open_button").onclick = toggleSettings;
|
|
12
|
-
document.querySelector("#settings_close_button").onclick = toggleSettings;
|
|
13
|
-
disableWarningStyle();
|
|
14
|
-
renderToolbarAutoreloadSetting();
|
|
15
|
-
renderToolbarAnimationSetting();
|
|
16
|
-
renderToolbarNotificationSetting();
|
|
17
|
-
renderToolbarThemeSetting();
|
|
18
|
-
effect(() => {
|
|
19
|
-
const settingsOpened = settingsOpenedSignal.value;
|
|
20
|
-
if (settingsOpened) {
|
|
21
|
-
activateToolbarSection(document.querySelector("#settings"));
|
|
22
|
-
} else {
|
|
23
|
-
deactivateToolbarSection(document.querySelector("#settings"));
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
const toggleSettings = () => {
|
|
28
|
-
const settingsOpened = settingsOpenedSignal.value;
|
|
29
|
-
if (settingsOpened) {
|
|
30
|
-
closeSettings();
|
|
31
|
-
} else {
|
|
32
|
-
openSettings();
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
export const enableWarningStyle = () => {
|
|
36
|
-
enableVariant(document.querySelector("#settings_open_button"), {
|
|
37
|
-
has_warning: "yes"
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
export const disableWarningStyle = () => {
|
|
41
|
-
enableVariant(document.querySelector("#settings_open_button"), {
|
|
42
|
-
has_warning: "no"
|
|
43
|
-
});
|
|
44
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const stateFromLocalStorage = localStorage.hasOwnProperty("jsenv_toolbar") ? JSON.parse(localStorage.getItem("jsenv_toolbar")) : {};
|