From b668829d85b43fc62cc7045f62202ddb43301f9c Mon Sep 17 00:00:00 2001 From: Keith Holliday Date: Sun, 22 Nov 2015 15:57:14 -0600 Subject: [PATCH 1/4] Added ability to invert pushToBottom when holding down ctrl or cmd button --- common/locales/en/tasks.json | 4 ++-- website/public/css/tasks.styl | 5 +++++ website/public/js/controllers/tasksCtrl.js | 15 ++++++++++++++- website/views/index.jade | 2 +- website/views/shared/tasks/meta_controls.jade | 2 +- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/common/locales/en/tasks.json b/common/locales/en/tasks.json index f40797789b..c353765433 100644 --- a/common/locales/en/tasks.json +++ b/common/locales/en/tasks.json @@ -54,7 +54,7 @@ "complete": "Done", "dated": "Dated", "due": "Due", - "notDue": "Not Due", + "notDue": "Not Due", "grey": "Grey", "score": "Score", "rewards": "Rewards", @@ -89,7 +89,7 @@ "sureDelete": "Are you sure you want to delete this task?", "streakCoins": "Streak Bonus!", "pushTaskToTop": "Push task to top", - "pushTaskToBottom": "Push task to bottom", + "pushTaskToBottom": "Push task to bottom. Hold ctrl or cmd to push to top.", "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/css/tasks.styl b/website/public/css/tasks.styl index 0318d9b5c8..e87b28186c 100644 --- a/website/public/css/tasks.styl +++ b/website/public/css/tasks.styl @@ -394,6 +394,11 @@ for $stage in $stages a.badge position: relative; top:-2px + a.push-down span + -ms-transform: rotate(180deg); /* IE 9 */ + -webkit-transform: rotate(180deg); /* Chrome, Safari, Opera */ + transform: rotate(180deg); + .task:hover .task-meta-controls opacity: 1 diff --git a/website/public/js/controllers/tasksCtrl.js b/website/public/js/controllers/tasksCtrl.js index 7eee145e37..9a7a8829d0 100644 --- a/website/public/js/controllers/tasksCtrl.js +++ b/website/public/js/controllers/tasksCtrl.js @@ -76,10 +76,23 @@ 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') ? -1 : 0; + var to = (location === 'bottom' || $scope.pushLocation === 'bottom') ? -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/index.jade b/website/views/index.jade index 33d1c78f68..7173062222 100644 --- a/website/views/index.jade +++ b/website/views/index.jade @@ -1,6 +1,6 @@ doctype html //html(ng-app="habitrpg", ng-controller="RootCtrl", ng-class='{"applying-action":applyingAction}', ui-keypress="{27:'castCancel()'}") -html(ng-app="habitrpg", ng-controller="RootCtrl", ng-class='{"applying-action":applyingAction}', ui-keyup="{27:'castCancel()'}", ng-keydown="$broadcast('habit:keyup', $event)") +html(ng-app="habitrpg", ng-controller="RootCtrl", ng-class='{"applying-action":applyingAction}', ui-keyup="{27:'castCancel()'}", ng-keydown="$broadcast('habit:keydown', $event)", ng-keyup="$broadcast('habit:keyup', $event)") head title=env.t('titleIndex') // ?v=1 needed to force refresh diff --git a/website/views/shared/tasks/meta_controls.jade b/website/views/shared/tasks/meta_controls.jade index e42210f240..c9c344a01b 100644 --- a/website/views/shared/tasks/meta_controls.jade +++ b/website/views/shared/tasks/meta_controls.jade @@ -13,7 +13,7 @@ // 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')) + a(ng-click='pushTask(task,$index,"top")', tooltip=env.t('pushTaskToTop'), ng-class="{'push-down': pushLocation == 'bottom'}") span.glyphicon.glyphicon-open // a(ng-click='pushTask(task,$index,"bottom")', tooltip=env.t('pushTaskToBottom')) // span.glyphicon.glyphicon-import From 9a8f9c693817afea76e39e723b4c4f27748e69ef Mon Sep 17 00:00:00 2001 From: Keith Holliday Date: Sun, 22 Nov 2015 15:59:18 -0600 Subject: [PATCH 2/4] Fixed wording to be parallel with logic --- website/public/js/controllers/inventoryCtrl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/public/js/controllers/inventoryCtrl.js b/website/public/js/controllers/inventoryCtrl.js index 76a59e4f4a..49cb8ebee2 100644 --- a/website/public/js/controllers/inventoryCtrl.js +++ b/website/public/js/controllers/inventoryCtrl.js @@ -257,7 +257,7 @@ habitrpg.controller("InventoryCtrl", } }; - $scope.$on("habit:keyup", function (e, keyEvent) { + $scope.$on("habit:keydown", function (e, keyEvent) { if (keyEvent.keyCode == "27") { $scope.deselectItem(); } From 274f4ab4d263aa028b31f9d8a8b4e7a9bedaf3ee Mon Sep 17 00:00:00 2001 From: Keith Holliday Date: Wed, 25 Nov 2015 23:44:13 -0600 Subject: [PATCH 3/4] Removed css in favor of using inverted glyphicon --- website/public/css/tasks.styl | 5 ----- website/views/shared/tasks/meta_controls.jade | 3 ++- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/website/public/css/tasks.styl b/website/public/css/tasks.styl index e87b28186c..0318d9b5c8 100644 --- a/website/public/css/tasks.styl +++ b/website/public/css/tasks.styl @@ -394,11 +394,6 @@ for $stage in $stages a.badge position: relative; top:-2px - a.push-down span - -ms-transform: rotate(180deg); /* IE 9 */ - -webkit-transform: rotate(180deg); /* Chrome, Safari, Opera */ - transform: rotate(180deg); - .task:hover .task-meta-controls opacity: 1 diff --git a/website/views/shared/tasks/meta_controls.jade b/website/views/shared/tasks/meta_controls.jade index c9c344a01b..d39e2e2fda 100644 --- a/website/views/shared/tasks/meta_controls.jade +++ b/website/views/shared/tasks/meta_controls.jade @@ -14,7 +14,8 @@ // 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.glyphicon.glyphicon-open + span(ng-hide="pushLocation == 'bottom'").glyphicon.glyphicon-open + span(ng-show="pushLocation == 'bottom'").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 From 0dcba276a632a0421940ad8d02e0b5d814794f00 Mon Sep 17 00:00:00 2001 From: Keith Holliday Date: Sat, 28 Nov 2015 12:06:34 -0600 Subject: [PATCH 4/4] 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