@@ -92,14 +92,27 @@ 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 = this . _getOverlayState ( config ) ;
100100 return this . _overlay . create ( overlayState ) ;
101101 }
102102
103+ /**
104+ * Creates an overlay state from a dialog config.
105+ * @param dialogConfig The dialog configuration.
106+ * @returns The overlay configuration.
107+ */
108+ private _getOverlayState ( dialogConfig : MdDialogConfig ) : OverlayState {
109+ let overlayState = new OverlayState ( ) ;
110+ overlayState . hasBackdrop = true ;
111+ overlayState . positionStrategy = this . _overlay . position ( ) . global ( ) ;
112+
113+ return overlayState ;
114+ }
115+
103116 /**
104117 * Attaches an MdDialogContainer to a dialog's already-created overlay.
105118 * @param overlay Reference to the dialog's underlying overlay.
@@ -129,10 +142,11 @@ export class MdDialog {
129142 componentOrTemplateRef : ComponentType < T > | TemplateRef < T > ,
130143 dialogContainer : MdDialogContainer ,
131144 overlayRef : OverlayRef ,
132- config ? : MdDialogConfig ) : MdDialogRef < T > {
145+ config : MdDialogConfig ) : MdDialogRef < T > {
133146 // Create a reference to the dialog we're creating in order to give the user a handle
134147 // to modify and close it.
135- let dialogRef = new MdDialogRef ( overlayRef , dialogContainer ) as MdDialogRef < T > ;
148+
149+ let dialogRef = new MdDialogRef < T > ( overlayRef , dialogContainer ) ;
136150
137151 if ( ! config . disableClose ) {
138152 // When the dialog backdrop is clicked, we want to close it.
@@ -153,37 +167,11 @@ export class MdDialog {
153167 dialogRef . componentInstance = contentRef . instance ;
154168 }
155169
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- }
183-
184- strategy . width ( dialogConfig . width ) . height ( dialogConfig . height ) ;
170+ dialogRef
171+ . updateSize ( config . width , config . height )
172+ . updatePosition ( config . position ) ;
185173
186- return state ;
174+ return dialogRef ;
187175 }
188176
189177 /**
@@ -221,10 +209,10 @@ export class MdDialog {
221209
222210/**
223211 * Applies default options to the dialog config.
224- * @param dialogConfig Config to be modified.
212+ * @param config Config to be modified.
225213 * @returns The new configuration object.
226214 */
227- function _applyConfigDefaults ( dialogConfig : MdDialogConfig ) : MdDialogConfig {
228- return extendObject ( new MdDialogConfig ( ) , dialogConfig ) ;
215+ function _applyConfigDefaults ( config : MdDialogConfig ) : MdDialogConfig {
216+ return extendObject ( new MdDialogConfig ( ) , config ) ;
229217}
230218
0 commit comments