This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
map-menu-submenu.html
executable file
·100 lines (89 loc) · 2.22 KB
/
map-menu-submenu.html
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<link rel="import" href="map-menu-item.html">
<link rel="import" href="map-menu-header.html">
<link rel="import" href="../paper-button/paper-button.html">
<dom-module id="map-menu-submenu">
<template>
<style>
:host {
display: block;
}
:host([collapsable])>map-menu-header {
cursor: pointer;
display: block;
}
#container {
margin-left: 1em;
}
#container ::slotted(map-menu-item) {
margin-top: .4em;
}
</style>
<map-menu-header avatar-label="[[avatarLabel]]" id="[[id]]" title="[[title]]" label="[[label]]" opened="[[opened]]" url="[[url]]" icon="[[icon]]"></map-menu-header>
<iron-collapse id="container">
<slot id="slot"></slot>
</iron-collapse>
</template>
<script>
Polymer({
is: 'map-menu-submenu',
properties: {
id: {
type: String
},
title: {
type: String
},
avatarLabel: {
type: String
},
label: {
type: String
},
icon: {
type: String
},
opened: {
type: Boolean,
value: false
},
collapsable: {
type: Boolean,
value: true
},
expandChildren: {
type: Boolean,
value: false
},
},
observers: [
'_openChanged(opened)',
],
listeners: {
'child-deactivated': '__childDeactivated',
'child-activated': '__childActivated',
'active-item': '__activeChanged',
'toggle-header': '__toggleHeader',
'link-clicked': '_headerClickHandler'
},
_openChanged: function (opened) {
var target = this.$.container;
if (opened) target.show();
if (!opened) target.hide();
},
_headerClickHandler: function (e) {
if (!this.opened) {
this.opened = !this.opened
}
},
__toggleHeader: function (e) {
// catch the event and end propagation
e.stopPropagation()
this.opened = !this.opened
this.fire('toggle-updated')
},
__activeChanged: function (e) {
this.opened = true
},
});
</script>
</dom-module>