-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjs_mk_alert.html
More file actions
129 lines (118 loc) · 3.8 KB
/
js_mk_alert.html
File metadata and controls
129 lines (118 loc) · 3.8 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<head>
<meta charset="utf-8" />
</head>
<button onclick="mk_alert('请填写…', function(){window.console && window.console.info('hello, world')});">click</button>
<style type="text/css">
#mk_dialog {
background: #000000;
opacity: 0.25;
z-index: 10240;
height: 100%;
width: 100%;
position: fixed;
top: 0;
left: 0;
display: none;
}
#mk_dialog_output {
background: rgb(255, 255, 255);
z-index: 10250;
min-width: 300px;
position: fixed;
text-align: center;
border-radius: 7px;
border: solid 1px #C6C6C6;
-webkit-box-shadow: 3px 3px 2px rgba(0, 0, 0, 0.1);
box-shadow: 3px 3px 2px rgba(0, 0, 0, 0.1);
display: none;
}
#mk_dialog_title {
font-size: 16px;
padding: 5px;
cursor: move;
text-align: right;
}
#mk_dialog_close {
font-size: 20px;
cursor: pointer;
}
#mk_dialog_teller {
margin-top: 35px;
font-size: 16px;
}
.mk_button {
background: -moz-linear-gradient(top, #F5F5F5, #F1F1F1);
background: -webkit-linear-gradient(top, #F5F5F5, #F1F1F1);
background: -o-linear-gradient(top, #F5F5F5, #F1F1F1);
border: solid 1px rgba(0, 0, 0, 0.1);
padding: 3px 10px;
border-radius: 2px;
-webkit-border-radius: 2px;
font-family: "微软雅黑", Microsoft YaHei, arial, sans-serif;
font-size: 16px;
}
.mk_button:hover {
background: -moz-linear-gradient(top, #F8F8F8, #F1F1F1);
background: -webkit-linear-gradient(top, #F8F8F8, #F1F1F1);
background: -o-linear-gradient(top, #F8F8F8, #F1F1F1);
border: solid 1px #C6C6C6;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
cursor: pointer;
}
</style>
<script>
function mk_alert(msg, callback){
var d = document.createDocumentFragment();
var d1 = document.createElement('div');
var d2 = document.createElement('div');
var d3 = document.createElement('div');
var d3_5 = document.createElement('span');
var d4 = document.createTextNode('X');
var d5 = document.createElement('div');
var d6 = document.createElement('p');
var d7 = document.createElement('button');
var d8 = document.createTextNode('确定');
d1.id = 'mk_dialog';
d2.id = 'mk_dialog_output';
d3.id = 'mk_dialog_title';
d3_5.className = 'mk_dialog_close';
d3_5.id = 'mk_dialog_close';
d3_5.appendChild(d4);
d3.appendChild(d3_5);
d6.id = 'mk_dialog_teller';
d5.appendChild(d6);
d7.className = 'mk_dialog_close mk_button';
d7.style.margin = '22px auto';
d7.appendChild(d8);
d2.appendChild(d3);
d2.appendChild(d5);
d2.appendChild(d7);
d.appendChild(d1);
d.appendChild(d2);
document.body.appendChild(d);
var dialog = document.getElementById('mk_dialog');
var output = document.getElementById('mk_dialog_output');
var title = document.getElementById('mk_dialog_title');
var teller = document.getElementById('mk_dialog_teller');
var msg = msg || '';
msg = document.createTextNode(msg);
dialog.style.display = 'block';
output.style.display = 'block';
teller.appendChild(msg);
var left = (window.screen.availWidth - output.offsetWidth)/2;
var top = (window.screen.availHeight - output.offsetHeight)/2-100;
output.style.left = left+'px';
output.style.top = top+'px';
var close = document.getElementsByClassName('mk_dialog_close');
var callback = callback || '';
for (c in close){
close[c].onclick = function(){
document.body.removeChild(dialog);
document.body.removeChild(output);
if (typeof callback == 'function'){
callback();
}
}
}
}
</script>