Chromium Code Reviews| 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: 'settings-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. |
| 11 * @private {?NodeList<!Element>} | 11 * @private {?NodeList<!Element>} |
| 12 */ | 12 */ |
| 13 options_: null, | 13 options_: null, |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Reference to the bound window's resize listener, such that it can be | 16 * Reference to the bound window's resize listener, such that it can be |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 showAt: function(anchorElement) { | 115 showAt: function(anchorElement) { |
| 116 this.onWindowResize_ = this.onWindowResize_ || function() { | 116 this.onWindowResize_ = this.onWindowResize_ || function() { |
| 117 if (this.open) | 117 if (this.open) |
| 118 this.close(); | 118 this.close(); |
| 119 }.bind(this); | 119 }.bind(this); |
| 120 window.addEventListener('resize', this.onWindowResize_); | 120 window.addEventListener('resize', this.onWindowResize_); |
| 121 | 121 |
| 122 this.showModal(); | 122 this.showModal(); |
| 123 | 123 |
| 124 var rect = anchorElement.getBoundingClientRect(); | 124 var rect = anchorElement.getBoundingClientRect(); |
| 125 if (new settings.DirectionDelegateImpl().isRtl()) { | 125 if (isRTL()) { |
|
Dan Beam
2016/11/02 16:36:12
can we just call getComputedStyle(anchorElement).d
dpapad
2016/11/02 17:24:13
I am reluctant calling getComputedStyle() every ti
Dan Beam
2016/11/02 18:54:18
i think in generic components (that don't necessar
| |
| 126 var right = window.innerWidth - rect.left - this.offsetWidth; | 126 var right = window.innerWidth - rect.left - this.offsetWidth; |
| 127 this.style.right = right + 'px'; | 127 this.style.right = right + 'px'; |
| 128 } else { | 128 } else { |
| 129 var left = rect.right - this.offsetWidth; | 129 var left = rect.right - this.offsetWidth; |
| 130 this.style.left = left + 'px'; | 130 this.style.left = left + 'px'; |
| 131 } | 131 } |
| 132 | 132 |
| 133 // Attempt to show the menu starting from the top of the rectangle and | 133 // Attempt to show the menu starting from the top of the rectangle and |
| 134 // extending downwards. If that does not fit within the window, fallback to | 134 // extending downwards. If that does not fit within the window, fallback to |
| 135 // starting from the bottom and extending upwards. | 135 // starting from the bottom and extending upwards. |
| 136 var top = rect.top + this.offsetHeight <= window.innerHeight ? | 136 var top = rect.top + this.offsetHeight <= window.innerHeight ? |
| 137 rect.top : | 137 rect.top : |
| 138 rect.bottom - this.offsetHeight - Math.max( | 138 rect.bottom - this.offsetHeight - Math.max( |
| 139 rect.bottom - window.innerHeight, 0); | 139 rect.bottom - window.innerHeight, 0); |
| 140 | 140 |
| 141 this.style.top = top + 'px'; | 141 this.style.top = top + 'px'; |
| 142 }, | 142 }, |
| 143 }); | 143 }); |
| OLD | NEW |