improve navigation functions

This commit is contained in:
Javier 2015-11-26 17:42:04 -03:00
commit 7941b7a0ef
2 changed files with 21 additions and 72 deletions

View file

@ -1,7 +1,7 @@
<div class="backup" ng-controller="backupController as wordsC">
<nav class="tab-bar">
<section class="left-small" ng-show="!wordsC.step1 && !wordsC.step4">
<a ng-click="wordsC.goToStep();">
<section class="left-small" ng-show="(wordsC.step != 1 && wordsC.step != 4)">
<a ng-click="wordsC.goToStep(1);">
<i class="icon-arrow-left3 icon-back"></i>
</a>
</section>
@ -29,7 +29,7 @@
## STEP 1
-->
<div ng-show="wordsC.step1">
<div ng-show="wordsC.step == 1">
<div ng-show="wordsC.mnemonicWords || (wordsC.credentialsEncrypted && !wordsC.deleted)">
<h5 class="text-center">Write your wallet seed</h5>
<div class="size-14 text-gray" ng-show="(index.n>1 && index.m != index.n )">
@ -62,7 +62,7 @@
</div>
<div ng-show="wordsC.mnemonicWords || (wordsC.credentialsEncrypted && !wordsC.deleted)">
<p class="text-center columns text-gray" ng-show="index.n==1 && wordsC.step1">
<p class="text-center columns text-gray" ng-show="index.n==1 && wordsC.step == 1">
<span translate>
You need the wallet seed to restore this personal wallet. Write it down and keep them somewhere safe.
</span>
@ -99,7 +99,7 @@
ng-disabled="wordsC.credentialsEncrypted"
class="round expand m0"
ng-style="{'background-color':index.backgroundColor}"
ng-click="wordsC.goToStep2();"
ng-click="wordsC.goToStep(2);"
translate>Continue
</button>
</div>
@ -109,7 +109,7 @@
## STEP 2
-->
<div ng-show="wordsC.step2">
<div ng-show="wordsC.step == 2">
<div class="columns text-center">
<h5>Confirm your wallet seed</h5>
<p class="text-gray m0">
@ -130,7 +130,7 @@
ng-disabled="!wordsC.selectComplete"
class="round expand m0"
ng-style="{'background-color':index.backgroundColor}"
ng-click="wordsC.goToStep3();"
ng-click="wordsC.goToStep(3);"
translate>Continue
</button>
</div>
@ -140,7 +140,7 @@
## STEP 3
-->
<div ng-show="wordsC.step3">
<div ng-show="wordsC.step == 3">
<div class="columns text-center">
<h5> Enter your passphrase</h5>
<p class="text-gray m0">
@ -156,7 +156,7 @@
ng-disabled="!passphrase"
ng-style="{'background-color':index.backgroundColor}"
class="button round expand m0"
ng-click="wordsC.goToStep4();"
ng-click="wordsC.goToStep(4);"
translate>Continue
</button>
</div>
@ -166,13 +166,7 @@
## STEP 4
-->
<div ng-show="wordsC.step4">
<!-- <div class="box-notification" ng-show="wordsC.backupError">
<span class="text-warning" translate>
Failed to verify backup. Please try again
</span>
</div> -->
<div ng-show="wordsC.step == 4">
<div class="row m10t m10b text-center" ng-show="!wordsC.backupError">
<div class="circle-icon">
<i class="fi-like size-48"></i>
@ -215,7 +209,7 @@
<button
ng-style="{'background-color':index.backgroundColor}"
class="button round expand"
ng-click="wordsC.goToStep1();"
ng-click="wordsC.goToStep(1);"
translate>Try again
</button>
<!-- hide this in multisig just to show less text -->

View file

@ -14,10 +14,7 @@ angular.module('copayApp.controllers').controller('backupController',
customWords = [];
mnemonic = null;
self.xPrivKey = null;
self.step1 = true;
self.step2 = false;
self.step3 = false;
self.step4 = false;
self.step = 1;
self.deleted = false;
self.credentialsEncrypted = false;
self.selectComplete = false;
@ -42,59 +39,17 @@ angular.module('copayApp.controllers').controller('backupController',
return mnemonic;
}
self.goToStep = function() {
if (self.step2) {
self.goToStep1();
} else if (self.step3) {
self.goToStep2();
self.goToStep = function(n) {
self.step = n;
if (self.step == 1)
init();
if (self.step == 3 && !self.mnemonicHasPassphrase)
self.step++;
if (self.step == 4) {
confirm();
}
}
self.goToStep1 = function() {
init();
$timeout(function() {
$scope.$apply();
}, 1);
}
self.goToStep2 = function() {
self.step1 = false;
self.step2 = true;
self.step3 = false;
self.step4 = false;
$timeout(function() {
$scope.$apply();
}, 1);
}
self.goToStep3 = function() {
if (self.mnemonicHasPassphrase) {
self.step1 = false;
self.step2 = false;
self.step3 = true;
self.step4 = false;
} else {
self.goToStep4();
}
$timeout(function() {
$scope.$apply();
}, 1);
}
self.goToStep4 = function() {
self.confirm();
self.step1 = false;
self.step2 = false;
self.step3 = false;
self.step4 = true;
$timeout(function() {
$scope.$apply();
}, 1);
}
function setWords(words) {
if (words) {
self.mnemonicWords = words.split(/[\u3000\s]+/);
@ -187,7 +142,7 @@ angular.module('copayApp.controllers').controller('backupController',
self.selectComplete = false;
}
self.confirm = function() {
function confirm() {
self.backupError = false;
var walletClient = bwcService.getClient();