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

Commit

Permalink
Merge 1de0f23 into 69e477c
Browse files Browse the repository at this point in the history
  • Loading branch information
jtormey committed Dec 11, 2015
2 parents 69e477c + 1de0f23 commit 53d678e
Show file tree
Hide file tree
Showing 23 changed files with 468 additions and 370 deletions.
22 changes: 11 additions & 11 deletions app/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,17 @@ head
script(src='build/js/directives/adverts.directive.js')
script(src='build/js/directives/amount.directive.js')
script(src='build/js/directives/setting-toggle.js')
script(src='build/js/directives/bc-async-input.js')
script(src='build/js/directives/completed-level.js')
script(src='build/js/directives/bc-async-input.directive.js')
script(src='build/js/directives/completed-level.directive.js')
script(src='build/js/directives/contextual-message.js')
script(src='build/js/directives/configure-mobile-number.js')
script(src='build/js/directives/configure-mobile-number.directive.js')
script(src='build/js/directives/verify-mobile-number.js')
script(src='build/js/directives/configure-second-password.js')
script(src='build/js/directives/confirm-recovery-phrase.js')
script(src='build/js/directives/currency-picker.js')
script(src='build/js/directives/did-you-know.js')
script(src='build/js/directives/fiat-or-btc.js')
script(src='build/js/directives/fiat.js')
script(src='build/js/directives/configure-second-password.directive.js')
script(src='build/js/directives/confirm-recovery-phrase.directive.js')
script(src='build/js/directives/currency-picker.directive.js')
script(src='build/js/directives/did-you-know.directive.js')
script(src='build/js/directives/fiat-or-btc.directive.js')
script(src='build/js/directives/fiat.directive.js')
script(src='build/js/directives/hd-address.js')
script(src='build/js/directives/imported-address.js')
script(src='build/js/directives/watch-only-address.js')
Expand All @@ -136,8 +136,8 @@ head
script(src='build/js/directives/transaction-status.js')
script(src='build/js/directives/ui-ladda.js')
script(src='build/js/directives/virtual-keyboard.js')
script(src='build/js/directives/btc-picker.js')
script(src='build/js/directives/focus-when.js')
script(src='build/js/directives/btc-picker.directive.js')
script(src='build/js/directives/focus-when.directive.js')
script(src='build/js/directives/is-valid.js')
script(src='build/js/directives/is-valid-amount.js')
script(src='build/js/directives/is-valid-async.js')
Expand Down
108 changes: 108 additions & 0 deletions assets/js/directives/bc-async-input.directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@

angular
.module('walletApp')
.directive('bcAsyncInput', bcAsyncInput);

bcAsyncInput.$inject = ['$timeout', 'Wallet'];

function bcAsyncInput($timeout, Wallet) {
const directive = {
restrict: 'E',
replace: true,
require: 'ngModel',
scope: {
ngModel: '=',
validator: '=',
onSave: '=',
onCancel: '=',
onChange: '=',
actionTitle: '=',
placeholder: '=',
_type: '@type',
errorMessage: '=',
_buttonClass: '@buttonClass',
maxLength: '@',
transform: '='
},
transclude: true,
templateUrl: (elem, attrs) => {
let templ = attrs.custom ? 'transclude.jade' : 'bc-async-input.jade';
return `templates/${templ}`;
},
link: link
};
return directive;

function link(scope, elem, attrs, ctrl, transclude) {
scope.isRequired = attrs.isRequired != null;
scope.inline = attrs.inline != null;

scope.type = scope._type || 'text';
scope.buttonClass = scope._buttonClass || 'button-primary btn-small';

scope.user = Wallet.user;
scope.status = {
edit: false,
saving: false
};

if (attrs.editing != null) scope.status.edit = true;

scope.form = {
newValue: scope.ngModel
};

scope.edit = function () {
// finds and focuses on the text input field
// a brief timeout is necessary before trying to focus
$timeout((function () {
elem.find('input')[0].focus();
}), 50);
return scope.status.edit = 1;
};

scope.focus = function () {
scope.status.edit = 1;
};

scope.validate = function () {
return scope.validator ? scope.validator(scope.form.newValue) : true;
};

scope.save = function () {
scope.status.saving = true;

let success = function () {
scope.ngModel = scope.form.newValue;
if (!attrs.custom) scope.bcAsyncForm.$setPristine();

// Fixes issue: hit enter after changing PBKDF2 iterations
// when 2nd password is enabled
scope.$evalAsync(function () {
scope.status.saving = false;
if (!attrs.editing) scope.status.edit = false;
});
scope.$root.$safeApply(scope);
};

let error = function () {
scope.status.saving = false;
scope.$root.$safeApply(scope);
};

scope.onSave(scope.form.newValue, success, error);
};

scope.cancel = function () {
if (!attrs.editing) scope.status.edit = false;
scope.bcAsyncForm.input.$rollbackViewValue();
scope.form.newValue = scope.ngModel;
scope.bcAsyncForm.$setPristine();
scope.onCancel && scope.onCancel();
};

transclude(scope, function (clone, scope) {
if (attrs.custom) elem.empty().append(clone);
});
}
}
101 changes: 0 additions & 101 deletions assets/js/directives/bc-async-input.js.coffee

This file was deleted.

30 changes: 30 additions & 0 deletions assets/js/directives/btc-picker.directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

angular
.module('walletApp')
.directive('btcPicker', btcPicker);

btcPicker.$inject = ['$translate', 'Wallet', 'currency'];

function btcPicker($translate, Wallet, currency) {
const directive = {
restrict: 'E',
replace: false,
scope: {
currency: '=',
displayCurrency: '='
},
templateUrl: 'templates/btc-picker.jade',
link: link
};
return directive;

function link(scope, elem, attrs) {
scope.currencies = currency.bitCurrencies;
scope.didSelect = (item, model) => {
scope.currency = item;
if (currency.isBitCurrency(scope.displayCurrency)) {
scope.displayCurrency = item;
}
};
}
}
19 changes: 0 additions & 19 deletions assets/js/directives/btc-picker.js.coffee

This file was deleted.

35 changes: 35 additions & 0 deletions assets/js/directives/completed-level.directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

angular
.module('walletApp')
.directive('completedLevel', completedLevel);

completedLevel.$inject = ['$translate'];

function completedLevel($translate) {
const directive = {
restrict: 'E',
replace: true,
scope: {
content: '@',
img: '@',
message: '@',
placement: '@'
},
templateUrl: 'templates/completed-level.jade',
link: link
};
return directive;

function link(scope, elem, attrs) {
$translate(scope.content).then((translation) => {
scope.content = translation;
});
$translate(scope.message).then((translation) => {
scope.message = translation;
});
scope.tooltip = {
templateUrl: 'templates/completed-level-tooltip.jade',
placement: scope.placement || 'top'
};
}
}
25 changes: 0 additions & 25 deletions assets/js/directives/completed-level.js.coffee

This file was deleted.

Loading

0 comments on commit 53d678e

Please sign in to comment.