UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

3 lines 7.51 kB
/* @license */ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`kendo.core.min.js`)):typeof define==`function`&&define.amd?define([`exports`,`kendo.core.min`],t):(e=typeof globalThis<`u`?globalThis:e||self,t((e.kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.Progressbar={}),e.kendo._globals.Core))})(this,function(e,t){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let n={id:`progressbar`,name:`ProgressBar`,category:`web`,description:`The ProgressBar offers rich functionality for displaying and tracking progress`,depends:[`core`]};(function(e,t){var n=window.kendo,r=n.ui.Widget,i=`horizontal`,a=`vertical`,o=0,s=100,c=0,l=5,u=`k-progressbar`,d=`k-progressbar-reverse`,f=`k-progressbar-indeterminate`,p=`k-complete`,m=`k-selected`,h=`k-progress-status`,g=`k-progress-end`,_=`k-selected`,v=`k-disabled`,y=`k-progressbar-value`,b=`k-progressbar-chunk`,x={VALUE:`value`,PERCENT:`percent`,CHUNK:`chunk`},S=`change`,C=`complete`,w=`boolean`,T=Math,E=e.extend,D=100,O=400,k=3,A={progressStatus:`<span class='k-progress-status-wrap `+g+`'><span class='k-progress-status'></span></span>`,noProgressStatus:`<span class='k-progress-status-wrap `+g+`'></span>`,announceElement:`<span aria-live="polite" class="k-sr-only k-progress-announce"></span>`},j=r.extend({init:function(e,t){var n=this;r.fn.init.call(this,e,t),t=n.options,n._progressProperty=t.orientation===i?`width`:`height`,n._fields(),t.value=n._validateValue(t.value),n._validateType(t.type),n._wrapper(),t.ariaRole&&n._aria(),n._progressAnimation(),t.value!==t.min&&t.value!==!1&&n._updateProgress()},setOptions:function(e){var t=this,n=t.wrapper;r.fn.setOptions.call(t,e),e.hasOwnProperty(`reverse`)&&n.toggleClass(`k-progressbar-reverse`,e.reverse),e.hasOwnProperty(`enable`)&&t.enable(e.enable),e.ariaRole&&t._aria(),t._progressAnimation(),t._validateValue(),t._updateProgress()},events:[S,C],options:{name:`ProgressBar`,orientation:i,reverse:!1,min:o,max:s,value:c,enable:!0,type:x.VALUE,chunkCount:l,showStatus:!0,animation:{},label:null,labelId:null,ariaRole:!1},_aria:function(){var t=this,n=t.options,r=t.wrapper;r.attr({role:`progressbar`,"aria-valuemin":n.min,"aria-valuemax":n.max}),n.labelId?r.attr(`aria-labelledby`,n.labelId):n.label&&r.attr(`aria-label`,n.label),t.announce=e(A.announceElement),t.announce.appendTo(e(`body`)),n.value!==!1&&(r.attr(`aria-valuenow`,n.value),t.announce.text(t._calculatePercentage().toFixed()+`%`))},_fields:function(){var t=this;t._isStarted=!1,t.progressWrapper=t.progressStatus=e()},_validateType:function(t){var r=!1;if(e.each(x,function(e,n){if(n===t)return r=!0,!1}),!r)throw Error(n.format(`Invalid ProgressBar type '{0}'`,t))},_wrapper:function(){var e=this,t=e.wrapper=e.element,n=e.options,r=n.orientation,o=n.value===!1?n.min:n.value;t.addClass(u),t.addClass(u+`-`+(r===i?i:a)),n.enable===!1&&t.addClass(v),n.reverse&&t.addClass(d),n.value===!1&&t.addClass(f),n.type===x.CHUNK?e._addChunkProgressWrapper():n.showStatus?(e.progressStatus=e.wrapper.prepend(A.progressStatus).find(`.`+h),n.type===x.VALUE?e.progressStatus.text(o):e.progressStatus.text(e._calculatePercentage(o).toFixed()+`%`)):e.wrapper.prepend(A.noProgressStatus)},value:function(e){return this._value(e)},_value:function(e){var n=this,r=n.options,i;if(e===t)return r.value;typeof e===w?e||(n.wrapper.addClass(f),n.wrapper.removeAttr(`aria-valuenow`),r.value=!1,n.announce&&n.announce.text(``)):(e=n._roundValue(e),isNaN(e)||(i=n._validateValue(e),i!==r.value&&(n.wrapper.removeClass(f),r.value=i,n._isStarted=!0,n._updateProgress())))},_roundValue:function(e){e=parseFloat(e);var t=T.pow(10,k);return n._round(e*t)/t},_validateValue:function(e){var t=this,n=t.options;if(e!==!1){if(e<=n.min||e===!0)return n.min;if(e>=n.max)return n.max}else if(e===!1)return!1;return isNaN(t._roundValue(e))?n.min:e},_updateProgress:function(){var e=this,t=e.options,n=e._calculatePercentage();t.type===x.CHUNK?(e._updateChunks(n),e._onProgressUpdateAlways(t.value)):e._updateProgressWrapper(n),t.ariaRole&&(e.wrapper.attr(`aria-valuenow`,e.options.value),e.announce&&e.announce.text(n.toFixed()+`%`))},_updateChunks:function(e){var t=this,r=t.options,o=r.chunkCount,s=parseInt(D/o*100,10)/100,c=parseInt(e*100,10)/100,l=T.floor(c/s),u=r.orientation===i&&!r.reverse||r.orientation===a&&r.reverse?t.wrapper.find(`li.`+b).slice(0,l):l===0?n.jQuery():t.wrapper.find(`li.`+b).slice(l*-1);t.wrapper.find(`.`+_).removeClass(_+` `+y),u.addClass(_+` `+y)},_updateProgressWrapper:function(e){var t=this,n=t.options,r=t.wrapper.find(`.`+m),i=t._isStarted?t._animation.duration:0,a={};r.length===0&&t._addRegularProgressWrapper(),a[t._progressProperty]=e+`%`,t.progressWrapper.animate(a,{duration:i,start:t._onProgressAnimateStart.bind(t),progress:t._onProgressAnimate.bind(t),complete:t._onProgressAnimateComplete.bind(t,n.value),always:t._onProgressUpdateAlways.bind(t,n.value)})},_onProgressAnimateStart:function(){this.progressWrapper.show()},_onProgressAnimate:function(e){var t=this,n=t.options,r=parseFloat(e.elem.style[t._progressProperty],10),i;n.showStatus&&(i=1e4/parseFloat(t.progressWrapper[0].style[t._progressProperty]),t.progressWrapper.find(`.k-progress-status-wrap`).css(t._progressProperty,i+`%`)),n.type!==x.CHUNK&&r<=98&&t.progressWrapper.removeClass(p)},_onProgressAnimateComplete:function(e){var t=this,n=t.options,r=parseFloat(t.progressWrapper[0].style[t._progressProperty]),i;n.type!==x.CHUNK&&r>98&&t.progressWrapper.addClass(p),n.showStatus&&(i=n.type===x.VALUE?e:n.type==x.PERCENT?t._calculatePercentage(e).toFixed()+`%`:T.floor(t._calculatePercentage(e))+`%`,t.progressStatus.text(i)),e===n.min&&t.progressWrapper.hide()},_onProgressUpdateAlways:function(e){var t=this,n=t.options;t._isStarted&&t.trigger(S,{value:e}),e===n.max&&t._isStarted&&t.trigger(C,{value:n.max})},enable:function(e){var t=this,n=t.options;n.enable=e===void 0?!0:e,t.wrapper.toggleClass(v,!n.enable)},destroy:function(){var e=this;e.announce&&e.announce.remove(),r.fn.destroy.call(e)},_addChunkProgressWrapper:function(){var e=this,t=e.options,n=e.wrapper,r=D/t.chunkCount,i=``;t.chunkCount<=1&&(t.chunkCount=1),e.element.addClass(`k-chunk-progressbar`),i+=`<ul class='k-reset k-progressbar-chunks'>`;for(var a=t.chunkCount-1;a>=0;a--)i+=`<li class='`+b+`'></li>`;i+=`</ul>`,n.append(i).find(`.`+b).css(e._progressProperty,r+`%`).first().addClass(`k-first`).end().last().addClass(`k-last`),e._normalizeChunkSize()},_normalizeChunkSize:function(){var e=this,t=e.options,n=e.wrapper.find(`.`+b).last(),r=parseFloat(n[0].style[e._progressProperty]),i=D-t.chunkCount*r;i>0&&n.css(e._progressProperty,r+i+`%`)},_addRegularProgressWrapper:function(){var t=this;t.progressWrapper=e(`<div class='`+m+` `+y+`'></div>`).appendTo(t.wrapper),t.options.showStatus?(t.progressWrapper.append(A.progressStatus),t.progressStatus=t.wrapper.find(`.`+h)):t.progressWrapper.prepend(A.noProgressStatus)},_calculateChunkSize:function(){var e=this,t=e.options.chunkCount,n=e.wrapper.find(`ul.k-reset`);return(parseInt(n.css(e._progressProperty),10)-(t-1))/t},_calculatePercentage:function(e){var n=this,r=n.options,i=e===t?r.value:e,a=r.min,o=r.max;return n._onePercent=T.abs((o-a)/100),T.abs((i-a)/n._onePercent)},_progressAnimation:function(){var e=this,t=e.options;t.animation===!1?e._animation={duration:0}:e._animation=E({duration:O},t.animation)}});n.ui.plugin(j)})(window.kendo.jQuery);var r=kendo;e.__meta__=n,e.default=r}); //# sourceMappingURL=kendo.progressbar.min.js.map