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

9 years ago
8 years ago
9 years ago
10 years ago
9 years ago
10 years ago
  1. /*!
  2. * # Semantic UI 2.2.0 - 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";t="undefined"!=typeof t&&t.Math==Math?t:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"undefined"!=typeof t&&t.Math==Math?t:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();e.fn.progress=function(t){var a,o=e(this),s=o.selector||"",i=(new Date).getTime(),l=[],u=arguments[0],c="string"==typeof u,g=[].slice.call(arguments,1);return o.each(function(){var o,p,v=e.isPlainObject(t)?e.extend(!0,{},e.fn.progress.settings,t):e.extend({},e.fn.progress.settings),d=v.className,f=v.metadata,m=v.namespace,b=v.selector,h=v.error,x="."+m,w="module-"+m,y=e(this),V=e(this).find(b.bar),C=e(this).find(b.progress),P=e(this).find(b.label),M=this,T=y.data(w),E=!1;p={initialize:function(){p.debug("Initializing progress bar",v),p.set.duration(),p.set.transitionEvent(),p.read.metadata(),p.read.settings(),p.instantiate()},instantiate:function(){p.verbose("Storing instance of progress",p),T=p,y.data(w,p)},destroy:function(){p.verbose("Destroying previous progress for",y),clearInterval(T.interval),p.remove.state(),y.removeData(w),T=r},reset:function(){p.remove.nextValue(),p.update.progress(0)},complete:function(){(p.percent===r||p.percent<100)&&(p.remove.progressPoll(),p.set.percent(100))},read:{metadata:function(){var e={percent:y.data(f.percent),total:y.data(f.total),value:y.data(f.value)};e.percent&&(p.debug("Current percent value set from metadata",e.percent),p.set.percent(e.percent)),e.total&&(p.debug("Total value set from metadata",e.total),p.set.total(e.total)),e.value&&(p.debug("Current value set from metadata",e.value),p.set.value(e.value),p.set.progress(e.value))},settings:function(){v.total!==!1&&(p.debug("Current total set in settings",v.total),p.set.total(v.total)),v.value!==!1&&(p.debug("Current value set in settings",v.value),p.set.value(v.value),p.set.progress(p.value)),v.percent!==!1&&(p.debug("Current percent set in settings",v.percent),p.set.percent(v.percent))}},increment:function(e){var t,n,r;p.has.total()?(n=p.get.value(),e=e||1,r=n+e):(n=p.get.percent(),e=e||p.get.randomValue(),r=n+e,t=100,p.debug("Incrementing percentage by",n,r)),r=p.get.normalizedValue(r),p.set.progress(r)},decrement:function(e){var t,n,r=p.get.total();r?(t=p.get.value(),e=e||1,n=t-e,p.debug("Decrementing value by",e,t)):(t=p.get.percent(),e=e||p.get.randomValue(),n=t-e,p.debug("Decrementing percentage by",e,t)),n=p.get.normalizedValue(n),p.set.progress(n)},has:{progressPoll:function(){return p.progressPoll},total:function(){return p.get.total()!==!1}},get:{text:function(e){var t=p.value||0,n=p.total||0,r=E?p.get.displayPercent():p.percent||0,a=p.total>0?n-t:100-r;return e=e||"",e=e.replace("{value}",t).replace("{total}",n).replace("{left}",a).replace("{percent}",r),p.verbose("Adding variables to progress bar text",e),e},normalizedValue:function(e){if(0>e)return p.debug("Value cannot decrement below 0"),0;if(p.has.total()){if(e>p.total)return p.debug("Value cannot increment above total",p.total),p.total}else if(e>100)return p.debug("Value cannot increment above 100 percent"),100;return e},updateInterval:function(){return"auto"==v.updateInterval?v.duration:v.updateInterval},randomValue:function(){return p.debug("Generating random increment percentage"),Math.floor(Math.random()*v.random.max+v.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=V.width(),t=y.width(),n=parseInt(V.css("min-width"),10),r=e>n?e/t*100:p.percent;return v.precision>0?Math.round(r*(10*v.precision))/(10*v.precision):Math.round(r)},percent:function(){return p.percent||0},value:function(){return p.nextValue||p.value||0},total:function(){return p.total||!1}},create:{progressPoll:function(){p.progressPoll=setTimeout(function(){p.update.toNextValue(),p.remove.progressPoll()},p.get