From 0dcba276a632a0421940ad8d02e0b5d814794f00 Mon Sep 17 00:00:00 2001 From: Keith Holliday Date: Sat, 28 Nov 2015 12:06:34 -0600 Subject: [PATCH] Fixed task push text and move ctrlPressed logic to rootScope. --- common/locales/en/tasks.json | 3 +-- website/public/js/controllers/rootCtrl.js | 14 ++++++++++++++ website/public/js/controllers/tasksCtrl.js | 15 +-------------- website/views/shared/tasks/meta_controls.jade | 6 +++--- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/common/locales/en/tasks.json b/common/locales/en/tasks.json index c353765433..66cca5774f 100644 --- a/common/locales/en/tasks.json +++ b/common/locales/en/tasks.json @@ -88,8 +88,7 @@ "fortifyText": "Fortify will return all your tasks to a neutral (yellow) state, as if you'd just added them, and top your Health off to full. This is great if all your red tasks are making the game too hard, or all your blue tasks are making the game too easy. If starting fresh sounds much more motivating, spend the Gems and catch a reprieve!", "sureDelete": "Are you sure you want to delete this task?", "streakCoins": "Streak Bonus!", - "pushTaskToTop": "Push task to top", - "pushTaskToBottom": "Push task to bottom. Hold ctrl or cmd to push to top.", + "pushTaskToTop": "Push task to top. Hold ctrl or cmd to push to bottom.", "emptyTask": "Enter the task's title first.", "dailiesRestingInInn": "You're Resting in the Inn! Your Dailies will NOT hurt you tonight, but they WILL still refresh every day. If you're in a quest, you won't deal damage/collect items until you check out of the Inn, but you can still be injured by a Boss if your Party mates skip their own Dailies.", "habitHelp1": "Good Habits are things that you do often. They award Gold and Experience every time you click the <%= plusIcon %>.", diff --git a/website/public/js/controllers/rootCtrl.js b/website/public/js/controllers/rootCtrl.js index 0e6fd743c7..8d0bf5f3d8 100644 --- a/website/public/js/controllers/rootCtrl.js +++ b/website/public/js/controllers/rootCtrl.js @@ -327,5 +327,19 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$ }); // error will be handled via $http interceptor } + + // Global Keyevents + var ctrlKeys = [17, 224, 91]; + $scope.$on("habit:keydown", function (e, keyEvent) { + if (ctrlKeys.indexOf(keyEvent.keyCode) !== -1) { + $scope.ctrlPressed = true; + } + }); + + $scope.$on("habit:keyup", function (e, keyEvent) { + if (ctrlKeys.indexOf(keyEvent.keyCode) !== -1) { + $scope.ctrlPressed = false; + } + }); } ]); diff --git a/website/public/js/controllers/tasksCtrl.js b/website/public/js/controllers/tasksCtrl.js index 9a7a8829d0..9797e7eb21 100644 --- a/website/public/js/controllers/tasksCtrl.js +++ b/website/public/js/controllers/tasksCtrl.js @@ -76,23 +76,10 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N * Pushes task to top or bottom of list */ $scope.pushTask = function(task, index, location) { - var to = (location === 'bottom' || $scope.pushLocation === 'bottom') ? -1 : 0; + var to = (location === 'bottom' || $scope.ctrlPressed) ? -1 : 0; User.user.ops.sortTask({params:{id:task.id},query:{from:index, to:to}}) }; - var ctrlKeys = [17, 224, 91]; - $scope.$on("habit:keydown", function (e, keyEvent) { - if (ctrlKeys.indexOf(keyEvent.keyCode) !== -1) { - $scope.pushLocation = "bottom"; - } - }); - - $scope.$on("habit:keyup", function (e, keyEvent) { - if (ctrlKeys.indexOf(keyEvent.keyCode) !== -1) { - $scope.pushLocation = "top"; - } - }); - /** * This is calculated post-change, so task.completed=true if they just checked it */ diff --git a/website/views/shared/tasks/meta_controls.jade b/website/views/shared/tasks/meta_controls.jade index d39e2e2fda..733b37d23a 100644 --- a/website/views/shared/tasks/meta_controls.jade +++ b/website/views/shared/tasks/meta_controls.jade @@ -13,9 +13,9 @@ // Icons only available if you own the tasks (aka, hidden from challenge stats) span(ng-if='!obj._locked') - a(ng-click='pushTask(task,$index,"top")', tooltip=env.t('pushTaskToTop'), ng-class="{'push-down': pushLocation == 'bottom'}") - span(ng-hide="pushLocation == 'bottom'").glyphicon.glyphicon-open - span(ng-show="pushLocation == 'bottom'").glyphicon.glyphicon-save + a(ng-click='pushTask(task,$index,"top")', tooltip=env.t('pushTaskToTop'), ng-class="{'push-down': ctrlPressed}") + span(ng-hide="ctrlPressed").glyphicon.glyphicon-open + span(ng-show="ctrlPressed").glyphicon.glyphicon-save // a(ng-click='pushTask(task,$index,"bottom")', tooltip=env.t('pushTaskToBottom')) // span.glyphicon.glyphicon-import // // glyphicon-import or glyphicon-save or glyphicon-sort-by-attributes