e619a3b0
Luigi Serra
Controllet cross ...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-menu-behavior/iron-menu-behavior.html">
<link rel="import" href="../iron-behaviors/iron-control-state.html">
<link rel="import" href="../iron-collapse/iron-collapse.html">
|
c5169e0e
Renato De Donato
a new hope
|
15
|
<link rel="import" href="../paper-styles/paper-styles.html">
|
e619a3b0
Luigi Serra
Controllet cross ...
|
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
|
<!--
`<paper-submenu>` is a nested menu inside of a parent `<paper-menu>`. It
consists of a trigger that expands or collapses another `<paper-menu>`:
<paper-menu>
<paper-submenu>
<paper-item class="menu-trigger">Topics</paper-item>
<paper-menu class="menu-content">
<paper-item>Topic 1</paper-item>
<paper-item>Topic 2</paper-item>
<paper-item>Topic 3</paper-item>
</paper-menu>
</paper-submenu>
<paper-submenu>
<paper-item class="menu-trigger">Faves</paper-item>
<paper-menu class="menu-content">
<paper-item>Fave 1</paper-item>
<paper-item>Fave 2</paper-item>
</paper-menu>
</paper-submenu>
<paper-submenu disabled>
<paper-item class="menu-trigger">Unavailable</paper-item>
<paper-menu class="menu-content">
<paper-item>Disabled 1</paper-item>
<paper-item>Disabled 2</paper-item>
</paper-menu>
</paper-submenu>
</paper-menu>
Just like in `<paper-menu>`, the focused item is highlighted, and the selected
item has bolded text. Please see the `<paper-menu>` docs for which attributes
(such as `multi` and `selected`), and styling options are available for the
`menu-content` menu.
@group Paper Elements
@element paper-submenu
@hero hero.svg
@demo demo/index.html
-->
<dom-module id="paper-submenu">
|
c5169e0e
Renato De Donato
a new hope
|
58
|
<link rel="import" type="css" href="paper-menu-shared.css">
|
a1a3bc73
Luigi Serra
graphs updates
|
59
|
|
c5169e0e
Renato De Donato
a new hope
|
60
|
<template>
|
e619a3b0
Luigi Serra
Controllet cross ...
|
61
62
63
64
|
<div class="selectable-content" on-tap="_onTap">
<content id="trigger" select=".menu-trigger"></content>
</div>
<iron-collapse id="collapse" opened="{{opened}}">
|
c5169e0e
Renato De Donato
a new hope
|
65
|
<content select=".menu-content"></content>
|
e619a3b0
Luigi Serra
Controllet cross ...
|
66
67
68
|
</iron-collapse>
</template>
|
c5169e0e
Renato De Donato
a new hope
|
69
|
</dom-module>
|
e619a3b0
Luigi Serra
Controllet cross ...
|
70
|
|
c5169e0e
Renato De Donato
a new hope
|
71
|
<script>
|
e619a3b0
Luigi Serra
Controllet cross ...
|
72
|
|
c5169e0e
Renato De Donato
a new hope
|
73
|
(function() {
|
a1a3bc73
Luigi Serra
graphs updates
|
74
|
|
c5169e0e
Renato De Donato
a new hope
|
75
|
Polymer({
|
a1a3bc73
Luigi Serra
graphs updates
|
76
|
|
c5169e0e
Renato De Donato
a new hope
|
77
|
is: 'paper-submenu',
|
a1a3bc73
Luigi Serra
graphs updates
|
78
|
|
c5169e0e
Renato De Donato
a new hope
|
79
|
properties: {
|
a1a3bc73
Luigi Serra
graphs updates
|
80
|
/**
|
c5169e0e
Renato De Donato
a new hope
|
81
|
* Fired when the submenu is opened.
|
e619a3b0
Luigi Serra
Controllet cross ...
|
82
|
*
|
c5169e0e
Renato De Donato
a new hope
|
83
|
* @event paper-submenu-open
|
e619a3b0
Luigi Serra
Controllet cross ...
|
84
|
*/
|
e619a3b0
Luigi Serra
Controllet cross ...
|
85
|
|
a1a3bc73
Luigi Serra
graphs updates
|
86
|
/**
|
c5169e0e
Renato De Donato
a new hope
|
87
|
* Fired when the submenu is closed.
|
a1a3bc73
Luigi Serra
graphs updates
|
88
|
*
|
c5169e0e
Renato De Donato
a new hope
|
89
|
* @event paper-submenu-close
|
a1a3bc73
Luigi Serra
graphs updates
|
90
|
*/
|
e619a3b0
Luigi Serra
Controllet cross ...
|
91
|
|
a1a3bc73
Luigi Serra
graphs updates
|
92
|
/**
|
c5169e0e
Renato De Donato
a new hope
|
93
|
* Set opened to true to show the collapse element and to false to hide it.
|
a1a3bc73
Luigi Serra
graphs updates
|
94
|
*
|
c5169e0e
Renato De Donato
a new hope
|
95
|
* @attribute opened
|
a1a3bc73
Luigi Serra
graphs updates
|
96
|
*/
|
c5169e0e
Renato De Donato
a new hope
|
97
98
99
100
101
|
opened: {
type: Boolean,
value: false,
notify: true,
observer: '_openedChanged'
|
e619a3b0
Luigi Serra
Controllet cross ...
|
102
|
}
|
c5169e0e
Renato De Donato
a new hope
|
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
},
behaviors: [
Polymer.IronControlState
],
get __parent() {
return Polymer.dom(this).parentNode;
},
get __trigger() {
return Polymer.dom(this.$.trigger).getDistributedNodes()[0];
},
attached: function() {
this.listen(this.__parent, 'iron-activate', '_onParentIronActivate');
},
dettached: function() {
this.unlisten(this.__parent, 'iron-activate', '_onParentIronActivate');
},
/**
* Expand the submenu content.
*/
open: function() {
if (this.disabled)
return;
this.$.collapse.show();
this._active = true;
this.__trigger.classList.add('iron-selected');
},
/**
* Collapse the submenu content.
*/
close: function() {
this.$.collapse.hide();
this._active = false;
this.__trigger.classList.remove('iron-selected');
},
/**
* A handler that is called when the trigger is tapped.
*/
_onTap: function() {
if (this.disabled)
return;
this.$.collapse.toggle();
},
/**
* Toggles the submenu content when the trigger is tapped.
*/
_openedChanged: function(opened, oldOpened) {
if (opened) {
this.fire('paper-submenu-open');
} else if (oldOpened != null) {
this.fire('paper-submenu-close');
}
},
/**
* A handler that is called when `iron-activate` is fired.
*
* @param {CustomEvent} event An `iron-activate` event.
*/
_onParentIronActivate: function(event) {
if (Polymer.Gestures.findOriginalTarget(event) !== this.__parent) {
return;
}
// The activated item can either be this submenu, in which case it
// should be expanded, or any of the other sibling submenus, in which
// case this submenu should be collapsed.
if (event.detail.item == this) {
if (this._active)
return;
this.open();
} else {
this.close();
}
},
/**
* If the dropdown is open when disabled becomes true, close the
* dropdown.
*
* @param {boolean} disabled True if disabled, otherwise false.
*/
_disabledChanged: function(disabled) {
Polymer.IronControlState._disabledChanged.apply(this, arguments);
if (disabled && this._active) {
this.close();
|
e619a3b0
Luigi Serra
Controllet cross ...
|
197
|
|
c5169e0e
Renato De Donato
a new hope
|
198
199
200
201
202
203
|
}
}
});
})();
|
e619a3b0
Luigi Serra
Controllet cross ...
|
204
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
205
|
</script>
|