-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjquery.loadBar.min.js
1 lines (1 loc) · 1.26 KB
/
jquery.loadBar.min.js
1
var loadBar={init:function(){$("body").append($("<canvas></canvas>",{id:"canvasBar",style:"position: absolute; top: 0; width: 100%; height: "+this.barHeight+"px; z-index: 9999;"}));this.context=document.getElementById("canvasBar").getContext("2d");this.docReady=1},trigger:function(a){if(!this.docReady){return}if(a=="show"){if(this.barOn){return}this.barOn=1;$("#canvasBar").css("display","block");$(".btn").prop("disabled",true);this.run()}else{if(a=="hide"){this.barOn=null;$("#canvasBar").css("display","none");$(".btn").prop("disabled",false)}}},run:function(){var a=loadBar.context.createLinearGradient(loadBar.gradientStartCnt,0,loadBar.gradientEndCnt,0);a.addColorStop(0,loadBar.mainColor);a.addColorStop(0.5,loadBar.stripColor);a.addColorStop(1,loadBar.mainColor);loadBar.context.fillStyle=a;loadBar.context.fillRect(0,0,300,300);if(loadBar.gradientStartCnt>300){loadBar.gradientEndCnt+=loadBar.barSpeed;if(loadBar.gradientEndCnt>300){loadBar.gradientStartCnt=0;loadBar.gradientEndCnt=0}}else{loadBar.gradientStartCnt+=loadBar.barSpeed}if(loadBar.barOn){setTimeout(loadBar.run,20)}},context:null,docReady:null,barOn:null,colorStopCnt:0,gradientStartCnt:0,gradientEndCnt:0,mainColor:"red",stripColor:"green",barSpeed:5,barHeight:5};$(document).ready(function(){loadBar.init()});