+
{{a.address}}
{{(a.amount/1e8).toFixed(8)}} BTC
diff --git a/public/views/tab-receive.html b/public/views/tab-receive.html
index f6738ef3a..956f42ae5 100644
--- a/public/views/tab-receive.html
+++ b/public/views/tab-receive.html
@@ -6,7 +6,7 @@
-
+
@@ -50,7 +50,8 @@ Error: {{addrError}}
- {{generatingAddress ? '...' : addr}}
+ ...
+ {{addr}}
diff --git a/src/js/app.js b/src/js/app.js
index 3e32f68ba..d4cd8448c 100644
--- a/src/js/app.js
+++ b/src/js/app.js
@@ -5,6 +5,8 @@ var modules = [
'monospaced.qrcode',
'gettext',
'ionic',
+ 'ionic-toast',
+ 'angular-clipboard',
'ngLodash',
'ngCsv',
'bwcModule',
diff --git a/src/js/controllers/modals/txDetails.js b/src/js/controllers/modals/txDetails.js
index af965d34a..84ca22954 100644
--- a/src/js/controllers/modals/txDetails.js
+++ b/src/js/controllers/modals/txDetails.js
@@ -85,11 +85,6 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
return n.substring(0, 4);
};
- $scope.copyToClipboard = function(addr, $event) {
- if (!addr) return;
- self.copyToClipboard(addr, $event);
- };
-
$scope.cancel = function() {
$scope.txDetailsModal.hide();
};
diff --git a/src/js/controllers/modals/txpDetails.js b/src/js/controllers/modals/txpDetails.js
index 3cb586fa0..5e9b89f8a 100644
--- a/src/js/controllers/modals/txpDetails.js
+++ b/src/js/controllers/modals/txpDetails.js
@@ -8,7 +8,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
var now = Math.floor(Date.now() / 1000);
$scope.loading = null;
-
+
$scope.copayerId = $scope.wallet.credentials.copayerId;
$scope.isShared = $scope.wallet.credentials.n > 1;
$scope.canSign = $scope.wallet.canSign() || $scope.wallet.isPrivKeyExternal();
@@ -187,11 +187,6 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
});
};
- $scope.copyToClipboard = function(addr, $event) {
- if (!addr) return;
- self.copyToClipboard(addr, $event);
- };
-
$scope.close = function(txp) {
$scope.loading = null;
if (txp) {
diff --git a/src/js/controllers/preferencesInformation.js b/src/js/controllers/preferencesInformation.js
index 1ee39ba21..ac2f205bc 100644
--- a/src/js/controllers/preferencesInformation.js
+++ b/src/js/controllers/preferencesInformation.js
@@ -113,13 +113,6 @@ angular.module('copayApp.controllers').controller('preferencesInformation',
save('#202020');
};
- $scope.copyToClipboard = function(data) {
- if ($scope.isCordova) {
- window.cordova.plugins.clipboard.copy(data);
- window.plugins.toast.showShortCenter(gettextCatalog.getString('Copied to clipboard'));
- }
- };
-
$scope.scan = function() {
walletService.startScan(wallet);
$state.go('tabs.home');
diff --git a/src/js/controllers/tab-receive.js b/src/js/controllers/tab-receive.js
index 50c80bcbd..28ede85ad 100644
--- a/src/js/controllers/tab-receive.js
+++ b/src/js/controllers/tab-receive.js
@@ -32,39 +32,6 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
});
}
- $scope.copyToClipboard = function(addr, $event) {
-
- var showPopover = function() {
-
- $ionicPopover.fromTemplateUrl('views/includes/copyToClipboard.html', {
- scope: $scope
- }).then(function(popover) {
- $scope.popover = popover;
- $scope.popover.show($event);
- });
-
- $scope.close = function() {
- $scope.popover.hide();
- }
-
- $timeout(function() {
- $scope.popover.hide(); //close the popover after 0.7 seconds
- }, 700);
-
- $scope.$on('$destroy', function() {
- $scope.popover.remove();
- });
- };
-
- if ($scope.isCordova) {
- window.cordova.plugins.clipboard.copy(addr);
- window.plugins.toast.showShortCenter(gettextCatalog.getString('Copied to clipboard'));
- } else if ($scope.isNW) {
- nodeWebkit.writeToClipboard(addr);
- showPopover($event);
- }
- };
-
$scope.shareAddress = function(addr) {
if ($scope.isCordova) {
window.plugins.socialsharing.share('bitcoin:' + addr, null, null, null);
diff --git a/src/js/directives/copyToClipboard.js b/src/js/directives/copyToClipboard.js
new file mode 100644
index 000000000..50165b70a
--- /dev/null
+++ b/src/js/directives/copyToClipboard.js
@@ -0,0 +1,39 @@
+'use strict';
+
+angular.module('copayApp.directives')
+ .directive('copyToClipboard', function(platformInfo, gettextCatalog, ionicToast, clipboard) {
+ return {
+ restrict: 'A',
+ scope: {
+ copyToClipboard: '=copyToClipboard'
+ },
+ link: function(scope, elem, attrs, ctrl) {
+ var isCordova = platformInfo.isCordova;
+ var isChromeApp = platformInfo.isChromeApp;
+ var isNW = platformInfo.isNW;
+ elem.bind('mouseover', function() {
+ elem.css('cursor', 'pointer');
+ });
+
+ var msg = gettextCatalog.getString('Copied to clipboard');
+ elem.bind('click', function() {
+ var data = scope.copyToClipboard;
+ if (isCordova) {
+ window.cordova.plugins.clipboard.copy(data);
+ window.plugins.toast.showShortCenter(msg);
+ } else if (isNW) {
+ nodeWebkit.writeToClipboard(data);
+ scope.$apply(function() {
+ ionicToast.show(msg, 'bottom', false, 1000);
+ });
+ } else if (clipboard.supported) {
+ clipboard.copyText(data);
+ scope.$apply(function() {
+ ionicToast.show(msg, 'bottom', false, 1000);
+ });
+ }
+ });
+ }
+ }
+ });
+
diff --git a/test/karma.conf.js b/test/karma.conf.js
index 0756f48fb..8274b222f 100644
--- a/test/karma.conf.js
+++ b/test/karma.conf.js
@@ -24,6 +24,8 @@ module.exports = function(config) {
'bower_components/angular-qrcode/angular-qrcode.js',
'bower_components/angular-gettext/dist/angular-gettext.js',
'bower_components/ng-csv/build/ng-csv.js',
+ 'bower_components/ionic-toast/dist/ionic-toast.bundle.min.js',
+ 'bower_components/angular-clipboard/angular-clipboard.js',
'bower_components/angular-mocks/angular-mocks.js',
'angular-pbkdf2/angular-pbkdf2.js',
'angular-bitcore-wallet-client/angular-bitcore-wallet-client.js',