You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openpower.foundation/themes/openpowerfoundation/static/lib/semantic-ui/components/progress.min.js

1 line
12 KiB
JavaScript

!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.percent||0},value:function(){return o.nextValue||o.value||0},total:function(){return o.total||!1}},create:{progressPoll:function(){o.progressPoll=setTimeout(function(){o.update.toNextValue(),o.remove.progressPoll()},o.get.updateInterval())}},is:{complete:function(){return o.is.success()||o.is.warning()||o.is.error()},success:function(){return w.hasClass(v.success)},warning:function(){return w.hasClass(v.warning)},error:function(){return w.hasClass(v.error)},active:function(){return w.hasClass(v.active)},visible:function(){return w.is(":visible")}},remove:{progressPoll:function(){o.verbose("Removing progress poll timer"),o.progressPoll&&(clearTimeout(o.progressPoll),delete o.progressPoll)},nextValue:function(){o.verbose("Removing progress value stored for next update"),delete o.nextValue},state:function(){o.verbose("Removing stored state"),delete o.total,delete o.percent,delete o.value},active:function(){o.verbose("Removing active state"),w.removeClass(v.active)},success:function(){o.verbose("Removing success state"),w.removeClass(v.success)},warning:function(){o.verbose("Removing warning state"),w.removeClass(v.warning)},error:function(){o.verbose("Removing error state"),w.removeClass(v.error)}},set:{barWidth:function(e){e>100?o.error(b.tooHigh,e):e<0?o.error(b.tooLow,e):(y.css("width",e+"%"),w.attr("data-percent",parseInt(e,10)))},duration:function(e){e="number"==typeof(e=e||g.duration)?e+"ms":e,o.verbose("Setting progress bar transition duration",e),y.css({"transition-duration":e})},percent:function(e){e="string"==typeof e?+e.replace("%",""):e,e=g.precision>0?Math.round(e*(10*g.precision))/(10*g.precision):Math.round(e),o.percent=e,o.has.total()||(o.value=g.precision>0?Math.round(e/100*o.total*(10*g.precision))/(10*g.precision):Math.round(e/100*o.total*10)/10,g.limitValues&&(o.value=o.value>100?100:o.value<0?0:o.value)),o.set.barWidth(e),o.set.labelInterval(),o.set.labels(),g.onChange.call(E,e,o.value,o.total)},labelInterval:function(){clearInterval(o.interval),o.bind.transitionEnd(function(){o.verbose("Bar finished animating, removing continuous label updates"),clearInterval(o.interval),T=!1,o.set.labels()}),T=!0,o.interval=setInterval(function(){e.contains(n.documentElement,E)||(clearInterval(o.interval),T=!1),o.set.labels()},g.framerate)},labels:function(){o.verbose("Setting both bar progress and outer label text"),o.set.barLabel(),o.set.state()},label:function(e){(e=e||"")&&(e=o.get.text(e),o.verbose("Setting label to text",e),C.text(e))},state:function(e){100===(e=e!==r?e:o.percent)?g.autoSuccess&&!(o.is.warning()||o.is.error()||o.is.success())?(o.set.success(),o.debug("Automatically triggering success at 100%")):(o.verbose("Reached 100% removing active state"),o.remove.active(),o.remove.progressPoll()):e>0?(o.verbose("Adjusting active progress bar label",e),o.set.active()):(o.remove.active(),o.set.label(g.text.active))},barLabel:function(e){e!==r?V.text(o.get.text(e)):"ratio"==g.label&&o.total?(o.verbose("Adding ratio to bar label"),V.text(o.get.text(g.text.ratio))):"percent"==g.label&&(o.verbose("Adding percentage to bar label"),V.text(o.get.text(g.text.percent)))},active:function(e){e=e||g.text.active,o.debug("Setting active state"),g.showActivity&&!o.is.active()&&w.addClass(v.active),o.remove.warning(),o.remove.error(),o.remove.success(),(e=g.onLabelUpdate("active",e,o.value,o.total))&&o.set.label(e),o.bind.transitionEnd(function(){g.onActive.call(E,o.value,o.total)})},success:function(e){e=e||g.text.success||g.text.active,o.debug("Setting success state"),w.addClass(v.success),o.remove.active(),o.remove.warning(),o.remove.error(),o.complete(),g.text.success?(e=g.onLabelUpdate("success",e,o.value,o.total),o.set.label(e)):(e=g.onLabelUpdate("active",e,o.value,o.total),o.set.label(e)),o.bind.transitionEnd(function(){g.onSuccess.call(E,o.total)})},warning:function(e){e=e||g.text.warning,o.debug("Setting warning state"),w.addClass(v.warning),o.remove.active(),o.remove.success(),o.remove.error(),o.complete(),(e=g.onLabelUpdate("warning",e,o.value,o.total))&&o.set.label(e),o.bind.transitionEnd(function(){g.onWarning.call(E,o.value,o.total)})},error:function(e){e=e||g.text.error,o.debug("Setting error state"),w.addClass(v.error),o.remove.active(),o.remove.success(),o.remove.warning(),o.complete(),(e=g.onLabelUpdate("error",e,o.value,o.total))&&o.set.label(e),o.bind.transitionEnd(function(){g.onError.call(E,o.value,o.total)})},transitionEvent:function(){o.get.transitionEnd()},total:function(e){o.total=e},value:function(e){o.value=e},progress:function(e){o.has.progressPoll()?(o.debug("Updated within interval, setting next update to use new value",e),o.set.nextValue(e)):(o.debug("First update in progress update interval, immediately updating",e),o.update.progress(e),o.create.progressPoll())},nextValue:function(e){o.nextValue=e}},update:{toNextValue:function(){var e=o.nextValue;e&&(o.debug("Update interval complete using last updated value",e),o.update.progress(e),o.remove.nextValue())},progress:function(e){var t;!1===(e=o.get.numericValue(e))&&o.error(b.nonNumeric,e),e=o.get.normalizedValue(e),o.has.total()?(o.set.value(e),t=e/o.total*100,o.debug("Calculating percent complete from total",t),o.set.percent(t)):(t=e,o.debug("Setting value to exact percentage value",t),o.set.percent(t))}},setting:function(t,n){if(o.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,g,t);else{if(n===r)return g[t];e.isPlainObject(g[t])?e.extend(!0,g[t],n):g[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,o,t);else{if(n===r)return o[t];o[t]=n}},debug:function(){!g.silent&&g.debug&&(g.performance?o.performance.log(arguments):(o.debug=Function.prototype.bind.call(console.info,console,g.name+":"),o.debug.apply(console,arguments)))},verbose:function(){!g.silent&&g.verbose&&g.debug&&(g.performance?o.performance.log(arguments):(o.verbose=Function.prototype.bind.call(console.info,console,g.name+":"),o.verbose.apply(console,arguments)))},error:function(){g.silent||(o.error=Function.prototype.bind.call(console.error,console,g.name+":"),o.error.apply(console,arguments))},performance:{log:function(e){var t,n;g.performance&&(n=(t=(new Date).getTime())-(s||t),s=t,l.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:E,"Execution Time":n})),clearTimeout(o.performance.timer),o.performance.timer=setTimeout(o.performance.display,500)},display:function(){var t=g.name+":",n=0;s=!1,clearTimeout(o.performance.timer),e.each(l,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",i&&(t+=" '"+i+"'"),(console.group!==r||console.table!==r)&&l.length>0&&(console.groupCollapsed(t),console.table?console.table(l):e.each(l,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),l=[]}},invoke:function(t,n,i){var s,l,c,u=P;return n=n||d,i=E||i,"string"==typeof t&&u!==r&&(t=t.split(/[\. ]/),s=t.length-1,e.each(t,function(n,a){var i=n!=s?a+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(u[i])&&n!=s)u=u[i];else{if(u[i]!==r)return l=u[i],!1;if(!e.isPlainObject(u[a])||n==s)return u[a]!==r?(l=u[a],!1):(o.error(b.method,t),!1);u=u[a]}})),e.isFunction(l)?c=l.apply(i,n):l!==r&&(c=l),e.isArray(a)?a.push(c):a!==r?a=[a,c]:c!==r&&(a=c),l}},u?(P===r&&o.initialize(),o.invoke(c)):(P!==r&&P.invoke("destroy"),o.initialize())}),a!==r?a:this},e.fn.progress.settings={name:"Progress",namespace:"progress",silent:!1,debug:!1,verbose:!1,performance:!0,random:{min:2,max:5},duration:300,updateInterval:"auto",autoSuccess:!0,showActivity:!0,limitValues:!0,label:"percent",precision:0,framerate:1e3/30,percent:!1,total:!1,value:!1,failSafeDelay:100,onLabelUpdate:function(e,t,n,r){return t},onChange:function(e,t,n){},onSuccess:function(e){},onActive:function(e,t){},onError:function(e,t){},onWarning:function(e,t){},error:{method:"The method you called is not defined.",nonNumeric:"Progress value is non numeric",tooHigh:"Value specified is above 100%",tooLow:"Value specified is below 0%"},regExp:{variable:/\{\$*[A-z0-9]+\}/g},metadata:{percent:"percent",total:"total",value:"value"},selector:{bar:"> .bar",label:"> .label",progress:".bar > .progress"},text:{active:!1,error:!1,success:!1,warning:!1,percent:"{percent}%",ratio:"{value} of {total}"},className:{active:"active",error:"error",success:"success",warning:"warning"}}}(jQuery,window,document);