This repository has been archived by the owner on Nov 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 160
/
bootstrap-progressbar.min.js
6 lines (6 loc) · 2.47 KB
/
bootstrap-progressbar.min.js
1
2
3
4
5
6
/* bootstrap-progressbar v0.4.2 | Copyright 2012 minddust.com | http://www.apache.org/licenses/LICENSE-2.0 */
(function(b){var e=function(c,d){this.element=b(c);this.options=b.extend({},b.fn.progressbar.defaults,d);this.transition()};e.prototype={constructor:e,transition:function(){var c=this.element,d=c.parent(),a=this.options,f=c.attr("data-percentage"),e=c.attr("data-amount-part"),i=c.attr("data-amount-total"),n,o,g;n=a.update&&"function"===typeof a.update?a.update:b.fn.progressbar.defaults.update;o=a.done&&"function"===typeof a.done?a.done:b.fn.progressbar.defaults.done;g=a.fail&&"function"===typeof a.fail?
a.fail:b.fn.progressbar.defaults.fail;if(a.use_percentage&&!f)g("bootstrap-progressbar: you can't use percentage without data-percentage being set");else{if(!a.use_percentage){if(!e&&!i){g("bootstrap-progressbar: you can't use values without data-amount-part and data-amount-total being set");return}f=Math.round(100*e/i)}if(a.display_text===b.fn.progressbar.display_text.center){d.css("position","relative");c.css({position:"absolute","float":"left",overflow:"hidden","-webkit-border-radius":a.border_radius,
"-moz-border-radius":a.border_radius,"border-radius":a.border_radius});d.prepend('<span class="progressbar-back-text" style="position:absolute;width:100%;text-align:center"></span>');c.prepend('<span class="progressbar-front-text" style="display:block;text-align:center"></span>');var p=d.find(".progressbar-back-text"),k=d.find(".progressbar-front-text");k.css("width",d.css("width"));b(window).resize(function(){k.css("width",d.css("width"))})}setTimeout(function(){c.css("width",f+"%");var h,g,l,m,
j,q=setInterval(function(){l=c.width();m=d.width();h=Math.round(100*l/m);g=Math.round(l/m*i);h>=f&&(h=f,g=e,o(),clearInterval(q));a.display_text!==b.fn.progressbar.display_text.none&&(j=a.use_percentage?h+"%":g+" / "+i,a.display_text===b.fn.progressbar.display_text.filled?c.text(j):a.display_text===b.fn.progressbar.display_text.center&&(k.text(j),p.text(j)));n(h)},a.refresh_speed)},a.transition_delay)}}};b.fn.progressbar=function(c){return this.each(function(){var d=b(this),a=d.data("progressbar"),
f="object"===typeof c&&c;a||d.data("progressbar",a=new e(this,f));if("string"===typeof c)a[c]()})};b.fn.progressbar.display_text={none:0,filled:1,center:2};b.fn.progressbar.defaults={transition_delay:300,refresh_speed:50,display_text:b.fn.progressbar.display_text.none,use_percentage:!0,border_radius:"4px",update:b.noop,done:b.noop,fail:b.noop};b.fn.progressbar.Constructor=e})(window.jQuery);