| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 Polymer({ | 5 Polymer({ |
| 6 is: 'cr-action-menu', | 6 is: 'cr-action-menu', |
| 7 extends: 'dialog', | 7 extends: 'dialog', |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * List of all options in this action menu. | 10 * List of all options in this action menu. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 'keydown': 'onKeyDown_', | 34 'keydown': 'onKeyDown_', |
| 35 'tap': 'onTap_', | 35 'tap': 'onTap_', |
| 36 }, | 36 }, |
| 37 | 37 |
| 38 /** override */ | 38 /** override */ |
| 39 attached: function() { | 39 attached: function() { |
| 40 this.options_ = this.querySelectorAll('.dropdown-item'); | 40 this.options_ = this.querySelectorAll('.dropdown-item'); |
| 41 }, | 41 }, |
| 42 | 42 |
| 43 /** override */ | 43 /** override */ |
| 44 detached: function() { this.removeResizeListener_(); }, | 44 detached: function() { |
| 45 this.removeResizeListener_(); |
| 46 }, |
| 45 | 47 |
| 46 /** @private */ | 48 /** @private */ |
| 47 removeResizeListener_: function() { | 49 removeResizeListener_: function() { |
| 48 window.removeEventListener('resize', this.onWindowResize_); | 50 window.removeEventListener('resize', this.onWindowResize_); |
| 49 }, | 51 }, |
| 50 | 52 |
| 51 /** | 53 /** |
| 52 * @param {!Event} e | 54 * @param {!Event} e |
| 53 * @private | 55 * @private |
| 54 */ | 56 */ |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // Attempt to show the menu starting from the top of the rectangle and | 144 // Attempt to show the menu starting from the top of the rectangle and |
| 143 // extending downwards. If that does not fit within the window, fallback to | 145 // extending downwards. If that does not fit within the window, fallback to |
| 144 // starting from the bottom and extending upwards. | 146 // starting from the bottom and extending upwards. |
| 145 var top = rect.top + this.offsetHeight <= window.innerHeight ? rect.top : | 147 var top = rect.top + this.offsetHeight <= window.innerHeight ? rect.top : |
| 146 rect.bottom - | 148 rect.bottom - |
| 147 this.offsetHeight - Math.max(rect.bottom - window.innerHeight, 0); | 149 this.offsetHeight - Math.max(rect.bottom - window.innerHeight, 0); |
| 148 | 150 |
| 149 this.style.top = top + 'px'; | 151 this.style.top = top + 'px'; |
| 150 }, | 152 }, |
| 151 }); | 153 }); |
| OLD | NEW |