(function(t,i,s,e){function n(i,s){this.element=i,this._name=a,this.settings=t.extend({},r,s),this._defaults=r,this._name=a,this.init()}var a="progressBarTimer",r={timeLimit:60,warningThreshold:5,autoStart:!0,onFinish:function(){},baseStyle:"",warningStyle:"bg-danger",smooth:!1,completeStyle:"bg-success"};t.extend(n.prototype,{init:function(){t(this).empty();var i=t("<div>").addClass("progress active progress-striped"),s=t("<div>").addClass("progress-bar").addClass(this.settings.baseStyle).attr("role","progressbar").attr("aria-valuenow","0").attr("aria-valuemin","0").attr("aria-valuemax",this.settings.timeLimit);s.appendTo(i),i.appendTo(this.element),this.settings.smooth?(this.timerInterval=20,this.ticks=50*this.settings.timeLimit):(this.timerInterval=1e3,this.ticks=this.settings.timeLimit),this.remainingTicks=this.ticks,this.settings.autoStart&&this.start(),this.bindEvents()},destroy:function(){this.unbindEvents(),this.element.removeData()},bindEvents:function(){},unbindEvents:function(){this.element.off("."+this._name)},start:function(){this.interval=setInterval(jQuery.proxy(this._draw,this),this.timerInterval)},stop:function(t){clearInterval(this.interval),t&&t()},getElapsedTime:function(){return(this.ticks-this.remainingTicks)*this.timerInterval},getTimeRemaining:function(){return this.remainingTicks*this.timerInterval},addSeconds:function(t){var i=this.setings.smooth?20*t:t;this.ticks+=i,this.remainingTicks+=i},_draw:function(){var i=t(this.element).find(".progress-bar"),s=this.ticks-this.remainingTicks;i.width(s/this.ticks*100+"%"),0===this.remainingTicks--&&(this.stop(),i.removeClass(this.settings.baseStyle).removeClass(this.settings.warningStyle).addClass(this.settings.completeStyle),this.settings.onFinish())}}),t.fn.progressBarTimer=function(i){var s;return this.each(function(){s=t.data(this,"plugin_"+a),s||(s=new n(this,i),t.data(this,"plugin_"+a,s))}),s}})(jQuery,window,document);