From f800b16f64ac8700763365ef96f7f63a4745dc52 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Mon, 20 Jun 2016 23:45:33 +0800 Subject: [PATCH] refactor code --- app/scripts/controllers/new.js | 12 ++++++++++-- app/scripts/controllers/task-detail.js | 12 ++++++++++-- app/views/new.html | 4 ++-- app/views/task-detail.html | 10 +++++----- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/app/scripts/controllers/new.js b/app/scripts/controllers/new.js index 3aaa354..745b362 100644 --- a/app/scripts/controllers/new.js +++ b/app/scripts/controllers/new.js @@ -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; diff --git a/app/scripts/controllers/task-detail.js b/app/scripts/controllers/task-detail.js index 7fa9a1b..74cc1d9 100644 --- a/app/scripts/controllers/task-detail.js +++ b/app/scripts/controllers/task-detail.js @@ -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; diff --git a/app/views/new.html b/app/views/new.html index 984b878..c3d3f15 100644 --- a/app/views/new.html +++ b/app/views/new.html @@ -2,10 +2,10 @@