'use strict'; angular.module('copayApp.controllers').controller('glideraController', function($rootScope, $scope, $timeout, $modal, profileService, configService, storageService, glideraService, isChromeApp, animationService, lodash) { window.ignoreMobilePause = true; this.getAuthenticateUrl = function() { return glideraService.getOauthCodeUrl(); }; this.submitOauthCode = function(code) { var self = this; var glideraTestnet = configService.getSync().glidera.testnet; var network = glideraTestnet ? 'testnet' : 'livenet'; this.loading = true; this.error = null; $timeout(function() { glideraService.getToken(code, function(err, data) { self.loading = null; if (err) { self.error = err; $timeout(function() { $scope.$apply(); }, 100); } else if (data && data.access_token) { storageService.setGlideraToken(network, data.access_token, function() { $scope.$emit('Local/GlideraUpdated', data.access_token); $timeout(function() { $scope.$apply(); }, 100); }); } }); }, 100); }; this.openTxModal = function(token, tx) { $rootScope.modalOpened = true; var self = this; var config = configService.getSync().wallet.settings; var fc = profileService.focusedClient; var ModalInstanceCtrl = function($scope, $modalInstance) { $scope.tx = tx; $scope.settings = config; $scope.color = fc.backgroundColor; $scope.noColor = true; glideraService.getTransaction(token, tx.transactionUuid, function(error, tx) { $scope.tx = tx; }); $scope.cancel = lodash.debounce(function() { $modalInstance.dismiss('cancel'); }, 0, 1000); }; var modalInstance = $modal.open({ templateUrl: 'views/modals/glidera-tx-details.html', windowClass: animationService.modalAnimated.slideRight, controller: ModalInstanceCtrl, }); var disableCloseModal = $rootScope.$on('closeModal', function() { modalInstance.dismiss('cancel'); }); modalInstance.result.finally(function() { $rootScope.modalOpened = false; disableCloseModal(); var m = angular.element(document.getElementsByClassName('reveal-modal')); m.addClass(animationService.modalAnimated.slideOutRight); }); }; });