Better style

This commit is contained in:
Esteban Ordano 2014-08-28 11:37:39 -03:00
commit 4e94060219

View file

@ -14,12 +14,12 @@ angular.module('copayApp.controllers').controller('SendController',
this.alternativeIsoCode = config.alternativeIsoCode; this.alternativeIsoCode = config.alternativeIsoCode;
this.rateService = rateService; this.rateService = rateService;
$scope._amount = 0; $scope.amount = 0;
$scope._alternative = 0;
var makeNumber = function(val) {
return -(-val);
};
/**
* Setting the two related amounts as properties prevents an infinite
* recursion for watches while preserving the original angular updates
*/
Object.defineProperty($scope, Object.defineProperty($scope,
"alternative", { "alternative", {
get: function () { get: function () {
@ -28,9 +28,9 @@ angular.module('copayApp.controllers').controller('SendController',
set: function (newValue) { set: function (newValue) {
this._alternative = newValue; this._alternative = newValue;
if (typeof(newValue) === 'number') { if (typeof(newValue) === 'number') {
this._amount = makeNumber( this._amount = Number.parseFloat(
(rateService.fromFiat(newValue, config.alternativeIsoCode) * satToUnit (rateService.fromFiat(newValue, config.alternativeIsoCode) * satToUnit
).toFixed(config.unitDecimals)); ).toFixed(config.unitDecimals), 10);
} }
}, },
enumerable: true, enumerable: true,
@ -44,9 +44,9 @@ angular.module('copayApp.controllers').controller('SendController',
set: function (newValue) { set: function (newValue) {
this._amount = newValue; this._amount = newValue;
if (newValue) { if (newValue) {
this._alternative = makeNumber( this._alternative = Number.parseFloat(
(rateService.toFiat(newValue * config.unitToSatoshi, config.alternativeIsoCode) (rateService.toFiat(newValue * config.unitToSatoshi, config.alternativeIsoCode)
).toFixed(2)); ).toFixed(2), 10);
} }
}, },
enumerable: true, enumerable: true,