ProgressBar_wev8.js 1.64 KB
define("ProgressBar_html",function(){return'<div id="NMEC_${id}" class="wev-comp-${compType}">    <div class="wev-progress-bar" style="height: ${lineHeight}; background-color: ${bgcolor};">    \t<div style="color: ${fontColor}; line-height: ${lineHeight}; font-size: ${fontSize}; background-color: ${areaColor};"></div>    </div></div>'}),define(["mUtil","Component"],function(n,t){return t.init(function(e){var r={};t.super(this,e),this.type="ProgressBar",this.tpl=this.type+"_html",this.css=this.type+"_css";var o=this.viewModel={bgcolor:"#DDD",fontColor:"#FFF",lineHeight:"22px",fontSize:"12px",showValue:!0};this.beforeMount=function(){var e,t,i=Number(o.value),r=0;o.fontSize=(parseFloat(o.fontSize)||12)+"px",o.lineHeight=(parseFloat(o.lineHeight)||22)+"px",i<0?i=0:r=100<i?100:i,~o.value.toString().indexOf(".")&&(e=i,t=Number(2),isNaN(t)&&(t=2),i=(e=Math.round(e*Math.pow(10,t))/Math.pow(10,t)).toFixed(t)),o.displayWidth=r,o.value=i,n.isArray(o.areaColor)&&o.areaColor.every(function(e){var t=Number(e.startPercent),r=Number(e.endPercent);return!(t<=i&&i<=r&&(o.areaColor=e.areaColor,1))})},this.mounted=function(){var t=$(".wev-progress-bar > div",this.$el);t.css("width","0%"),setTimeout(function(){t.css("width",o.displayWidth+"%"),o.showValue&&(isNaN(o.value)?n.getLabel(5285,"进度条数值不合法,不是数字类型",function(e){t.append("<div>"+e+"</div>")}):r.countProgressBar(600,o.value))},500)},r.countProgressBar=function(e,t){if(!(t<=0))var r=$(".wev-progress-bar > div",this.$el),i=Math.abs(e/t),o=0,n=setInterval(function(){r.text(++o+"%"),o==Math.ceil(t)&&(r.text(t+"%"),clearInterval(n))},i)},r.countProgressBar=r.countProgressBar.bind(this)})});