(function($, window, document,undefined){
var dialogInfo = {message: 'this ia a message', // 消息内容style: 'info', // 弹窗类型time: 1000, // 显示时间model:false // 是否模态};$.gmNoticeWnd = function(opt) {var settings = $.extend({},dialogInfo, opt),
dialogHtml = "";
dialogHtml += '<div class = "notice alert" style = "width:200px; padding:0px">';dialogHtml += "<div class = 'notice-head' style = 'height: 10px'>";dialogHtml += "<button type = 'button' class = 'close' style = 'display: none'>×</button>";dialogHtml += "</div>";dialogHtml += "<div class = 'notice-body' style = 'text-align: center; line-height: 40px; height: 40px'>";dialogHtml += "<p style = 'margin: 0px'>" + settings.message + "</p>";dialogHtml += "</div>";dialogHtml += '</div>';
var modalDialog = "<div class = 'noticecover' style = 'position: absolute; top: 0; left: 0; width:100%; height:100%; background: rgba(0,0,0,.5); z-index: 9999;'>" +
dialogHtml +
"</div>";
return (function setNotice() {
var noticeStyle = settings.style;
if (settings.model == false) {
$("body").append(dialogHtml);
} else {
$("body").append(modalDialog);
$("button").css("display","block");
};
var $notice = $(".notice"),
noticeTop = (screen.height / 2) - $notice.height(),
noticeLeft = (screen.width / 2) - $notice.width() / 2;
$notice.css({"position": "absolute",
"top": noticeTop,
"left": noticeLeft,
});
switch (noticeStyle) {
case 'error':
$notice.addClass("alert-danger");
break;
case 'normal':
$notice.addClass("alert-success");
break;
case 'warning':
$notice.addClass("alert-warning");
break;
default:
$notice.addClass("alert-info");
};
setTimeout(function() {
if (settings.model == false) {
$notice.remove();
} else {
$(".close").click(function() {
$(".noticecover").remove();
});
};
}, settings.time);
} ());
};
$.fn.appearDialog = function(opt) {
$.gmNoticeWnd(opt);
};
})(jQuery, window, document);