forked from peachananr/loading-bar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.loadingbar.min.js
1 lines (1 loc) · 1.92 KB
/
jquery.loadingbar.min.js
1
;(function(e,t,n,r){var i={replaceURL:!1,target:"#loadingbar-frame",direction:"right",async:!0,complete:function(e,t){},cache:!0,error:function(e,t,n){},global:!0,headers:{},statusCode:{},success:function(e,t,n){},dataType:"html"};e.fx.step.textShadowBlur=function(t){e(t.elem).prop("textShadowBlur",t.now).css({textShadow:"0 0 "+Math.floor(t.now)+"px black"})};e.fn.loadingbar=function(t){var r=e.extend({},i,t),s=e(this),o=s.attr("href"),u=s.data("target")?s.data("target"):r.target,a=s.data("type")?s.data("type"):r.type,f=s.data("datatype")?s.data("datatype"):r.dataType;return this.each(function(){s.click(function(){e.ajax({type:a,url:o,async:r.async,complete:r.complete,cache:r.cache,error:r.error,global:r.global,headers:r.headers,statusCode:r.statusCode,success:r.success,dataType:f,beforeSend:function(){if(e("#loadingbar").length===0){e("body").append("<div id='loadingbar'></div>");e("#loadingbar").addClass("waiting").append(e("<dt/><dd/>"));switch(r.direction){case"right":e("#loadingbar").width(50+Math.random()*30+"%");break;case"left":e("#loadingbar").addClass("left").animate({right:0,left:100-(50+Math.random()*30)+"%"},200);break;case"down":e("#loadingbar").addClass("down").animate({left:0,height:50+Math.random()*30+"%"},200);break;case"up":e("#loadingbar").addClass("up").animate({left:0,top:100-(50+Math.random()*30)+"%"},200)}}}}).always(function(){switch(r.direction){case"right":e("#loadingbar").width("101%").delay(200).fadeOut(400,function(){e(this).remove()});break;case"left":e("#loadingbar").css("left","0").delay(200).fadeOut(400,function(){e(this).remove()});break;case"down":e("#loadingbar").height("101%").delay(200).fadeOut(400,function(){e(this).remove()});break;case"up":e("#loadingbar").css("top","0").delay(200).fadeOut(400,function(){e(this).remove()})}}).done(function(t){history.replaceState&&r.replaceURL===!0&&history.pushState({},n.title,o);r.done?r.done(t,u):e(u).html(t)});return!1})})}})(jQuery,window,document);