@@ -2,11 +2,14 @@ var CONFIRM_TEXT = '确定';
2
2
var CANCEL_TEXT = '取消' ;
3
3
4
4
var defaults = {
5
- title : '' ,
5
+ title : '提示 ' ,
6
6
message : '' ,
7
7
type : '' ,
8
8
showInput : false ,
9
+ showClose : true ,
10
+ modalFade : false ,
9
11
lockScroll : false ,
12
+ closeOnClickModal : true ,
10
13
inputValue : null ,
11
14
inputPlaceholder : '' ,
12
15
inputPattern : null ,
@@ -87,7 +90,7 @@ var showNextMsg = function() {
87
90
initInstance ( ) ;
88
91
}
89
92
90
- if ( ! instance . visible || instance . closeTimer ) {
93
+ if ( ! instance . value || instance . closeTimer ) {
91
94
if ( msgQueue . length > 0 ) {
92
95
currentMsg = msgQueue . shift ( ) ;
93
96
@@ -97,10 +100,15 @@ var showNextMsg = function() {
97
100
instance [ prop ] = options [ prop ] ;
98
101
}
99
102
}
100
- instance . $appendTo ( document . body ) ;
103
+ [ 'modal' , 'showClose' , 'closeOnClickModal' , 'closeOnPressEscape' ] . forEach ( prop => {
104
+ if ( instance [ prop ] === undefined ) {
105
+ instance [ prop ] = true ;
106
+ }
107
+ } ) ;
108
+ document . body . appendChild ( instance . $el ) ;
101
109
102
110
Vue . nextTick ( ( ) => {
103
- instance . visible = true ;
111
+ instance . value = true ;
104
112
} ) ;
105
113
}
106
114
}
@@ -122,7 +130,7 @@ var MessageBox = function(options, callback) {
122
130
}
123
131
124
132
if ( typeof Promise !== 'undefined' ) {
125
- return new Promise ( function ( resolve , reject ) {
133
+ return new Promise ( function ( resolve , reject ) { // eslint-disable-line
126
134
msgQueue . push ( {
127
135
options : merge ( { } , defaults , MessageBox . defaults || { } , options ) ,
128
136
callback : callback ,
@@ -154,7 +162,9 @@ MessageBox.alert = function(message, title, options) {
154
162
return MessageBox ( merge ( {
155
163
title : title ,
156
164
message : message ,
157
- $type : 'alert'
165
+ $type : 'alert' ,
166
+ closeOnPressEscape : false ,
167
+ closeOnClickModal : false
158
168
} , options ) ) ;
159
169
} ;
160
170
@@ -186,7 +196,7 @@ MessageBox.prompt = function(message, title, options) {
186
196
} ;
187
197
188
198
MessageBox . close = function ( ) {
189
- instance . visible = false ;
199
+ instance . value = false ;
190
200
msgQueue = [ ] ;
191
201
currentMsg = null ;
192
202
} ;
0 commit comments