refactor code

This commit is contained in:
MaysWind 2016-06-20 23:45:33 +08:00
parent 0797237deb
commit f800b16f64
4 changed files with 27 additions and 11 deletions

View file

@ -18,11 +18,19 @@
return aria2SettingService.getSpecifiedOptions(keys);
})();
$scope.changeTab = function (tabName) {
if (tabName == 'options') {
$scope.loadDefaultOption();
}
$scope.context.currentTab = tabName;
};
$rootScope.swipeActions.extentLeftSwipe = function () {
var tabIndex = tabOrders.indexOf($scope.context.currentTab);
if (tabIndex < tabOrders.length - 1) {
$scope.context.currentTab = tabOrders[tabIndex + 1];
$scope.changeTab(tabOrders[tabIndex + 1]);
return true;
} else {
return false;
@ -33,7 +41,7 @@
var tabIndex = tabOrders.indexOf($scope.context.currentTab);
if (tabIndex > 0) {
$scope.context.currentTab = tabOrders[tabIndex - 1];
$scope.changeTab(tabOrders[tabIndex - 1]);
return true;
} else {
return false;

View file

@ -81,11 +81,19 @@
availableOptions: []
};
$scope.changeTab = function (tabName) {
if (tabName == 'settings') {
$scope.loadTaskOption($scope.task);
}
$scope.context.currentTab = tabName;
};
$rootScope.swipeActions.extentLeftSwipe = function () {
var tabIndex = tabOrders.indexOf($scope.context.currentTab);
if (tabIndex < tabOrders.length - 1) {
$scope.context.currentTab = tabOrders[tabIndex + 1];
$scope.changeTab(tabOrders[tabIndex + 1]);
return true;
} else {
return false;
@ -96,7 +104,7 @@
var tabIndex = tabOrders.indexOf($scope.context.currentTab);
if (tabIndex > 0) {
$scope.context.currentTab = tabOrders[tabIndex - 1];
$scope.changeTab(tabOrders[tabIndex - 1]);
return true;
} else {
return false;

View file

@ -2,10 +2,10 @@
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<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 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>
</ul>

View file

@ -2,19 +2,19 @@
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<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 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 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 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 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>
</a>
</li>