-
Notifications
You must be signed in to change notification settings - Fork 0
/
geopkg_controls_ui.js
47 lines (35 loc) · 977 Bytes
/
geopkg_controls_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
// geopkg_controls.ui.js
// Martin Pravda
/*jslint browser */
import make_ui from "./ui.js";
import dom from "./dom.js";
const geopkg_controls_ui = make_ui("geopkg-controls-ui", function (element, {
on_close
}) {
let add_button;
let close_button;
const shadow = element.attachShadow({mode: "closed"});
function attach_listeners({on_add}) {
add_button.onclick = on_add;
}
function remove_listeners() {
[add_button].forEach(function (button) {
delete button.onclick;
});
}
add_button = dom("button", [
"Add"
]);
close_button = dom("button", {
onclick: function (event) {
event.preventDefault();
on_close();
}
}, [
"Close"
]);
shadow.append(add_button, close_button);
element.attach_listeners = attach_listeners;
element.remove_listeners = remove_listeners;
});
export default Object.freeze(geopkg_controls_ui);