wishthis/semantic/dist/components/progress.min.js

11 lines
14 KiB
JavaScript
Raw Normal View History

2022-01-13 13:00:31 +00:00
/*
* # Fomantic UI - 2.8.8
* https://github.com/fomantic/Fomantic-UI
* http://fomantic-ui.com/
*
* Copyright 2022 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
2022-02-23 21:46:34 +00:00
!function(E,e,T,P){"use strict";E.isFunction=E.isFunction||function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},e=void 0!==e&&e.Math==Math?e:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),E.fn.progress=function(m){var b,e=E(this),h=e.selector||"",x=(new Date).getTime(),y=[],w=m,A="string"==typeof w,V=[].slice.call(arguments,1);return e.each(function(){var i=E.isPlainObject(m)?E.extend(!0,{},E.fn.progress.settings,m):E.extend({},E.fn.progress.settings),n=i.className,t=i.metadata,e=i.namespace,a=i.selector,s=i.error,o="."+e,g="module-"+e,r=E(this),c=E(this).find(a.bar),v=E(this).find(a.progress),f=E(this).find(a.label),l=this,u=r.data(g),p=!1,d={helper:{sum:function(e){return Array.isArray(e)?e.reduce(function(e,t){return e+Number(t)},0):0},derivePrecision:function(e,t){for(var n=0,r=1,a=e/t;n<10&&!(1<(a*=r));)r=Math.pow(10,n++);return r},forceArray:function(e){return Array.isArray(e)?e:isNaN(e)?"string"==typeof e?e.split(","):[]:[e]}},initialize:function(){d.set.duration(),d.set.transitionEvent(),d.debug(l),d.read.metadata(),d.read.settings(),d.instantiate()},instantiate:function(){d.verbose("Storing instance of progress",d),u=d,r.data(g,d)},destroy:function(){d.verbose("Destroying previous progress for",r),clearInterval(u.interval),d.remove.state(),r.removeData(g),u=P},reset:function(){d.remove.nextValue(),d.update.progress(0)},complete:function(e){(d.percent===P||d.percent<100)&&(d.remove.progressPoll(),!0!==e&&d.set.percent(100))},read:{metadata:function(){var e={percent:d.helper.forceArray(r.data(t.percent)),total:r.data(t.total),value:d.helper.forceArray(r.data(t.value))};e.total!==P&&(d.debug("Total value set from metadata",e.total),d.set.total(e.total)),0<e.value.length&&(d.debug("Current value set from metadata",e.value),d.set.value(e.value),d.set.progress(e.value)),0<e.percent.length&&(d.debug("Current percent value set from metadata",e.percent),d.set.percent(e.percent))},settings:function(){!1!==i.total&&(d.debug("Current total set in settings",i.total),d.set.total(i.total)),!1!==i.value&&(d.debug("Current value set in settings",i.value),d.set.value(i.value),d.set.progress(d.value)),!1!==i.percent&&(d.debug("Current percent set in settings",i.percent),d.set.percent(i.percent))}},bind:{transitionEnd:function(t){var e=d.get.transitionEnd();c.one(e+o,function(e){clearTimeout(d.failSafeTimer),t.call(this,e)}),d.failSafeTimer=setTimeout(function(){c.triggerHandler(e)},i.duration+i.failSafeDelay),d.verbose("Adding fail safe timer",d.timer)}},increment:function(e){var t;e=d.has.total()?(t=d.get.value(),e||1):(t=d.get.percent(),e||d.get.randomValue()),d.debug("Incrementing percentage by",t,t=t+e,e),t=d.get.normalizedValue(t),d.set.progress(t)},decrement:function(e){var t,n;d.get.total()?(n=(t=d.get.value())-(e=e||1),d.debug("Decrementing value by",e,t)):(n=(t=d.get.percent())-(e=e||d.get.randomValue()),d.debug("Decrementing percentage by",e,t)),n=d.get.normalizedValue(n),d.set.progress(n)},has:{progressPoll:function(){return d.progressPoll},total:function(){return!1!==d.get.total()}},get:{text:function(e,t){var t=t||0,n=d.get.value(t),r=d.get.total(),a=p?d.get.displayPercent(t):d.get.percent(t),o=!1!==r?Math.max(0,r-n):100-a;return e=(e=e||"").replace("{value}",n).replace("{total}",r||0).replace("{left}",o).replace("{percent}",a).replace("{bar}",i.text.bars[t]||""),d.verbose("Adding variables to progress bar text",e),e},normalizedValue:function(e){if(e<0)return d.debug("Value cannot decrement below 0"),0;if(d.has.total()){if(e>d.total)return d.debug("Value cannot increment above total",d.total),d.total}else if(100<e)return d.debug("Value cannot increment above 100 percent"),100;return e},updateInterval:function(){return"auto"==i.updateInterval?i.duration:i.updateInterval},randomValue:function(){return d.debug("Generating random increment percentage"),Math.floor(Math.random()*i.random.max+i.random.min)},numericValue:function(e){return"string"==typeof e?""!==e.replace(/[^\d.]/g,"")&&+e.replace(/[^\d.]/g,""):e},transitionEnd:function(){var e,t=T.createElement("element"),n={transit