From 608fed438663a23b2138aaf6d47ce5bfbf0efeac Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Thu, 22 Jan 2015 17:12:55 -0300 Subject: [PATCH] copy address to clipboard on mobile --- js/controllers/receive.js | 18 +++++++++++++----- views/modals/qr-address.html | 14 ++++++++++---- views/receive.html | 2 +- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/js/controllers/receive.js b/js/controllers/receive.js index 07aa6b6d8..ddb125490 100644 --- a/js/controllers/receive.js +++ b/js/controllers/receive.js @@ -1,17 +1,20 @@ 'use strict'; angular.module('copayApp.controllers').controller('ReceiveController', - function($scope, $rootScope, $timeout, $modal) { + function($scope, $rootScope, $timeout, $modal, isCordova) { $scope.newAddr = function() { var w = $rootScope.wallet; - $scope.loading = true; var lastAddr = w.generateAddress(null); $scope.setAddressList(); $scope.addr = lastAddr; - $timeout(function() { - $scope.loading = false; - }, 1); + }; + + $scope.copyAddress = function(addr) { + if (isCordova) { + window.cordova.plugins.clipboard.copy(addr); + window.plugins.toast.showShortCenter('Copied to clipboard'); + } }; $scope.init = function() { @@ -32,8 +35,13 @@ angular.module('copayApp.controllers').controller('ReceiveController', }; $scope.openAddressModal = function(address) { + var scope = $scope; var ModalInstanceCtrl = function($scope, $modalInstance, address) { $scope.address = address; + $scope.isCordova = isCordova; + $scope.copyAddress = function(addr) { + scope.copyAddress(addr); + }; $scope.cancel = function() { $modalInstance.dismiss('cancel'); diff --git a/views/modals/qr-address.html b/views/modals/qr-address.html index 78444bfa0..8654a2e96 100644 --- a/views/modals/qr-address.html +++ b/views/modals/qr-address.html @@ -1,13 +1,19 @@ -
- +
+ -
+
- {{address.address}} change + {{addr}} change
({{label}})
+
+ +
diff --git a/views/receive.html b/views/receive.html index d76f3387d..abf765ce3 100644 --- a/views/receive.html +++ b/views/receive.html @@ -10,7 +10,7 @@

My Bitcoin address:

-
+

{{addr}}