Allow addons menu items to run arbitrary code on click
This would allow for addon to have separate view, not only tab view in home contoller.
This commit is contained in:
parent
be61c3039c
commit
89bf65b97c
2 changed files with 33 additions and 17 deletions
|
|
@ -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 = {};
|
||||
|
|
@ -143,6 +143,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;
|
||||
|
||||
|
|
@ -152,27 +165,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…
Add table
Add a link
Reference in a new issue