Improved timing. Made code more readable.

This commit is contained in:
Tobias Theuer 2017-03-15 13:21:29 +01:00 committed by Lorenz Hübschle-Schneider
parent 811e76d443
commit 833a2a8c0f
2 changed files with 44 additions and 39 deletions

View file

@ -467,10 +467,10 @@ div.colourbox {
}
#sidebar .showjumpkeys .buffer .buffer-jump-key {
transition: all ease-in-out 0.5s;
-webkit-transition: all ease-in-out 0.5s;
transition-delay: 0.2s;
-webkit-transition-delay: 0.2s;
transition: all ease-in-out 0.2s;
-webkit-transition: all ease-in-out 0.2s;
transition-delay: 0s;
-webkit-transition-delay: 0s;
opacity: 0.7;
margin-left: -1.2em;
margin-right: 0.1em;
@ -479,8 +479,8 @@ div.colourbox {
margin-left: -1.2em;
margin-right: -0.2em;
font-size: smaller;
transition: all ease-in-out 0.5s;
-webkit-transition: all ease-in-out 0.5s;
transition: all ease-in-out 0.2s;
-webkit-transition: all ease-in-out 0.2s;
opacity: 0;
text-shadow: -1px 0px 4px rgba(255, 255, 255, 0.4),
0px -1px 4px rgba(255, 255, 255, 0.4),

View file

@ -251,40 +251,47 @@ weechat.directive('inputBar', function() {
var filteredBufferNum;
var activeBufferId;
// if Alt+J was pressed last, we expect two numbers now
if ($rootScope.showJumpKeys && !$event.altKey && (code > 47 && code < 58) && $scope.jumpDecimal === undefined) {
$scope.jumpDecimal = code - 48;
$event.preventDefault();
} else if ($rootScope.showJumpKeys && !$event.altKey && (code > 47 && code < 58) && $scope.jumpDecimal !== undefined) {
bufferNumber = ($scope.jumpDecimal * 10) + (code - 48) - 1;
// quick select filtered entries
if (($scope.$parent.search.length || $scope.$parent.onlyUnread) && $scope.$parent.filteredBuffers.length) {
filteredBufferNum = $scope.$parent.filteredBuffers[bufferNumber];
if (filteredBufferNum !== undefined) {
activeBufferId = [filteredBufferNum.number, filteredBufferNum.id];
// if Alt+J was pressed last...
if ($rootScope.showJumpKeys) {
// ... we expect two digits now
if (!$event.altKey && (code > 47 && code < 58)) {
// first digit
if ($scope.jumpDecimal === undefined) {
$scope.jumpDecimal = code - 48;
$event.preventDefault();
// second digit
} else {
bufferNumber = ($scope.jumpDecimal * 10) + (code - 48) - 1;
// quick select filtered entries
if (($scope.$parent.search.length || $scope.$parent.onlyUnread) && $scope.$parent.filteredBuffers.length) {
filteredBufferNum = $scope.$parent.filteredBuffers[bufferNumber];
if (filteredBufferNum !== undefined) {
activeBufferId = [filteredBufferNum.number, filteredBufferNum.id];
}
} else {
// Map the buffers to only their numbers and IDs so we don't have to
// copy the entire (possibly very large) buffer object, and then sort
// the buffers according to their WeeChat number
sortedBuffers = _.map(models.getBuffers(), function (buffer) {
return [buffer.number, buffer.id];
}).sort(function (left, right) {
// By default, Array.prototype.sort() sorts alphabetically.
// Pass an ordering function to sort by first element.
return left[0] - right[0];
});
activeBufferId = sortedBuffers[bufferNumber];
}
if (activeBufferId) {
$scope.$parent.setActiveBuffer(activeBufferId[1]);
}
$event.preventDefault();
$rootScope.showJumpKeys = false;
$scope.jumpDecimal = undefined;
}
} else {
// Map the buffers to only their numbers and IDs so we don't have to
// copy the entire (possibly very large) buffer object, and then sort
// the buffers according to their WeeChat number
sortedBuffers = _.map(models.getBuffers(), function(buffer) {
return [buffer.number, buffer.id];
}).sort(function(left, right) {
// By default, Array.prototype.sort() sorts alphabetically.
// Pass an ordering function to sort by first element.
return left[0] - right[0];
});
activeBufferId = sortedBuffers[bufferNumber];
$rootScope.showJumpKeys = false;
$scope.jumpDecimal = undefined;
}
if (activeBufferId) {
$scope.$parent.setActiveBuffer(activeBufferId[1]);
}
$event.preventDefault();
$rootScope.showJumpKeys = false;
$scope.jumpDecimal = undefined;
} else {
$rootScope.showJumpKeys = false;
$scope.jumpDecimal = undefined;
}
// Left Alt+[0-9] -> jump to buffer
@ -414,9 +421,7 @@ weechat.directive('inputBar', function() {
// Alt+J -> Jump to buffer
if ($event.altKey && (code === 106 || code === 74)) {
$event.preventDefault();
$rootScope.showJumpKeys = true;
return true;
}