Skip to content
This repository has been archived by the owner on Oct 8, 2019. It is now read-only.

Commit

Permalink
refactor(DeCoffee): convert label-origin directive to es6
Browse files Browse the repository at this point in the history
  • Loading branch information
jtormey committed Mar 2, 2016
1 parent fbae317 commit bf4221d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 29 deletions.
2 changes: 1 addition & 1 deletion app/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ head
script(src='build/js/directives/is-valid.directive.js')
script(src='build/js/directives/is-not-equal.directive.js')
script(src='build/js/directives/transform-currency.js')
script(src='build/js/directives/label-origin.js')
script(src='build/js/directives/label-origin.directive.js')
script(src='build/js/directives/destinationInput.directive.js')
script(src='build/js/directives/scroll-in-view.js')
script(src='build/js/directives/public-header.directive.js')
Expand Down
38 changes: 38 additions & 0 deletions assets/js/directives/label-origin.directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
angular
.module('walletApp')
.directive('labelOrigin', labelOrigin);

function labelOrigin(Wallet, currency) {
const directive = {
restrict: 'E',
replace: true,
templateUrl: 'templates/label-origin.jade',
scope: {
origin: '=',
fee: '=',
highlight: '='
},
link: link
};
return directive;

function link(scope, elem, attrs) {
scope.settings = Wallet.settings;
scope.isBitCurrency = currency.isBitCurrency;

scope.determineAvailableBalance = (balance) => {
if (balance == null) return;

finalBalance = parseInt(balance);
if (scope.fee) finalBalance -= parseInt(scope.fee);

return finalBalance < 0 ? 0 : finalBalance;
};

scope.determineLabel = (origin) => {
if (origin == null) return;
return origin.label || origin.address;
};

}
}
28 changes: 0 additions & 28 deletions assets/js/directives/label-origin.js.coffee

This file was deleted.

0 comments on commit bf4221d

Please sign in to comment.