/* *usage //显示 $.AlerStatus({ status:'loading', //状态 msg:'上传中...', //文字0 duration:2000 //默认多少秒后隐藏,设null则一直不隐藏 }) //隐藏 $.AlerStatus({ type:'hide', //显示或隐藏,默认为show time:3000 //3s后隐藏,默认为0 }) */ (function (window,document) { $(function(){ init(); //初始化 }) function init() { _html = ' ' + '
' + '
' + '' + '
' + '
' + '
' + '
' + ''; AlerHTML = document.createElement('div'); AlerHTML.innerHTML = _html; document.body.appendChild(AlerHTML); } var opts; $.AlerStatus = function (options) { var defaults = { type: 'show', status: null, msg: null, time: 0, duration: 2000 }; opts = $.extend({}, defaults, options); if (opts.type == 'show') { show_box(opts.status, opts.msg, opts.time, opts.duration); } else { hide_box(opts.time); } } function show_box(status, msg, time, duration) { setTimeout(function () { $('#AlerStatus').show(); $('#AlerStatus .status').removeClass().addClass('status').addClass(status); $('#AlerStatus .title').html(msg); if (duration != null) { hide_box(duration); } if (status == "loading") { $('#AlerStatus .AlerStatusBg').show(); } }, time); } function hide_box(time) { setTimeout(function () { $('#AlerStatus').fadeOut(300); $('#AlerStatus .AlerStatusBg').hide(); }, time); } })(window,document);