/**
* @author Jerry.hou
*
* 提示框
* iAlert(param);
*
* 说明:
* param = {text:'提示内容',title:'提示标题',callback:'回调方法',btext:'确认按钮文字,缺省值为:我知道了'}
*
* 例:
* iAlert({title:'温馨提示',text:'hello world',callback:function(){this.remove();删除提示框}})
*/
function iAlert(param){
var _this = this,
text = param.text || '',
title = param.title || '',
callback = param.callback || '',
btext = param.btext || '我知道了';
var bg = $('<div class="x-tip-bg">'),
box = $('<div class="x-tip-box">'),
h1 = $('<h1>'),
p = $('<p>').html(text),
a = $('<a href="javascript:void(0)">').html(btext).click(function(){
callback && callback.call(_this);
}),
style = $('<style type="text/css">').html(bulidCss());
if(title){
h1.html(title);
box.append(h1);
}
box.append(p).append(a);
remove();
$('body').append(bg).append(box);
$('head').append(style);
//public fn.
_this.remove = remove;
//private fn
function remove(){
$(".x-tip-bg,.x-tip-box").empty().remove();
}
function bulidCss(){
return '.x-tip-bg{width:100%;height:100%;overflow:hidden;margin:0 auto;position:fixed;top:0;left:0;background:#000;opacity:.2;z-index:10}.x-tip-box{position:fixed;top:15%;left:10%;z-index:999;width:80%;height:auto;overflow:hidden;margin:0 auto;border-radius:5px;border:1px solid #CCC;background:#FFF}.x-tip-box h1{font-size:20px;font-weight:normal;text-align:center;font-family:"Microsoft YaHei"}.x-tip-box p{font-size:14px;line-height:24px;width:90%;margin:0 auto;height:auto;overflow:hidden;color:#999;font-family:"Microsoft YaHei"}.x-tip-box a{font-size:18px;line-height:40px;height:40px;text-align:center;color:#2087fc;text-decoration:none;outline:0;display:block;width:100%;border-top:1px solid #CCC;font-family:"Microsoft YaHei"}';
}
return _this;
}
* @author Jerry.hou
*
* 提示框
* iAlert(param);
*
* 说明:
* param = {text:'提示内容',title:'提示标题',callback:'回调方法',btext:'确认按钮文字,缺省值为:我知道了'}
*
* 例:
* iAlert({title:'温馨提示',text:'hello world',callback:function(){this.remove();删除提示框}})
*/
function iAlert(param){
var _this = this,
text = param.text || '',
title = param.title || '',
callback = param.callback || '',
btext = param.btext || '我知道了';
var bg = $('<div class="x-tip-bg">'),
box = $('<div class="x-tip-box">'),
h1 = $('<h1>'),
p = $('<p>').html(text),
a = $('<a href="javascript:void(0)">').html(btext).click(function(){
callback && callback.call(_this);
}),
style = $('<style type="text/css">').html(bulidCss());
if(title){
h1.html(title);
box.append(h1);
}
box.append(p).append(a);
remove();
$('body').append(bg).append(box);
$('head').append(style);
//public fn.
_this.remove = remove;
//private fn
function remove(){
$(".x-tip-bg,.x-tip-box").empty().remove();
}
function bulidCss(){
return '.x-tip-bg{width:100%;height:100%;overflow:hidden;margin:0 auto;position:fixed;top:0;left:0;background:#000;opacity:.2;z-index:10}.x-tip-box{position:fixed;top:15%;left:10%;z-index:999;width:80%;height:auto;overflow:hidden;margin:0 auto;border-radius:5px;border:1px solid #CCC;background:#FFF}.x-tip-box h1{font-size:20px;font-weight:normal;text-align:center;font-family:"Microsoft YaHei"}.x-tip-box p{font-size:14px;line-height:24px;width:90%;margin:0 auto;height:auto;overflow:hidden;color:#999;font-family:"Microsoft YaHei"}.x-tip-box a{font-size:18px;line-height:40px;height:40px;text-align:center;color:#2087fc;text-decoration:none;outline:0;display:block;width:100%;border-top:1px solid #CCC;font-family:"Microsoft YaHei"}';
}
return _this;
}