-
Notifications
You must be signed in to change notification settings - Fork 128
/
jquery.loadingbar.min.js
1 lines (1 loc) · 1.94 KB
/
jquery.loadingbar.min.js
1
!function(e){var t={replaceURL:false,target:"#loadingbar-frame",direction:"right",async:true,complete:function(e,t){},cache:true,error:function(e,t,n){},global:true,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(n){var r=e.extend({},t,n),i=e(this),s=i.attr("href"),o=i.data("target")?i.data("target"):r.target,u=i.data("type")?i.data("type"):r.type,a=i.data("datatype")?i.data("datatype"):r.dataType;return this.each(function(){i.click(function(){e.ajax({type:u,url:s,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:a,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);break}}}}).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()});break}}).done(function(t){if(history.replaceState&&r.replaceURL==true)history.pushState({},document.title,s);if(r.done){r.done(t,o)}else{e(o).html(t)}});return false})})}}(window.jQuery)