From 9fedae1a674699bd516b95b806e1df2216446fd0 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Wed, 10 Feb 2016 15:35:26 -0500 Subject: [PATCH] Updates tx modal --- public/views/includes/tx-details.html | 1 - public/views/walletHome.html | 16 +----- src/css/main.css | 6 +-- src/js/controllers/tx.js | 33 ++++++++---- src/js/controllers/walletHome.js | 75 +-------------------------- src/js/directives/directives.js | 1 - 6 files changed, 27 insertions(+), 105 deletions(-) diff --git a/public/views/includes/tx-details.html b/public/views/includes/tx-details.html index ad356c598..86315a5a2 100644 --- a/public/views/includes/tx-details.html +++ b/public/views/includes/tx-details.html @@ -1,7 +1,6 @@
diff --git a/public/views/walletHome.html b/public/views/walletHome.html index a2adaac87..d3558256d 100644 --- a/public/views/walletHome.html +++ b/public/views/walletHome.html @@ -199,21 +199,7 @@
diff --git a/src/css/main.css b/src/css/main.css index f03714489..07083ee56 100644 --- a/src/css/main.css +++ b/src/css/main.css @@ -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; } @@ -1400,7 +1400,7 @@ input.ng-invalid-match, input.ng-invalid-match:focus { } .txModal { - background: #FFFFFF; + background: #f6f7f9; border-radius: 5px; position: absolute; width: 100%; diff --git a/src/js/controllers/tx.js b/src/js/controllers/tx.js index 5d4de53ba..f39ab69ab 100644 --- a/src/js/controllers/tx.js +++ b/src/js/controllers/tx.js @@ -1,21 +1,31 @@ 'use strict'; angular.module('copayApp.controllers').controller('txController', - function($rootScope, $scope, $timeout, profileService, notification, go, gettext, isCordova, nodeWebkit) { + function($rootScope, $scope, $timeout, $filter, lodash, profileService, isCordova, nodeWebkit, configService, animationService) { 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) { - $scope.modalOpening = true; - $timeout(function() { - $scope.modalOpening = false; - }, 300); + $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, @@ -48,18 +58,19 @@ angular.module('copayApp.controllers').controller('txController', } else if (nodeWebkit.isDefined()) { nodeWebkit.writeToClipboard(addr); } - }; + }; - this.cancel = function() { + this.cancel = lodash.debounce(function() { + m.addClass(animationService.modalAnimated.slideOutRight); if (isCordova) { - $scope.modalClosing = true; + $rootScope.modalOpened = false; + disableCloseModal(); $timeout(function() { - $scope.modalClosing = false; $rootScope.$emit('Local/TxModal', null); - }, 300); + }, 350); } else { $rootScope.$emit('Local/TxModal', null); } - }; + }, 0, 1000); }); diff --git a/src/js/controllers/walletHome.js b/src/js/controllers/walletHome.js index d2f13f912..5bbb9ae88 100644 --- a/src/js/controllers/walletHome.js +++ b/src/js/controllers/walletHome.js @@ -1149,83 +1149,10 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi return this.alternativeIsoCode; }; - this.openNewTxModal = function(tx) { + this.openTxModal = function(tx) { $rootScope.$emit('Local/TxModal', tx); }; - 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.hasAction = function(actions, action) { return actions.hasOwnProperty('create'); }; diff --git a/src/js/directives/directives.js b/src/js/directives/directives.js index d3be47c24..f3f725538 100644 --- a/src/js/directives/directives.js +++ b/src/js/directives/directives.js @@ -326,7 +326,6 @@ angular.module('copayApp.directives') if (!isCordova) { element.on('click', function(){ scope.someCtrlFn(); - console.log('click real'); }); } else { var trackingClick = false;