OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 28 matching lines...) Expand all Loading... | |
39 | 39 |
40 this.contentElement.createChild('content'); | 40 this.contentElement.createChild('content'); |
41 this.contentElement.tabIndex = 0; | 41 this.contentElement.tabIndex = 0; |
42 this.contentElement.addEventListener('focus', this._onFocus.bind(this), fals e); | 42 this.contentElement.addEventListener('focus', this._onFocus.bind(this), fals e); |
43 this._keyDownBound = this._onKeyDown.bind(this); | 43 this._keyDownBound = this._onKeyDown.bind(this); |
44 | 44 |
45 this._wrapsContent = false; | 45 this._wrapsContent = false; |
46 this._dimmed = false; | 46 this._dimmed = false; |
47 /** @type {!Map<!HTMLElement, number>} */ | 47 /** @type {!Map<!HTMLElement, number>} */ |
48 this._tabIndexMap = new Map(); | 48 this._tabIndexMap = new Map(); |
49 this._fixedHeight = true; | |
dgozman
2016/12/27 19:36:48
Let's instead position based on maxHeight (if pres
einbinder
2017/01/09 23:19:17
Done.
| |
49 } | 50 } |
50 | 51 |
51 /** | 52 /** |
52 * @return {boolean} | 53 * @return {boolean} |
53 */ | 54 */ |
54 static hasInstance() { | 55 static hasInstance() { |
55 return !!UI.Dialog._instance; | 56 return !!UI.Dialog._instance; |
56 } | 57 } |
57 | 58 |
58 /** | 59 /** |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 this._wrapsContent = wraps; | 145 this._wrapsContent = wraps; |
145 } | 146 } |
146 | 147 |
147 /** | 148 /** |
148 * @param {boolean} dimmed | 149 * @param {boolean} dimmed |
149 */ | 150 */ |
150 setDimmed(dimmed) { | 151 setDimmed(dimmed) { |
151 this._dimmed = dimmed; | 152 this._dimmed = dimmed; |
152 } | 153 } |
153 | 154 |
155 /** | |
156 * @param {boolean} fixedHeight | |
157 */ | |
158 setFixedHeight(fixedHeight) { | |
159 this._fixedHeight = fixedHeight; | |
160 } | |
161 | |
154 contentResized() { | 162 contentResized() { |
155 if (this._wrapsContent) | 163 if (this._wrapsContent) |
156 this._position(); | 164 this._position(); |
157 } | 165 } |
158 | 166 |
159 /** | 167 /** |
160 * @param {!Document} document | 168 * @param {!Document} document |
161 */ | 169 */ |
162 _disableTabIndexOnElements(document) { | 170 _disableTabIndexOnElements(document) { |
163 this._tabIndexMap.clear(); | 171 this._tabIndexMap.clear(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 | 228 |
221 var positionY; | 229 var positionY; |
222 if (typeof this._defaultPositionY === 'number') { | 230 if (typeof this._defaultPositionY === 'number') { |
223 positionY = this._defaultPositionY; | 231 positionY = this._defaultPositionY; |
224 } else { | 232 } else { |
225 positionY = (container.offsetHeight - height) / 2; | 233 positionY = (container.offsetHeight - height) / 2; |
226 positionY = Number.constrain(positionY, 0, container.offsetHeight - height ); | 234 positionY = Number.constrain(positionY, 0, container.offsetHeight - height ); |
227 } | 235 } |
228 | 236 |
229 this.element.style.width = width + 'px'; | 237 this.element.style.width = width + 'px'; |
230 this.element.style.height = height + 'px'; | 238 if (this._fixedHeight) |
239 this.element.style.height = height + 'px'; | |
240 else | |
241 this.element.style.maxHeight = height + 'px'; | |
231 this.element.positionAt(positionX, positionY, container); | 242 this.element.positionAt(positionX, positionY, container); |
232 } | 243 } |
233 | 244 |
234 /** | 245 /** |
235 * @param {!Event} event | 246 * @param {!Event} event |
236 */ | 247 */ |
237 _onKeyDown(event) { | 248 _onKeyDown(event) { |
238 if (event.keyCode === UI.KeyboardShortcut.Keys.Esc.code) { | 249 if (event.keyCode === UI.KeyboardShortcut.Keys.Esc.code) { |
239 event.consume(true); | 250 event.consume(true); |
240 this.detach(); | 251 this.detach(); |
241 } | 252 } |
242 } | 253 } |
243 }; | 254 }; |
244 | 255 |
245 | 256 |
246 /** @type {?Element} */ | 257 /** @type {?Element} */ |
247 UI.Dialog._previousFocusedElement = null; | 258 UI.Dialog._previousFocusedElement = null; |
248 | 259 |
249 /** @type {?UI.Widget} */ | 260 /** @type {?UI.Widget} */ |
250 UI.Dialog._modalHostView = null; | 261 UI.Dialog._modalHostView = null; |
OLD | NEW |