Merge branch 'slow_chat' into develop

This commit is contained in:
Blade Barringer 2016-06-03 21:43:32 -05:00
commit 30d09c2e7f
3 changed files with 37 additions and 3 deletions

View file

@ -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() {

View file

@ -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

View file

@ -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