wolegca.github.io/initialize.js

69 lines
1.8 KiB
JavaScript
Raw Normal View History

2019-09-12 23:24:39 +08:00
$(function () {
window.onselectstart = block;
window.ontouchstart = block;
window.ondragstart = block;
$('.msg-header').Drag($('.msg-container'));
$('.menu-container ul li span').on('click',function(){
2019-09-13 22:35:43 +08:00
message.alert('这里是','<div style="text-align:right"><div style="font-size:28px;height:70px;padding-top:20px;text-align:center">AHPU-老中医</div>的博客&nbsp;&nbsp;&nbsp;</div>');
2019-09-12 23:24:39 +08:00
});
function block() {
return false;
}
});
(function(){
$(window).on('resize',function(){
$('.msg-container').css({
"top":"50%",
"left":"50%"
});
});
$(document.body).on('click','.msg-footer span',function(){
var p = $(this).parent().parent();
2019-09-13 13:04:03 +08:00
var m = $('.mask');
2019-09-13 15:52:47 +08:00
p.css('animation','fadeOut .2s forwards');
m.css('animation','fadeOut .3s forwards');
2019-09-12 23:24:39 +08:00
setTimeout(function(){
p.remove();
2019-09-14 16:44:41 +08:00
m.remove();
2019-09-13 15:52:47 +08:00
},300);
2019-09-15 14:27:21 +08:00
message.alertCode = '';
2019-09-12 23:24:39 +08:00
});
})();
var message = new function () {
2019-09-15 14:27:21 +08:00
this.alertCode = '';
2019-09-12 23:24:39 +08:00
this.alert = function (header, content) {
2019-09-15 14:27:21 +08:00
if(message.alertCode){
console.warn('存在未关闭的提示框');
return;
}
2019-09-12 23:24:39 +08:00
var id = uuid();
var html =
'<div class="msg-container" id="mc-' + id + '">' +
'<div class="msg-header" id="mh-'+id+'">' +
2019-09-15 14:27:21 +08:00
(header || '提示框') +
2019-09-12 23:24:39 +08:00
'</div>' +
'<div class="msg-content">' +
2019-09-15 14:27:21 +08:00
(content || '提示内容') +
2019-09-12 23:24:39 +08:00
'</div>' +
'<div class="msg-footer">'+
'<span>关闭</span>'+
'</div>' +
2019-09-14 16:44:41 +08:00
'</div>' +
'<div class="mask"></div>';
2019-09-12 23:24:39 +08:00
$(document.body).append(html);
2019-09-15 14:27:21 +08:00
$('.mask').css('animation','fadeIn .2s forwards');
2019-09-12 23:24:39 +08:00
$('#mh-'+id).Drag($('#mc-'+id));
2019-09-15 14:27:21 +08:00
message.alertCode = id;
2019-09-12 23:24:39 +08:00
}
2019-09-12 16:12:08 +08:00
}
2019-09-12 23:24:39 +08:00
function uuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0,
v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
2019-09-12 16:12:08 +08:00
}