5 is: 'paper-dropdown-menu',
8 * Fired when the dropdown opens.
10 * @event paper-dropdown-open
14 * Fired when the dropdown closes.
16 * @event paper-dropdown-close
20 Polymer.IronControlState,
21 Polymer.IronButtonState
26 * The derived "label" of the currently selected item. This value
27 * is the `label` property on the selected item if set, or else the
28 * trimmed text content of the selected item.
33 computed: '_computeSelectedItemLabel(selectedItem)'
37 * The last selected item. An item is selected if the dropdown menu has
38 * a child with class `dropdown-content`, and that child triggers an
39 * `iron-select` event with the selected `item` in the `detail`.
48 * The label for the dropdown.
55 * The placeholder for the dropdown.
62 * True if the dropdown is open. Otherwise, false.
71 * Set to true to disable the floating label. Bind this to the
72 * `<paper-input-container>`'s `noLabelFloat` property.
77 reflectToAttribute: true
81 * Set to true to always float the label. Bind this to the
82 * `<paper-input-container>`'s `alwaysFloatLabel` property.
90 * Set to true to disable animations when opening and closing the
110 'aria-haspopup': 'true'
113 attached: function() {
114 // NOTE(cdata): Due to timing, a preselected value in a `IronSelectable`
115 // child will cause an `iron-select` event to fire while the element is
116 // still in a `DocumentFragment`. This has the effect of causing
117 // handlers not to fire. So, we double check this value on attached:
118 var contentElement = this.contentElement;
119 if (contentElement && contentElement.selectedItem) {
120 this._setSelectedItem(contentElement.selectedItem);
125 * The content element that is contained by the dropdown menu, if any.
127 get contentElement() {
128 return Polymer.dom(this.$.content).getDistributedNodes()[0];
132 * Show the dropdown content.
135 this.$.menuButton.open();
139 * Hide the dropdown content.
142 this.$.menuButton.close();
146 * A handler that is called when `iron-select` is fired.
148 * @param {CustomEvent} event An `iron-select` event.
150 _onIronSelect: function(event) {
151 this._setSelectedItem(event.detail.item);
155 * A handler that is called when the dropdown is tapped.
157 * @param {CustomEvent} event A tap event.
159 _onTap: function(event) {
160 if (Polymer.Gestures.findOriginalTarget(event) === this) {
166 * Compute the label for the dropdown given a selected item.
168 * @param {Element} selectedItem A selected Element item, with an
169 * optional `label` property.
171 _computeSelectedItemLabel: function(selectedItem) {
176 return selectedItem.label || selectedItem.textContent.trim();
180 * Compute the vertical offset of the menu based on the value of
183 * @param {boolean} noLabelFloat True if the label should not float
184 * above the input, otherwise false.
186 _computeMenuVerticalOffset: function(noLabelFloat) {
187 // NOTE(cdata): These numbers are somewhat magical because they are
188 // derived from the metrics of elements internal to `paper-input`'s
189 // template. The metrics will change depending on whether or not the
190 // input has a floating label.
191 return noLabelFloat ? -4 : 16;