-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproto-menu-item.html
59 lines (48 loc) · 1.38 KB
/
proto-menu-item.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
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="../paper-item/paper-item-behavior.html">
<dom-module id="proto-menu-item">
<template>
<style>
:host {
@apply(--layout-horizontal);
@apply(--layout-center);
padding: 8px 16px;
position: relative;
}
</style>
<content></content>
<div class="nested-arrow" hidden$="[[!_nestedMenu]]"> →</div>
</template>
<script>
Polymer({
is: 'proto-menu-item',
behaviors: [
Polymer.PaperItemBehavior
],
properties: {
_nestedMenu: Element
},
listeners: {
tap: '_onTap'
},
attached: function() {
this._nestedMenu = null;
this._nestedMenuObserver = Polymer.dom(this).observeNodes(function() {
this._nestedMenu = this.queryEffectiveChildren('proto-menu');
}.bind(this));
},
detached: function() {
Polymer.dom(this).unobserveNodes(this._nestedMenuObserver);
},
_hasNestedMenu: function(nestedMenu) {
return Boolean(nestedMenu);
},
_onTap: function(event) {
if (!this._nestedMenu || Polymer.dom(event).path.indexOf(this._nestedMenu) === -1) {
this.fire('menu-item-click');
}
},
});
</script>
</dom-module>