4 var PaperMenuButton = Polymer({
5 is: 'paper-menu-button',
8 * Fired when the dropdown opens.
10 * @event paper-dropdown-open
14 * Fired when the dropdown closes.
16 * @event paper-dropdown-close
20 Polymer.IronA11yKeysBehavior,
21 Polymer.IronControlState
27 * True if the content is currently displayed.
36 * The orientation against which to align the menu dropdown
37 * horizontally relative to the dropdown trigger.
42 reflectToAttribute: true
46 * The orientation against which to align the menu dropdown
47 * vertically relative to the dropdown trigger.
52 reflectToAttribute: true
56 * A pixel value that will be added to the position calculated for the
57 * given `horizontalAlign`. Use a negative value to offset to the
58 * left, or a positive value to offset to the right.
67 * A pixel value that will be added to the position calculated for the
68 * given `verticalAlign`. Use a negative value to offset towards the
69 * top, or a positive value to offset towards the bottom.
78 * Set to true to disable animations when opening and closing the
87 * Set to true to disable automatically closing the dropdown after
88 * a selection has been made.
96 * An animation config. If provided, this will be used to animate the
97 * opening of the dropdown.
99 openAnimationConfig: {
103 name: 'fade-in-animation',
109 name: 'paper-menu-grow-width-animation',
113 easing: PaperMenuButton.ANIMATION_CUBIC_BEZIER
116 name: 'paper-menu-grow-height-animation',
120 easing: PaperMenuButton.ANIMATION_CUBIC_BEZIER
127 * An animation config. If provided, this will be used to animate the
128 * closing of the dropdown.
130 closeAnimationConfig: {
134 name: 'fade-out-animation',
139 name: 'paper-menu-shrink-width-animation',
143 easing: PaperMenuButton.ANIMATION_CUBIC_BEZIER
146 name: 'paper-menu-shrink-height-animation',
158 'aria-haspopup': 'true'
162 'iron-activate': '_onIronActivate'
166 * Make the dropdown content appear as an overlay positioned relative
167 * to the dropdown trigger.
174 this.$.dropdown.open();
178 * Hide the dropdown content.
181 this.$.dropdown.close();
185 * When an `iron-activate` event is received, the dropdown should
186 * automatically close on the assumption that a value has been chosen.
188 * @param {CustomEvent} event A CustomEvent instance with type
189 * set to `"iron-activate"`.
191 _onIronActivate: function(event) {
192 if (!this.ignoreActivate) {
198 * When the dropdown opens, the `paper-menu-button` fires `paper-open`.
199 * When the dropdown closes, the `paper-menu-button` fires `paper-close`.
201 * @param {boolean} opened True if the dropdown is opened, otherwise false.
202 * @param {boolean} oldOpened The previous value of `opened`.
204 _openedChanged: function(opened, oldOpened) {
206 this.fire('paper-dropdown-open');
207 } else if (oldOpened != null) {
208 this.fire('paper-dropdown-close');
213 * If the dropdown is open when disabled becomes true, close the
216 * @param {boolean} disabled True if disabled, otherwise false.
218 _disabledChanged: function(disabled) {
219 Polymer.IronControlState._disabledChanged.apply(this, arguments);
220 if (disabled && this.opened) {
226 PaperMenuButton.ANIMATION_CUBIC_BEZIER = 'cubic-bezier(.3,.95,.5,1)';
227 PaperMenuButton.MAX_ANIMATION_TIME_MS = 400;
229 Polymer.PaperMenuButton = PaperMenuButton;