Added spinner to all buttons

This commit is contained in:
Gustavo Cortez 2014-04-24 22:43:19 -03:00
parent bea2d6cf78
commit 872cfaba68
8 changed files with 52 additions and 18 deletions

View File

@ -248,6 +248,10 @@ button.secondary { background-color: #FAE448 !important; }
button.primary:hover { background-color: #333;}
button.secondary:hover { background-color: #FFDF00 !important;}
[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
display: none !important;
}
.dn {display: none;}
.text-gray { color: #999 !important;}
.pr {position: relative;}
.m0 {margin: 0;}

BIN
img/loading.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

View File

@ -93,7 +93,7 @@
</div>
<div class="row">
<div class="row" ng-cloak class="ng-cloak">
<div class="large-12 columns" ng-view></div>
</div>
@ -110,7 +110,7 @@
<h3>Create a New Wallet</h3>
</div>
<div class="large-3 columns">
<button class="button secondary expand round" ng-click="create()">Create</button>
<button class="button secondary expand round" ng-click="create()" ng-disabled="loading" loading="Creating">Create</button>
</div>
</div>
<hr>
@ -125,7 +125,7 @@
</div>
<div class="large-3 columns">
<button class="button secondary expand round" type="button"
ng-click="open(selectedWalletId)">Open</button>
ng-click="open(selectedWalletId)" ng-disabled="loading" loading="Opening">Open</button>
</div>
</div>
<hr>
@ -139,7 +139,7 @@
</div>
<div class="large-3 columns">
<button class="button primary expand round"
ng-click="join(connectionId)">Join</button>
ng-click="join(connectionId)" ng-disabled="loading" loading="Joining">Join</button>
</div>
</div>
<hr>
@ -148,7 +148,7 @@
<div class="row">
<div class="large-12 columns">
<div ng-show="wallets.length">
<a ng-click="create()">Create a new wallet</a>
<a ng-click="create()" ng-disabled="loading" loading="Creating">Create a new wallet</a>
</div>
<a class="right" ng-click="import()">Import from file</a>
</div>
@ -245,7 +245,7 @@
</div>
<div class="large-3 columns text-center">
<p> Create a New <strong> Address </strong> </p>
<button class="secondary round expand" ng-click="newAddr()"> Create </button>
<button class="secondary round expand" ng-click="newAddr()" ng-disabled="loading" loading="Creating"> Create </button>
</div>
</div>
</div>
@ -316,10 +316,10 @@
<i class="fi-check size-40"></i> Signed by you already
</div>
<div ng-show="!tx.signedByUs && !tx.rejectedByUs && !tx.finallyRejected && tx.missingSignatures">
<button class="secondary round" ng-click="sign(tx.ntxid)">
<button class="secondary round" ng-click="sign(tx.ntxid)" ng-disabled="loading" loading="Signing">
<i class="fi-check"></i> Sign
</button>
<button class="primary round" ng-click="reject(tx.ntxid)">
<button class="primary round" ng-click="reject(tx.ntxid)" ng-disabled="loading" loading>
<i class="fi-x" ></i> Reject
</button>
</div>
@ -331,7 +331,7 @@
<span ng-show="!tx.missingSignatures && !tx.sentTs">
Transaction ready.
<button class="secondary round" ng-click="send(tx.ntxid)">
<button class="secondary round" ng-click="send(tx.ntxid)" ng-disabled="loading" loading="Broadcasting">
Broadcast Transaction
</button>
</span>
@ -443,8 +443,8 @@
</div>
</div>
<div class="row">
<div class="large-4 columns">
<button type="submit" class="button secondary round text-center" ng-disabled="sendForm.$invalid">
<div class="large-5 columns">
<button type="submit" class="button secondary round text-center" ng-disabled="sendForm.$invalid || loading" loading="Sending">
Send
</button>
</div>

View File

@ -16,12 +16,14 @@ angular.module('copay.addresses').controller('AddressesController',
$scope.isMain = isMain;
$scope.addrs = Object.keys(balanceByAddr);
$scope.selectedAddr = $scope.addrs[0];
$scope.loading = false;
$rootScope.$digest();
}
});
};
$scope.newAddr = function() {
$scope.loading = true;
w.generateAddress();
_updateBalance();
};

View File

@ -3,6 +3,7 @@
angular.module('copay.send').controller('SendController',
function($scope, $rootScope, $location) {
$scope.title = 'Send';
$scope.loading = false;
$scope.unitIds = ['BTC','mBTC'];
$scope.selectedUnit = $scope.unitIds[0];
@ -13,20 +14,24 @@ angular.module('copay.send').controller('SendController',
return;
}
$scope.loading = true;
var address = form.address.$modelValue;
var amount = (form.amount.$modelValue * 100000000).toString(); // satoshi to string
var w = $rootScope.wallet;
w.createTx( address, amount,function() {
// reset fields
$scope.address = null;
$scope.amount = null;
form.address.$pristine = true;
form.amount.$pristine = true;
$scope.loading = false;
$rootScope.flashMessage = { message: 'The transaction proposal has been created', type: 'success'};
$rootScope.$digest();
});
};
// reset fields
$scope.address = null;
$scope.amount = null;
form.address.$pristine = true;
form.amount.$pristine = true;
};
});

View File

@ -7,6 +7,7 @@ angular.module('copay.signin').controller('SigninController',
$scope.selectedWalletId = $scope.wallets.length ? $scope.wallets[0].id : null;
$scope.create = function() {
$scope.loading = true;
$location.path('setup');
};

View File

@ -5,6 +5,7 @@ angular.module('copay.transactions').controller('TransactionsController',
var bitcore = require('bitcore');
$scope.title = 'Transactions';
$scope.loading = false;
var _updateTxs = function() {
var w =$rootScope.wallet;
if (!w) return;
@ -34,9 +35,11 @@ angular.module('copay.transactions').controller('TransactionsController',
$scope.txs = txs;
w.removeListener('txProposalsUpdated',_updateTxs)
w.once('txProposalsUpdated',_updateTxs);
$scope.loading = false;
};
$scope.send = function (ntxid) {
$scope.loading = true;
var w = $rootScope.wallet;
w.sendTx(ntxid, function(txid) {
console.log('[transactions.js.68:txid:] SENTTX CALLBACK',txid); //TODO
@ -50,6 +53,7 @@ angular.module('copay.transactions').controller('TransactionsController',
};
$scope.sign = function (ntxid) {
$scope.loading = true;
var w = $rootScope.wallet;
var ret = w.sign(ntxid);
@ -84,6 +88,7 @@ angular.module('copay.transactions').controller('TransactionsController',
};
$scope.reject = function (ntxid) {
$scope.loading = true;
var w = $rootScope.wallet;
w.reject(ntxid);
$rootScope.flashMessage = {type:'warning', message: 'Transaction rejected by you'};

View File

@ -58,5 +58,22 @@ angular.module('copay.directives')
}
};
}])
.directive('loading', function () {
return {
restrict: 'A',
link: function (scope, element, attr) {
var a = element.html();
var text = attr.loading;
scope.$watch('loading', function (val) {
if (val) {
element.html('<img src="img/loading.gif"> ' + text + '...' );
}
else {
element.html(a);
}
});
}
}
})
;