@@ -50,39 +50,41 @@ var MessageBoxConstructor = Vue.extend(msgboxVue);
50
50
var currentMsg , instance ;
51
51
var msgQueue = [ ] ;
52
52
53
- var initInstance = function ( ) {
54
- instance = new MessageBoxConstructor ( {
55
- el : document . createElement ( 'div' )
56
- } ) ;
57
-
58
- instance . callback = function ( action ) {
59
- if ( currentMsg ) {
60
- var callback = currentMsg . callback ;
61
- if ( typeof callback === 'function' ) {
62
- if ( instance . showInput ) {
63
- callback ( instance . inputValue , action ) ;
64
- } else {
65
- callback ( action ) ;
66
- }
53
+ const defaultCallback = action => {
54
+ if ( currentMsg ) {
55
+ var callback = currentMsg . callback ;
56
+ if ( typeof callback === 'function' ) {
57
+ if ( instance . showInput ) {
58
+ callback ( instance . inputValue , action ) ;
59
+ } else {
60
+ callback ( action ) ;
67
61
}
68
- if ( currentMsg . resolve ) {
69
- var $type = currentMsg . options . $type ;
70
- if ( $type === 'confirm' || $type === 'prompt' ) {
71
- if ( action === 'confirm' ) {
72
- if ( instance . showInput ) {
73
- currentMsg . resolve ( { value : instance . inputValue , action } ) ;
74
- } else {
75
- currentMsg . resolve ( action ) ;
76
- }
77
- } else if ( action === 'cancel' && currentMsg . reject ) {
78
- currentMsg . reject ( action ) ;
62
+ }
63
+ if ( currentMsg . resolve ) {
64
+ var $type = currentMsg . options . $type ;
65
+ if ( $type === 'confirm' || $type === 'prompt' ) {
66
+ if ( action === 'confirm' ) {
67
+ if ( instance . showInput ) {
68
+ currentMsg . resolve ( { value : instance . inputValue , action } ) ;
69
+ } else {
70
+ currentMsg . resolve ( action ) ;
79
71
}
80
- } else {
81
- currentMsg . resolve ( action ) ;
72
+ } else if ( action === 'cancel' && currentMsg . reject ) {
73
+ currentMsg . reject ( action ) ;
82
74
}
75
+ } else {
76
+ currentMsg . resolve ( action ) ;
83
77
}
84
78
}
85
- } ;
79
+ }
80
+ } ;
81
+
82
+ var initInstance = function ( ) {
83
+ instance = new MessageBoxConstructor ( {
84
+ el : document . createElement ( 'div' )
85
+ } ) ;
86
+
87
+ instance . callback = defaultCallback ;
86
88
} ;
87
89
88
90
var showNextMsg = function ( ) {
@@ -100,6 +102,9 @@ var showNextMsg = function() {
100
102
instance [ prop ] = options [ prop ] ;
101
103
}
102
104
}
105
+ if ( options . callback === undefined ) {
106
+ instance . callback = defaultCallback ;
107
+ }
103
108
[ 'modal' , 'showClose' , 'closeOnClickModal' , 'closeOnPressEscape' ] . forEach ( prop => {
104
109
if ( instance [ prop ] === undefined ) {
105
110
instance [ prop ] = true ;
0 commit comments