Move amount directive to a separate branch
This commit is contained in:
parent
2b32fe9bdc
commit
2b96293c80
4 changed files with 0 additions and 125 deletions
|
|
@ -1,76 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* @desc amount directive that can be used to display formatted financial values
|
||||
* @example <amount value="12.49382901" currency="BCH"></amount>
|
||||
*/
|
||||
angular.module('bitcoincom.directives')
|
||||
.directive('amount', [
|
||||
'$timeout',
|
||||
function($timeout) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
value: '=',
|
||||
currency: '='
|
||||
},
|
||||
templateUrl: 'views/includes/amount.html',
|
||||
controller: ['$scope', function($scope) {
|
||||
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';
|
||||
};
|
||||
|
||||
switch (getDecimalPlaces($scope.currency)) {
|
||||
case '0':
|
||||
var valueFormatted = numberWithCommas(Math.round(parseFloat($scope.value)));
|
||||
buildAmount(valueFormatted, '', '');
|
||||
break;
|
||||
|
||||
case '2':
|
||||
var valueProcessing = parseFloat(parseFloat($scope.value).toFixed(2));
|
||||
var valueFormatted = numberWithCommas(valueProcessing);
|
||||
buildAmount(valueFormatted, '', '');
|
||||
break;
|
||||
|
||||
case '3':
|
||||
var valueProcessing = parseFloat(parseFloat($scope.value).toFixed(3));
|
||||
var valueFormatted = numberWithCommas(valueProcessing);
|
||||
buildAmount(valueFormatted, '', '');
|
||||
break;
|
||||
|
||||
case '8':
|
||||
var valueFormatted = parseFloat($scope.value).toFixed(8);
|
||||
if (parseFloat($scope.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;
|
||||
}
|
||||
}]
|
||||
};
|
||||
}
|
||||
]);
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
.amount {
|
||||
.start,
|
||||
.middle,
|
||||
.end,
|
||||
.currency {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.start {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.middle {
|
||||
font-size: 0.7857em;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.end {
|
||||
font-size: 0.7857em;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.currency {
|
||||
font-size: 1em;
|
||||
margin-left: 5px;
|
||||
}
|
||||
}
|
||||
|
|
@ -8,4 +8,3 @@
|
|||
@import "action-minor";
|
||||
@import "expand-content";
|
||||
@import "fee-summary";
|
||||
@import "amount";
|
||||
|
|
|
|||
|
|
@ -15241,27 +15241,6 @@ ion-content.padded-bottom-cta-with-summary {
|
|||
.fee-summary .fee-crypto {
|
||||
color: #A7A7A7; }
|
||||
|
||||
.amount .start,
|
||||
.amount .middle,
|
||||
.amount .end,
|
||||
.amount .currency {
|
||||
display: inline-block; }
|
||||
|
||||
.amount .start {
|
||||
font-size: 1em; }
|
||||
|
||||
.amount .middle {
|
||||
font-size: 0.7857em;
|
||||
margin-left: 5px; }
|
||||
|
||||
.amount .end {
|
||||
font-size: 0.7857em;
|
||||
margin-left: 5px; }
|
||||
|
||||
.amount .currency {
|
||||
font-size: 1em;
|
||||
margin-left: 5px; }
|
||||
|
||||
/* This is for rules that don't yet have a home.
|
||||
* Our goal is to delete this file. Search the regex: /class=".*CLASS.*?"/
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue