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
9.9 KiB

9 years ago
9 years ago
9 years ago
10 years ago
  1. /*!
  2. * # Semantic UI 1.11.5 - Progress
  3. * http://github.com/semantic-org/semantic-ui/
  4. *
  5. *
  6. * Copyright 2014 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),i=o.selector||"",s=(new Date).getTime(),c=[],l=arguments[0],u="string"==typeof l,g=[].slice.call(arguments,1);return o.each(function(){var o,v,d=e.isPlainObject(t)?e.extend(!0,{},e.fn.progress.settings,t):e.extend({},e.fn.progress.settings),p=d.className,m=d.metadata,b=d.namespace,f=d.selector,h=d.error,w="."+b,x="module-"+b,y=e(this),C=e(this).find(f.bar),T=e(this).find(f.progress),A=e(this).find(f.label),E=this,S=y.data(x),I=!1;v={initialize:function(){v.debug("Initializing progress bar",d),o=v.get.transitionEnd(),v.read.metadata(),v.set.duration(),v.set.initials(),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)},complete:function(){(v.percent===r||v.percent<100)&&v.set.percent(100)},read:{metadata:function(){y.data(m.percent)&&(v.verbose("Current percent value set from metadata"),v.percent=y.data(m.percent)),y.data(m.total)&&(v.verbose("Total value set from metadata"),v.total=y.data(m.total)),y.data(m.value)&&(v.verbose("Current value set from metadata"),v.value=y.data(m.value))},currentValue:function(){return v.value!==r?v.value:!1}},increment:function(e){var t,n,r,a=v.total||!1;a?(n=v.value||0,e=e||1,r=n+e,t=v.total,v.debug("Incrementing value by",e,n,t),r>t&&(v.debug("Value cannot increment above total",t),r=t),v.set.progress(r)):(n=v.percent||0,e=e||v.get.randomValue(),r=n+e,t=100,v.debug("Incrementing percentage by",e,n),r>t&&(v.debug("Value cannot increment above 100 percent"),r=t),v.set.progress(r))},decrement:function(e){var t,n,r=v.total||!1,a=0;r?(t=v.value||0,e=e||1,n=t-e,v.debug("Decrementing value by",e,t)):(t=v.percent||0,e=e||v.get.randomValue(),n=t-e,v.debug("Decrementing percentage by",e,t)),a>n&&(v.debug("Value cannot decrement below 0"),n=0),v.set.progress(n)},get:{text:function(e){var t=v.value||0,n=v.total||0,r=v.is.visible()&&I?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()*d.random.max+d.random.min)},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 Math.round(0===d.precision?r:10*r*d.precision/(10*d.precision))},percent:function(){return v.percent||0},value:function(){return v.value||!1},total:function(){return v.total||!1}},is:{success:function(){return y.hasClass(p.success)},warning:function(){return y.hasClass(p.warning)},error:function(){return y.hasClass(p.error)},active:function(){return y.hasClass(p.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(p.active)},success:function(){v.verbose("Removing success state"),y.removeClass(p.success)},warning:function(){v.verbose("Removing warning state"),y.removeClass(p.warning)},error:function(){v.verbose("Removing error state"),y.removeClass(p.error)}},set:{barWidth:function(e){e>100?v.error(h.tooHigh,e):0>e?v.error(h.tooLow,e):(C.css("width",e+"%"),y.attr("data-percent",parseInt(e,10)))},duration:function(e){e=e||d.duration,e="number"==typeof e?e+"ms":e,v.verbose("Setting progress bar transition duration",e),C.css({"-webkit-transition-duration":e,"-moz-transition-duration":e,"-ms-transition-duration":e,"-o-transition-duration":e,"transition-duration":e})},initials:function(){d.total!==!1&&(v.verbose("Current total set in