forked from dcloudio/mui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmui.dialog.prompt.js
46 lines (43 loc) · 942 Bytes
/
mui.dialog.prompt.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(function($, window) {
/**
* 输入对话框
*/
$.prompt = function(text, defaultText, title, btnArray, callback) {
if ($.os.plus) {
if (typeof message === 'undefined') {
return;
} else {
if (typeof defaultText === 'function') {
callback = defaultText;
defaultText = null;
title = null;
btnArray = null;
} else if (typeof title === 'function') {
callback = title;
title = null;
btnArray = null;
} else if (typeof btnArray === 'function') {
callback = btnArray;
btnArray = null;
}
$.plusReady(function() {
plus.nativeUI.prompt(text, callback, title, defaultText, btnArray);
});
}
} else {
//H5版本(确认index为0,取消index为1)
var result = window.prompt(text);
if (result) {
callback({
index: 0,
value: result
});
} else {
callback({
index: 1,
value: ''
});
}
}
};
})(mui, window);