|
|
/* * # Semantic UI * https://github.com/Semantic-Org/Semantic-UI
* http://www.semantic-ui.com/
* * Copyright 2014 Contributors * Released under the MIT license * http://opensource.org/licenses/MIT
* */ !function(e,t,n,r){"use strict";e.fn.progress=function(t){var n,a=e(this),o=a.selector||"",s=(new Date).getTime(),i=[],c=arguments[0],l="string"==typeof c,u=[].slice.call(arguments,1);return a.each(function(){var a,g=e.isPlainObject(t)?e.extend(!0,{},e.fn.progress.settings,t):e.extend({},e.fn.progress.settings),p=g.className,v=g.metadata,m=g.namespace,d=g.selector,b=g.error,f="module-"+m,h=e(this),x=e(this).find(d.bar),y=e(this).find(d.progress),w=e(this).find(d.label),C=this,A=h.data(f);a={initialize:function(){a.debug("Initializing progress",g),a.read.metadata(),a.set.initials(),a.instantiate()},instantiate:function(){a.verbose("Storing instance of progress",a),A=a,h.data(f,a)},destroy:function(){a.verbose("Destroying previous progress for",h),a.remove.state(),h.removeData(f),A=r},reset:function(){a.set.percent(0)},complete:function(){(a.percent===r||a.percent<100)&&a.set.percent(100)},read:{metadata:function(){h.data(v.percent)&&(a.verbose("Current percent value set from metadata"),a.percent=h.data(v.percent)),h.data(v.total)&&(a.verbose("Total value set from metadata"),a.total=h.data(v.total)),h.data(v.value)&&(a.verbose("Current value set from metadata"),a.value=h.data(v.value))},currentValue:function(){return a.value!==r?a.value:!1}},increment:function(e){var t,n,r,o=a.total||!1;o?(n=a.value||0,e=e||1,r=n+e,t=a.total,a.debug("Incrementing value by",e,n,t),r>t&&(a.debug("Value cannot increment above total",t),r=t),a.set.progress(r)):(n=a.percent||0,e=e||a.get.randomValue(),r=n+e,t=100,a.debug("Incrementing percentage by",e,n),r>t&&(a.debug("Value cannot increment above 100 percent"),r=t),a.set.progress(r))},decrement:function(e){var t,n,r=a.total||!1,o=0;r?(t=a.value||0,e=e||1,n=t-e,a.debug("Decrementing value by",e,t)):(t=a.percent||0,e=e||a.get.randomValue(),n=t-e,a.debug("Decrementing percentage by",e,t)),o>n&&(a.debug("Value cannot decrement below 0"),n=0),a.set.progress(n)},get:{text:function(e){var t=a.value||0,n=a.total||0,r=a.percent||0;return e=e||"",e=e.replace("{value}",t).replace("{total}",n).replace("{percent}",r),a.debug("Adding variables to progress bar text",e),e},randomValue:function(){return a.debug("Generating random increment percentage"),Math.floor(Math.random()*g.random.max+g.random.min)},percent:function(){return a.percent||0},value:function(){return a.value||!1},total:function(){return a.total||!1}},is:{success:function(){return h.hasClass(p.success)},warning:function(){return h.hasClass(p.warning)},error:function(){return h.hasClass(p.error)}},remove:{state:function(){a.verbose("Removing stored state"),delete a.total,delete a.percent,delete a.value},active:function(){a.verbose("Removing active state"),h.removeClass(p.active)},success:function(){a.verbose("Removing success state"),h.removeClass(p.success)},warning:function(){a.verbose("Removing warning state"),h.removeClass(p.warning)},error:function(){a.verbose("Removing error state"),h.removeClass(p.error)}},set:{barWidth:function(e){e>100?a.error(b.tooHigh,e):0>e?a.error(b.tooLow,e):x.css("width",e+"%")},initials:function(){g.total!==!1&&(a.verbose("Current total set in settings",g.total),a.total=g.total),g.value!==!1&&(a.verbose("Current value set in settings",g.value),a.value=g.value),g.percent!==!1&&(a.verbose("Current percent set in settings",g.percent),a.percent=g.percent),a.percent!==r?a.set.percent(a.percent):a.value!==r&&a.set.progress(a.value)},percent:function(t){t="string"==typeof t?+t.replace("%",""):t,t>0&&1>t&&(a.verbose("Module percentage passed as decimal, converting"),t=100*t),t=Math.round(0===g.precision?t:10*t*g.precision/(10*g.precision)),a.percent=t,a.total&&(a.value=Math.round(t/100*a.total)),g.limitValues&&(a.value=a.value>100?100:a.value<0?0:a.value),a.set.barWidth(t),a.set.barLabel(),100===t?!g.autoSuccess||a.is.warning()||a.is.error()?a.remove.active():(a.set.success(),a.debug("Automatically triggering success at 100%")):t>0&&a.set.active(),e.proxy(g.onChange,C)(t,a.value,a.total)},label:function(e){e=e||"",e&&(e=a.get.text(e),a.debug("Setting label to text",e),w.text(e))},barLabel:function(e){e!==r?y.text(a.get.
|