| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 }, | 98 }, |
| 99 | 99 |
| 100 addCloseButton: function() | 100 addCloseButton: function() |
| 101 { | 101 { |
| 102 var closeButton = this.contentElement.createChild("div", "dialog-close-b
utton", "dt-close-button"); | 102 var closeButton = this.contentElement.createChild("div", "dialog-close-b
utton", "dt-close-button"); |
| 103 closeButton.gray = true; | 103 closeButton.gray = true; |
| 104 closeButton.addEventListener("click", this.detach.bind(this, false), fal
se); | 104 closeButton.addEventListener("click", this.detach.bind(this, false), fal
se); |
| 105 }, | 105 }, |
| 106 | 106 |
| 107 /** | 107 /** |
| 108 * @param {number=} positionX |
| 109 * @param {number=} positionY |
| 110 */ |
| 111 setPosition: function(positionX, positionY) |
| 112 { |
| 113 this._defaultPositionX = positionX; |
| 114 this._defaultPositionY = positionY; |
| 115 }, |
| 116 |
| 117 /** |
| 108 * @param {!Size} size | 118 * @param {!Size} size |
| 109 */ | 119 */ |
| 110 setMaxSize: function(size) | 120 setMaxSize: function(size) |
| 111 { | 121 { |
| 112 this._maxSize = size; | 122 this._maxSize = size; |
| 113 }, | 123 }, |
| 114 | 124 |
| 115 /** | 125 /** |
| 116 * @param {boolean} wraps | 126 * @param {boolean} wraps |
| 117 */ | 127 */ |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 if (this._wrapsContent) { | 197 if (this._wrapsContent) { |
| 188 width = Math.min(width, this.contentElement.offsetWidth); | 198 width = Math.min(width, this.contentElement.offsetWidth); |
| 189 height = Math.min(height, this.contentElement.offsetHeight); | 199 height = Math.min(height, this.contentElement.offsetHeight); |
| 190 } | 200 } |
| 191 | 201 |
| 192 if (this._maxSize) { | 202 if (this._maxSize) { |
| 193 width = Math.min(width, this._maxSize.width); | 203 width = Math.min(width, this._maxSize.width); |
| 194 height = Math.min(height, this._maxSize.height); | 204 height = Math.min(height, this._maxSize.height); |
| 195 } | 205 } |
| 196 | 206 |
| 197 var positionX = (container.offsetWidth - width) / 2; | 207 var positionX; |
| 198 positionX = Number.constrain(positionX, 0, container.offsetWidth - width
); | 208 if (typeof this._defaultPositionX === "number") { |
| 209 positionX = this._defaultPositionX; |
| 210 } else { |
| 211 positionX = (container.offsetWidth - width) / 2; |
| 212 positionX = Number.constrain(positionX, 0, container.offsetWidth - w
idth); |
| 213 } |
| 199 | 214 |
| 200 var positionY = (container.offsetHeight - height) / 2; | 215 var positionY; |
| 201 positionY = Number.constrain(positionY, 0, container.offsetHeight - heig
ht); | 216 if (typeof this._defaultPositionY === "number") { |
| 217 positionY = this._defaultPositionY; |
| 218 } else { |
| 219 positionY = (container.offsetHeight - height) / 2; |
| 220 positionY = Number.constrain(positionY, 0, container.offsetHeight -
height); |
| 221 } |
| 202 | 222 |
| 203 this.element.style.width = width + "px"; | 223 this.element.style.width = width + "px"; |
| 204 this.element.style.height = height + "px"; | 224 this.element.style.height = height + "px"; |
| 205 this.element.positionAt(positionX, positionY, container); | 225 this.element.positionAt(positionX, positionY, container); |
| 206 }, | 226 }, |
| 207 | 227 |
| 208 /** | 228 /** |
| 209 * @param {!Event} event | 229 * @param {!Event} event |
| 210 */ | 230 */ |
| 211 _onKeyDown: function(event) | 231 _onKeyDown: function(event) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 { | 271 { |
| 252 return WebInspector.Dialog._modalHostView; | 272 return WebInspector.Dialog._modalHostView; |
| 253 }; | 273 }; |
| 254 | 274 |
| 255 WebInspector.Dialog.modalHostRepositioned = function() | 275 WebInspector.Dialog.modalHostRepositioned = function() |
| 256 { | 276 { |
| 257 if (WebInspector.Dialog._instance) | 277 if (WebInspector.Dialog._instance) |
| 258 WebInspector.Dialog._instance._position(); | 278 WebInspector.Dialog._instance._position(); |
| 259 }; | 279 }; |
| 260 | 280 |
| OLD | NEW |