Skip to content

Commit c676f38

Browse files
support vue 2.0
1 parent 2305cfa commit c676f38

File tree

3 files changed

+206
-193
lines changed

3 files changed

+206
-193
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@
3535
"file-loader": "^0.8.5",
3636
"style-loader": "^0.13.0",
3737
"url-loader": "^0.5.7",
38+
"vue": "^2.0.3",
3839
"vue-hot-reload-api": "^1.2.2",
3940
"vue-html-loader": "^1.0.0",
40-
"vue-loader": "^7.3.0",
41+
"vue-loader": "^9.7.0",
4142
"webpack": "^1.12.9",
4243
"webpack-dev-server": "^1.14.0"
4344
},
4445
"dependencies": {
45-
"vue-popup": "^0.1.13"
46+
"vue-popup": "^0.2.9"
4647
}
4748
}

src/index.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ var CONFIRM_TEXT = '确定';
22
var CANCEL_TEXT = '取消';
33

44
var defaults = {
5-
title: '',
5+
title: '提示',
66
message: '',
77
type: '',
88
showInput: false,
9+
showClose: true,
10+
modalFade: false,
911
lockScroll: false,
12+
closeOnClickModal: true,
1013
inputValue: null,
1114
inputPlaceholder: '',
1215
inputPattern: null,
@@ -87,7 +90,7 @@ var showNextMsg = function() {
8790
initInstance();
8891
}
8992

90-
if (!instance.visible || instance.closeTimer) {
93+
if (!instance.value || instance.closeTimer) {
9194
if (msgQueue.length > 0) {
9295
currentMsg = msgQueue.shift();
9396

@@ -97,10 +100,15 @@ var showNextMsg = function() {
97100
instance[prop] = options[prop];
98101
}
99102
}
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);
101109

102110
Vue.nextTick(() => {
103-
instance.visible = true;
111+
instance.value = true;
104112
});
105113
}
106114
}
@@ -122,7 +130,7 @@ var MessageBox = function(options, callback) {
122130
}
123131

124132
if (typeof Promise !== 'undefined') {
125-
return new Promise(function (resolve, reject) {
133+
return new Promise(function(resolve, reject) { // eslint-disable-line
126134
msgQueue.push({
127135
options: merge({}, defaults, MessageBox.defaults || {}, options),
128136
callback: callback,
@@ -154,7 +162,9 @@ MessageBox.alert = function(message, title, options) {
154162
return MessageBox(merge({
155163
title: title,
156164
message: message,
157-
$type: 'alert'
165+
$type: 'alert',
166+
closeOnPressEscape: false,
167+
closeOnClickModal: false
158168
}, options));
159169
};
160170

@@ -186,7 +196,7 @@ MessageBox.prompt = function(message, title, options) {
186196
};
187197

188198
MessageBox.close = function() {
189-
instance.visible = false;
199+
instance.value = false;
190200
msgQueue = [];
191201
currentMsg = null;
192202
};

0 commit comments

Comments
 (0)