tom@1119: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
tom@1119:  * Software engineering by Intevation GmbH
tom@1119:  *
tom@1119:  * This file is Free Software under the GNU GPL (v>=3)
tom@1119:  * and comes with ABSOLUTELY NO WARRANTY! Check out
tom@1119:  * the documentation coming with IMIS-Labordaten-Application for details.
tom@1119:  */
tom@1119: 
tom@1119: /**
tom@1119:  * Number field for display and editing of exponential numbers
tom@1119:  */
tom@1119: Ext.define('Lada.view.form.ExpNumberField', {
tom@1119:     extend: 'Ext.form.field.Number',
tom@1119:     alias: 'widget.expnumberfield',
tom@1119: 
tom@1119:     baseChars: '0123456789eE',
tom@1119: 
tom@1119:     hideTrigger: true,
tom@1119:     keyNavEnabled: false,
tom@1119:     mouseWheelEnabled: false,
tom@1119: 
tom@1119:     valueToRaw: function(value) {
tom@1119:         if (!value || value === '') {
tom@1119:             return value;
tom@1119:         }
tom@1119: 
tom@1119:         // XXX: this will be applied to any input before being sent to
tom@1119:         // the server! Thus, toExponential(2) would lead to incorrectly
tom@1119:         // rounded numbers at this point.
tom@1119:         value = parseFloat(value).toExponential()
tom@1119:             .toString().replace('.', this.decimalSeparator);
tom@1119: 
tom@1119:         return value;
tom@1119:     },
tom@1119: 
tom@1119:     rawToValue: function(value) {
tom@1119:         if (!value || value === '') {
tom@1119:             return value;
tom@1119:         }
tom@1119: 
tom@1119:         value = parseFloat(
tom@1119:             value.toString().replace(this.decimalSeparator, '.'));
tom@1119: 
tom@1119:         return value;
tom@1119:     }
tom@1119: });