You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

10 lines
10 KiB

  1. /*!
  2. * # Semantic UI 2.1.6 - Progress
  3. * http://github.com/semantic-org/semantic-ui/
  4. *
  5. *
  6. * Copyright 2015 Contributors
  7. * Released under the MIT license
  8. * http://opensource.org/licenses/MIT
  9. *
  10. */
  11. !function(e,t,n,r){"use strict";e.fn.progress=function(t){var a,o=e(this),s=o.selector||"",i=(new Date).getTime(),c=[],l=arguments[0],u="string"==typeof l,g=[].slice.call(arguments,1);return o.each(function(){var o,v,p=e.isPlainObject(t)?e.extend(!0,{},e.fn.progress.settings,t):e.extend({},e.fn.progress.settings),d=p.className,m=p.metadata,b=p.namespace,f=p.selector,h=p.error,w="."+b,x="module-"+b,y=e(this),C=e(this).find(f.bar),T=e(this).find(f.progress),E=e(this).find(f.label),A=this,S=y.data(x),V=!1;v={initialize:function(){v.debug("Initializing progress bar",p),v.set.duration(),v.set.transitionEvent(),v.read.metadata(),v.read.settings(),v.instantiate()},instantiate:function(){v.verbose("Storing instance of progress",v),S=v,y.data(x,v)},destroy:function(){v.verbose("Destroying previous progress for",y),clearInterval(S.interval),v.remove.state(),y.removeData(x),S=r},reset:function(){v.set.percent(0),v.set.value(0)},complete:function(){(v.percent===r||v.percent<100)&&v.set.percent(100)},read:{metadata:function(){var e={percent:y.data(m.percent),total:y.data(m.total),value:y.data(m.value)};e.percent&&(v.debug("Current percent value set from metadata",e.percent),v.set.percent(e.percent)),e.total&&(v.debug("Total value set from metadata",e.total),v.set.total(e.total)),e.value&&(v.debug("Current value set from metadata",e.value),v.set.value(e.value),v.set.progress(e.value))},settings:function(){p.total!==!1&&(v.debug("Current total set in settings",p.total),v.set.total(p.total)),p.value!==!1&&(v.debug("Current value set in settings",p.value),v.set.value(p.value),v.set.progress(v.value)),p.percent!==!1&&(v.debug("Current percent set in settings",p.percent),v.set.percent(p.percent))}},increment:function(e){var t,n,r;v.has.total()?(n=v.get.value(),e=e||1,r=n+e,t=v.get.total(),v.debug("Incrementing value",n,r,t),r>t&&(v.debug("Value cannot increment above total",t),r=t)):(n=v.get.percent(),e=e||v.get.randomValue(),r=n+e,t=100,v.debug("Incrementing percentage by",n,r),r>t&&(v.debug("Value cannot increment above 100 percent"),r=t)),v.set.progress(r)},decrement:function(e){var t,n,r=v.get.total();r?(t=v.get.value(),e=e||1,n=t-e,v.debug("Decrementing value by",e,t)):(t=v.get.percent(),e=e||v.get.randomValue(),n=t-e,v.debug("Decrementing percentage by",e,t)),0>n&&(v.debug("Value cannot decrement below 0"),n=0),v.set.progress(n)},has:{total:function(){return v.get.total()!==!1}},get:{text:function(e){var t=v.value||0,n=v.total||0,r=V?v.get.displayPercent():v.percent||0,a=v.total>0?n-t:100-r;return e=e||"",e=e.replace("{value}",t).replace("{total}",n).replace("{left}",a).replace("{percent}",r),v.debug("Adding variables to progress bar text",e),e},randomValue:function(){return v.debug("Generating random increment percentage"),Math.floor(Math.random()*p.random.max+p.random.min)},numericValue:function(e){return"string"==typeof e?""!==e.replace(/[^\d.]/g,"")?+e.replace(/[^\d.]/g,""):!1:e},transitionEnd:function(){var e,t=n.createElement("element"),a={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(e in a)if(t.style[e]!==r)return a[e]},displayPercent:function(){var e=C.width(),t=y.width(),n=parseInt(C.css("min-width"),10),r=e>n?e/t*100:v.percent;return p.precision>0?Math.round(r*(10*p.precision))/(10*p.precision):Math.round(r)},percent:function(){return v.percent||0},value:function(){return v.value||0},total:function(){return v.total||!1}},is:{success:function(){return y.hasClass(d.success)},warning:function(){return y.hasClass(d.warning)},error:function(){return y.hasClass(d.error)},active:function(){return y.hasClass(d.active)},visible:function(){return y.is(":visible")}},remove:{state:function(){v.verbose("Removing stored state"),delete v.total,delete v.percent,delete v.value},active:function(){v.verbose("Removing active state"),y.removeClass(d.active)},success:function(){v.verbose("Removing success state"),y.removeClass(d.success)},warning:function(){v.verbose("Removing warning state"),y.removeClass(d.warning)},error:function(){v.verbose("Removing error