This repository has been archived by the owner on Oct 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
468 additions
and
370 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
}; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
}; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.