JQuery+Bootstrap 自定义全屏Loading插件
/**
* 自定义Loading插件
* @param {Object} config
* {
* content[加载显示文本],
* time[自动关闭等待时间(ms)]
* }
* @param {String} config
* 加载显示文本
* @refer 依赖 JQuery-1.9.1及以上、Bootstrap-3.3.7及以上
* @return {KZ_Loading} 对象实例
*/
function KZ_Loading(config) {
if (this instanceof KZ_Loading) {
const domTemplate = '<div class="modal fade kz-loading" data-kzid="@@KZ_Loadin_ID@@" backdrop="static" keyboard="false"><div style="width: 200px;height:20px; z-index: 20000; position: absolute; text-align: center; left: 50%; top: 50%;margin-left:-100px;margin-top:-10px"><div class="progress progress-striped active" style="margin-bottom: 0;"><div class="progress-bar" style="width: 100%;"></div></div><h5>@@KZ_Loading_Text@@</h5></div></div>';
this.config = {
content: 'loading...',
time: 0,
};
if (config != null) {
if (typeof config === 'string') {
this.config = Object.assign(this.config, {
content: config
});
} else if (typeof config === 'object') {
this.config = Object.assign(this.config, config);
}
}
this.id = new Date().getTime().toString();
this.state = 'hide'; /*显示 */
this.show = function () {
$('.kz-loading[data-kzid=' + this.id + ']').modal({
backdrop: 'static',
keyboard: false
});
this.state = 'show';
if (this.config.time > 0) {
var that = this;
setTimeout(function () {
that.hide();
}, this.config.time);
}
};
/*隐藏 */
this.hide = function (callback) {
$('.kz-loading[data-kzid=' + this.id + ']').modal('hide');
this.state = 'hide';
if (callback) {
callback();
}
};
/*销毁dom */
this.destroy = function () {
var that = this;
this.hide(function () {
var node = $('.kz-loading[data-kzid=' + that.id + ']');
node.next().remove();
node.remove();
that.show = function () {
throw new Error('对象已销毁!');
};
that.hide = function () {};
that.destroy = function () {};
});
} var domHtml = domTemplate.replace('@@KZ_Loadin_ID@@', this.id).replace('@@KZ_Loading_Text@@', this.config.content);
$('body').append(domHtml);
} else {
return new KZ_Loading(config);
}
}
基本调用:
var loading = new KZ_Loading('数据加载中。。。');
setTimeout(function () {
console.log('加载完成!');
loading.hide();
}, 1000);
自动关闭:
var loading = new KZ_Loading({
content: '数据加载中。。。',
time: 2000
});
loading.show();
销毁Loading Dom节点:
loading.destroy();
JQuery+Bootstrap 自定义全屏Loading插件的更多相关文章
- jquery.fullPage.js全屏滚动插件教程演示
css部分(此处需要导入jquery.fullPage.css) <style> .section { text-align: center; font: 50px "Micro ...
- jquery.fullPage.js全屏滚动插件
注:本文内容复制于http://www.51xuediannao.com/js/jquery/jquery.fullPage.html 和 http://www.360doc.com/content/ ...
- Scrollify – jQuery全屏滚动插件
和 fullPage.js 一样,Scrollify 也是一款基于 jQuery 的全屏滚动插件.跟 fullPage.js 相比,Scrollify 更加小巧,压缩后不足 4KB.但功能上不如 fu ...
- 基于jQuery全屏相册插件zoomVisualizer
基于jQuery全屏相册插件zoomVisualizer.这是一款基于jquery ui实现的相册插件,支持隐藏显示相册缩略图,支持左右箭头切换图片,支持放大缩及缩小图片.效果图如下: 在线预览 ...
- jQuery全屏滚动插件fullPage.js中文帮助文档API
jQuery全屏滚动插件fullPage.js中文帮助文档API 发现了一个fullPage.js插件,于是百度了一下,还就是这个插件的作用,其实有很多网站都做了全屏滚动的特效,效果也很好看,今天 ...
- 学习 | jQuery全屏滚动插件FullPage.js
简介 fullPage.js是一个基于jQuery的全屏滚动插件,它能够很方便.很轻松的制作出全屏网站. 主要功能 支持鼠标滚动 支持前进后退和键盘控制 多个回调函数 支持手机.平板触摸事件 支持 C ...
- fullpage.js全屏滚动插件使用方法
在移动端经常会用到全屏滚动插件,实现常见H5活动页的效果,fullpage是一个很不错的jquery全屏滚动插件 fullpage.js插件的API:http://www.dowebok.com/77 ...
- JS框架_(JQuery.js)文章全屏动画切换
百度云盘 传送门 密码:anap 文章全屏动画切换效果 <!doctype html> <html lang="zh"> <head> < ...
- AlloyTouch全屏滚动插件发布--30秒搞定顺滑H5页
原文链接:https://github.com/AlloyTeam/AlloyTouch/wiki/AlloyTouch-FullPage-Plugin 先验货 插件代码可以在这里找到. 注意,虽然是 ...
随机推荐
- oracle使用Union时遇到列格式clob和varchar2不符,不能转的问题
其实这个很简单,思路就是把clob转为varchar,在查询的时候使用dbms_lob.substr(coulmn,4000):就可以把指定列从clob转化为varchar2.
- python windows下安装pip及rarfile
python之所以被广泛使用,倒不见得是本身语法简单,而是而nodejs/javascript一样把三方库的依赖管理简化了,而不用和java一样非得通过maven管理,而且还得打包后在classpat ...
- Vscode 修改主题颜色
首先向大家演示如何使用VSCode自带的颜色主题:依次点击左上角的文件-首选项-颜色主题,出现如下的主题选取界面.
- 面试突击(五)——Java常用集合
为了勾起回忆,我画了一个常用集合类的结构关系图,话不多说,详见下图: 实际开发中ArrayList/HashMap/HashSet是三种最常用的集合工具类,通过其结构关系图也能清晰的了解他们的特性,所 ...
- 安装MySQL Server
之前安装了MySQL Workbench 8.0 CE,现在来安装MySQL Server. 点击 add next next next 完成 MySQL安装包地址: 链接:https://p ...
- WebGL学习笔记(十一):混合和透明
到目前为止我们绘制了不少模型,用到了不少颜色,颜色中有四个分量(RGBA),其中的A分量表示透明度,这个分量目前为止我们还没有真正的用到: A分量,表示的是当前的透明度,如果设定为 0.5 就会半透明 ...
- c# 通过win32 api 得到指定Console application Content
已知的问题: 1. 调试的时候会报IO 异常,非调试环境是正常的 2. Windows 应用程序才可以使用,可以用非windows应用程序包一层 using System; using System. ...
- robotframework启动ride失败,提示wxpython ImportError: DLL load failed: 找不到指定的模块
背景:按照rf的操作,安装是没有问题,就是在启动ride.py 这个文件,就有问题了,提示 wxpython ImportError: DLL load failed: 找不到指定的模块 在pytho ...
- 仿简书MarkDown编辑器可同步滚动
模仿简书的MarkDown编辑器,使用Angular8写的示例 1.支持同步滚动 编辑的过程中,右侧预览界面会同步滚动.滚动右侧预览界面,左侧编辑区也会同步滚动哦 2.支持语法高亮 如下: using ...
- Fiddler抓包工具的简单使用
Fiddler的官方网站:http://www.fiddler2.com Fiddler的官方帮助:http://docs.telerik.com/fiddler/knowledgebase/quic ...