| 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); |
| 25 } |
| 25 return maxAllowedHeight; | 26 return maxAllowedHeight; |
| 26 } | 27 }, |
| 28 |
| 29 /** |
| 30 * Computes max-width for an element so that it does fit the |
| 31 * outer-container. |
| 32 * @param {element} DOM element |
| 33 */ |
| 34 getMaxWidthToFit : function(element) { |
| 35 var maxAllowedWidth = |
| 36 $('outer-container').offsetWidth - |
| 37 element.getBoundingClientRect().left - |
| 38 parseInt(window.getComputedStyle(element).marginLeft) - |
| 39 parseInt(window.getComputedStyle(element).marginRight); |
| 40 return maxAllowedWidth; |
| 41 }, |
| 27 } | 42 } |
| 28 }); | 43 }); |
| OLD | NEW |