mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-04 09:39:23 +00:00
Merge branch 'slow_chat' into develop
This commit is contained in:
commit
30d09c2e7f
3 changed files with 37 additions and 3 deletions
|
|
@ -264,10 +264,18 @@ habitrpg.controller("InventoryCtrl",
|
|||
}
|
||||
};
|
||||
|
||||
$scope.$on("habit:keydown", function (e, keyEvent) {
|
||||
if (keyEvent.keyCode == "27") {
|
||||
var listenForEscape = function (event) {
|
||||
if (event.keyCode === 27) {
|
||||
$scope.deselectItem();
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', listenForEscape);
|
||||
|
||||
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams, options){
|
||||
if (toState.name.indexOf('options.inventory') < 0) {
|
||||
document.removeEventListener('keydown', listenForEscape);
|
||||
}
|
||||
});
|
||||
|
||||
$scope.deselectItem = function() {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
|||
$scope.obj = User.user; // used for task-lists
|
||||
$scope.user = User.user;
|
||||
|
||||
var CTRL_KEYS = [17, 224, 91];
|
||||
|
||||
$scope.armoireCount = function(gear) {
|
||||
return Shared.count.remainingGearInSet(gear, 'armoire');
|
||||
};
|
||||
|
|
@ -292,6 +294,30 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
|||
}
|
||||
}
|
||||
|
||||
var isCtrlPressed = function (keyEvent) {
|
||||
if (CTRL_KEYS.indexOf(keyEvent.keyCode) > -1) {
|
||||
$scope.ctrlPressed = true;
|
||||
$scope.$apply();
|
||||
}
|
||||
}
|
||||
|
||||
var isCtrlLetGo = function (keyEvent) {
|
||||
if (CTRL_KEYS.indexOf(keyEvent.keyCode) > -1) {
|
||||
$scope.ctrlPressed = false;
|
||||
$scope.$apply();
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', isCtrlPressed);
|
||||
document.addEventListener('keyup', isCtrlLetGo);
|
||||
|
||||
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams, options){
|
||||
if (toState.name.indexOf('tasks') < 0) {
|
||||
document.removeEventListener('keydown', isCtrlPressed);
|
||||
document.removeEventListener('keyup', isCtrlLetGo);
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
------------------------
|
||||
Tags
|
||||
|
|
|
|||
|
|
@ -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:keydown', $event)", ng-keyup="$broadcast('habit:keyup', $event)")
|
||||
html(ng-app="habitrpg", ng-controller="RootCtrl", ng-class='{"applying-action":applyingAction}', ui-keyup="{27:'castCancel()'}")
|
||||
head
|
||||
title(ng-bind="env.t('habitica') + ' | ' + $root.pageTitle")
|
||||
// ?v=1 needed to force refresh
|
||||
|
|
|
|||
Loading…
Reference in a new issue