This commit is contained in:
Matias Alejo Garcia 2015-04-23 15:19:30 -03:00
commit 1515b9446f
4 changed files with 41 additions and 25 deletions

View file

@ -104,18 +104,22 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}; };
self.setTab = function(tab) { self.setTab = function(tab) {
document.getElementById(self.tab).className='tab-out tab-view ' + self.tab; if (self.tab && document.getElementById(self.tab)) {
document.getElementById(tab).className='tab-in tab-view ' + tab; document.getElementById(self.tab).className = 'tab-out tab-view ' + self.tab;
var old = document.getElementById('menu-' + self.tab);
old.className = '';
old.style.borderTopColor = '';
}
var old =document.getElementById('menu-'+self.tab); if (document.getElementById(tab)) {
old.className=''; document.getElementById(tab).className = 'tab-in tab-view ' + tab;
old.style.borderTopColor = ''; var newe = document.getElementById('menu-' + tab);
newe.className = 'active';
var newe = document.getElementById('menu-'+tab); newe.style.borderTopColor = self.backgroundColor;
newe.className='active'; }
newe.style.borderTopColor = self.backgroundColor;
self.tab = tab; self.tab = tab;
$rootScope.$emit('Local/TabChanged', tab);
}; };
self.updateAll = function(walletStatus) { self.updateAll = function(walletStatus) {
@ -472,8 +476,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
gettextCatalog.setCurrentLanguage(userLang); gettextCatalog.setCurrentLanguage(userLang);
amMoment.changeLocale(userLang); amMoment.changeLocale(userLang);
} }
} } else {
else {
configService.set({ configService.set({
wallet: { wallet: {
settings: { settings: {
@ -486,7 +489,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}); });
} }
self.defaultLanguageIsoCode = setLang || userLang; self.defaultLanguageIsoCode = setLang || userLang;
self.defaultLanguageName = lodash.result(lodash.find(self.availableLanguages, { 'isoCode': self.defaultLanguageIsoCode }), 'name'); self.defaultLanguageName = lodash.result(lodash.find(self.availableLanguages, {
'isoCode': self.defaultLanguageIsoCode
}), 'name');
}; };
// UX event handlers // UX event handlers
@ -629,8 +634,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.setTab(tab); self.setTab(tab);
}); });
$rootScope.$on('Local/NeedsPassword', function(event, isSetup, cb) { $rootScope.$on('Local/NeedsPassword', function(event, isSetup, cb) {
self.askPassword = { self.askPassword = {
isSetup: isSetup, isSetup: isSetup,

View file

@ -21,7 +21,7 @@ angular.module('copayApp.controllers').controller('topbarController', function($
}, 100); }, 100);
alert('Scanning error'); alert('Scanning error');
}); });
$scope.$emit('Local/SetTab', 'send'); go.send();
}; };
var modalOpenScanner = function() { var modalOpenScanner = function() {
@ -79,7 +79,7 @@ angular.module('copayApp.controllers').controller('topbarController', function($
$scope.init = function() { $scope.init = function() {
setScanner(); setScanner();
$timeout(function() { $timeout(function() {
$scope.$emit('Local/SetTab', 'send'); go.send();
canvas = document.getElementById('qr-canvas'); canvas = document.getElementById('qr-canvas');
context = canvas.getContext('2d'); context = canvas.getContext('2d');

View file

@ -40,10 +40,23 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
self.getAddress(); self.getAddress();
}); });
var disableTabListener = $rootScope.$on('Local/TabChanged', function(e,tab){
switch(tab) {
case 'send':
self.resetError();
self.setInputs();
case 'receive':
self.getAddress();
break;
};
});
$scope.$on('$destroy', function() { $scope.$on('$destroy', function() {
disableAddrListener(); disableAddrListener();
disableScannerListener(); disableScannerListener();
disablePaymentUriListener(); disablePaymentUriListener();
disableTabListener();
$rootScope.hideMenuBar = false; $rootScope.hideMenuBar = false;
}); });
@ -765,11 +778,4 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
return actions.hasOwnProperty('create'); return actions.hasOwnProperty('create');
}; };
// ToDo a send...
this.resetError();
this.setInputs();
// Todo Receive
this.getAddress();
}); });

View file

@ -52,9 +52,16 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope,
root.path('copayers'); root.path('copayers');
} else { } else {
root.path('walletHome'); root.path('walletHome');
$rootScope.$emit('Local/SetTab', 'walletHome');
} }
}; };
root.send = function() {
root.path('walletHome');
$rootScope.$emit('Local/SetTab', 'walletHome');
};
root.home = function() { root.home = function() {
if ($rootScope.iden) if ($rootScope.iden)
root.walletHome(); root.walletHome();