|
|
- /*!
- * # Semantic UI 2.0.0 - Progress
- * http://github.com/semantic-org/semantic-ui/
- *
- *
- * Copyright 2015 Contributors
- * Released under the MIT license
- * http://opensource.org/licenses/MIT
- *
- */
- !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),E=e(this).find(f.label),A=this,S=y.data(x),V=!1;v={initialize:function(){v.debug("Initializing progress bar",d),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)},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))},settings:function(){d.total!==!1&&(v.debug("Current total set in settings",d.total),v.set.total(d.total)),d.value!==!1&&(v.debug("Current value set in settings",d.value),v.set.value(d.value),v.set.progress(v.value)),d.percent!==!1&&(v.debug("Current percent set in settings",d.percent),v.set.percent(d.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()*d.random.max+d.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 d.precision>0?Math.round(10*r*d.precision)/(10*d.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(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:{bar
|