@@ -26,11 +26,9 @@ export class Alert extends Virtual<Vue>() {
2626 showCancelButton : true ,
2727 confirmButtonColor : "#DD6B55" ,
2828 confirmButtonText : "Yes, delete it!" ,
29- closeOnConfirm : false
30- } ,
31- function ( ) {
32- swal ( "Deleted!" , "Your imaginary file has been deleted." , "success" ) ;
33- } )
29+ } ) . then ( ( ) => {
30+ this . $ui . alert ( "Deleted!" , "Your imaginary file has been deleted." , "success" ) ;
31+ } )
3432 }
3533
3634 sample5 ( ) {
@@ -41,17 +39,20 @@ export class Alert extends Virtual<Vue>() {
4139 showCancelButton : true ,
4240 confirmButtonColor : "#DD6B55" ,
4341 confirmButtonText : "Yes, delete it!" ,
44- cancelButtonText : "No, cancel plx!" ,
45- closeOnConfirm : false ,
46- closeOnCancel : false
47- } ,
48- function ( isConfirm ) {
49- if ( isConfirm ) {
50- swal ( "Deleted!" , "Your imaginary file has been deleted." , "success" ) ;
51- } else {
52- swal ( "Cancelled" , "Your imaginary file is safe :)" , "error" ) ;
53- }
54- } )
42+ cancelButtonText : "No, cancel plx!"
43+ } ) . then ( ( ) => {
44+ this . $ui . alert ( "Deleted!" , "Your imaginary file has been deleted." , "success" ) ;
45+ } , ( dismiss ) => {
46+ // dismiss can be 'cancel', 'overlay',
47+ // 'close', and 'timer'
48+ if ( dismiss === 'cancel' ) {
49+ this . $ui . alert (
50+ 'Cancelled' ,
51+ 'Your imaginary file is safe :)' ,
52+ 'error'
53+ )
54+ }
55+ } )
5556 }
5657
5758 sample6 ( ) {
@@ -65,8 +66,7 @@ export class Alert extends Virtual<Vue>() {
6566 sample7 ( ) {
6667 this . $ui . alert ( {
6768 title : "HTML <small>Title</small>!" ,
68- text : "A custom <span style=\"color: #F8BB86\">html<span> message." ,
69- html : true
69+ html : "A custom <span style=\"color: #F8BB86\">html<span> message."
7070 } )
7171 }
7272
@@ -84,38 +84,45 @@ export class Alert extends Virtual<Vue>() {
8484 this . $ui . alert ( {
8585 title : "An input!" ,
8686 text : "Write something interesting:" ,
87- type : "input" ,
87+ input : 'text' ,
8888 showCancelButton : true ,
89- closeOnConfirm : false ,
90- animation : "slide-from-top " ,
91- inputPlaceholder : "Write something"
92- } ,
93- function ( inputValue ) {
94- if ( inputValue === false ) return false ;
95-
96- if ( inputValue === "" ) {
97- swal . showInputError ( "You need to write something!" ) ;
98- return false
99- }
100-
101- swal ( "Nice!" , "You wrote: " + inputValue , "success" ) ;
102- } )
89+ animation : true ,
90+ inputPlaceholder : "Write something " ,
91+ inputValidator : ( value ) => {
92+ return new Promise ( ( resolve , reject ) => {
93+ if ( value ) {
94+ resolve ( )
95+ } else {
96+ reject ( 'You need to write something!' )
97+ }
98+ } ) as any
99+ }
100+ } ) . then ( ( inputValue ) => {
101+ this . $ui . alert ( "Nice!" , "You wrote: " + inputValue , "success" ) ;
102+ } )
103103 }
104104
105105 sample10 ( ) {
106106 this . $ui . alert ( {
107107 title : "Ajax request example" ,
108- text : "Submit to run ajax request" ,
109- type : "info" ,
108+ input : 'email' ,
110109 showCancelButton : true ,
111- closeOnConfirm : false ,
112- showLoaderOnConfirm : true ,
113- } ,
114- function ( ) {
115- setTimeout ( function ( ) {
116- swal ( "Ajax request finished!" ) ;
117- } , 2000 ) ;
118- } )
110+ showLoaderOnConfirm : true ,
111+ preConfirm : function ( email ) {
112+ return new Promise ( function ( resolve , reject ) {
113+ setTimeout ( function ( ) {
114+ if ( email === '[email protected] ' ) { 115+ reject ( 'This email is already taken.' )
116+ } else {
117+ resolve ( )
118+ }
119+ } , 2000 )
120+ } )
121+ } ,
122+ allowOutsideClick : false
123+ } ) . then ( ( email ) => {
124+ this . $ui . alert ( "Email submitted to '" + email + "'!" ) ;
125+ } )
119126 }
120127
121128
0 commit comments