/** * @fileOverview * * 通知小组件 * * @author: techird * @copyright: Baidu FEX, 2014 */ KityMinder.registerUI('widget/notice', function(minder) { var errorMessage = minder.getLang('error_message'); var memory = minder.getUI('memory'); var $notice = $('
').text(msg)); $notice.addClass('show'); clearTimeout(info.ttl); time = time || (warn ? 5000 : 3000); info.ttl = setTimeout(function() { $notice.removeClass('show'); info.ttl2 = setTimeout(function() { $notice.empty(); }, 1000); }, time); } function warn(msg) { info(msg, warn); } function descriptReason(e) { e = e || new Error(); if (typeof(e) == 'string') { e = new Error(e); } if (e.getDetail) return e; // 文件访问错误 if (typeof(fio) != 'undefined' && (e instanceof fio.FileRequestError)) { if (!e.status) { e.description = errorMessage.err_network; } else { e.description = errorMessage.pcs_code[e.detail.error_code]; } e.getDetail = function() { return JSON.stringify(e, null, 4); }; } // jqXhr else if ('readyState' in e) { } else { e.getDetail = function() { return e.stack || new Error().stack; }; } return e; } function error(name, e) { if (arguments.length == 1) { e = name; name = 'unknown'; } $error_body.empty(); e = descriptReason(e); var $content = $('
') .text(e.message || e.description || errorMessage.unknownreason) .appendTo($content); if (e.getDetail) { var $detail = $('