]> git.proxmox.com Git - extjs.git/blob - extjs/build/examples/kitchensink/modern/src/view/binding/TwoWayFormulaModel.js
add extjs 6.0.1 sources
[extjs.git] / extjs / build / examples / kitchensink / modern / src / view / binding / TwoWayFormulaModel.js
1 Ext.define('KitchenSink.view.binding.TwoWayFormulaModel', {
2 extend: 'Ext.app.ViewModel',
3 alias: 'viewmodel.binding-twowayformula',
4
5 formulas: {
6 // The calls to correctFloat here are to preserve the stability
7 // of the values, we don't want precision rounding to cause the
8 // viewmodel to think the data is different.
9 celcius: {
10 get: function(get) {
11 return Ext.Number.correctFloat(get('kelvin') - 273.15);
12 },
13 set: function(v) {
14 this.set('kelvin', Ext.Number.correctFloat(v + 273.15));
15 }
16 },
17 fahrenheit: {
18 get: function(get) {
19 return Ext.Number.correctFloat(get('celcius') * 1.8 + 32);
20 },
21 set: function(v) {
22 this.set('celcius', Ext.Number.correctFloat((v - 32) / 1.8));
23 }
24 }
25 },
26
27 data: {
28 kelvin: 300.1
29 }
30 });