diff --git a/src/js/directives/amount.js b/src/js/directives/amount.js
deleted file mode 100644
index 9622ca09d..000000000
--- a/src/js/directives/amount.js
+++ /dev/null
@@ -1,92 +0,0 @@
-'use strict';
-
-/**
- * @desc amount directive that can be used to display formatted financial values
- * size-equal attribute is optional, defaults to false.
- * @example fee = {
- * value: 12.49382901,
- * currency: 'BCH'
- * }
- * @example
- * @example
- */
-angular.module('bitcoincom.directives')
- .directive('amount', [
- '$timeout',
- function($timeout) {
- return {
- restrict: 'E',
- scope: {
- value: '=',
- currency: '=',
- sizeEqual: '='
- },
- templateUrl: 'views/includes/amount.html',
- controller: ['$scope', function($scope) {
- $scope.displaySizeEqual = typeof $scope.sizeEqual == 'undefined' ? false : true;
-
- var decimalPlaces = {
- '0': ['BIF', 'CLP', 'DJF', 'GNF', 'ILS', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'],
- '3': ['BHD', 'IQD', 'JOD', 'KWD', 'OMR', 'TND'],
- '8': ['BCH', 'BTC']
- };
-
- var numberWithCommas = function(x) {
- return parseFloat(x).toLocaleString();
- };
-
- var buildAmount = function(start, middle, end) {
- $scope.start = start;
- $scope.middle = middle;
- $scope.end = end;
- };
-
- var getDecimalPlaces = function(currency) {
- if (decimalPlaces['0'].indexOf($scope.currency.toUpperCase()) > -1) return '0';
- if (decimalPlaces['3'].indexOf($scope.currency.toUpperCase()) > -1) return '3';
- if (decimalPlaces['8'].indexOf($scope.currency.toUpperCase()) > -1) return '8';
- return '2';
- };
-
- var formatNumbers = function(currency, value) {
- switch (getDecimalPlaces(currency)) {
- case '0':
- var valueFormatted = numberWithCommas(Math.round(parseFloat(value)));
- buildAmount(valueFormatted, '', '');
- break;
-
- case '2':
- var valueProcessing = parseFloat(parseFloat(value).toFixed(2));
- var valueFormatted = numberWithCommas(valueProcessing);
- buildAmount(valueFormatted, '', '');
- break;
-
- case '3':
- var valueProcessing = parseFloat(parseFloat(value).toFixed(3));
- var valueFormatted = numberWithCommas(valueProcessing);
- buildAmount(valueFormatted, '', '');
- break;
-
- case '8':
- var valueFormatted = parseFloat(value).toFixed(8);
- if (parseFloat(value) == 0) {
- buildAmount('0', '', '');
- } else {
- buildAmount(valueFormatted, '', '');
- var start = numberWithCommas(valueFormatted.slice(0, -5));
- var middle = valueFormatted.slice(-5, -2);
- var end = valueFormatted.substr(valueFormatted.length - 2);
- buildAmount(start, middle, end);
- }
- break;
- }
- }
-
- formatNumbers($scope.currency, $scope.value);
- $scope.$watchGroup(['currency', 'value'], function() {
- formatNumbers($scope.currency, $scope.value);
- });
- }]
- };
- }
-]);
\ No newline at end of file
diff --git a/src/js/directives/formattedAmount.js b/src/js/directives/formattedAmount.js
new file mode 100644
index 000000000..c5b2dfcd4
--- /dev/null
+++ b/src/js/directives/formattedAmount.js
@@ -0,0 +1,136 @@
+'use strict';
+
+/**
+ * @desc amount directive that can be used to display formatted financial values
+ * size-equal attribute is optional, defaults to false.
+ * @example fee = {
+ * value: 12.49382901,
+ * currency: 'BCH'
+ * }
+ * @example
+ * @example
+ */
+angular.module('bitcoincom.directives')
+ .directive('formattedAmount', function(configService, uxLanguage) {
+ return {
+ restrict: 'E',
+ scope: {
+ value: '@',
+ currency: '@',
+ sizeEqual: '@'
+ },
+ templateUrl: 'views/includes/formatted-amount.html',
+ controller: function($scope, $timeout) {
+ $scope.canShow = false;
+
+ $scope.displaySizeEqual = !!$scope.sizeEqual;
+
+ configService.whenAvailable(function onConfigServiceAvailable(config) {
+
+ $timeout(function onFormattedAmountTimeout() {
+
+ var decimalPlaces = {
+ '0': ['BIF', 'CLP', 'DJF', 'GNF', 'ILS', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'],
+ '3': ['BHD', 'IQD', 'JOD', 'KWD', 'OMR', 'TND'],
+ '8': ['BCH', 'BTC']
+ };
+ var localizeNumbers = function(x, minimumFractionDigits = 0, useGrouping = true) {
+ return parseFloat(x).toLocaleString(uxLanguage.getCurrentLanguage(), {
+ minimumFractionDigits: minimumFractionDigits,
+ useGrouping: useGrouping
+ });
+ };
+
+ var buildAmount = function(start, middle, end) {
+ $scope.start = start;
+ $scope.middle = middle;
+ $scope.end = end;
+ };
+
+ var getDecimalPlaces = function(currency) {
+ if (decimalPlaces['0'].indexOf(currency.toUpperCase()) > -1) return '0';
+ if (decimalPlaces['3'].indexOf(currency.toUpperCase()) > -1) return '3';
+ if (decimalPlaces['8'].indexOf(currency.toUpperCase()) > -1) return '8';
+ return '2';
+ };
+
+ var getDecimalSeparator = function() {
+ var testNum = 1.5;
+ var testString = testNum.toLocaleString(uxLanguage.getCurrentLanguage());
+ // Some environments let you set decimal separators that are more than one character
+ var separator = /^1(.+)5$/.exec(testString)[1]
+ return separator;
+ };
+
+ var formatNumbers = function() {
+
+ if (!$scope.currency && $scope.value) { // If there is no currency available..
+ // Try to extract currency from value..
+ var currencySplit = $scope.value.split(" ");
+ if (currencySplit.length === 2) {
+ $scope.currency = currencySplit[1];
+ }
+ }
+
+ var parsed = parseFloat($scope.value);
+ var valueFormatted = '';
+ var valueProcessing = '';
+ switch (getDecimalPlaces($scope.currency)) {
+ case '0':
+ if (isNaN(parsed)) {
+ buildAmount('-', '', '');
+ } else {
+ valueFormatted = localizeNumbers(Math.round(parsed));
+ buildAmount(valueFormatted, '', '');
+ }
+ break;
+
+ case '3':
+ if (isNaN(parsed)) {
+ buildAmount('-' + getDecimalSeparator() + '---', '', '');
+ } else {
+ valueProcessing = parsed.toFixed(3);
+ valueFormatted = localizeNumbers(valueProcessing, 3);
+ buildAmount(valueFormatted, '', '');
+ }
+ break;
+
+ case '8':
+ if (isNaN(parsed)) {
+ buildAmount('-' + getDecimalSeparator() + '---', '', '');
+ } else if (parsed === 0) {
+ buildAmount('0', '', '');
+ } else {
+ valueFormatted = parsed.toFixed(8);
+ valueFormatted = localizeNumbers(valueFormatted, 8);
+ var start = valueFormatted.slice(0, -5);
+ var middle = valueFormatted.slice(-5, -2);
+ var end = valueFormatted.substr(valueFormatted.length - 2);
+ buildAmount(start, middle, end);
+
+ }
+ break;
+
+ default: // 2
+ if (isNaN(parsed)) {
+ buildAmount('-' + getDecimalSeparator() + '--', '', '');
+ } else {
+ valueProcessing = parseFloat(parsed.toFixed(2));
+ valueFormatted = localizeNumbers(valueProcessing, 2);
+ buildAmount(valueFormatted, '', '');
+ }
+ break;
+ }
+ $scope.canShow = true;
+ };
+
+ formatNumbers();
+ $scope.$watchGroup(['currency', 'value'], function onFormattedAmountWatch() {
+ formatNumbers();
+ });
+ });
+ });
+ }
+ };
+ }
+);
\ No newline at end of file
diff --git a/src/sass/components/components.scss b/src/sass/components/components.scss
index 0af55e5be..fb53508b0 100644
--- a/src/sass/components/components.scss
+++ b/src/sass/components/components.scss
@@ -8,4 +8,4 @@
@import "action-minor";
@import "expand-content";
@import "fee-summary";
-@import "amount.scss";
+@import "formatted-amount";
diff --git a/src/sass/components/amount.scss b/src/sass/components/formatted-amount.scss
similarity index 89%
rename from src/sass/components/amount.scss
rename to src/sass/components/formatted-amount.scss
index 363d38a20..6678572c9 100644
--- a/src/sass/components/amount.scss
+++ b/src/sass/components/formatted-amount.scss
@@ -1,4 +1,6 @@
-.amount {
+.formatted-amount {
+ display: inline-block;
+
.start,
.middle,
.end,
diff --git a/www/views/amount.html b/www/views/amount.html
index 270dbb3fb..9db5d189d 100644
--- a/www/views/amount.html
+++ b/www/views/amount.html
@@ -15,11 +15,13 @@
@@ -42,7 +44,7 @@
@@ -52,7 +54,7 @@
diff --git a/www/views/includes/amount.html b/www/views/includes/formatted-amount.html
similarity index 72%
rename from www/views/includes/amount.html
rename to www/views/includes/formatted-amount.html
index 361dededc..24149849d 100644
--- a/www/views/includes/amount.html
+++ b/www/views/includes/formatted-amount.html
@@ -1,4 +1,4 @@
-
+
{{start}}{{middle}}{{end}}{{currency}}
\ No newline at end of file
diff --git a/www/views/includes/walletHistory.html b/www/views/includes/walletHistory.html
index 4a40e93d8..296b35b1a 100644
--- a/www/views/includes/walletHistory.html
+++ b/www/views/includes/walletHistory.html
@@ -64,17 +64,16 @@
- –
(possible double spend)
- {{btx.amountValueStr}} {{btx.amountUnitStr}}
+
- {{btx.alternativeAmountStr}}
+
diff --git a/www/views/includes/walletList.html b/www/views/includes/walletList.html
index f7a061740..d5fb65302 100644
--- a/www/views/includes/walletList.html
+++ b/www/views/includes/walletList.html
@@ -7,8 +7,12 @@
Incomplete
- {{wallet.status.totalBalanceStr ? wallet.status.totalBalanceStr : ( wallet.cachedBalance ? wallet.cachedBalance + (wallet.cachedBalanceUpdatedOn ? ' · ' + ( wallet.cachedBalanceUpdatedOn * 1000 | amTimeAgo) : '') : '' ) }}
- {{wallet.status.totalBalanceAlternative ? wallet.status.totalBalanceAlternative : ( wallet.cachedBalance ? wallet.cachedBalance + (wallet.cachedBalanceUpdatedOn ? ' · ' + ( wallet.cachedBalanceUpdatedOn * 1000 | amTimeAgo) : '') : '' ) }} {{wallet.status.alternativeIsoCode}}
+
+
+
+
+
+
Scanning funds...
[Balance Hidden]
diff --git a/www/views/includes/walletSelector.html b/www/views/includes/walletSelector.html
index 97dfeb552..237f5ace4 100644
--- a/www/views/includes/walletSelector.html
+++ b/www/views/includes/walletSelector.html
@@ -27,8 +27,8 @@
Incomplete
- {{wallet.status.totalBalanceAlternative}} {{wallet.status.alternativeIsoCode}}
- {{wallet.status.availableBalanceStr}}
+
+
[Balance Hidden]
@@ -58,8 +58,8 @@
Incomplete
- {{wallet.status.totalBalanceAlternative}} {{wallet.status.alternativeIsoCode}}
- {{wallet.status.availableBalanceStr}}
+
+
[Balance Hidden]
diff --git a/www/views/tab-receive.html b/www/views/tab-receive.html
index 046a19ba8..773b3249d 100644
--- a/www/views/tab-receive.html
+++ b/www/views/tab-receive.html
@@ -61,8 +61,8 @@
Payment Received!
- {{ paymentReceivedAmount }} {{ paymentReceivedCoin }}
- {{ paymentReceivedAlternativeAmount }}
+
+
Return To Address
@@ -95,8 +95,8 @@
{{wallet.name || wallet.id}}
- {{wallet.status.totalBalanceAlternative}} {{wallet.status.alternativeIsoCode}}
- {{wallet.status.totalBalanceStr}}
+
+
[Balance Hidden]
diff --git a/www/views/tx-details.html b/www/views/tx-details.html
index e3a7a06b4..467ce28e3 100644
--- a/www/views/tx-details.html
+++ b/www/views/tx-details.html
@@ -24,13 +24,13 @@
Receiving
-
{{btx.amountValueStr}} {{btx.amountUnitStr}}
+
- {{btx.alternativeAmountStr}}
+
...
- {{rate| currency:'':2}} {{alternativeIsoCode}} ({{rateDate | amDateFormat:'MM/DD/YYYY HH:mm a'}})
+ ({{rateDate | amDateFormat:'MM/DD/YYYY HH:mm a'}})
@@ -115,7 +115,7 @@
Fee
{{btx.feeStr || '...'}}
- {{btx.feeFiatStr || '...'}} - {{btx.feeRateStr}} of the transaction
+ ...- {{btx.feeRateStr}} of the transaction
diff --git a/www/views/walletDetails.html b/www/views/walletDetails.html
index f9cf662cb..f10759ca6 100644
--- a/www/views/walletDetails.html
+++ b/www/views/walletDetails.html
@@ -34,12 +34,14 @@
on-hold="hideToggle()"
ng-style="{'transform': amountScale}"
ng-class="{amount__balance: amountIsCollapsible}">
-
{{status.totalBalanceAlternative}} {{status.alternativeIsoCode}}
+
+
+
- {{status.totalBalanceStr}}
+
@@ -47,13 +49,16 @@
ng-show="selectedPriceDisplay=='crypto' && !updateStatusError && !wallet.balanceHidden && !wallet.scanning"
on-hold="hideToggle()"
ng-style="{'transform': amountScale}"
+ ng-if="status.totalBalanceStr"
ng-class="{amount__balance: amountIsCollapsible}">
- {{status.totalBalanceStr}}
+
+
+
- {{status.totalBalanceAlternative}} {{status.alternativeIsoCode}}
+
@@ -86,7 +91,7 @@
- {{status.spendableBalanceAlternative}} {{status.alternativeIsoCode}}
+
@@ -143,12 +148,12 @@
on-hold="hideToggle()"
ng-style="{'transform': amountScale}"
ng-class="{amount__balance: amountIsCollapsible}">
- {{status.totalBalanceStr}}
+
- {{status.totalBalanceAlternative}} {{status.alternativeIsoCode}}
+
@@ -158,12 +163,12 @@
on-hold="hideToggle()"
ng-style="{'transform': amountScale}"
ng-class="{amount__balance: amountIsCollapsible}">
- {{status.totalBalanceAlternative}} {{status.alternativeIsoCode}}
+
- {{status.totalBalanceStr}}
+
@@ -196,7 +201,7 @@
- {{status.spendableBalanceAlternative}} {{status.alternativeIsoCode}}
+
@@ -205,7 +210,7 @@