-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayer_ui.js
78 lines (65 loc) · 1.64 KB
/
layer_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
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
// layer_ui.js
// Martin Pravda
/*jslint browser */
import make_ui from "./ui.js";
import dom from "./dom.js";
function render_css() {
return `
label:hover {
cursor: pointer;
}
`;
}
const layer_ui = make_ui("layer-ui", function (element, {
is_checked = false,
on_layer_removed,
on_properties_clicked,
on_visibility_checked,
title
}) {
let check_box;
let label;
let delete_button;
const style = dom("style");
const shadow = element.attachShadow({mode: "closed"});
style.textContent = render_css();
check_box = dom("input", {
checked: is_checked,
onchange: function (event) {
on_visibility_checked(event.target.checked);
},
type: "checkbox"
});
label = dom("label", {
onclick: function (event) {
event.preventDefault();
on_properties_clicked();
}
}, [
title
]);
delete_button = dom("button", {
onclick: function (event) {
event.preventDefault();
on_layer_removed();
}
}, [
"Delete"
]);
shadow.append(style, check_box, label, delete_button);
});
//demo import demo from "./demo.js";
//demo demo(layer_ui({
//demo is_checked: true,
//demo on_layer_removed: function () {
//demo console.log("remove");
//demo },
//demo on_properties_clicked: function () {
//demo console.log("clicked");
//demo },
//demo on_visibility_checked: function () {
//demo console.log("checked");
//demo },
//demo title: "MapZen"
//demo }));
export default Object.freeze(layer_ui);