cherryext/orun/extjs/static/ext-6.2.0/packages/ux/modern/ux.js

1 line
38 KiB
JavaScript
Raw Permalink Normal View History

2018-08-17 12:14:11 +03:00
Ext.define("Ext.ux.Gauge",{extend:"Ext.Gadget",xtype:"gauge",requires:["Ext.util.Region"],config:{baseCls:Ext.baseCSSPrefix+"gauge",padding:10,trackStart:135,trackLength:270,angleOffset:0,minValue:0,maxValue:100,value:50,clockwise:true,textTpl:['<tpl>{value:number("0.00")}%</tpl>'],textAlign:"c-c",trackStyle:{outerRadius:"100%",innerRadius:"100% - 20",round:false},valueStyle:{outerRadius:"100% - 2",innerRadius:"100% - 18",round:false},animation:true},template:[{reference:"innerElement",children:[{reference:"textElement",cls:Ext.baseCSSPrefix+"gauge-text"}]}],defaultBindProperty:"value",pathAttributes:{fill:true,fillOpacity:true,stroke:true,strokeOpacity:true,strokeWidth:true},easings:{linear:Ext.identityFn,"in":function(a){return a*a*a},out:function(a){return(--a)*a*a+1},inOut:function(a){return a<0.5?4*a*a*a:(a-1)*(2*a-2)*(2*a-2)+1}},resizeDelay:0,resizeTimerId:0,size:null,svgNS:"http://www.w3.org/2000/svg",svg:null,defs:null,trackArc:null,valueArc:null,trackGradient:null,valueGradient:null,fx:null,fxValue:0,fxAngleOffset:0,constructor:function(a){var b=this;b.fitSectorInRectCache={startAngle:null,lengthAngle:null,minX:null,maxX:null,minY:null,maxY:null};b.interpolator=b.createInterpolator();b.callParent([a]);b.on("resize","onElementResize",b)},doDestroy:function(){var a=this;a.un("resize","onElementResize",a);a.stopAnimation();a.callParent()},onElementResize:function(b,a){this.handleResize(a)},handleResize:function(b,a){var d=this,c=d.element;if(!(c&&(b=b||c.getSize())&&b.width&&b.height)){return}clearTimeout(d.resizeTimerId);if(a||d.resizeDelay){d.resizeTimerId=0}else{d.resizeTimerId=Ext.defer(d.handleResize,d.resizeDelay,d,[b,true]);return}d.size=b;d.resizeHandler(b)},updateMinValue:function(b){var a=this;a.interpolator.setDomain(b,a.getMaxValue());if(!a.isConfiguring){a.render()}},updateMaxValue:function(b){var a=this;a.interpolator.setDomain(a.getMinValue(),b);if(!a.isConfiguring){a.render()}},updateAngleOffset:function(a,b){var c=this,d=c.getAnimation();c.fxAngleOffset=a;if(!c.isConfiguring){if(d.duration){c.animate(b,a,d.duration,c.easings[d.easing],function(e){c.fxAngleOffset=e;c.render()})}else{c.render()}}},updateTrackStart:function(b){var a=this;if(!a.isConfiguring){a.render()}},updateTrackLength:function(a){var b=this;b.interpolator.setRange(0,a);if(!b.isConfiguring){b.render()}},applyPadding:function(b){if(typeof b==="string"){var a=parseFloat(b)/100;return function(c){return c*a}}return function(){return b}},updatePadding:function(){if(!this.isConfiguring){this.render()}},applyValue:function(b){var a=this.getMinValue(),c=this.getMaxValue();return Math.min(Math.max(b,a),c)},updateValue:function(d,a){var b=this,c=b.getAnimation();b.fxValue=d;if(!b.isConfiguring){b.writeText();if(c.duration){b.animate(a,d,c.duration,b.easings[c.easing],function(e){b.fxValue=e;b.render()})}else{b.render()}}},applyTextTpl:function(a){if(a&&!a.isTemplate){a=new Ext.XTemplate(a)}return a},updateTextTpl:function(){this.writeText();if(!this.isConfiguring){this.centerText()}},writeText:function(a){var c=this,e=c.getValue(),d=c.getMinValue(),f=c.getMaxValue(),g=f-d,b=c.getTextTpl();b.overwrite(c.textElement,{value:e,percent:(e-d)/g*100,minValue:d,maxValue:f,delta:g})},centerText:function(e,d,c,g,f){var b=this.textElement,a=this.getTextAlign(),i,h;if(Ext.Number.isEqual(g,0,0.1)||c.isOutOfBound({x:e,y:d})){i=b.getRegion().alignTo({align:a,target:c});b.setLeft(i.left);b.setTop(i.top)}else{h=b.getBox();b.setLeft(e-h.width/2);b.setTop(d-h.height/2)}},camelCaseRe:/([a-z])([A-Z])/g,camelToHyphen:function(a){return a.replace(this.camelCaseRe,"$1-$2").toLowerCase()},applyTrackStyle:function(a){var c=this,b;a.innerRadius=c.getRadiusFn(a.innerRadius);a.outerRadius=c.getRadiusFn(a.outerRadius);if(Ext.isArray(a.fill)){b=c.getTrackGradient();c.setGradientStops(b,a.fill);a.fill="url(#"+b.getAttribute("id")+")"}return a},updateTrackStyle:function(a){var d=this,c=Ext.fly(d.getTrackArc()),b;for(b in a){if(b in d.pathAttributes){c.setStyle(d.camelToHyphen(b),a[b])}}},applyValueStyle:function(a){var c=this,b;a.innerRadius=c.getRadiusFn(a.innerRadius);a