@@ -92,11 +92,16 @@ export class MdDialog {
9292
9393 /**
9494 * Creates the overlay into which the dialog will be loaded.
95- * @param dialogConfig The dialog configuration.
95+ * @param config The dialog configuration.
9696 * @returns A promise resolving to the OverlayRef for the created overlay.
9797 */
98- private _createOverlay ( dialogConfig : MdDialogConfig ) : OverlayRef {
99- let overlayState = this . _getOverlayState ( dialogConfig ) ;
98+ private _createOverlay ( config : MdDialogConfig ) : OverlayRef {
99+ let overlayState = new OverlayState ( ) ;
100+ let strategy = this . _overlay . position ( ) . global ( ) ;
101+
102+ overlayState . hasBackdrop = true ;
103+ overlayState . positionStrategy = strategy ;
104+
100105 return this . _overlay . create ( overlayState ) ;
101106 }
102107
@@ -129,10 +134,11 @@ export class MdDialog {
129134 componentOrTemplateRef : ComponentType < T > | TemplateRef < T > ,
130135 dialogContainer : MdDialogContainer ,
131136 overlayRef : OverlayRef ,
132- config ? : MdDialogConfig ) : MdDialogRef < T > {
137+ config : MdDialogConfig ) : MdDialogRef < T > {
133138 // Create a reference to the dialog we're creating in order to give the user a handle
134139 // to modify and close it.
135- let dialogRef = new MdDialogRef ( overlayRef , dialogContainer ) as MdDialogRef < T > ;
140+
141+ let dialogRef = new MdDialogRef < T > ( overlayRef , dialogContainer ) ;
136142
137143 if ( ! config . disableClose ) {
138144 // When the dialog backdrop is clicked, we want to close it.
@@ -153,37 +159,9 @@ export class MdDialog {
153159 dialogRef . componentInstance = contentRef . instance ;
154160 }
155161
156- return dialogRef ;
157- }
158-
159- /**
160- * Creates an overlay state from a dialog config.
161- * @param dialogConfig The dialog configuration.
162- * @returns The overlay configuration.
163- */
164- private _getOverlayState ( dialogConfig : MdDialogConfig ) : OverlayState {
165- let state = new OverlayState ( ) ;
166- let strategy = this . _overlay . position ( ) . global ( ) ;
167- let position = dialogConfig . position ;
168-
169- state . hasBackdrop = true ;
170- state . positionStrategy = strategy ;
171-
172- if ( position && ( position . left || position . right ) ) {
173- position . left ? strategy . left ( position . left ) : strategy . right ( position . right ) ;
174- } else {
175- strategy . centerHorizontally ( ) ;
176- }
177-
178- if ( position && ( position . top || position . bottom ) ) {
179- position . top ? strategy . top ( position . top ) : strategy . bottom ( position . bottom ) ;
180- } else {
181- strategy . centerVertically ( ) ;
182- }
162+ dialogRef . updateDimensions ( config . width , config . height , config . position ) ;
183163
184- strategy . width ( dialogConfig . width ) . height ( dialogConfig . height ) ;
185-
186- return state ;
164+ return dialogRef ;
187165 }
188166
189167 /**
@@ -221,10 +199,10 @@ export class MdDialog {
221199
222200/**
223201 * Applies default options to the dialog config.
224- * @param dialogConfig Config to be modified.
202+ * @param config Config to be modified.
225203 * @returns The new configuration object.
226204 */
227- function _applyConfigDefaults ( dialogConfig : MdDialogConfig ) : MdDialogConfig {
228- return extendObject ( new MdDialogConfig ( ) , dialogConfig ) ;
205+ function _applyConfigDefaults ( config : MdDialogConfig ) : MdDialogConfig {
206+ return extendObject ( new MdDialogConfig ( ) , config ) ;
229207}
230208
0 commit comments