demo20230512/Scripts/kendo/2014.2.716/kendo.progressbar.min.js
2023-05-12 10:20:28 +08:00

16 lines
6.3 KiB
JavaScript

/**
* Copyright 2014 Telerik AD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
!function(e,define){define(["./kendo.core.min"],e)}(function(){return function(e,t){var n=window.kendo,i=n.ui,r=i.Widget,o="horizontal",a="vertical",s=0,l=100,d=0,c=5,u="k-progressbar",p="k-progressbar-reverse",f="k-progressbar-indeterminate",h="k-complete",m="k-state-selected",g="k-progress-status",v="k-state-selected",_="k-state-default",k="k-state-disabled",b={VALUE:"value",PERCENT:"percent",CHUNK:"chunk"},w="change",y="complete",x="boolean",C=Math,T=e.extend,S=e.proxy,F=100,D=400,E=3,A={progressStatus:"<span class='k-progress-status-wrap'><span class='k-progress-status'></span></span>"},H=r.extend({init:function(e,t){var n=this;r.fn.init.call(this,e,t),t=n.options,n._progressProperty=t.orientation===o?"width":"height",n._fields(),t.value=n._validateValue(t.value),n._validateType(t.type),n._wrapper(),n._progressAnimation(),t.value!==t.min&&t.value!==!1&&n._updateProgress()},setOptions:function(e){var t=this;r.fn.setOptions.call(t,e),e.hasOwnProperty("reverse")&&t.wrapper.toggleClass("k-progressbar-reverse",e.reverse),e.hasOwnProperty("enable")&&t.enable(e.enable),t._progressAnimation(),t._validateValue(),t._updateProgress()},events:[w,y],options:{name:"ProgressBar",orientation:o,reverse:!1,min:s,max:l,value:d,enable:!0,type:b.VALUE,chunkCount:c,showStatus:!0,animation:{}},_fields:function(){var t=this;t._isStarted=!1,t.progressWrapper=t.progressStatus=e()},_validateType:function(i){var r=!1;if(e.each(b,function(e,n){return n===i?(r=!0,!1):t}),!r)throw Error(n.format("Invalid ProgressBar type '{0}'",i))},_wrapper:function(){var e,t=this,n=t.wrapper=t.element,i=t.options,r=i.orientation;n.addClass("k-widget "+u),n.addClass(u+"-"+(r===o?o:a)),i.enable===!1&&n.addClass(k),i.reverse&&n.addClass(p),i.value===!1&&n.addClass(f),i.type===b.CHUNK?t._addChunkProgressWrapper():i.showStatus&&(t.progressStatus=t.wrapper.prepend(A.progressStatus).find("."+g),e=i.value!==!1?i.value:i.min,t.progressStatus.text(i.type===b.VALUE?e:t._calculatePercentage(e)+"%"))},value:function(e){return this._value(e)},_value:function(e){var n,i=this,r=i.options;return e===t?r.value:(typeof e!==x?(e=i._roundValue(e),isNaN(e)||(n=i._validateValue(e),n!==r.value&&(i.wrapper.removeClass(f),r.value=n,i._isStarted=!0,i._updateProgress()))):e||(i.wrapper.addClass(f),r.value=!1),t)},_roundValue:function(e){e=parseFloat(e);var t=C.pow(10,E);return C.floor(e*t)/t},_validateValue:function(e){var t=this,n=t.options;if(e!==!1){if(n.min>=e||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===b.CHUNK?(e._updateChunks(n),e._onProgressUpdateAlways(t.value)):e._updateProgressWrapper(n)},_updateChunks:function(e){var t,n=this,i=n.options,r=i.chunkCount,s=parseInt(F/r*100,10)/100,l=parseInt(100*e,10)/100,d=C.floor(l/s);t=n.wrapper.find(i.orientation===o&&!i.reverse||i.orientation===a&&i.reverse?"li.k-item:lt("+d+")":"li.k-item:gt(-"+(d+1)+")"),n.wrapper.find("."+v).removeClass(v).addClass(_),t.removeClass(_).addClass(v)},_updateProgressWrapper:function(e){var t=this,n=t.options,i=t.wrapper.find("."+m),r=t._isStarted?t._animation.duration:0,o={};0===i.length&&t._addRegularProgressWrapper(),o[t._progressProperty]=e+"%",t.progressWrapper.animate(o,{duration:r,start:S(t._onProgressAnimateStart,t),progress:S(t._onProgressAnimate,t),complete:S(t._onProgressAnimateComplete,t,n.value),always:S(t._onProgressUpdateAlways,t,n.value)})},_onProgressAnimateStart:function(){this.progressWrapper.show()},_onProgressAnimate:function(e){var t,n=this,i=n.options,r=parseFloat(e.elem.style[n._progressProperty],10);i.showStatus&&(t=1e4/parseFloat(n.progressWrapper[0].style[n._progressProperty]),n.progressWrapper.find(".k-progress-status-wrap").css(n._progressProperty,t+"%")),i.type!==b.CHUNK&&98>=r&&n.progressWrapper.removeClass(h)},_onProgressAnimateComplete:function(e){var t=this,n=t.options,i=parseFloat(t.progressWrapper[0].style[t._progressProperty]);n.type!==b.CHUNK&&i>98&&t.progressWrapper.addClass(h),n.showStatus&&t.progressStatus.text(n.type===b.VALUE?e:C.floor(t._calculatePercentage(e))+"%"),e===n.min&&t.progressWrapper.hide()},_onProgressUpdateAlways:function(e){var t=this,n=t.options;t._isStarted&&t.trigger(w,{value:e}),e===n.max&&t._isStarted&&t.trigger(y,{value:n.max})},enable:function(e){var n=this,i=n.options;i.enable=t===e?!0:e,n.wrapper.toggleClass(k,!i.enable)},destroy:function(){var e=this;r.fn.destroy.call(e)},_addChunkProgressWrapper:function(){var e,t=this,n=t.options,i=t.wrapper,r=F/n.chunkCount,o="";for(1>=n.chunkCount&&(n.chunkCount=c),o+="<ul class='k-reset'>",e=n.chunkCount-1;e>=0;e--)o+="<li class='k-item k-state-default'></li>";o+="</ul>",i.append(o).find(".k-item").css(t._progressProperty,r+"%").first().addClass("k-first").end().last().addClass("k-last"),t._normalizeChunkSize()},_normalizeChunkSize:function(){var e=this,t=e.options,n=e.wrapper.find(".k-item:last"),i=parseFloat(n[0].style[e._progressProperty]),r=F-t.chunkCount*i;r>0&&n.css(e._progressProperty,i+r+"%")},_addRegularProgressWrapper:function(){var t=this;t.progressWrapper=e("<div class='"+m+"'></div>").appendTo(t.wrapper),t.options.showStatus&&(t.progressWrapper.append(A.progressStatus),t.progressStatus=t.wrapper.find("."+g))},_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,i=n.options,r=e!==t?e:i.value,o=i.min,a=i.max;return n._onePercent=C.abs((a-o)/100),C.abs((r-o)/n._onePercent)},_progressAnimation:function(){var e=this,t=e.options,n=t.animation;e._animation=n===!1?{duration:0}:T({duration:D},t.animation)}});n.ui.plugin(H)}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t){t()});