-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalert.js
72 lines (61 loc) · 1.95 KB
/
alert.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
$(function () {
div = $('<div></div>');
div.css('background-color', '#f2dede');
div.css('width', '480px');
div.css('position', 'fixed');
div.css('left', '0px');
div.css('right', '0px');
div.css('margin-left', 'auto');
div.css('margin-right', 'auto');
div.css('top', '30px');
div.css('z-index', '10000');
div.css('padding-bottom', '14px');
div.css('padding-top', '14px');
div.css('border-color', '#eed3d7');
div.css('color', '#b94a48');
div.css('border-radius', '4px')
div.css('border-width', '2px');
div.css('border-style', 'solid');
div.css('margin-bottom', '20px');
div.css('text-shadow', '0 1px 0 rgba(255, 255, 255, 0.5)');
div.css('text-align', 'right');
var btn = $('<button>×</button>');
btn.css('line-height', '20px');
btn.css('position', 'relative');
btn.css('right', '15px');
btn.css('top', '-10px');
btn.css('background', 'none repeat scroll 0 0 transparent');
btn.css('border', '0 none');
btn.css('cursor', 'pointer');
btn.css('padding', '0');
btn.css('color', '#000');
btn.css('float', 'right');
btn.css('font-size', '20px');
btn.css('font-weight', 'bold');
btn.css('line-height', '20px');
btn.css('opacity', '0.2');
btn.css('text-shadow', '0 1px 0 #fff');
var span = $('<span><p align="center" id="alert_content"></p></span>');
div.append(btn);
div.append(span);
div.hide();
$("body").append(div);
window.alert = function (msg, fn) {
$("#alert_content").text(msg);
var display = true;
var hide = function () {
if (display) {
div.fadeOut('slow', function () {
display = false;
if (fn) {
fn();
}
});
}
}
btn.one('click', hide);
div.fadeIn('slow', function () {
setTimeout(hide, 2000);
});
}
})