1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- /**
- * 显示加载中控件 2016/8/9 康国前加
- */
- ;(function($,window,document,undefined) {
-
- $.extend({
- /**
- * 获取加载中不同的样式
- */
- getLoadingCSS : function(idx,loadingText){
- var result = "";
- switch (idx){
- case 1 ://系统加载样式一
- result = {
- 'loadingBgClass':'work-loading-bg',
- 'loadingBoxClass':'work-loading-box',
- 'loadingText':loadingText ==null ?"页面加载中...":loadingText
- //'loadingHtml':'<span>页面加载中...</span>'
- };
- break;
- case 2 ://系统加载样式二
- result = {
- 'loadingBgClass':'single-loading-bg',
- 'loadingBoxClass':'single-loading-box',
- 'loadingText':loadingText
- };
- }
- return result;
- }
- });
-
- var IndexLoading = function (ele,opts){
- this.$loadingBg,
- this.$loadingBox,
- this.$ele = ele,
- this.defaults = {
- 'loadingBgClass':'idxModule-loading-bg',
- 'loadingBoxClass':'idxModule-loading-box',
- 'loadingHtml':'',
- 'loadingText':'正在加载中...'
- },
- this.options = $.extend({},this.defaults,opts);
- };
-
- IndexLoading.prototype = {
- init:function(){
- if(this.$ele.find("."+this.options.loadingBgClass).length!=0){
- this.$loadingBg = this.$ele.find("."+this.options.loadingBgClass).last();
- this.$loadingBox = this.$ele.find("."+this.options.loadingBoxClass).last();
- }else{
- var loadHtml = '<span>'+this.options.loadingText+'</span>';
- if(this.options.loadingHtml && this.options.loadingHtml!=null && this.options.loadingHtml!=""){
- loadHtml = this.options.loadingHtml;
- }
- this.$loadingBg = $('<div class="'+this.options.loadingBgClass+'" ></div>');
- this.$loadingBox = $('<div class="'+this.options.loadingBoxClass+'">'+loadHtml+'</div>');
- this.$ele.append(this.$loadingBg).append(this.$loadingBox);
- };
- },
- destroy:function(){//释放节点所占内存
- this.$loadingBg = null;
- this.$loadingBox = null;
- this.$ele = null;
- },
- show:function(){
- return this.$loadingBg.css({'display':'block'}),this.$loadingBox.css({'display':'block'}),this.destroy();
- },
- hide:function(){
- return this.$loadingBg.css({'display':'none'}),this.$loadingBox.css({'display':'none'}),this.destroy();
- }
- };
-
- $.fn.indexLoading = function (options){
- var indexLoad = new IndexLoading(this,options);
- indexLoad.init();
- return indexLoad;
- };
- })(jQuery,window,document);
|