diff --git a/bower.json b/bower.json
index cf1a4f301..ba78d8346 100644
--- a/bower.json
+++ b/bower.json
@@ -21,6 +21,7 @@
"bitcore": "0.1.34",
"angular-moment": "~0.7.1",
"socket.io-client": ">=1.0.0",
- "mousetrap": "1.4.6"
+ "mousetrap": "1.4.6",
+ "zeroclipboard": "~2.1.6"
}
}
diff --git a/img/icons/copy.png b/img/icons/copy.png
new file mode 100644
index 000000000..b43ca0634
Binary files /dev/null and b/img/icons/copy.png differ
diff --git a/index.html b/index.html
index acc29b64d..69fd2321f 100644
--- a/index.html
+++ b/index.html
@@ -74,6 +74,7 @@
+
diff --git a/js/directives.js b/js/directives.js
index b1d6c3b35..8601249b3 100644
--- a/js/directives.js
+++ b/js/directives.js
@@ -232,4 +232,38 @@ angular.module('copayApp.directives')
}
};
})
+ .directive('clipCopy', function() {
+ ZeroClipboard.config({
+ moviePath: '/lib/zeroclipboard/dist/ZeroClipboard.swf',
+ trustedDomains: ['*'],
+ allowScriptAccess: 'always',
+ forceHandCursor: true
+ });
+
+ return {
+ restric: 'A',
+ scope: { clipCopy: '=clipCopy' },
+ link: function(scope, elm) {
+ var client = new ZeroClipboard(elm);
+
+ client.on( 'ready', function(event) {
+ client.on( 'copy', function(event) {
+ event.clipboardData.setData('text/plain', scope.clipCopy);
+ });
+
+ client.on( 'aftercopy', function(event) {
+ elm.removeClass('btn-copy').addClass('btn-copied').html('Copied!');
+ setTimeout(function() {
+ elm.addClass('btn-copy').removeClass('btn-copied').html('');
+ }, 1000);
+ });
+ });
+
+ client.on( 'error', function(event) {
+ console.log( 'ZeroClipboard error of type "' + event.name + '": ' + event.message );
+ ZeroClipboard.destroy();
+ });
+ }
+ };
+ })
;