refactor code
This commit is contained in:
parent
0797237deb
commit
f800b16f64
|
@ -18,11 +18,19 @@
|
||||||
return aria2SettingService.getSpecifiedOptions(keys);
|
return aria2SettingService.getSpecifiedOptions(keys);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
$scope.changeTab = function (tabName) {
|
||||||
|
if (tabName == 'options') {
|
||||||
|
$scope.loadDefaultOption();
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.context.currentTab = tabName;
|
||||||
|
};
|
||||||
|
|
||||||
$rootScope.swipeActions.extentLeftSwipe = function () {
|
$rootScope.swipeActions.extentLeftSwipe = function () {
|
||||||
var tabIndex = tabOrders.indexOf($scope.context.currentTab);
|
var tabIndex = tabOrders.indexOf($scope.context.currentTab);
|
||||||
|
|
||||||
if (tabIndex < tabOrders.length - 1) {
|
if (tabIndex < tabOrders.length - 1) {
|
||||||
$scope.context.currentTab = tabOrders[tabIndex + 1];
|
$scope.changeTab(tabOrders[tabIndex + 1]);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -33,7 +41,7 @@
|
||||||
var tabIndex = tabOrders.indexOf($scope.context.currentTab);
|
var tabIndex = tabOrders.indexOf($scope.context.currentTab);
|
||||||
|
|
||||||
if (tabIndex > 0) {
|
if (tabIndex > 0) {
|
||||||
$scope.context.currentTab = tabOrders[tabIndex - 1];
|
$scope.changeTab(tabOrders[tabIndex - 1]);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -81,11 +81,19 @@
|
||||||
availableOptions: []
|
availableOptions: []
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.changeTab = function (tabName) {
|
||||||
|
if (tabName == 'settings') {
|
||||||
|
$scope.loadTaskOption($scope.task);
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.context.currentTab = tabName;
|
||||||
|
};
|
||||||
|
|
||||||
$rootScope.swipeActions.extentLeftSwipe = function () {
|
$rootScope.swipeActions.extentLeftSwipe = function () {
|
||||||
var tabIndex = tabOrders.indexOf($scope.context.currentTab);
|
var tabIndex = tabOrders.indexOf($scope.context.currentTab);
|
||||||
|
|
||||||
if (tabIndex < tabOrders.length - 1) {
|
if (tabIndex < tabOrders.length - 1) {
|
||||||
$scope.context.currentTab = tabOrders[tabIndex + 1];
|
$scope.changeTab(tabOrders[tabIndex + 1]);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -96,7 +104,7 @@
|
||||||
var tabIndex = tabOrders.indexOf($scope.context.currentTab);
|
var tabIndex = tabOrders.indexOf($scope.context.currentTab);
|
||||||
|
|
||||||
if (tabIndex > 0) {
|
if (tabIndex > 0) {
|
||||||
$scope.context.currentTab = tabOrders[tabIndex - 1];
|
$scope.changeTab(tabOrders[tabIndex - 1]);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
<div class="nav-tabs-custom">
|
<div class="nav-tabs-custom">
|
||||||
<ul class="nav nav-tabs">
|
<ul class="nav nav-tabs">
|
||||||
<li ng-class="{'active': context.currentTab == 'download'}">
|
<li ng-class="{'active': context.currentTab == 'download'}">
|
||||||
<a class="pointer-cursor" ng-click="context.currentTab = 'download'" translate>Download</a>
|
<a class="pointer-cursor" ng-click="changeTab('download')" translate>Download</a>
|
||||||
</li>
|
</li>
|
||||||
<li ng-class="{'active': context.currentTab == 'options'}">
|
<li ng-class="{'active': context.currentTab == 'options'}">
|
||||||
<a class="pointer-cursor" ng-click="context.currentTab = 'options';loadDefaultOption();" translate>Options</a>
|
<a class="pointer-cursor" ng-click="changeTab('options')" translate>Options</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
|
@ -2,19 +2,19 @@
|
||||||
<div class="nav-tabs-custom">
|
<div class="nav-tabs-custom">
|
||||||
<ul class="nav nav-tabs">
|
<ul class="nav nav-tabs">
|
||||||
<li ng-class="{'active': context.currentTab == 'overview'}">
|
<li ng-class="{'active': context.currentTab == 'overview'}">
|
||||||
<a class="pointer-cursor" ng-click="context.currentTab = 'overview'" translate>Overview</a>
|
<a class="pointer-cursor" ng-click="changeTab('overview')" translate>Overview</a>
|
||||||
</li>
|
</li>
|
||||||
<li ng-class="{'active': context.currentTab == 'blocks'}">
|
<li ng-class="{'active': context.currentTab == 'blocks'}">
|
||||||
<a class="pointer-cursor" ng-click="context.currentTab = 'blocks'" translate>Blocks</a>
|
<a class="pointer-cursor" ng-click="changeTab('blocks')" translate>Blocks</a>
|
||||||
</li>
|
</li>
|
||||||
<li ng-class="{'active': context.currentTab == 'filelist'}">
|
<li ng-class="{'active': context.currentTab == 'filelist'}">
|
||||||
<a class="pointer-cursor" ng-click="context.currentTab = 'filelist'" translate>Files</a>
|
<a class="pointer-cursor" ng-click="changeTab('filelist')" translate>Files</a>
|
||||||
</li>
|
</li>
|
||||||
<li ng-class="{'active': context.currentTab == 'btpeers'}" ng-if="task && task.status == 'active' && task.bittorrent">
|
<li ng-class="{'active': context.currentTab == 'btpeers'}" ng-if="task && task.status == 'active' && task.bittorrent">
|
||||||
<a class="pointer-cursor" ng-click="context.currentTab = 'btpeers';" translate>Peers</a>
|
<a class="pointer-cursor" ng-click="changeTab('btpeers')" translate>Peers</a>
|
||||||
</li>
|
</li>
|
||||||
<li ng-class="{'active': context.currentTab == 'settings'}" ng-if="task && (task.status == 'active' || task.status == 'waiting' || task.status == 'paused')" class="slim">
|
<li ng-class="{'active': context.currentTab == 'settings'}" ng-if="task && (task.status == 'active' || task.status == 'waiting' || task.status == 'paused')" class="slim">
|
||||||
<a class="pointer-cursor" ng-click="context.currentTab = 'settings';loadTaskOption(task);">
|
<a class="pointer-cursor" ng-click="changeTab('settings')">
|
||||||
<i class="fa fa-gear"></i>
|
<i class="fa fa-gear"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
Reference in a new issue