@@ -88,11 +88,16 @@ export class MdDialog {
8888
8989 /**
9090 * Creates the overlay into which the dialog will be loaded.
91- * @param dialogConfig The dialog configuration.
91+ * @param config The dialog configuration.
9292 * @returns A promise resolving to the OverlayRef for the created overlay.
9393 */
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+
96101 return this . _overlay . create ( overlayState ) ;
97102 }
98103
@@ -124,10 +129,10 @@ export class MdDialog {
124129 component : ComponentType < T > ,
125130 dialogContainer : MdDialogContainer ,
126131 overlayRef : OverlayRef ,
127- config ? : MdDialogConfig ) : MdDialogRef < T > {
132+ config : MdDialogConfig ) : MdDialogRef < T > {
128133 // Create a reference to the dialog we're creating in order to give the user a handle
129134 // to modify and close it.
130- let dialogRef = < MdDialogRef < T > > new MdDialogRef ( overlayRef ) ;
135+ let dialogRef = new MdDialogRef < T > ( overlayRef ) ;
131136
132137 if ( ! dialogContainer . dialogConfig . disableClose ) {
133138 // When the dialog backdrop is clicked, we want to close it.
@@ -140,47 +145,17 @@ export class MdDialog {
140145 // We create an injector specifically for the component we're instantiating so that it can
141146 // inject the MdDialogRef. This allows a component loaded inside of a dialog to close itself
142147 // and, optionally, to return a value.
143- let userInjector = config && config . viewContainerRef && config . viewContainerRef . injector ;
148+ let userInjector = config . viewContainerRef && config . viewContainerRef . injector ;
144149 let dialogInjector = new DialogInjector ( dialogRef , userInjector || this . _injector ) ;
145-
146150 let contentPortal = new ComponentPortal ( component , null , dialogInjector ) ;
147-
148151 let contentRef = dialogContainer . attachComponentPortal ( contentPortal ) ;
152+
149153 dialogRef . componentInstance = contentRef . instance ;
154+ dialogRef . updateDimensions ( config . width , config . height , config . position ) ;
150155
151156 return dialogRef ;
152157 }
153158
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-
184159 /**
185160 * Removes a dialog from the array of open dialogs.
186161 * @param dialogRef Dialog to be removed.
@@ -201,10 +176,10 @@ export class MdDialog {
201176
202177/**
203178 * Applies default options to the dialog config.
204- * @param dialogConfig Config to be modified.
179+ * @param config Config to be modified.
205180 * @returns The new configuration object.
206181 */
207- function _applyConfigDefaults ( dialogConfig : MdDialogConfig ) : MdDialogConfig {
208- return extendObject ( new MdDialogConfig ( ) , dialogConfig ) ;
182+ function _applyConfigDefaults ( config : MdDialogConfig ) : MdDialogConfig {
183+ return extendObject ( new MdDialogConfig ( ) , config ) ;
209184}
210185
0 commit comments