clipboard service

This commit is contained in:
Sebastiaan Pasma 2018-06-28 10:52:06 +02:00
commit 8006af279b
2 changed files with 30 additions and 19 deletions

View file

@ -0,0 +1,28 @@
'use strict';
angular.module('copayApp.services').factory('clipboardService', function ($http, $log, platformInfo, nodeWebkitService, gettextCatalog, ionicToast, clipboard) {
var root = {};
root.copyToClipboard = function (data, scope) {
var msg = gettextCatalog.getString('Copied to clipboard');
if (!data) return;
if (platformInfo.isCordova) {
cordova.plugins.clipboard.copy(data);
} else if (platformInfo.isNW) {
nodeWebkitService.writeToClipboard(data);
} else if (clipboard.supported) {
clipboard.copyText(data);
} else {
// No supported
return;
}
scope.$apply(function () {
ionicToast.show(msg, 'bottom', false, 1000);
});
};
return root;
});