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 /** | 5 /** |
| 6 * @fileoverview 'settings-dialog' is a component for showing a modal dialog. | 6 * @fileoverview 'settings-dialog' is a component for showing a modal dialog. |
| 7 */ | 7 */ |
| 8 Polymer({ | 8 Polymer({ |
| 9 is: 'settings-dialog', | 9 is: 'settings-dialog', |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 | 23 |
| 24 /** @override */ | 24 /** @override */ |
| 25 withBackdrop: { | 25 withBackdrop: { |
| 26 type: Boolean, | 26 type: Boolean, |
| 27 value: true, | 27 value: true, |
| 28 }, | 28 }, |
| 29 }, | 29 }, |
| 30 | 30 |
| 31 behaviors: [Polymer.PaperDialogBehavior], | 31 behaviors: [Polymer.PaperDialogBehavior], |
| 32 | 32 |
| 33 /** @override */ | |
| 34 center: function() { | |
|
valdrin
2016/05/18 18:43:37
This should not be needed, as iron-fit-behavior is
valdrin
2016/05/18 18:47:18
Sorry, i meant max-width, max-height. If you set t
Dan Beam
2016/05/24 02:22:11
valdrin: every <settings-dialog> has a different h
| |
| 35 Polymer.IronFitBehavior.center.call(this); | |
| 36 | |
| 37 // Height of stuff that should never scroll (i.e. title, buttons). | |
| 38 var staticHeight = this.$$('.title-container').offsetHeight + | |
| 39 this.$$('.button-container').offsetHeight + | |
| 40 this.$$('.footer-container').offsetHeight; | |
| 41 | |
| 42 // The amount of space we've got to work with based on window size. | |
| 43 var availableHeight = parseInt(this.style.maxHeight, 10); | |
|
dpapad
2016/05/18 17:50:10
The code seems to assume that avaailableHeight is
| |
| 44 | |
| 45 var MIN_BODY_HEIGHT = 120; | |
| 46 | |
| 47 // Constrain body height to the remaining space; might add middle scrollbar. | |
| 48 var bodyHeight = Math.max(availableHeight - staticHeight, MIN_BODY_HEIGHT); | |
| 49 this.$$('.body-container').style.maxHeight = bodyHeight + 'px'; | |
| 50 | |
| 51 var requiredHeight = staticHeight + MIN_BODY_HEIGHT; | |
| 52 var needsMinHeight = availableHeight < requiredHeight; | |
| 53 this.style.minHeight = needsMinHeight ? requiredHeight + 'px' : ''; | |
| 54 | |
| 55 // TODO(dbeam): give a min-height to something like <body> so if the window | |
| 56 // get smaller than this dialog, buttons can still be scrolled to. Adding a | |
|
dpapad
2016/05/18 17:50:11
s/get/gets
| |
| 57 // min-height to either this dialog or the backdropElement doesn't help as | |
| 58 // they're position: fixed; and not in the flow of the page. | |
| 59 }, | |
| 60 | |
| 33 /** @return {!PaperIconButtonElement} */ | 61 /** @return {!PaperIconButtonElement} */ |
| 34 getCloseButton: function() { | 62 getCloseButton: function() { |
| 35 return this.$.close; | 63 return this.$.close; |
| 36 }, | 64 }, |
| 37 }); | 65 }); |
| OLD | NEW |