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 { #sidebar .showjumpkeys .buffer .buffer-jump-key {
transition: all ease-in-out 0.5s; transition: all ease-in-out 0.2s;
-webkit-transition: all ease-in-out 0.5s; -webkit-transition: all ease-in-out 0.2s;
transition-delay: 0.2s; transition-delay: 0s;
-webkit-transition-delay: 0.2s; -webkit-transition-delay: 0s;
opacity: 0.7; opacity: 0.7;
margin-left: -1.2em; margin-left: -1.2em;
margin-right: 0.1em; margin-right: 0.1em;
@ -479,8 +479,8 @@ div.colourbox {
margin-left: -1.2em; margin-left: -1.2em;
margin-right: -0.2em; margin-right: -0.2em;
font-size: smaller; font-size: smaller;
transition: all ease-in-out 0.5s; transition: all ease-in-out 0.2s;
-webkit-transition: all ease-in-out 0.5s; -webkit-transition: all ease-in-out 0.2s;
opacity: 0; opacity: 0;
text-shadow: -1px 0px 4px rgba(255, 255, 255, 0.4), text-shadow: -1px 0px 4px rgba(255, 255, 255, 0.4),
0px -1px 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 filteredBufferNum;
var activeBufferId; var activeBufferId;
// if Alt+J was pressed last, we expect two numbers now // if Alt+J was pressed last...
if ($rootScope.showJumpKeys && !$event.altKey && (code > 47 && code < 58) && $scope.jumpDecimal === undefined) { if ($rootScope.showJumpKeys) {
$scope.jumpDecimal = code - 48; // ... we expect two digits now
$event.preventDefault(); if (!$event.altKey && (code > 47 && code < 58)) {
} else if ($rootScope.showJumpKeys && !$event.altKey && (code > 47 && code < 58) && $scope.jumpDecimal !== undefined) { // first digit
bufferNumber = ($scope.jumpDecimal * 10) + (code - 48) - 1; if ($scope.jumpDecimal === undefined) {
// quick select filtered entries $scope.jumpDecimal = code - 48;
if (($scope.$parent.search.length || $scope.$parent.onlyUnread) && $scope.$parent.filteredBuffers.length) { $event.preventDefault();
filteredBufferNum = $scope.$parent.filteredBuffers[bufferNumber]; // second digit
if (filteredBufferNum !== undefined) { } else {
activeBufferId = [filteredBufferNum.number, filteredBufferNum.id]; 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 { } else {
// Map the buffers to only their numbers and IDs so we don't have to $rootScope.showJumpKeys = false;
// copy the entire (possibly very large) buffer object, and then sort $scope.jumpDecimal = undefined;
// 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 {
$rootScope.showJumpKeys = false;
$scope.jumpDecimal = undefined;
} }
// Left Alt+[0-9] -> jump to buffer // Left Alt+[0-9] -> jump to buffer
@ -414,9 +421,7 @@ weechat.directive('inputBar', function() {
// Alt+J -> Jump to buffer // Alt+J -> Jump to buffer
if ($event.altKey && (code === 106 || code === 74)) { if ($event.altKey && (code === 106 || code === 74)) {
$event.preventDefault(); $event.preventDefault();
$rootScope.showJumpKeys = true; $rootScope.showJumpKeys = true;
return true; return true;
} }