Ref About
This commit is contained in:
parent
9908046766
commit
a200d42bcd
25 changed files with 208 additions and 171 deletions
14
src/js/services/externalLinkService.js
Normal file
14
src/js/services/externalLinkService.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').service('externalLinkService', function(platformInfo, nodeWebkitService) {
|
||||
|
||||
this.open = function(url, target) {
|
||||
if (platformInfo.isNW) {
|
||||
nodeWebkitService.openExternalLink(url);
|
||||
} else {
|
||||
target = target || '_blank';
|
||||
var ref = window.open(url, target, 'location=no');
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('nodeWebkit', function nodeWebkitFactory() {
|
||||
var root = {};
|
||||
|
||||
var isNodeWebkit = function() {
|
||||
var isNode = (typeof process !== "undefined" && typeof require !== "undefined");
|
||||
if(isNode) {
|
||||
try {
|
||||
return (typeof require('nw.gui') !== "undefined");
|
||||
} catch(e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
root.readFromClipboard = function() {
|
||||
if (!isNodeWebkit()) return;
|
||||
var gui = require('nw.gui');
|
||||
var clipboard = gui.Clipboard.get();
|
||||
return clipboard.get();
|
||||
};
|
||||
|
||||
root.writeToClipboard = function(text) {
|
||||
if (!isNodeWebkit()) return;
|
||||
var gui = require('nw.gui');
|
||||
var clipboard = gui.Clipboard.get();
|
||||
return clipboard.set(text);
|
||||
};
|
||||
|
||||
root.openExternalLink = function(url) {
|
||||
if (!isNodeWebkit()) return;
|
||||
var gui = require('nw.gui');
|
||||
return gui.Shell.openExternal(url);
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
22
src/js/services/nodeWebkitService.js
Normal file
22
src/js/services/nodeWebkitService.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').service('nodeWebkitService', function() {
|
||||
|
||||
this.readFromClipboard = function() {
|
||||
var gui = require('nw.gui');
|
||||
var clipboard = gui.Clipboard.get();
|
||||
return clipboard.get();
|
||||
};
|
||||
|
||||
this.writeToClipboard = function(text) {
|
||||
var gui = require('nw.gui');
|
||||
var clipboard = gui.Clipboard.get();
|
||||
return clipboard.set(text);
|
||||
};
|
||||
|
||||
this.openExternalLink = function(url) {
|
||||
var gui = require('nw.gui');
|
||||
return gui.Shell.openExternal(url);
|
||||
};
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue