@@ -88,11 +88,16 @@ export class MdDialog {
88
88
89
89
/**
90
90
* Creates the overlay into which the dialog will be loaded.
91
- * @param dialogConfig The dialog configuration.
91
+ * @param config The dialog configuration.
92
92
* @returns A promise resolving to the OverlayRef for the created overlay.
93
93
*/
94
- private _createOverlay ( dialogConfig : MdDialogConfig ) : OverlayRef {
95
- let overlayState = this . _getOverlayState ( dialogConfig ) ;
94
+ private _createOverlay ( config : MdDialogConfig ) : OverlayRef {
95
+ let overlayState = new OverlayState ( ) ;
96
+ let strategy = this . _overlay . position ( ) . global ( ) ;
97
+
98
+ overlayState . hasBackdrop = true ;
99
+ overlayState . positionStrategy = strategy ;
100
+
96
101
return this . _overlay . create ( overlayState ) ;
97
102
}
98
103
@@ -124,10 +129,10 @@ export class MdDialog {
124
129
component : ComponentType < T > ,
125
130
dialogContainer : MdDialogContainer ,
126
131
overlayRef : OverlayRef ,
127
- config ? : MdDialogConfig ) : MdDialogRef < T > {
132
+ config : MdDialogConfig ) : MdDialogRef < T > {
128
133
// Create a reference to the dialog we're creating in order to give the user a handle
129
134
// to modify and close it.
130
- let dialogRef = < MdDialogRef < T > > new MdDialogRef ( overlayRef ) ;
135
+ let dialogRef = new MdDialogRef < T > ( overlayRef ) ;
131
136
132
137
if ( ! dialogContainer . dialogConfig . disableClose ) {
133
138
// When the dialog backdrop is clicked, we want to close it.
@@ -140,47 +145,17 @@ export class MdDialog {
140
145
// We create an injector specifically for the component we're instantiating so that it can
141
146
// inject the MdDialogRef. This allows a component loaded inside of a dialog to close itself
142
147
// and, optionally, to return a value.
143
- let userInjector = config && config . viewContainerRef && config . viewContainerRef . injector ;
148
+ let userInjector = config . viewContainerRef && config . viewContainerRef . injector ;
144
149
let dialogInjector = new DialogInjector ( dialogRef , userInjector || this . _injector ) ;
145
-
146
150
let contentPortal = new ComponentPortal ( component , null , dialogInjector ) ;
147
-
148
151
let contentRef = dialogContainer . attachComponentPortal ( contentPortal ) ;
152
+
149
153
dialogRef . componentInstance = contentRef . instance ;
154
+ dialogRef . updateDimensions ( config . width , config . height , config . position ) ;
150
155
151
156
return dialogRef ;
152
157
}
153
158
154
- /**
155
- * Creates an overlay state from a dialog config.
156
- * @param dialogConfig The dialog configuration.
157
- * @returns The overlay configuration.
158
- */
159
- private _getOverlayState ( dialogConfig : MdDialogConfig ) : OverlayState {
160
- let state = new OverlayState ( ) ;
161
- let strategy = this . _overlay . position ( ) . global ( ) ;
162
- let position = dialogConfig . position ;
163
-
164
- state . hasBackdrop = true ;
165
- state . positionStrategy = strategy ;
166
-
167
- if ( position && ( position . left || position . right ) ) {
168
- position . left ? strategy . left ( position . left ) : strategy . right ( position . right ) ;
169
- } else {
170
- strategy . centerHorizontally ( ) ;
171
- }
172
-
173
- if ( position && ( position . top || position . bottom ) ) {
174
- position . top ? strategy . top ( position . top ) : strategy . bottom ( position . bottom ) ;
175
- } else {
176
- strategy . centerVertically ( ) ;
177
- }
178
-
179
- strategy . width ( dialogConfig . width ) . height ( dialogConfig . height ) ;
180
-
181
- return state ;
182
- }
183
-
184
159
/**
185
160
* Removes a dialog from the array of open dialogs.
186
161
* @param dialogRef Dialog to be removed.
@@ -201,10 +176,10 @@ export class MdDialog {
201
176
202
177
/**
203
178
* Applies default options to the dialog config.
204
- * @param dialogConfig Config to be modified.
179
+ * @param config Config to be modified.
205
180
* @returns The new configuration object.
206
181
*/
207
- function _applyConfigDefaults ( dialogConfig : MdDialogConfig ) : MdDialogConfig {
208
- return extendObject ( new MdDialogConfig ( ) , dialogConfig ) ;
182
+ function _applyConfigDefaults ( config : MdDialogConfig ) : MdDialogConfig {
183
+ return extendObject ( new MdDialogConfig ( ) , config ) ;
209
184
}
210
185
0 commit comments