Merge pull request #3869 from cmgustavo/bug/improv-open-modal

Improvement open TX modal
This commit is contained in:
Matias Alejo Garcia 2016-02-18 16:21:50 -03:00
commit 0b36c5f885
16 changed files with 348 additions and 105 deletions

View File

@ -46,7 +46,6 @@ module.exports = function(grunt) {
},
angular: {
src: [
'bower_components/fastclick/lib/fastclick.js',
'bower_components/qrcode-generator/js/qrcode.js',
'bower_components/qrcode-decoder-js/lib/qrcode-decoder.js',
'bower_components/moment/min/moment-with-locales.js',

View File

@ -16,7 +16,6 @@
"angular-ui-router": "0.2.15",
"angular-ui-switch": "0.1.1",
"animate.css": "3.4.0",
"fastclick": "1.0.6",
"foundation": "5.5.2",
"foundation-icon-fonts": "*",
"moment": "2.10.3",

View File

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" type="text/css" href="css/foundation.css">
@ -14,20 +14,19 @@
</head>
<body ng-cloak class="ng-cloak">
<div class="page"
ng-controller="indexController as index"
ng-swipe-disable-mouse
ng-swipe-left="index.closeMenu()"
ng-swipe-right="index.openMenu()">
<div class="off-canvas-wrap" id="off-canvas-wrap">
<div class="page" ng-controller="indexController as index">
<div notifications="right top"></div>
<div ng-include="'views/includes/tx-details.html'" ng-if="index.showTx"></div>
<div ng-include="'views/includes/password.html'" ng-if="index.askPassword"></div>
<div ng-include="'views/includes/alert.html'" ng-if="index.showAlert"></div>
<div ng-include="'views/includes/confirm-tx.html'" ng-if="index.confirmTx"></div>
<div class="off-canvas-wrap" id="off-canvas-wrap"
ng-swipe-disable-mouse
ng-swipe-left="index.closeMenu()"
ng-swipe-right="index.openMenu()">
<div class="inner-wrap">
<div ng-include="'views/includes/sidebar.html'" ng-if="index.hasProfile"></div>
<div notifications="right top"></div>
<div ng-include="'views/includes/password.html'" ng-if="index.askPassword"></div>
<div ng-include="'views/includes/alert.html'" ng-if="index.showAlert"></div>
<div ng-include="'views/includes/confirm-tx.html'" ng-if="index.confirmTx"></div>
<div id="sectionContainer">
<div id="mainSection">
<section ui-view="main"
@ -36,7 +35,7 @@
}"></section>
</div>
</div>
<a class="close-menu" ng-click="index.closeMenu()"></a>
<a class="close-menu" fast-click callback-fn="index.closeMenu()"></a>
</div>
</div>

View File

@ -9,7 +9,7 @@
ng-repeat="item in sidebar.wallets track by $index"
ng-class="{'selected': item.id == index.walletId}"
class="nav-item">
<a ng-click="sidebar.switchWallet(item.id, index.walletId)" class="oh">
<a fast-click callback-fn="sidebar.switchWallet(item.id, index.walletId)" class="oh">
<div class="avatar-wallet"
ng-style="{'background-color':item.color}">
<i class="icon-wallet size-21"></i>

View File

@ -3,21 +3,21 @@
ng-style="{'background-color': noColor ? '#4B6178' : index.backgroundColor}">
<section class="left-small">
<a id="hamburger" class="p10" ng-show="!goBackToState && !closeToHome && !index.noFocusedWallet"
ng-click="index.openMenu()"><i class="fi-list size-24"></i>
fast-click callback-fn="index.openMenu()"><i class="fi-list size-24"></i>
</a>
<a ng-show="goBackToState"
ng-click="$root.go(goBackToState); goBackToState = null"><i class="icon-arrow-left3 icon-back"></i>
fast-click callback-fn="$root.go(goBackToState); goBackToState = null"><i class="icon-arrow-left3 icon-back"></i>
<span class="text-back">{{'Back'|translate}}</span>
</a>
<a ng-show="closeToHome" class="p10 "
ng-click="topbar.goHome(); index.setCompactTxHistory(); closeToHome = null">
fast-click callback-fn="topbar.goHome(); index.setCompactTxHistory(); closeToHome = null">
<span class="text-close">{{'Close'|translate}}</span>
</a>
</section>
<section class="right-small" ng-show="showPreferences && !index.noFocusedWallet">
<a class="p10" ng-click="topbar.goPreferences(); index.setCompactTxHistory()">
<a class="p10" fast-click callback-fn="topbar.goPreferences(); index.setCompactTxHistory()">
<i class="fi-widget size-24"></i>
</a>
</section>

View File

@ -1,6 +1,6 @@
<div class="ng-animate-disabled row collapse last-transactions-content line-b"
ng-class="{'text-gray':!tx.pendingForUs}"
ng-click="home.openTxpModal(tx, index.copayers, !!index.glideraStatus)">
fast-click callback-fn="home.openTxpModal(tx, index.copayers, !!index.glideraStatus)">
<div class="large-6 medium-6 small-6 columns size-14">
<div class="m10r left pr">
<i class="icon-circle-active size-10" ng-show="tx.pendingForUs" ng-style="{'color':index.backgroundColor}"></i>

View File

@ -0,0 +1,159 @@
<div
ng-controller="txController as txc"
class="txModal"
ng-swipe-disable-mouse
ng-swipe-right="txc.cancel()">
<nav class="tab-bar" ng-style="{'background-color':txc.color}">
<section class="left-small">
<a ng-click="txc.cancel()">
<i class="icon-arrow-left3 icon-back"></i>
<span class="text-back" translate>Back</span>
</a>
</section>
<section class="middle tab-bar-section">
<h1 class="title ellipsis" translate>
Transaction
</h1>
</section>
</nav>
<div class="txModal-content">
<div class="header-modal text-center" ng-init="txc.getAlternativeAmount(index.showTx)">
<div ng-show="index.showTx.action != 'invalid'">
<div ng-show="index.showTx.action == 'received'">
<img src="img/icon-receive-history.svg" alt="sync" width="50">
<p class="m0 text-gray size-14" translate>Received</p>
</div>
<div ng-show="index.showTx.action == 'sent'">
<img src="img/icon-sent-history.svg" alt="sync" width="50">
<p class="m0 text-gray size-14" translate>Sent</p>
</div>
<div ng-show="index.showTx.action == 'moved'">
<img src="img/icon-moved.svg" alt="sync" width="50">
<p class="m0 text-gray size-14" translate>Moved</p>
</div>
<div class="size-36" ng-click="txc.copyToClipboard(index.showTx.amountStr)">
<span ng-if="index.showTx.action == 'received'">+</span>
<span ng-if="index.showTx.action == 'sent'">-</span>
<span class="enable_text_select">{{index.showTx.amountStr}}</span>
</div>
<div class="alternative-amount" ng-click="showRate=!showRate" ng-init="showRate = false">
<span class="label gray radius" ng-show="!showRate && alternativeAmountStr">
{{alternativeAmountStr}}
</span>
<span class="size-12" ng-show="showRate && alternativeAmountStr">
{{rateStr}} ({{rateDate | amDateFormat:'MM/DD/YYYY HH:mm a'}})
</span>
</div>
</div>
<div ng-show="index.showTx.action == 'invalid'">
-
</div>
</div>
<h4 class="title m0" translate>Details</h4>
<ul class="no-bullet size-14 m0">
<li ng-if="!index.showTx.hasMultiplesOutputs && index.showTx.addressTo && index.showTx.addressTo != 'N/A'" class="line-b p10 oh"
ng-click="txc.copyToClipboard(index.showTx.addressTo)">
<span class="text-gray" translate>To</span>
<span class="right">
<span ng-if="index.showTx.merchant">
<span ng-show="index.showTx.merchant.pr.ca"><i class="fi-lock color-greeni"></i> {{index.showTx.merchant.domain}}</span>
<span ng-show="!index.showTx.merchant.pr.ca"><i class="fi-unlock color-yellowi"></i> {{index.showTx.merchant.domain}}</span>
</span>
<span ng-if="!index.showTx.merchant">
<span ng-show="index.showTx.labelTo">{{index.showTx.labelTo}}</span>
<contact ng-show="!index.showTx.labelTo" class="enable_text_select" address="{{index.showTx.addressTo}}"></contact>
</span>
</span>
</li>
<li ng-show="index.showTx.hasMultiplesOutputs" class="line-b p10 oh"
ng-click="showMultiplesOutputs = !showMultiplesOutputs">
<span class="text-gray" translate>Recipients</span>
<span class="right">{{index.showTx.recipientCount}}
<i ng-show="showMultiplesOutputs" class="icon-arrow-up3 size-24"></i>
<i ng-show="!showMultiplesOutputs" class="icon-arrow-down3 size-24"></i>
</span>
</li>
<div class="line-b" ng-show="index.showTx.hasMultiplesOutputs && showMultiplesOutputs"
ng-repeat="output in index.showTx.outputs"
ng-include="'views/includes/output.html'">
</div>
<li ng-if="index.showTx.action == 'invalid'" class="line-b p10 oh">
<span class="right" translate>
This transaction has become invalid; possibly due to a double spend attempt.
</span>
<li ng-if="index.showTx.time" class="line-b p10 oh">
<span class="text-gray" translate>Date</span>
<span class="right enable_text_select">
<time>{{ index.showTx.time * 1000 | amDateFormat:'MM/DD/YYYY HH:mm a'}}</time>
<time>({{ index.showTx.time * 1000 | amTimeAgo}})</time>
</span>
</li>
<li class="line-b p10" ng-show="index.showTx.action != 'received'"
ng-click="txc.copyToClipboard(index.showTx.feeStr)">
<span class="text-gray" translate>Fee</span>
<span class="right enable_text_select">{{index.showTx.feeStr}}</span>
</li>
<li class="line-b p10 oh" ng-if="index.showTx.message && index.showTx.action != 'received'"
ng-click="txc.copyToClipboard(index.showTx.message)">
<span class="text-gray" translate>Note</span>
<span class="right enable_text_select">{{index.showTx.message}}</span>
</li>
<li ng-if="index.showTx.merchant" class="line-b p10 oh"
ng-click="txc.copyToClipboard(index.showTx.merchant.pr.pd.memo)">
<span class="text-gray" translate>Merchant message</span>
<span class="right enable_text_select">
{{index.showTx.merchant.pr.pd.memo}}
</span>
</li>
<li ng-if="index.showTx.time" class="line-b p10 oh">
<span class="text-gray" translate>Confirmations</span>
<span class="right" >
<span class="text-warning" ng-show="!index.showTx.confirmations || index.showTx.confirmations == 0" translate>
Unconfirmed
</span>
<span class="label gray radius" ng-show="index.showTx.confirmations>0 && !index.showTx.safeConfirmed">
{{index.showTx.confirmations}}
</span>
<span class="label gray radius" ng-show="index.showTx.safeConfirmed">
{{index.showTx.safeConfirmed}}
</span>
</span>
</li>
</ul>
<div ng-if="index.showTx.actions[0] && txc.isShared">
<h4 class="title m0" translate>Participants</h4>
<ul class="no-bullet size-14 m0">
<li class="line-b p10 text-gray" ng-repeat="c in index.showTx.actions">
<i class="icon-contact size-24"></i>
<span class="right">
<i ng-if="c.type == 'reject'" class="fi-x icon-sign x db"></i>
<i ng-if="c.type == 'accept'" class="fi-check icon-sign check db"></i>
</span>
{{c.copayerName}} <span ng-if="c.copayerId == txc.copayerId">({{'Me'|translate}})</span>
</li>
</ul>
</div>
<div ng-show="index.showTx.txid" class="tx-details-blockchain">
<div class="text-center m20t">
<button class="button outline round dark-gray tiny" ng-click="$root.openExternalLink('https://' +
(txc.getShortNetworkName() == 'test' ? 'test-' : '') + 'insight.bitpay.com/tx/' + index.showTx.txid)">
<span class="text-gray" translate>See it on the blockchain</span>
</button>
</div>
</div>
<div class="extra-margin-bottom"></div>
</div>
</div>

View File

@ -1,7 +1,7 @@
<div ng-init="wallets[0] ? selectedWalletsOpt = true : selectedWalletsOpts = false; checkClipboard()">
<nav class="tab-bar" ng-style="{'background-color':color}">
<section class="left-small">
<a ng-show="!editAddressbook && !addAddressbookEntry" ng-click="cancel()" class="p10">
<a ng-show="!editAddressbook && !addAddressbookEntry" fast-click callback-fn="cancel()" class="p10">
<span class="text-close" translate>Close</span>
</a>
</section>
@ -30,16 +30,14 @@
ng-style="{'border-color':selectedWalletsOpt ? color : 'inherit'}"
ng-click="selectedWalletsOpt = true">
<a href
ng-style="{'color':selectedWalletsOpt ? color : 'inherit'}"
ng-click="create.setTotalCopayers(1)" translate> My wallets</a>
ng-style="{'color':selectedWalletsOpt ? color : 'inherit'}" translate> My wallets</a>
</div>
<div class="tab-container small-6 medium-3 large-2"
ng-class="{'selected':!selectedWalletsOpt}"
ng-style="{'border-color':!selectedWalletsOpt ? color : 'inherit'}"
ng-click="selectedWalletsOpt = false">
<a href
ng-style="{'color':!selectedWalletsOpt ? color : 'inherit'}"
ng-click="create.setTotalCopayers(3)" translate>My contacts</a>
ng-style="{'color':!selectedWalletsOpt ? color : 'inherit'}" translate>My contacts</a>
</div>
</div>
</div>

View File

@ -199,7 +199,7 @@
</div>
<div ng-repeat="btx in index.txHistory"
ng-click="home.openTxModal(btx)"
fast-click callback-fn="home.openTxModal(btx)"
class="row collapse last-transactions-content">
<div class="large-6 medium-6 small-6 columns size-14">
<div class="m10r left">
@ -404,7 +404,7 @@
</div>
<a class="postfix size-12 m0 text-gray"
ng-style="{'color':index.backgroundColor}"
ng-click="home.openDestinationAddressModal(index.otherWallets, _address)">
fast-click callback-fn="home.openDestinationAddressModal(index.otherWallets, _address)">
<i class="icon-wallet text-bold size-18"></i>
</a>
</div>

View File

@ -73,7 +73,7 @@ h4.title a {
}
.preferences h4, .modal-content h4, .glidera h4 {
.preferences h4, .modal-content h4, .glidera h4, .txModal h4 {
background: #F6F7F9;
padding: 25px 0px 5px 10px;
text-transform: uppercase;
@ -88,7 +88,7 @@ h4.title a {
}
.preferences ul, .modal-content ul {
.preferences ul, .modal-content ul, .txModal ul {
font-size:14px;
background: white;
}
@ -1399,7 +1399,21 @@ input.ng-invalid-match, input.ng-invalid-match:focus {
border-top-right-radius: 5px;
}
/*******************/
.txModal-content {
overflow: auto;
height: 100%;
padding-bottom: 50px;
}
.txModal {
background: #f6f7f9;
position: absolute;
width: 100%;
top: 0;
bottom: 0;
overflow: hidden;
z-index: 1100;
}
.alertModal {
background: #FFFFFF;

View File

@ -644,6 +644,8 @@ body.modal-open {
.reveal-modal.animated.slideInRight,
.reveal-modal.animated.slideOutRight,
.txModal.animated.slideInRight,
.txModal.animated.slideOutRight,
.reveal-modal.animated.fadeOutUp,
.reveal-modal.animated.slideInUp,
.reveal-modal.animated.slideInDown {

View File

@ -1344,6 +1344,13 @@ angular.module('copayApp.controllers').controller('indexController', function($r
});
});
$rootScope.$on('Local/TxModal', function(event, tx) {
self.showTx = tx;
$timeout(function() {
$rootScope.$apply();
});
});
$rootScope.$on('NewIncomingTx', function() {
self.newTx = true;
self.updateAll({

75
src/js/controllers/tx.js Normal file
View File

@ -0,0 +1,75 @@
'use strict';
angular.module('copayApp.controllers').controller('txController',
function($rootScope, $scope, $timeout, $filter, lodash, profileService, isCordova, nodeWebkit, configService, animationService, gettextCatalog) {
var fc = profileService.focusedClient;
var config = configService.getSync();
var configWallet = config.wallet;
var walletSettings = configWallet.settings;
var m = angular.element(document.getElementsByClassName('txModal'));
m.addClass(animationService.modalAnimated.slideRight);
this.alternativeIsoCode = walletSettings.alternativeIsoCode;
this.color = fc.backgroundColor;
this.copayerId = fc.credentials.copayerId;
this.isShared = fc.credentials.n > 1;
if (isCordova) {
$rootScope.modalOpened = true;
var self = this;
var disableCloseModal = $rootScope.$on('closeModal', function() {
self.cancel();
});
}
this.getAlternativeAmount = function(btx) {
var self = this;
var satToBtc = 1 / 100000000;
fc.getFiatRate({
code: self.alternativeIsoCode,
ts: btx.time * 1000
}, function(err, res) {
if (err) {
$log.debug('Could not get historic rate');
return;
}
if (res && res.rate) {
var alternativeAmountBtc = (btx.amount * satToBtc).toFixed(8);
$scope.rateDate = res.fetchedOn;
$scope.rateStr = res.rate + ' ' + self.alternativeIsoCode;
$scope.alternativeAmountStr = $filter('noFractionNumber')(alternativeAmountBtc * res.rate, 2) + ' ' + self.alternativeIsoCode;
$scope.$apply();
}
});
};
this.getShortNetworkName = function() {
var n = fc.credentials.network;
return n.substring(0, 4);
};
this.copyToClipboard = function(value) {
if (isCordova) {
window.cordova.plugins.clipboard.copy(value);
window.plugins.toast.showShortCenter(gettextCatalog.getString('Copied to clipboard'));
} else if (nodeWebkit.isDefined()) {
nodeWebkit.writeToClipboard(value);
}
};
this.cancel = lodash.debounce(function() {
m.addClass(animationService.modalAnimated.slideOutRight);
if (isCordova) {
$rootScope.modalOpened = false;
disableCloseModal();
$timeout(function() {
$rootScope.$emit('Local/TxModal', null);
}, 350);
} else {
$rootScope.$emit('Local/TxModal', null);
}
}, 0, 1000);
});

View File

@ -1149,77 +1149,8 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
return this.alternativeIsoCode;
};
this.openTxModal = function(btx) {
$rootScope.modalOpened = true;
var self = this;
var fc = profileService.focusedClient;
var ModalInstanceCtrl = function($scope, $filter, $log, $modalInstance) {
$scope.btx = btx;
$scope.settings = walletSettings;
$scope.color = fc.backgroundColor;
$scope.copayerId = fc.credentials.copayerId;
$scope.isShared = fc.credentials.n > 1;
$scope.getAlternativeAmount = function() {
var satToBtc = 1 / 100000000;
fc.getFiatRate({
code: self.alternativeIsoCode,
ts: btx.time * 1000
}, function(err, res) {
if (err) {
$log.debug('Could not get historic rate');
return;
}
if (res && res.rate) {
var alternativeAmountBtc = (btx.amount * satToBtc).toFixed(8);
$scope.rateDate = res.fetchedOn;
$scope.rateStr = res.rate + ' ' + self.alternativeIsoCode;
$scope.alternativeAmountStr = $filter('noFractionNumber')(alternativeAmountBtc * res.rate, 2) + ' ' + self.alternativeIsoCode;
$scope.$apply();
}
});
};
$scope.getAmount = function(amount) {
return self.getAmount(amount);
};
$scope.getUnitName = function() {
return self.getUnitName();
};
$scope.getShortNetworkName = function() {
var n = fc.credentials.network;
return n.substring(0, 4);
};
$scope.copyToClipboard = function(addr) {
if (!addr) return;
self.copyToClipboard(addr);
};
$scope.cancel = lodash.debounce(function() {
$modalInstance.dismiss('cancel');
}, 0, 1000);
};
var modalInstance = $modal.open({
templateUrl: 'views/modals/tx-details.html',
windowClass: animationService.modalAnimated.slideRight,
controller: ModalInstanceCtrl,
});
var disableCloseModal = $rootScope.$on('closeModal', function() {
modalInstance.dismiss('cancel');
});
modalInstance.result.finally(function() {
$rootScope.modalOpened = false;
disableCloseModal();
var m = angular.element(document.getElementsByClassName('reveal-modal'));
m.addClass(animationService.modalAnimated.slideOutRight);
});
this.openTxModal = function(tx) {
$rootScope.$emit('Local/TxModal', tx);
};
this.hasAction = function(actions, action) {

View File

@ -317,4 +317,65 @@ angular.module('copayApp.directives')
replace: true,
templateUrl: 'views/includes/available-balance.html'
}
});
})
.directive('fastClick', [ 'isCordova', '$timeout', function(isCordova, $timeout) {
return {
scope: { someCtrlFn: '&callbackFn'},
link: function(scope, element, attrs) {
if (!isCordova) {
element.on('click', function(){
scope.someCtrlFn();
});
} else {
var trackingClick = false;
var targetElement = null;
var touchStartX = 0;
var touchStartY = 0;
var touchBoundary = 10;
element.on('touchstart', function(event) {
trackingClick = true;
targetElement = event.target;
touchStartX = event.targetTouches[0].pageX;
touchStartY = event.targetTouches[0].pageY;
return true;
});
element.on('touchend', function(event) {
if (trackingClick) {
scope.someCtrlFn();
event.preventDefault();
}
trackingClick = false;
return false;
});
element.on('touchmove', function(event) {
if (!trackingClick) {
return true;
}
// If the touch has moved, cancel the click tracking
if (targetElement !== event.target
|| (Math.abs(event.changedTouches[0].pageX - touchStartX) > touchBoundary
|| (Math.abs(event.changedTouches[0].pageY - touchStartY) > touchBoundary))) {
trackingClick = false;
targetElement = null;
}
return true;
});
element.on('touchcancel', function() {
trackingClick = false;
targetElement = null;
});
}
}
}
}]);
;

View File

@ -511,7 +511,6 @@ angular
});
})
.run(function($rootScope, $state, $log, uriHandler, isCordova, profileService, $timeout, nodeWebkit, uxLanguage, animationService) {
FastClick.attach(document.body);
uxLanguage.init();