import { IDialogOptions , IModalDialog , IModalDialogObj } from "../../../@types/helper" ; /**
 * Modal Dialog
 */ export const ModalDialog = ( ( ) => { let getDialog = ( dialog ) : IModalDialogObj => { dialog . show = ( ) => { let el = dialog . get_dialogElement ( ) as HTMLDivElement ; if ( el ) { el . style . display = "" ; } el = dialog . get_frameElement ( ) as HTMLIFrameElement ; if ( el ) { el . style . display = "" ; } } ; dialog . setTitle = ( value ) => { let elDlg = dialog . get_dialogElement ( ) ; let elTitle = elDlg ? elDlg . querySelector ( ".ms-dlgLoadingTextDiv .ms-core-pageTitle" ) : null ; elTitle = elTitle || elDlg . querySelector ( ".ms-dlgTitle .ms-dlgTitleText" ) ; if ( elTitle ) { elTitle . innerHTML = value ; } } ; dialog . setSubTitle = ( value ) => { let elDlg = dialog . get_dialogElement ( ) ; let elSubTitle = elDlg ? elDlg . querySelector ( ".ms-dlgLoadingTextDiv ~ div" ) : null ; if ( elSubTitle ) { elSubTitle . innerHTML = value ; } } ; return dialog ; } ; return { commonModalDialogClose : ( dialogResult ? , returnVal ? ) => { ModalDialog . load ( ) . then ( ( ) => { window [ "SP" ] . UI . ModalDialog . commonModalDialogClose ( dialogResult , returnVal ) ; } ) ; } , commonModalDialogOpen : ( url , options ? , callback ? , args ? ) => { ModalDialog . load ( ) . then ( ( ) => { window [ "SP" ] . UI . ModalDialog . commonModalDialogOpen ( url , options , callback , args ) ; } ) ; } , load : ( ) : PromiseLike < void > => { return new Promise ( ( resolve , reject ) => { if ( window [ "SP" ] && window [ "SP" ] . UI && window [ "SP" ] . UI . ModalDialog ) { resolve ( ) ; } else { window [ "SP" ] . SOD . executeFunc ( "sp.js" , "SP.UI.ModalDialog" , ( ) => { resolve ( ) ; } ) ; } } ) ; } , OpenPopUpPage : ( url , callback ? , width ? , height ? ) => { ModalDialog . load ( ) . then ( ( ) => { window [ "SP" ] . UI . ModalDialog . OpenPopUpPage ( url , callback , width , height ) ; } ) ; } , RefreshPage : ( dialogResult ? ) => { ModalDialog . load ( ) . then ( ( ) => { window [ "SP" ] . UI . ModalDialog . RefreshPage ( dialogResult ) ; } ) ; } , showModalDialog : ( options ) : PromiseLike < IModalDialogObj > => { return new Promise ( ( resolve ) => { ModalDialog . load ( ) . then ( ( ) => { resolve ( getDialog ( window [ "SP" ] . UI . ModalDialog . showModalDialog ( options ) ) ) ; } ) ; } ) ; } , ShowPopupDialog : ( url ) => { ModalDialog . load ( ) . then ( ( ) => { window [ "SP" ] . UI . ModalDialog . ShowPopupDialog ( url ) ; } ) ; } , showWaitScreenSize : ( title , message ? , callback ? , height ? , width ? ) : PromiseLike < IModalDialogObj > => { return new Promise ( ( resolve ) => { ModalDialog . load ( ) . then ( ( ) => { resolve ( getDialog ( window [ "SP" ] . UI . ModalDialog . showWaitScreenSize ( title , message , callback , height , width ) ) ) ; } ) ; } ) ; } , showWaitScreenWithNoClose : ( title , message ? , height ? , width ? ) : PromiseLike < IModalDialogObj > => { return new Promise ( ( resolve ) => { ModalDialog . load ( ) . then ( ( ) => { resolve ( getDialog ( window [ "SP" ] . UI . ModalDialog . showWaitScreenWithNoClose ( title , message , height , width ) ) ) ; } ) ; } ) ; } } ; } ) ( ) ;