mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #3069 from troggy/addon/state
Allow addon menu items to run arbitrary code on click
This commit is contained in:
commit
b1b0fb929a
|
@ -1,4 +1,4 @@
|
|||
<a ng-click="index.setTab(item.link)" ng-class="{'active': index.tab == item.link}" id="menu-{{item.link}}">
|
||||
<a ng-click="index.setTab(item)" ng-class="{'active': index.tab == item.link}" id="menu-{{item.link}}">
|
||||
<i class="size-24 {{item.icon}} db"></i>
|
||||
<div class="size-10 tu">
|
||||
{{ item.title|translate }}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettextCatalog, gettext, amMoment, nodeWebkit, addonManager, feeService, isChromeApp, bwsError, utilService) {
|
||||
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettextCatalog, gettext, amMoment, nodeWebkit, addonManager, feeService, isChromeApp, bwsError, utilService, $state) {
|
||||
var self = this;
|
||||
self.isCordova = isCordova;
|
||||
self.onGoingProcess = {};
|
||||
|
@ -144,6 +144,19 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
|
||||
self.setTab = function(tab, reset, tries) {
|
||||
tries = tries || 0;
|
||||
|
||||
// check if the whole menu item passed
|
||||
if (typeof tab == 'object') {
|
||||
if (tab.open) {
|
||||
if (tab.link) {
|
||||
self.tab = tab.link;
|
||||
}
|
||||
tab.open();
|
||||
return;
|
||||
} else {
|
||||
return self.setTab(tab.link);
|
||||
}
|
||||
}
|
||||
if (self.tab === tab && !reset)
|
||||
return;
|
||||
|
||||
|
@ -153,27 +166,30 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
}, 300);
|
||||
}
|
||||
|
||||
if (!self.tab)
|
||||
if (!self.tab || !$state.is('walletHome'))
|
||||
self.tab = 'walletHome';
|
||||
|
||||
if (document.getElementById(self.tab)) {
|
||||
document.getElementById(self.tab).className = 'tab-out tab-view ' + self.tab;
|
||||
var old = document.getElementById('menu-' + self.tab);
|
||||
if (old) {
|
||||
old.className = '';
|
||||
}
|
||||
}
|
||||
go.path('walletHome', function() {
|
||||
|
||||
if (document.getElementById(tab)) {
|
||||
document.getElementById(tab).className = 'tab-in tab-view ' + tab;
|
||||
var newe = document.getElementById('menu-' + tab);
|
||||
if (newe) {
|
||||
newe.className = 'active';
|
||||
if (document.getElementById(self.tab)) {
|
||||
document.getElementById(self.tab).className = 'tab-out tab-view ' + self.tab;
|
||||
var old = document.getElementById('menu-' + self.tab);
|
||||
if (old) {
|
||||
old.className = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.tab = tab;
|
||||
$rootScope.$emit('Local/TabChanged', tab);
|
||||
if (document.getElementById(tab)) {
|
||||
document.getElementById(tab).className = 'tab-in tab-view ' + tab;
|
||||
var newe = document.getElementById('menu-' + tab);
|
||||
if (newe) {
|
||||
newe.className = 'active';
|
||||
}
|
||||
}
|
||||
|
||||
self.tab = tab;
|
||||
$rootScope.$emit('Local/TabChanged', tab);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue