mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Deselect food, egg, and potion when hitting the escape key
This commit is contained in:
@@ -89,4 +89,27 @@ describe('Inventory Controller', function() {
|
|||||||
expect(user.balance).to.eql(3.25);
|
expect(user.balance).to.eql(3.25);
|
||||||
expect(user.items.eggs).to.eql({Cactus: 1, Wolf: 1})
|
expect(user.items.eggs).to.eql({Cactus: 1, Wolf: 1})
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
describe('Deselecting Items', function() {
|
||||||
|
|
||||||
|
it('deselects a food', function(){
|
||||||
|
scope.chooseFood('Meat');
|
||||||
|
scope.deselectItem();
|
||||||
|
expect(scope.selectedFood).to.eql(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('deselects a potion', function(){
|
||||||
|
scope.choosePotion('Base');
|
||||||
|
scope.deselectItem();
|
||||||
|
expect(scope.selectedPotion).to.eql(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('deselects a egg', function(){
|
||||||
|
scope.chooseEgg('Cactus');
|
||||||
|
scope.deselectItem();
|
||||||
|
expect(scope.selectedEgg).to.eql(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -211,5 +211,25 @@ habitrpg.controller("InventoryCtrl",
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.$on("habit:keyup", function (e, keyEvent) {
|
||||||
|
if (keyEvent.keyCode == "27") {
|
||||||
|
$scope.deselectItem();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//$scope.listen(keyEvent)
|
||||||
|
|
||||||
|
$scope.deselectItem = function() {
|
||||||
|
if ($scope.selectedFood) {
|
||||||
|
$scope.selectedFood = null;
|
||||||
|
}
|
||||||
|
if ($scope.selectedPotion) {
|
||||||
|
$scope.selectedPotion = null
|
||||||
|
}
|
||||||
|
if ($scope.selectedEgg) {
|
||||||
|
$scope.selectedEgg = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
doctype html
|
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-keypress="{27:'castCancel()'}")
|
||||||
html(ng-app="habitrpg", ng-controller="RootCtrl", ng-class='{"applying-action":applyingAction}', ui-keyup="{27:'castCancel()'}")
|
html(ng-app="habitrpg", ng-controller="RootCtrl", ng-class='{"applying-action":applyingAction}', ui-keyup="{27:'castCancel()'}", ng-keydown="$broadcast('habit:keyup', $event)")
|
||||||
head
|
head
|
||||||
title=env.t('titleIndex')
|
title=env.t('titleIndex')
|
||||||
// ?v=1 needed to force refresh
|
// ?v=1 needed to force refresh
|
||||||
|
|||||||
Reference in New Issue
Block a user