1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- /*!
- * jQuery loading Plugin v1.0.1
- *
- * Copyright 2017 Nick Han
- */
- (function (factory) {
- if (typeof define === 'function' && define.amd) {
- // AMD
- define(['jquery'], factory);
- } else if (typeof exports === 'object') {
- // CommonJS
- factory(require('jquery'));
- } else {
- // Browser globals
- factory(jQuery);
- }
- }(function ($) {
- //给窗口添加滚动事件,在滚动时遮罩跟着元素移动
- $(window).bind("scroll",function() {
- var masks = $(".mask");
- for (var i = 0; i < masks.length; i++) {
- var ele_id = $(masks[i]).attr("ele");
- var eleTop= $(ele_id).offset().top;
- var gun = $(document).scrollTop();
- var top = eleTop-gun;
- $(masks[i]).css({
- "top": top+'px'
- });
- }
- });
- //timeout cache
- var cache = {};
- var mask_html = "<div id='lot3d_loading_text'>数据加载中...</div>";
- /*
- * full screen loading mask
- */
- $.mask_fullscreen = function(timeout){
- if($(".mask[ele=full_screen]").length > 0){
- return;
- }
- //禁止滚动
- // $("body").addClass("scroll-off");
- var mask = '<div id="lot3d_loading_mask_html" class="mask" ele="full_screen">'+mask_html+'</div>';
- $("body").append(mask);
- clearTimeout(cache["full_screen"]);
- if(timeout && timeout > 0){
- var s = setTimeout(function(){
- $(".mask[ele=full_screen]").remove();
- $("body").removeClass("scroll-off");
- }, timeout);
- cache["full_screen"] = s;
- }
- }
- /*
- * close all loading mask
- */
- $.mask_close_all = function(){
- $(".mask").remove();
- }
- $.mask_text = function(text){
- $("#lot3d_loading_text")[0].innerText = text;
- }
- $.mask_html = function(html){
- mask_html = html;
- }
- }));
|