60 lines
2.8 KiB
JavaScript
60 lines
2.8 KiB
JavaScript
/**
|
|
* 信息提示框
|
|
* @param msg 提示信息
|
|
*/
|
|
function msgAlert(msg)
|
|
{
|
|
var htmlStr = "<div class='msgAlert' style='max-width:300px; min-width:150px; min-height:50px; max-height:100px; padding:20px; position:fixed; left:40%; top:15%; background:#6E6E6E; border-radius:10px; text-align:center; ' >";
|
|
htmlStr += "<span style='font-size:15px; color:#fff'>"+msg+"</span>";
|
|
htmlStr += "</div>";
|
|
$('body').append(htmlStr);
|
|
setTimeout(function(){
|
|
$('.msgAlert').remove();
|
|
},2000);
|
|
}
|
|
|
|
/**
|
|
* 信息确认框
|
|
* @param msg 要确认的信息
|
|
* @param confirmFunc 确定后要执行的代码
|
|
* @param cancelFunc 取消后要执行的代码
|
|
*/
|
|
function msgConfirm(msg,confirmFunc,cancelFunc)
|
|
{
|
|
var htmlStr = "<div class='shadow' style='width:100%; height:100%; background:#F2F2F2; position:fixed; left:0; top:0; opacity:0.7; '></div>";
|
|
htmlStr += "<div class='msgConfirm' style='width:300px; height:150px; position:fixed; left:35%; top:30%; background:#fff;'>";
|
|
htmlStr += "<div style='width:300px; height:35px; padding-left:15px;line-height:35px; font-size:16px;letter-spacing:3px; background:#0E7FB9; '>信息</div>";
|
|
htmlStr += "<div style='width:300px; height:65px; padding:15px; font-size:16px;letter-spacing:3px;word-wrap:break-word '>"+msg+"</div>";
|
|
htmlStr += "<div style='width:300px; height:50px; padding-left:15px;line-height:50px; font-size:16px;letter-spacing:3px; position:relative;'>";
|
|
htmlStr += "<div class='confirm' style='width:60px; height:30px; cursor:default; position:absolute; border:1px solid rgb(156,156,156); top:10px; left:150px; text-align:center; line-height:30px; font-size:16px;letter-spacing:3px; '>确定</div>";
|
|
htmlStr += "<div class='cancel' style='width:60px; height:30px; cursor:default; position:absolute; border:1px solid rgb(156,156,156); top:10px; left:220px; text-align:center; line-height:30px; font-size:16px;letter-spacing:3px; '>取消</div>";
|
|
htmlStr += "</div>";
|
|
htmlStr += "</div>";
|
|
$('body').append(htmlStr);
|
|
$(document).on('mouseover', '.confirm', function(){
|
|
$(this).css('background','#0E7FB9');
|
|
});
|
|
$(document).on('mouseout', '.confirm', function(){
|
|
$(this).css('background','');
|
|
});
|
|
$(document).on('mouseover', '.cancel', function(){
|
|
$(this).css('background','#0E7FB9');
|
|
});
|
|
$(document).on('mouseout', '.cancel', function(){
|
|
$(this).css('background','');
|
|
});
|
|
$(document).on('click', '.confirm', function(){
|
|
$('.msgConfirm').remove();
|
|
$('.shadow').remove();
|
|
if(confirmFunc !=undefined){
|
|
(confirmFunc)();
|
|
}
|
|
});
|
|
$(document).on('click', '.cancel', function(){
|
|
$('.msgConfirm').remove();
|
|
$('.shadow').remove();
|
|
if(cancelFunc !=undefined){
|
|
(cancelFunc)();
|
|
}
|
|
});
|
|
} |