-
Notifications
You must be signed in to change notification settings - Fork 0
/
blockui.min.js
8 lines (8 loc) · 3.51 KB
/
blockui.min.js
1
2
3
4
5
6
7
8
/*!
* jQuery blockUI plugin v20240416 - by raveren - MIT license
* https://github.com/raveren/blockui
* Usage:
* $('.selector').block() -> $('.selector').unblock() -> $('.selector').isBlocked()
* $.blockUi() -> $.unblockUi() -> $.isUiBlocked()
*/
(function(){function e(u){const b="blockUi.isBlocked";u.blockUi=function(){e(window)};u.unblockUi=function(){i(window)};u.isUiBlocked=function(){return u(window).isBlocked()};u.fn.block=function(){if(this[0]===window){u.blockUi();return this}return this.each(function(){e(this)})};u.fn.unblock=function(){if(this[0]===window){u.unblockUi();return this}return this.each(function(){i(this)})};u.fn.isBlocked=function(){return this.data(b)};document.head.appendChild(document.createElement("style")).innerHTML="@keyframes block-ui-animation{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";u.blockUi.defaults={message:'<div style="width:35px;height:35px;border:5px solid;border-color:#ed6f2f transparent;'+"border-radius:50%;display:inline-block;box-sizing:border-box;"+'animation:block-ui-animation 1s linear infinite;"></div>',css:{padding:0,margin:0,width:"",top:"calc(50% - 17px)",left:"calc(50% - 17px)",textAlign:"center",color:"#000",border:"0",backgroundColor:"#fff",background:"transparent",cursor:"progress"},overlayCSS:{backgroundColor:"#fff",backgroundImage:"linear-gradient(45deg,#eee 25%,rgba(238,238,238,0) 25%,rgba(238,238,238,0) 75%,"+"#eee 75%,#eee),linear-gradient(45deg,#eee 25%,rgba(238,238,238,0) 25%,rgba(238,238,238,0) 75%,"+"#eee 75%,#eee)",backgroundSize:"20px 20px",backgroundPosition:"0 0,10px 10px",opacity:.6,cursor:"progress"},baseZ:1e3,fadeIn:200,fadeOut:400,timeout:0};function e(e){const i=e===window;const o=i?u("body"):u(e);const n=u.blockUi.defaults;let t=n.css;let s=n.message;let a=n.baseZ;if(o.data(b)){return}o.data(b,true);p(o,true);if(o.css("position")==="static"){o.css("position","relative").data("blockUi.wasStatic",true)}let c,d,l,r;c=u('<div class="block-ui" style="display:none"></div>');d=u('<div class="block-ui block-ui-overlay" style="z-index:'+a+++';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');if(i){r='<div class="block-ui block-ui-page" style="z-index:'+(a+10)+';display:none;position:fixed"></div>'}else{r='<div class="block-ui block-ui-element" style="z-index:'+(a+10)+';display:none;position:absolute"></div>'}l=u(r);l.css(t);d.css(n.overlayCSS);d.css("position",i?"fixed":"absolute");const f=[c,d,l];u.each(f,function(){this.appendTo(o)});l.append(s);if(s.jquery||s.nodeType){u(s).show()}if(n.fadeIn){d.fadeIn(n.fadeIn);l.fadeIn(n.fadeIn)}else{d.show();l.show()}}function i(i){const e=i===window;const o=e?u("body"):u(i);const n=u.blockUi.defaults;if(!o.data(b)){return}o.data(b,false);p(o,false);let t=o.find(">.block-ui");if(n.fadeOut){let e=t.length;t.stop().fadeOut(n.fadeOut,function(){if(--e===0){s(t,n,i)}})}else{s(t,n,i)}}function s(e,i,o){const n=u(o);e.each(function(){if(this.parentNode){this.parentNode.removeChild(this)}});if(n.data("blockUi.wasStatic")){n.css("position","static")}}function p(e,i){const o="mousedown.blockUi mouseup.blockUi keydown.blockUi keypress.blockUi keyup.blockUi "+"touchstart.blockUi touchend.blockUi touchmove.blockUi submit.blockUi";if(i){e.each(function(){let i=this;u(i).on(o,function(e){e.preventDefault();e.stopImmediatePropagation();return false});o.split(" ").forEach(function(e){handlers=u._data(i).events[e.split(".")[0]];handlers.unshift(handlers.pop())})})}else{e.off(o)}}}if(typeof define==="function"&&define.amd&&define.amd.jQuery){define(["jquery"],e)}else{e(jQuery)}})();