copay/old/go.js

83 lines
1.9 KiB
JavaScript
Raw Normal View History

2014-12-07 07:44:50 -08:00
'use strict';
2016-05-18 11:15:14 -07:00
angular.module('copayApp.services').factory('go', function($window, $ionicSideMenuDelegate, $rootScope, $location, $state, $timeout, $log, profileService, platformInfo, nodeWebkit) {
2014-12-07 07:44:50 -08:00
var root = {};
root.openExternalLink = function(url, target) {
2016-05-18 11:15:14 -07:00
if (platformInfo.isNW) {
2015-05-28 06:52:33 -07:00
nodeWebkit.openExternalLink(url);
2015-11-24 12:16:52 -08:00
} else {
target = target || '_blank';
var ref = window.open(url, target, 'location=no');
2015-05-28 06:52:33 -07:00
}
2014-12-09 11:11:56 -08:00
};
root.is = function(name) {
return $state.is(name);
};
root.path = function(path, cb) {
$state.transitionTo(path)
.then(function() {
if (cb) return cb();
2015-05-18 08:43:15 -07:00
}, function() {
if (cb) return cb('animation in progress');
});
2014-12-07 07:44:50 -08:00
};
2016-05-18 11:15:14 -07:00
root.toggleLeftMenu = function() {
2016-05-18 13:28:12 -07:00
$ionicSideMenuDelegate.toggleLeft();
};
root.walletHome = function() {
2016-08-19 09:14:23 -07:00
var wallet = profileService.getWallet($stateParams.walletId);
if (wallet && !wallet.isComplete()) {
2016-08-17 20:27:23 -07:00
$log.debug("Wallet not complete at startup... redirecting");
2016-08-19 09:14:23 -07:00
$state.transitionTo('wallet.details', {
walletId: wallet.credentials.walletId
})
} else {
2016-08-17 11:23:17 -07:00
root.path('tabs.home');
}
};
2016-08-17 15:25:07 -07:00
root.confirm = function(params) {
$state.transitionTo('send.confirm', params)
2016-08-17 15:25:07 -07:00
};
2015-04-23 11:19:30 -07:00
root.send = function() {
2016-08-17 11:23:17 -07:00
root.path('tabs.send');
2015-04-23 11:19:30 -07:00
};
2015-03-06 07:00:10 -08:00
root.addWallet = function() {
$state.transitionTo('add');
2015-03-06 07:00:10 -08:00
};
2015-03-06 07:00:10 -08:00
root.preferences = function() {
$state.transitionTo('preferences');
2015-03-06 07:00:10 -08:00
};
root.preferencesGlobal = function() {
2016-08-15 13:42:04 -07:00
$state.transitionTo('tabs.settings');
};
2015-03-06 07:00:10 -08:00
root.reload = function() {
$state.reload();
};
2014-12-10 07:07:26 -08:00
// Global go. This should be in a better place TODO
2016-01-16 15:04:01 -08:00
// We don't do a 'go' directive, to use the benefits of ng-touch with ng-click
2015-03-06 07:00:10 -08:00
$rootScope.go = function(path) {
2014-12-10 07:07:26 -08:00
root.path(path);
};
$rootScope.openExternalLink = function(url, target) {
root.openExternalLink(url, target);
2014-12-10 07:07:26 -08:00
};
2014-12-07 07:44:50 -08:00
return root;
});