LinkStack/assets/js/jquery-block-ui.js

16 lines
9.3 KiB
JavaScript

/*!
* jQuery blockUI plugin
* Version 2.70.0-2014.11.23
* Requires jQuery v1.7 or later
*
* Examples at: http://malsup.com/jquery/block/
* Copyright (c) 2007-2013 M. Alsup
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Thanks to Amir-Hossein Sobhi for some excellent contributions!
*/
/*jshint eqeqeq:false curly:false latedef:false */
!function(){"use strict";function a($){$.fn._fadeIn=$.fn.fadeIn;var a=$.noop||function(){},b=/MSIE/.test(navigator.userAgent),c=/MSIE 6.0/.test(navigator.userAgent)&&!/MSIE 8.0/.test(navigator.userAgent);document.documentMode;var d=$.isFunction(document.createElement("div").style.setExpression);$.blockUI=function(a){g(window,a)},$.unblockUI=function(a){h(window,a)},$.growlUI=function(b,c,d,f){var a=$('<div class="growlUI"></div>');b&&a.append("<h1>"+b+"</h1>"),c&&a.append("<h2>"+c+"</h2>"),void 0===d&&(d=3e3);var e=function(b){b=b||{},$.blockUI({message:a,fadeIn:void 0!==b.fadeIn?b.fadeIn:700,fadeOut:void 0!==b.fadeOut?b.fadeOut:1e3,timeout:void 0!==b.timeout?b.timeout:d,centerY:!1,showOverlay:!1,onUnblock:f,css:$.blockUI.defaults.growlCSS})};e(),a.css("opacity"),a.mouseover(function(){e({fadeIn:0,timeout:3e4});var a=$(".blockMsg");a.stop(),a.fadeTo(300,1)}).mouseout(function(){$(".blockMsg").fadeOut(1e3)})},$.fn.block=function(a){if(this[0]===window)return $.blockUI(a),this;var b=$.extend({},$.blockUI.defaults,a||{});return this.each(function(){var a=$(this);b.ignoreIfBlocked&&a.data("blockUI.isBlocked")||a.unblock({fadeOut:0})}),this.each(function(){"static"==$.css(this,"position")&&(this.style.position="relative",$(this).data("blockUI.static",!0)),this.style.zoom=1,g(this,a)})},$.fn.unblock=function(a){return this[0]===window?($.unblockUI(a),this):this.each(function(){h(this,a)})},$.blockUI.version=2.7,$.blockUI.defaults={message:"<h1>Please wait...</h1>",title:null,draggable:!0,theme:!1,css:{padding:0,margin:0,width:"30%",top:"40%",left:"35%",textAlign:"center",color:"#000",border:"3px solid #aaa",backgroundColor:"#fff",cursor:"wait"},themedCSS:{width:"30%",top:"40%",left:"35%"},overlayCSS:{backgroundColor:"#000",opacity:.6,cursor:"wait"},cursorReset:"default",growlCSS:{width:"350px",top:"10px",left:"",right:"10px",border:"none",padding:"5px",opacity:.6,cursor:"default",color:"#fff",backgroundColor:"#000","-webkit-border-radius":"10px","-moz-border-radius":"10px","border-radius":"10px"},iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank",forceIframe:!1,baseZ:1e3,centerX:!0,centerY:!0,allowBodyStretch:!0,bindEvents:!0,constrainTabKey:!0,fadeIn:200,fadeOut:400,timeout:0,showOverlay:!0,focusInput:!0,focusableElements:":input:enabled:visible",onBlock:null,onUnblock:null,onOverlayClick:null,quirksmodeOffsetHack:4,blockMsgClass:"blockMsg",ignoreIfBlocked:!1};var e=null,f=[];function g(o,g){var w,x,v,t,k,p,q=o==window,i=g&& void 0!==g.message?g.message:void 0;if(!((g=$.extend({},$.blockUI.defaults,g||{})).ignoreIfBlocked&&$(o).data("blockUI.isBlocked"))){if(g.overlayCSS=$.extend({},$.blockUI.defaults.overlayCSS,g.overlayCSS||{}),w=$.extend({},$.blockUI.defaults.css,g.css||{}),g.onOverlayClick&&(g.overlayCSS.cursor="pointer"),x=$.extend({},$.blockUI.defaults.themedCSS,g.themedCSS||{}),i=void 0===i?g.message:i,q&&e&&h(window,{fadeOut:0}),i&&"string"!=typeof i&&(i.parentNode||i.jquery)){var u=i.jquery?i[0]:i,r={};$(o).data("blockUI.history",r),r.el=u,r.parent=u.parentNode,r.display=u.style.display,r.position=u.style.position,r.parent&&r.parent.removeChild(u)}$(o).data("blockUI.onUnblock",g.onUnblock);var s=g.baseZ;v=b||g.forceIframe?$('<iframe class="blockUI" style="z-index:'+s+++';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+g.iframeSrc+'"></iframe>'):$('<div class="blockUI" style="display:none"></div>'),t=g.theme?$('<div class="blockUI blockOverlay ui-widget-overlay" style="z-index:'+s+++';display:none"></div>'):$('<div class="blockUI blockOverlay" style="z-index:'+s+++';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>'),g.theme&&q?(p='<div class="blockUI '+g.blockMsgClass+' blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+(s+10)+';display:none;position:fixed">',g.title&&(p+='<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(g.title||"&nbsp;")+"</div>"),p+='<div class="ui-widget-content ui-dialog-content"></div>',p+="</div>"):g.theme?(p='<div class="blockUI '+g.blockMsgClass+' blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+(s+10)+';display:none;position:absolute">',g.title&&(p+='<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(g.title||"&nbsp;")+"</div>"),p+='<div class="ui-widget-content ui-dialog-content"></div>',p+="</div>"):p=q?'<div class="blockUI '+g.blockMsgClass+' blockPage" style="z-index:'+(s+10)+';display:none;position:fixed"></div>':'<div class="blockUI '+g.blockMsgClass+' blockElement" style="z-index:'+(s+10)+';display:none;position:absolute"></div>',k=$(p),i&&(g.theme?(k.css(x),k.addClass("ui-widget-content")):k.css(w)),g.theme||t.css(g.overlayCSS),t.css("position",q?"fixed":"absolute"),(b||g.forceIframe)&&v.css("opacity",0);var y=[v,t,k],G=q?$("body"):$(o);$.each(y,function(){this.appendTo(G)}),g.theme&&g.draggable&&$.fn.draggable&&k.draggable({handle:".ui-dialog-titlebar",cancel:"li"});var C=d&&(!$.support.boxModel||$("object,embed",q?null:o).length>0);if(c||C){if(q&&g.allowBodyStretch&&$.support.boxModel&&$("html,body").css("height","100%"),(c||!$.support.boxModel)&&!q)var z=n(o,"borderTopWidth"),A=n(o,"borderLeftWidth"),H=z?"(0 - "+z+")":0,I=A?"(0 - "+A+")":0;$.each(y,function(b,c){var a=c[0].style;if(a.position="absolute",b<2)q?a.setExpression("height","Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.support.boxModel?0:"+g.quirksmodeOffsetHack+') + "px"'):a.setExpression("height",'this.parentNode.offsetHeight + "px"'),q?a.setExpression("width",'jQuery.support.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"'):a.setExpression("width",'this.parentNode.offsetWidth + "px"'),I&&a.setExpression("left",I),H&&a.setExpression("top",H);else if(g.centerY)q&&a.setExpression("top",'(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"'),a.marginTop=0;else if(!g.centerY&&q){var d="((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "+(g.css&&g.css.top?parseInt(g.css.top,10):0)+') + "px"';a.setExpression("top",d)}})}if(i&&(g.theme?k.find(".ui-widget-content").append(i):k.append(i),(i.jquery||i.nodeType)&&$(i).show()),(b||g.forceIframe)&&g.showOverlay&&v.show(),g.fadeIn){var B=g.onBlock?g.onBlock:a,D=g.showOverlay&&!i?B:a,E=i?B:a;g.showOverlay&&t._fadeIn(g.fadeIn,D),i&&k._fadeIn(g.fadeIn,E)}else g.showOverlay&&t.show(),i&&k.show(),g.onBlock&&g.onBlock.bind(k)();if(j(1,o,g),q?(e=k[0],f=$(g.focusableElements,e),g.focusInput&&setTimeout(l,20)):m(k[0],g.centerX,g.centerY),g.timeout){var F=setTimeout(function(){q?$.unblockUI(g):$(o).unblock(g)},g.timeout);$(o).data("blockUI.timeout",F)}}}function h(d,a){var k,b,g=d==window,c=$(d),l=c.data("blockUI.history"),h=c.data("blockUI.timeout");h&&(clearTimeout(h),c.removeData("blockUI.timeout")),j(0,d,a=$.extend({},$.blockUI.defaults,a||{})),null===a.onUnblock&&(a.onUnblock=c.data("blockUI.onUnblock"),c.removeData("blockUI.onUnblock")),b=g?$("body").children().filter(".blockUI").add("body > .blockUI"):c.find(">.blockUI"),a.cursorReset&&(b.length>1&&(b[1].style.cursor=a.cursorReset),b.length>2&&(b[2].style.cursor=a.cursorReset)),g&&(e=f=null),a.fadeOut?(k=b.length,b.stop().fadeOut(a.fadeOut,function(){0== --k&&i(b,l,a,d)})):i(b,l,a,d)}function i(g,a,d,e){var b=$(e);if(!b.data("blockUI.isBlocked")){g.each(function(a,b){this.parentNode&&this.parentNode.removeChild(this)}),a&&a.el&&(a.el.style.display=a.display,a.el.style.position=a.position,a.el.style.cursor="default",a.parent&&a.parent.appendChild(a.el),b.removeData("blockUI.history")),b.data("blockUI.static")&&b.css("position","static"),"function"==typeof d.onUnblock&&d.onUnblock(e,d);var c=$(document.body),f=c.width(),h=c[0].style.width;c.width(f-1).width(f),c[0].style.width=h}}function j(a,d,b){var c=d==window,f=$(d);if((a||(!c||e)&&(c||f.data("blockUI.isBlocked")))&&(f.data("blockUI.isBlocked",a),c&&b.bindEvents&&(!a||b.showOverlay))){var g="mousedown mouseup keydown keypress keyup touchstart touchend touchmove";a?$(document).bind(g,b,k):$(document).unbind(g,k)}}function k(a){if("keydown"===a.type&&a.keyCode&&9==a.keyCode&&e&&a.data.constrainTabKey){var b=f,g=!a.shiftKey&&a.target===b[b.length-1],h=a.shiftKey&&a.target===b[0];if(g||h)return setTimeout(function(){l(h)},10),!1}var c=a.data,d=$(a.target);return d.hasClass("blockOverlay")&&c.onOverlayClick&&c.onOverlayClick(a),d.parents("div."+c.blockMsgClass).length>0||0===d.parents().children().filter("div.blockUI").length}function l(b){if(f){var a=f[!0===b?f.length-1:0];a&&a.focus()}}function m(a,f,g){var b=a.parentNode,c=a.style,d=(b.offsetWidth-a.offsetWidth)/2-n(b,"borderLeftWidth"),e=(b.offsetHeight-a.offsetHeight)/2-n(b,"borderTopWidth");f&&(c.left=d>0?d+"px":"0"),g&&(c.top=e>0?e+"px":"0")}function n(a,b){return parseInt($.css(a,b),10)||0}}"function"==typeof define&&define.amd&&define.amd.jQuery?define(["jquery"],a):a(jQuery)}()