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.
bazarr/static/semantic/components/progress.min.js

1 line
12 KiB

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