2016-09-05 14:59:11 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
2016-10-12 08:57:08 -04:00
|
|
|
angular.module('copayApp.services').service('externalLinkService', function(platformInfo, nodeWebkitService, popupService, gettextCatalog) {
|
2016-09-05 14:59:11 -03:00
|
|
|
|
2016-10-12 11:19:09 -04:00
|
|
|
this.open = function(url, optIn, title, desc, okText, cancelText) {
|
2016-10-12 11:40:14 -03:00
|
|
|
var old = $window.handleOpenURL;
|
|
|
|
|
|
|
|
|
|
$window.handleOpenURL = function(url) {
|
|
|
|
|
// Ignore external URLs
|
|
|
|
|
$log.debug('Skip: ' + url);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$timeout(function() {
|
|
|
|
|
$window.handleOpenURL = old;
|
|
|
|
|
}, 500);
|
|
|
|
|
|
2016-09-05 14:59:11 -03:00
|
|
|
if (platformInfo.isNW) {
|
|
|
|
|
nodeWebkitService.openExternalLink(url);
|
|
|
|
|
} else {
|
2016-10-12 11:19:09 -04:00
|
|
|
var message = gettextCatalog.getString(desc),
|
|
|
|
|
title = gettextCatalog.getString(title),
|
2016-10-12 08:57:08 -04:00
|
|
|
openBrowser = function(res) {
|
|
|
|
|
if (res) window.open(url, '_system');
|
|
|
|
|
};
|
2016-10-12 11:19:09 -04:00
|
|
|
popupService.showConfirm(title, message, 'Open', 'Cancel', openBrowser);
|
2016-09-05 14:59:11 -03:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
});
|