Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 5 /** |
| 6 * @fileoverview This file provides utility functions for position popups. | 6 * @fileoverview This file provides utility functions for position popups. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 cr.exportPath('cr.ui'); | 9 cr.exportPath('cr.ui'); |
| 10 | 10 |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 var anchorRect = anchorElement.getBoundingClientRect(); | 219 var anchorRect = anchorElement.getBoundingClientRect(); |
| 220 positionPopupAroundRect(anchorRect, popupElement, type, | 220 positionPopupAroundRect(anchorRect, popupElement, type, |
| 221 !!opt_invertLeftRight); | 221 !!opt_invertLeftRight); |
| 222 } | 222 } |
| 223 | 223 |
| 224 /** | 224 /** |
| 225 * Positions a popup around a point. | 225 * Positions a popup around a point. |
| 226 * @param {number} x The client x position. | 226 * @param {number} x The client x position. |
| 227 * @param {number} y The client y position. | 227 * @param {number} y The client y position. |
| 228 * @param {!HTMLElement} popupElement The popup element we are positioning. | 228 * @param {!HTMLElement} popupElement The popup element we are positioning. |
| 229 * @param {cr.ui.AnchorType} opt_anchorType The type of anchoring we want. | |
|
tsergeant
2016/01/29 03:27:19
You'll need to mark this as optional for this to c
yingran
2016/01/29 04:17:52
Done.
| |
| 229 */ | 230 */ |
| 230 function positionPopupAtPoint(x, y, popupElement) { | 231 function positionPopupAtPoint(x, y, popupElement, opt_anchorType) { |
| 231 var rect = { | 232 var rect = { |
| 232 left: x, | 233 left: x, |
| 233 top: y, | 234 top: y, |
| 234 width: 0, | 235 width: 0, |
| 235 height: 0, | 236 height: 0, |
| 236 right: x, | 237 right: x, |
| 237 bottom: y | 238 bottom: y |
| 238 }; | 239 }; |
| 239 positionPopupAroundRect(rect, popupElement, AnchorType.BELOW); | 240 |
| 241 var anchorType = opt_anchorType || AnchorType.BELOW; | |
| 242 positionPopupAroundRect(rect, popupElement, anchorType); | |
| 240 } | 243 } |
| 241 | 244 |
| 242 // Export | 245 // Export |
| 243 return { | 246 return { |
| 244 positionPopupAroundElement: positionPopupAroundElement, | 247 positionPopupAroundElement: positionPopupAroundElement, |
| 245 positionPopupAtPoint: positionPopupAtPoint | 248 positionPopupAtPoint: positionPopupAtPoint |
| 246 }; | 249 }; |
| 247 }); | 250 }); |
| OLD | NEW |