Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 JS helpers used on login. | 6 * @fileoverview JS helpers used on login. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 cr.define('cr.ui.LoginUITools', function() { | 9 cr.define('cr.ui.LoginUITools', function() { |
| 10 return { | 10 return { |
| 11 /** | 11 /** |
| 12 * Computes max-height for an element so that it doesn't overlap shelf. | 12 * Computes max-height for an element so that it doesn't overlap shelf. |
| 13 * @param {element} DOM element | 13 * @param {element} DOM element |
| 14 * @param {wholeWindow} Whether the element can go outside outer-container. | 14 * @param {wholeWindow} Whether the element can go outside outer-container. |
| 15 */ | 15 */ |
| 16 getMaxHeightBeforeShelfOverlapping : function(element, wholeWindow) { | 16 getMaxHeightBeforeShelfOverlapping : function(element, wholeWindow) { |
| 17 var maxAllowedHeight = | 17 var maxAllowedHeight = |
| 18 $('outer-container').offsetHeight - | 18 $('outer-container').offsetHeight - |
| 19 element.getBoundingClientRect().top - | 19 element.getBoundingClientRect().top - |
| 20 parseInt(window.getComputedStyle(element).marginTop) - | 20 parseInt(window.getComputedStyle(element).marginTop) - |
| 21 parseInt(window.getComputedStyle(element).marginBottom); | 21 parseInt(window.getComputedStyle(element).marginBottom); |
| 22 if (wholeWindow) | 22 if (wholeWindow) |
| 23 maxAllowedHeight += | 23 maxAllowedHeight += |
| 24 parseInt(window.getComputedStyle($('outer-container')).bottom); | 24 parseInt(window.getComputedStyle($('outer-container')).bottom); |
|
xiyuan
2016/11/02 16:17:22
unrelated to your change, but could you wrap this
Alexander Alekseev
2016/11/03 01:27:43
Done.
| |
| 25 return maxAllowedHeight; | 25 return maxAllowedHeight; |
| 26 } | 26 }, |
| 27 | |
| 28 /** | |
| 29 * Computes max-width for an element so that it does fit the | |
| 30 * outer-container. | |
| 31 * @param {element} DOM element | |
| 32 */ | |
| 33 getMaxWidthToFit : function(element) { | |
| 34 var maxAllowedWidth = | |
| 35 $('outer-container').offsetWidth - | |
| 36 element.getBoundingClientRect().left - | |
| 37 parseInt(window.getComputedStyle(element).marginLeft) - | |
| 38 parseInt(window.getComputedStyle(element).marginRight); | |
| 39 return maxAllowedWidth; | |
| 40 }, | |
| 27 } | 41 } |
| 28 }); | 42 }); |
| OLD | NEW |