diff --git a/ToProgress.js b/ToProgress.js index 2e330a3..8a8f33b 100644 --- a/ToProgress.js +++ b/ToProgress.js @@ -1,5 +1,5 @@ /* -** ToProgress v0.1.0 +** ToProgress v0.1.1 ** http://github.com/djyde/ToProgress */ !(function(w){ diff --git a/ToProgress.min.js b/ToProgress.min.js index 759cf27..145d9d6 100644 --- a/ToProgress.min.js +++ b/ToProgress.min.js @@ -1,5 +1,5 @@ /* -** ToProgress v0.1.0 +** ToProgress v0.1.1 ** http://github.com/djyde/ToProgress */ !function(t){function s(){var t,s=document.createElement("fakeelement"),o={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(t in o)if(void 0!==s.style[t])return o[t]}var o=s();t.ToProgress=function(t,s){if(this.progress=0,this.options={id:"top-progress-bar",color:"#F44336",height:"2px",duration:.2},t&&"object"==typeof t)for(var o in t)this.options[o]=t[o];if(this.options.opacityDuration=3*this.options.duration,this.progressBar=document.createElement("div"),this.progressBar.id=this.options.id,this.progressBar.setCSS=function(t){for(var s in t)this.style[s]=t[s]},this.progressBar.setCSS({position:s?"relative":"fixed",top:"0",left:"0",right:"0","background-color":this.options.color,height:this.options.height,width:"0%",transition:"width "+this.options.duration+"s, opacity "+this.options.opacityDuration+"s","-moz-transition":"width "+this.options.duration+"s, opacity "+this.options.opacityDuration+"s","-webkit-transition":"width "+this.options.duration+"s, opacity "+this.options.opacityDuration+"s"}),s){var i=document.querySelector(s);i&&(i.hasChildNodes()?i.insertBefore(this.progressBar,i.firstChild):i.appendChild(this.progressBar))}else document.body.appendChild(this.progressBar)},ToProgress.prototype.transit=function(){this.progressBar.style.width=this.progress+"%"},ToProgress.prototype.getProgress=function(){return this.progress},ToProgress.prototype.setProgress=function(t,s){this.show(),this.progress=t>100?100:0>t?0:t,this.transit(),s&&s()},ToProgress.prototype.increase=function(t,s){this.show(),this.setProgress(this.progress+t,s)},ToProgress.prototype.decrease=function(t,s){this.show(),this.setProgress(this.progress-t,s)},ToProgress.prototype.finish=function(t){var s=this;this.setProgress(100,t),this.hide(),o&&this.progressBar.addEventListener(o,function(t){s.reset(),s.progressBar.removeEventListener(t.type,arguments.callee)})},ToProgress.prototype.reset=function(t){this.progress=0,this.transit(),t&&t()},ToProgress.prototype.hide=function(){this.progressBar.style.opacity="0"},ToProgress.prototype.show=function(){this.progressBar.style.opacity="1"}}(window); \ No newline at end of file