@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 6.33 kB
JavaScript
module.exports=function(e){function r(s){if(t[s])return t[s].exports;var a=t[s]={exports:{},id:s,loaded:!1};return e[s].call(a.exports,a,a.exports,r),a.loaded=!0,a.exports}var t={};return r.m=e,r.c=t,r.p="",r(0)}({0:function(e,r,t){e.exports=t(1284)},3:function(e,r){e.exports=function(){throw Error("define cannot be used indirect")}},1006:function(e,r){e.exports=require("./kendo.core")},1284:function(e,r,t){var s,a,o;!function(n,define){a=[t(1006)],s=n,o="function"==typeof s?s.apply(r,a):s,!(void 0!==o&&(e.exports=o))}(function(){return function(e,r){var t=window.kendo,s=t.ui,a=s.Widget,o="horizontal",n="vertical",p=0,i=100,u=0,l=5,d="k-progressbar",c="k-progressbar-reverse",g="k-progressbar-indeterminate",v="k-complete",f="k-state-selected",_="k-progress-status",h="k-state-selected",m="k-state-default",k="k-state-disabled",P={VALUE:"value",PERCENT:"percent",CHUNK:"chunk"},w="change",C="complete",y="boolean",x=Math,S=e.extend,W=e.proxy,b=100,A=400,U=3,N={progressStatus:"<span class='k-progress-status-wrap'><span class='k-progress-status'></span></span>"},V=a.extend({init:function(e,r){var t=this;a.fn.init.call(this,e,r),r=t.options,t._progressProperty=r.orientation===o?"width":"height",t._fields(),r.value=t._validateValue(r.value),t._validateType(r.type),t._wrapper(),t._progressAnimation(),r.value!==r.min&&r.value!==!1&&t._updateProgress()},setOptions:function(e){var r=this;a.fn.setOptions.call(r,e),e.hasOwnProperty("reverse")&&r.wrapper.toggleClass("k-progressbar-reverse",e.reverse),e.hasOwnProperty("enable")&&r.enable(e.enable),r._progressAnimation(),r._validateValue(),r._updateProgress()},events:[w,C],options:{name:"ProgressBar",orientation:o,reverse:!1,min:p,max:i,value:u,enable:!0,type:P.VALUE,chunkCount:l,showStatus:!0,animation:{}},_fields:function(){var r=this;r._isStarted=!1,r.progressWrapper=r.progressStatus=e()},_validateType:function(r){var s=!1;if(e.each(P,function(e,t){if(t===r)return s=!0,!1}),!s)throw Error(t.format("Invalid ProgressBar type '{0}'",r))},_wrapper:function(){var e,r=this,t=r.wrapper=r.element,s=r.options,a=s.orientation;t.addClass("k-widget "+d),t.addClass(d+"-"+(a===o?o:n)),s.enable===!1&&t.addClass(k),s.reverse&&t.addClass(c),s.value===!1&&t.addClass(g),s.type===P.CHUNK?r._addChunkProgressWrapper():s.showStatus&&(r.progressStatus=r.wrapper.prepend(N.progressStatus).find("."+_),e=s.value!==!1?s.value:s.min,r.progressStatus.text(s.type===P.VALUE?e:r._calculatePercentage(e).toFixed()+"%"))},value:function(e){return this._value(e)},_value:function(e){var t,s=this,a=s.options;return e===r?a.value:(typeof e!==y?(e=s._roundValue(e),isNaN(e)||(t=s._validateValue(e),t!==a.value&&(s.wrapper.removeClass(g),a.value=t,s._isStarted=!0,s._updateProgress()))):e||(s.wrapper.addClass(g),a.value=!1),r)},_roundValue:function(e){e=parseFloat(e);var r=x.pow(10,U);return x.floor(e*r)/r},_validateValue:function(e){var r=this,t=r.options;if(e!==!1){if(e<=t.min||e===!0)return t.min;if(e>=t.max)return t.max}else if(e===!1)return!1;return isNaN(r._roundValue(e))?t.min:e},_updateProgress:function(){var e=this,r=e.options,t=e._calculatePercentage();r.type===P.CHUNK?(e._updateChunks(t),e._onProgressUpdateAlways(r.value)):e._updateProgressWrapper(t)},_updateChunks:function(e){var r,t=this,s=t.options,a=s.chunkCount,p=parseInt(b/a*100,10)/100,i=parseInt(100*e,10)/100,u=x.floor(i/p);r=t.wrapper.find(s.orientation===o&&!s.reverse||s.orientation===n&&s.reverse?"li.k-item:lt("+u+")":"li.k-item:gt(-"+(u+1)+")"),t.wrapper.find("."+h).removeClass(h).addClass(m),r.removeClass(m).addClass(h)},_updateProgressWrapper:function(e){var r=this,t=r.options,s=r.wrapper.find("."+f),a=r._isStarted?r._animation.duration:0,o={};0===s.length&&r._addRegularProgressWrapper(),o[r._progressProperty]=e+"%",r.progressWrapper.animate(o,{duration:a,start:W(r._onProgressAnimateStart,r),progress:W(r._onProgressAnimate,r),complete:W(r._onProgressAnimateComplete,r,t.value),always:W(r._onProgressUpdateAlways,r,t.value)})},_onProgressAnimateStart:function(){this.progressWrapper.show()},_onProgressAnimate:function(e){var r,t=this,s=t.options,a=parseFloat(e.elem.style[t._progressProperty],10);s.showStatus&&(r=1e4/parseFloat(t.progressWrapper[0].style[t._progressProperty]),t.progressWrapper.find(".k-progress-status-wrap").css(t._progressProperty,r+"%")),s.type!==P.CHUNK&&a<=98&&t.progressWrapper.removeClass(v)},_onProgressAnimateComplete:function(e){var r,t=this,s=t.options,a=parseFloat(t.progressWrapper[0].style[t._progressProperty]);s.type!==P.CHUNK&&a>98&&t.progressWrapper.addClass(v),s.showStatus&&(r=s.type===P.VALUE?e:s.type==P.PERCENT?t._calculatePercentage(e).toFixed()+"%":x.floor(t._calculatePercentage(e))+"%",t.progressStatus.text(r)),e===s.min&&t.progressWrapper.hide()},_onProgressUpdateAlways:function(e){var r=this,t=r.options;r._isStarted&&r.trigger(w,{value:e}),e===t.max&&r._isStarted&&r.trigger(C,{value:t.max})},enable:function(e){var t=this,s=t.options;s.enable=r===e||e,t.wrapper.toggleClass(k,!s.enable)},destroy:function(){var e=this;a.fn.destroy.call(e)},_addChunkProgressWrapper:function(){var e,r=this,t=r.options,s=r.wrapper,a=b/t.chunkCount,o="";for(t.chunkCount<=1&&(t.chunkCount=1),o+="<ul class='k-reset'>",e=t.chunkCount-1;e>=0;e--)o+="<li class='k-item k-state-default'></li>";o+="</ul>",s.append(o).find(".k-item").css(r._progressProperty,a+"%").first().addClass("k-first").end().last().addClass("k-last"),r._normalizeChunkSize()},_normalizeChunkSize:function(){var e=this,r=e.options,t=e.wrapper.find(".k-item:last"),s=parseFloat(t[0].style[e._progressProperty]),a=b-r.chunkCount*s;a>0&&t.css(e._progressProperty,s+a+"%")},_addRegularProgressWrapper:function(){var r=this;r.progressWrapper=e("<div class='"+f+"'></div>").appendTo(r.wrapper),r.options.showStatus&&(r.progressWrapper.append(N.progressStatus),r.progressStatus=r.wrapper.find("."+_))},_calculateChunkSize:function(){var e=this,r=e.options.chunkCount,t=e.wrapper.find("ul.k-reset");return(parseInt(t.css(e._progressProperty),10)-(r-1))/r},_calculatePercentage:function(e){var t=this,s=t.options,a=e!==r?e:s.value,o=s.min,n=s.max;return t._onePercent=x.abs((n-o)/100),x.abs((a-o)/t._onePercent)},_progressAnimation:function(){var e=this,r=e.options,t=r.animation;e._animation=t===!1?{duration:0}:S({duration:A},r.animation)}});t.ui.plugin(V)}(window.kendo.jQuery),window.kendo},t(3))}});