依赖于jQuery-loading.js
显示遮罩层(正在查询...)
参数:content [String](遮罩层内容),dom [Object](dom节点),time [Number](延迟生成时间)
jqLoading = function (content, dom, time) {
if (content && 'string' !== typeof content) return;
if (dom && 'object' !== typeof dom ) return;
setTimeout(function() {
if (!dom) {
$.fn.jqLoading({
height: 80,
width: 240,
text: content || '正在加载,请稍后...',
backgroundImage: 'assets/images/loading.gif',
type: 0
});
// 改Id(重复)
$('#content').attr('id', 'shadow_id');
$('#shadow_id).append(
"<a class='cancel' style='cursor: pointer; vertical-align: middle; margin- left: 10px; color: #337AB7;'>取消</a>"
);
$('.cancel').off('click').on('click'), function() {
$.fn.jqLoading('destroy');
});
$('#shadow_id').attr('id', content);
} else {
dom.jqLoading({
height: 36,
width: 36,
text: content,
type: 1
});
}
}, time || 0);
}
隐藏遮罩层
hideLoading = function(time) {
setTimeout(function() {
$.fn.jqLoading('destroy');
}, time || 500);
}