2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6 Code distributed by Google as part of the polymer project is also
7 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
12 `core-dropdown-menu` works together with `core-dropdown` and `core-selector` to
13 implement a drop-down menu. The currently selected item is displayed in the
14 control. If no item is selected, the `label` is displayed instead.
16 The child element with the class `dropdown` will be used as the drop-down
17 menu. It should be a `core-dropdown` or other overlay element. You should
18 also provide a `core-selector` or other selector element, such as `core-menu`,
23 <core-dropdown-menu label="Choose a pastry">
24 <core-dropdown class="dropdown">
26 <core-item label="Croissant"></core-item>
27 <core-item label="Donut"></core-item>
28 <core-item label="Financier"></core-item>
29 <core-item label="Madeleine"></core-item>
34 @group Polymer Core Elements
35 @element core-dropdown-menu
36 @extends core-dropdown-base
41 <link href=
"../polymer/polymer.html" rel=
"import">
42 <link href=
"../core-a11y-keys/core-a11y-keys.html" rel=
"import">
43 <link href=
"../core-dropdown/core-dropdown-base.html" rel=
"import">
44 <link href=
"../core-focusable/core-focusable.html" rel=
"import">
45 <link href=
"../core-icon/core-icon.html" rel=
"import">
46 <link href=
"../core-icons/core-icons.html" rel=
"import">
48 <polymer-element name=
"core-dropdown-menu" extends=
"core-dropdown-base" relative layout inline horizontal center
tabindex=
"0">
53 background-color: #fff;
63 text-overflow: ellipsis;
67 <core-a11y-keys target=
"{{}}" keys=
"enter space" on-keys-pressed=
"{{toggleOverlay}}"></core-a11y-keys>
69 <div flex auto
id=
"label">{{selectedItemLabel || label}}
</div>
70 <core-icon id=
"arrow" icon=
"{{opened ? openedIcon : closedIcon}}"></core-icon>
84 * A label for the control. The label is displayed if no item is selected.
88 * @default 'Select an item'
90 label
: 'Select an item',
93 * The icon to display when the drop-down is opened.
95 * @attribute openedIcon
97 * @default 'arrow-drop-up'
99 openedIcon
: 'arrow-drop-up',
102 * The icon to display when the drop-down is closed.
104 * @attribute closedIcon
106 * @default 'arrow-drop-down'
108 closedIcon
: 'arrow-drop-down'
112 selectedItemLabel
: '',
115 'core-overlay-open': 'openAction',
116 'core-activate': 'activateAction',
117 'core-select': 'selectAction'
120 activateAction: function(e
) {
124 selectAction: function(e
) {
125 var detail
= e
.detail
;
126 if (detail
.isSelected
) {
127 this.selectedItemLabel
= detail
.item
.label
|| detail
.item
.textContent
;
129 this.selectedItemLabel
= '';
135 Polymer
.mixin2(p
, Polymer
.CoreFocusable
);