1 /*jshint node:true, indent:2, curly:true, eqeqeq:true, immed:true, latedef:true, newcap:true, noarg:true,
2 regexp:true, undef:true, trailing:true, white:true */
3 /*global XT:true, XV:true, Globalize:true, enyo:true, _:true */
7 // ..........................................................
18 name: "XV.CostWidget",
19 kind: "XV.NumberWidget",
23 // ..........................................................
28 name: "XV.ExtendedPrice",
30 scale: XT.EXTENDED_PRICE_SCALE
34 name: "XV.ExtendedPriceWidget",
35 kind: "XV.NumberWidget",
36 scale: XT.EXTENDED_PRICE_SCALE
39 // ..........................................................
51 name: "XV.HoursWidget",
52 kind: "XV.NumberWidget",
57 // ..........................................................
64 scale: XT.PERCENT_SCALE,
65 validate: function (value) {
66 // this takes the string from the input field and parses it (including understanding commas, which isNaN cannot)
67 // if it cannot parse the value, it returns NaN
68 value = Globalize.parseFloat(value);
69 // use isNaN here because parseFloat could return NaN
70 // if you pass NaN into _.isNumber, it will misleadingly return true
71 // only bad string and null/undefined cases do we want to fail validation
72 return !isNaN(value) ? value / 100 : false;
74 valueChanged: function (value) {
75 // use isNaN here because this value may be a number string and _isNaN requires
76 // a separate falsy check.
77 // In this case, it is ok for 0 to fall to the true case, just not null or a bad string
78 value = !isNaN(value) ? value * 100 : value;
79 XV.Number.prototype.valueChanged.call(this, value);
84 name: "XV.PercentWidget",
85 kind: "XV.NumberWidget",
86 scale: XT.PERCENT_SCALE,
87 validate: function (value) {
88 // this takes the string from the input field and parses it (including understanding commas, which isNaN cannot)
89 // if it cannot parse the value, it returns NaN
90 value = Globalize.parseFloat(value);
91 // use isNaN here because parseFloat could return NaN
92 // if you pass NaN into _.isNumber, it will misleadingly return true
93 // only bad string and null/undefined cases do we want to fail validation
94 return !isNaN(value) ? value / 100 : false;
96 valueChanged: function (value) {
97 // use isNaN here because this value may be a number string and _isNaN requires
98 // a separate falsy check.
99 // In this case, it is ok for 0 to fall to the true case, just not null or a bad string
100 value = !isNaN(value) ? value * 100 : value;
101 XV.NumberWidget.prototype.valueChanged.call(this, value);
105 // ..........................................................
110 name: "XV.PurchasePrice",
112 scale: XT.PURCHASE_PRICE_SCALE
116 name: "XV.PurchasePriceWidget",
117 kind: "XV.NumberWidget",
118 scale: XT.PURCHASE_PRICE_SCALE
121 // ..........................................................
133 name: "XV.QuantityWidget",
134 kind: "XV.NumberWidget",
139 // ..........................................................
144 name: "XV.QuantityPer",
146 scale: XT.QTY_PER_SCALE
150 name: "XV.QuantityPerWidget",
151 kind: "XV.NumberWidget",
152 scale: XT.QTY_PER_SCALE
155 // ..........................................................
160 name: "XV.SalesPrice",
162 scale: XT.SALES_PRICE_SCALE
166 name: "XV.SalesPriceWidget",
167 kind: "XV.NumberWidget",
168 scale: XT.SALES_PRICE_SCALE
171 // ..........................................................
176 name: "XV.UnitRatio",
178 scale: XT.UNIT_RATIO_SCALE
182 name: "XV.UnitRatioWidget",
183 kind: "XV.NumberWidget",
184 scale: XT.UNIT_RATIO_SCALE
187 // ..........................................................
194 scale: XT.WEIGHT_SCALE
198 name: "XV.WeightWidget",
199 kind: "XV.NumberWidget",
200 scale: XT.WEIGHT_SCALE