Wallet/src/js/directives/incomingDataMenu.js

54 lines
1.8 KiB
JavaScript
Raw Normal View History

2016-10-13 18:29:03 -04:00
'use strict';
angular.module('copayApp.directives')
2016-10-18 18:06:50 -04:00
.directive('incomingDataMenu', function($timeout, $rootScope, $state, externalLinkService) {
2016-10-13 18:29:03 -04:00
return {
restrict: 'E',
templateUrl: 'views/includes/incomingDataMenu.html',
link: function(scope, element, attrs) {
$rootScope.$on('incomingDataMenu.showMenu', function(event, data) {
2016-10-14 15:21:16 -04:00
$timeout(function() {
scope.data = data.data;
scope.type = data.type;
2016-10-14 15:21:16 -04:00
scope.showMenu = true;
2016-10-18 18:39:23 -04:00
console.log('scope.type', scope.type);
if(scope.type === 'url') {
console.log('scope.data', scope.data);
console.log('scope.data.indexOf("https://")', scope.data.indexOf('https://'));
if(scope.data.indexOf('https://') === 0) {
scope.https = true;
}
}
console.log('data', data);
2016-10-14 15:21:16 -04:00
});
});
2016-10-14 15:54:20 -04:00
scope.hide = function() {
scope.showMenu = false;
$rootScope.$broadcast('incomingDataMenu.menuHidden');
2016-10-14 15:54:20 -04:00
};
2016-10-18 18:06:50 -04:00
scope.goToUrl = function(url){
externalLinkService.open(url);
};
scope.sendPaymentToAddress = function(bitcoinAddress) {
scope.showMenu = false;
2016-10-18 17:23:43 -04:00
$state.go('tabs.send').then(function() {
$timeout(function() {
$state.transitionTo('tabs.send.amount', {toAddress: bitcoinAddress});
}, 50);
2016-10-18 17:23:43 -04:00
});
};
2016-10-18 16:36:47 -04:00
scope.addToAddressBook = function(bitcoinAddress) {
scope.showMenu = false;
2016-10-18 16:36:47 -04:00
$timeout(function() {
2016-10-18 17:23:43 -04:00
$state.go('tabs.send').then(function() {
$timeout(function() {
$state.transitionTo('tabs.send.addressbook', {addressbookEntry: bitcoinAddress});
}, 10);
});
2016-10-18 16:36:47 -04:00
}, 100);
};
2016-10-13 18:29:03 -04:00
}
};
});