-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtq-all.js
1 lines (1 loc) · 7.78 KB
/
tq-all.js
1
Ext.define("TQ.String",{statics:{highlight:function(b,j,h){j=j.toUpperCase();var g=0;if(b.nodeType==3){var f=b.data.toUpperCase().indexOf(j);if(f>=0){var e=document.createElement("span"),c=b.splitText(f),a=c.splitText(j.length);middleclone=c.cloneNode(true);e.className=h||"tq-search-highlight";e.appendChild(middleclone);c.parentNode.replaceChild(e,c);g=1}}else{if(b.nodeType==1&&b.childNodes&&!/(script|style)/i.test(b.tagName)){for(var d=0;d<b.childNodes.length;++d){d+=this.highlight(b.childNodes[d],j,h)}}}return g}}});Ext.define("TQ.button.Url",{extend:Ext.button.Button,alias:"widget.tq-urlbutton",url:null,handler:function(a,c){if(a.url){window.location.href=a.url}}});Ext.define("TQ.grid.column.Checkbox",{extend:Ext.grid.column.Column,alias:"widget.tq-checkboxcolumn",align:"center",checkboxType:"check",checkedSymbol:"x",uncheckedSymbol:"-",editable:true,nullIsFalse:false,undefinedText:"",nullText:"",doNotShowText:"",initComponent:function(){var a=this;var b=a.renderer||function(c){return c};a.renderer=function(g,h,d,i,f,e,c){g=a.getColumnValue(g,d);if(g===undefined){return a.undefinedText}else{if(g===null&&!a.nullIsFalse){return a.nullText}else{if(!a.showCheckbox(g,d)){return a.doNotShowText}else{if(!a.canEditRecord(d)){return b('<div class="tq-checkboxcolumn-text">'+a.getCheckboxSymbol(g,d,f)+"</div>",h,d,i,f,e,c)}else{return b('<div class="tq-checkboxcolumn '+a.getCheckboxCls(g,d,f)+'"></div>',h,d,i,f,e,c)}}}}};a.callParent(arguments);this.addEvents("beforecheckchange","checkchange")},getColumnValue:function(b,a){return b},showCheckbox:function(b,a){return true},canEditRecord:function(a){return this.editable},processEvent:function(g,c,a,d,f,h){if(h.getTarget(".tq-checkboxcolumn")&&g=="click"){var b=c.getStore().getAt(d);if(this.canEditRecord(b)){this.onCheckboxClick(b,h,this);return false}}return this.callParent(arguments)},getCheckboxCls:function(c,a,b){return"tq-grid-"+this.checkboxType+"-col"+(c?"-on":"")},getCheckboxSymbol:function(c,a,b){return(c)?this.checkedSymbol:this.uncheckedSymbol},onCheckboxClick:function(a,d,b){var c=!a.get(b.dataIndex);if(this.fireEvent("beforecheckchange",this,c,a)!==false){this.setValueOnRecord(a,b.dataIndex,c,b);this.fireEvent("checkchange",this,c,a)}},setValueOnRecord:function(a,b,d,c){a.set(b,d)}});Ext.define("TQ.grid.column.Editable",{editable:true,initEditableColumn:function(){if(this.isXType("gridcolumn")&&this.editable){var a=this.createEditor();if(a){this.editor=a}}},createEditor:function(){return null}});Ext.define("TQ.grid.column.Numeric",{extend:Ext.grid.column.Number,mixins:{editable:TQ.grid.column.Editable},alias:"widget.tq-grid-column-numeric",smartFormatting:true,maxPrecision:12,stripTrailingZeros:true,withThousands:true,stringWhenNull:"",align:"right",factor:1,invertValue:false,renderPrefix:null,renderPrefixCallback:null,renderSuffix:null,renderSuffixCallback:null,allowBlank:false,minValue:null,editorConfig:null,numberRenderer:null,constructor:function(a){var b=this;b.callParent(arguments);if(Ext.isFunction(b.numberRenderer)){b.numberRenderer=b.numberRenderer}else{if(b.smartFormatting){b.numberRenderer=TQ.util.Format.smartNumberRenderer()}else{b.numberRenderer=TQ.util.Format.numberRenderer(b.maxPrecision,b.withThousands,b.stripTrailingZeros,b.maxPrecision)}}var c=a.renderer;if(!Ext.isFunction(c)){c=function(d){return d}}else{delete a.renderer}b.renderer=function(i,f,e,j,h,g,d){i=b.getNumericValue(i,e);b.applyCellFormatting(i,f,e);if(!Ext.isEmpty(i)){if(b.invertValue){i*=-1}i=i/b.factor;i=b.numberRenderer(i);if(b.renderPrefix){i=b.renderPrefix+i}else{if(Ext.isFunction(b.renderPrefixCallback)){i=b.renderPrefixCallback.call(b,i,e)+i}}if(b.renderSuffix){i=i+b.renderSuffix}else{if(Ext.isFunction(b.renderSuffixCallback)){i=i+b.renderSuffixCallback.call(b,i,e)}}return c.call(b,i,f,e,j,h,g,d)}else{return c.call(b,b.stringWhenNull,f,e,j,h,g,d)}}},initComponent:function(){var a=this;a.initEditableColumn();a.callParent(arguments);if(this.editable){this.on({beforeedit:function(b,c){if(this.factor!==1){c.value=c.value/this.factor}},afteredit:function(b,c){if(this.factor!==1){c.value=c.value*this.factor}},scope:this})}},getNumericValue:function(a,b){return a},applyCellFormatting:function(b,a,c){},createEditor:function(){var a=this;return Ext.apply({},{xtype:"tq-numberfield",align:a.align,allowBlank:a.allowBlank,decimalSeparator:TQ_DECIMAL_POINT,decimalPrecision:a.maxPrecision,minValue:a.minValue,cls:"tq-number-editor"},a.editorConfig||{})}});Ext.define("TQ.math.Statistic",{statics:{average:function(b){b=Ext.Array.from(b);var a=TQ.math.Statistic.sum(b);return(a/b.length)},sum:function(c){c=Ext.Array.from(c);var a=c.length,b=0;while(a--){b+=c[a]}return b},variance:function(d,c){d=Ext.Array.from(d);var e=TQ.math.Statistic.average(d),b=d.length,f=(c)?d.length-1:d.length,a=0;while(b--){a+=Math.pow((d[b]-e),2)}return(a/f)},standardDeviation:function(b,a){b=Ext.Array.from(b);return Math.sqrt(TQ.math.Statistic.variance(b,a))},coefficientOfVariation:function(d,c){d=Ext.Array.from(d);var b=Math.sqrt(TQ.math.Statistic.variance(d,c)),a=TQ.math.Statistic.average(d);return b/a},min:function(a){return Math.min.apply(Math,a)},max:function(a){return Math.max.apply(Math,a)},median:function(f){f=Ext.Array.from(f);f.sort(function(h,g){return h-g});var d=f.length,b=Math.floor((d-1)/2),c;if(d===0){return null}if(d%2){c=f[b]}else{var a=f[b],e=f[b+1];c=((a+e)/2)}return c},quantile:function(d,c){c=Ext.Array.from(c);d=(d>1)?d/100:d;var f=c.length,e,a,b;if(f==0||d<=0){return null}c.sort(function(h,g){return h-g});e=f*d;a=Math.floor(e);b=e-a;if(b>0){return c[a+1]}else{return(c[a-1]+c[a])/2}}}});(function(){Ext.ns("TQ.util");TQ.util.Format={};var b=TQ.util.Format,a=Ext.util.Format;Ext.apply(b,{thousandSeparator:a.thousandSeparator,decimalSeparator:a.decimalSeparator,precision:2,showThousandSeparator:true,stripTrailingZeroes:true,numberFormatString:function(d,c){if(Ext.isEmpty(d)){d=b.precision}if(Ext.isEmpty(c)){c=b.showThousandSeparator}var e="0";if(c){e+=b.thousandSeparator+"000"}if(d>0){e+=b.decimalSeparator+""+Ext.String.repeat("0",d)}if(b.decimalSeparator!="."){e+="/i"}return e},number:function(k,f,l,d){if(Ext.isEmpty(d)){d=b.stripTrailingZeroes}var j=b.numberFormatString(f,l),e=a.number(k,j);if(d){var m=String(k);if(m.indexOf("e")!==-1){m=String(Number(m).toFixed())}var i=m.split(".",2);if(i.length>1){var g=i[1].length;var h=m.charAt(m.length-1);if(g<f){e=e.replace(new RegExp("\\d{"+(f-g)+"}$"),"");var c=e.charAt(e.length-1);if(parseInt(c,10)!=h){e=e.replace(/\d$/,h)}}e=e.replace(new RegExp("((()"+Ext.String.escapeRegex(b.decimalSeparator)+"0*)|("+Ext.String.escapeRegex(b.decimalSeparator)+"[0-9]+?)(0*))$"),"$4")}}return e},numberRenderer:function(d,c,e){return function(f){return b.number(f,d,c,e)}},smartNumberRenderer:function(c){var d=new TQ.util.SmartFormat(c);return d.numberRenderer()},smartNumber:function(c,d){var e=new TQ.util.SmartFormat(d);return e.number(c)}})}());(function(){Ext.ns("TQ.util");TQ.util.SmartFormat={};var a=TQ.util.SmartFormat,c=TQ.util.Format,b=[{p:function(d,e){return e>=100},f:function(f,d,e){return c.number(f,0,d,false)}},{p:function(d,e){return e>=10},f:function(f,d,e){return c.number(f,1,d,e)}},{p:function(d,e){return e>=1},f:function(f,d,e){return c.number(f,2,d,e)}},{p:function(d,e){return e==0},f:function(f,d,e){return c.number(f,0,d,false)}},{p:function(d,e){return e>Math.pow(10,-1*6)},f:function(f,d,e){return c.number(f,6,d,false)}},{p:function(d,e){return true},f:function(h,d,f){var g=0,i=Math.abs(h);if(i>0){g=Math.floor(Math.log(i)/Math.LN10)}if(g===0){return c.number(h,6,d,f)}var e=a.number(h/Math.pow(10,g));return e+"e"+g}}];Ext.apply(a,{showThousandSeparator:true,stripTrailingZeroes:true,number:function(e,g){if(!Ext.isEmpty(e)&&Ext.isNumber(e)){g=g||b;var h=Math.abs(e),d=g.length,f;for(f=0;f<d;f++){if(g[f].p(e,h)){return g[f].f(e,a.showThousandSeparator,a.stripTrailingZeroes)}}}return""},numberRenderer:function(d){return function(e){return a.number(e,d)}}})}());