Support narrowing buffer selection with Alt+0-9 after using Alt+g or when onlyUnread is enabled, and show numeric overlays for Alt+0-9 keys on the buffers
This commit is contained in:
parent
10dde0e7d9
commit
9827710736
4 changed files with 106 additions and 16 deletions
|
@ -326,6 +326,28 @@ table.notimestampseconds td.time span.seconds {
|
|||
display: none !important;
|
||||
}
|
||||
|
||||
#sidebar .showquickkeys .buffer .buffer-quick-key {
|
||||
transition:all linear 1s;
|
||||
-webkit-transition:all ease-out 1s;
|
||||
opacity: 0.7;
|
||||
}
|
||||
#sidebar .buffer .buffer-quick-key {
|
||||
margin-left: -0.8em;
|
||||
margin-right: -0.2em;
|
||||
font-size: smaller;
|
||||
transition:all linear 2s;
|
||||
-webkit-transition:all ease-in 2s;
|
||||
opacity: 0;
|
||||
text-shadow: -1px 0px 4px rgba(255, 255, 255, 0.4),
|
||||
0px -1px 4px rgba(255, 255, 255, 0.4),
|
||||
1px 0px 4px rgba(255, 255, 255, 0.4),
|
||||
0px 1px 4px rgba(255, 255, 255, 0.4);
|
||||
vertical-align: baseline;
|
||||
display: inline-block;
|
||||
width: 1em;
|
||||
align: right;
|
||||
}
|
||||
|
||||
.gb-modal {
|
||||
z-index: 1000;
|
||||
height: 100%;
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<script type="text/javascript" src="js/plugins.js"></script>
|
||||
<script type="text/javascript" src="3rdparty/favico-0.3.5.min.js"></script>
|
||||
</head>
|
||||
<body ng-controller="WeechatCtrl" ng-keydown="handleKeyPress($event)" ng-keypress="handleKeyPress($event)" ng-class="{'no-overflow': connected}" lang="en-US">
|
||||
<body ng-controller="WeechatCtrl" ng-keydown="handleKeyPress($event)" ng-keyup="handleKeyRelease($event)" ng-keypress="handleKeyPress($event)" ng-class="{'no-overflow': connected}" lang="en-US">
|
||||
<link ng-href="css/themes/{{theme}}.css" rel="stylesheet" media="screen" />
|
||||
<div ng-hide="connected" class="container">
|
||||
<h2>
|
||||
|
@ -228,15 +228,16 @@ $ openssl req -nodes -newkey rsa:4096 -keyout relay.pem -x509 -days 365 -out rel
|
|||
</div>
|
||||
</div>
|
||||
<div id="sidebar" data-state="visible" ng-swipe-left="hideSidebar()" class="vertical-line">
|
||||
<ul class="nav nav-pills nav-stacked" ng-class="{'indented': (predicate === 'serverSortKey')}">
|
||||
<ul class="nav nav-pills nav-stacked" ng-class="{'indented': (predicate === 'serverSortKey'), 'showquickkeys': showQuickKeys}">
|
||||
<li class="bufferfilter">
|
||||
<form role="form">
|
||||
<input class="form-control favorite-font" type="text" id="bufferFilter" ng-model="search" ng-keydown="handleSearchBoxKey($event)" placeholder="Search">
|
||||
</form>
|
||||
</li>
|
||||
<li class="buffer" ng-class="{'active': buffer.active, 'indent': buffer.indent, 'channel': buffer.type === 'channel', 'private': buffer.type === 'private'}" ng-repeat="(key, buffer) in (filteredBuffers = (getBuffers() | toArray | filter:{fullName:search} | filter:hasUnread | orderBy:predicate))">
|
||||
<li class="buffer" ng-class="{'active': buffer.active, 'indent': buffer.indent, 'channel': buffer.type === 'channel', 'private': buffer.type === 'private'}" ng-repeat="(key, buffer) in (filteredBuffers = (getBuffers() | toArray:'withidx' | filter:{fullName:search} | filter:hasUnread | orderBy:predicate | getBufferQuickKeys:this))">
|
||||
<a href="#" ng-click="setActiveBuffer(buffer.id)" title="{{ buffer.fullName }}">
|
||||
<span class="badge pull-right" ng-class="{'danger': buffer.notification}" ng-if="buffer.notification || buffer.unread" ng-bind="buffer.notification || buffer.unread"></span>
|
||||
<span class="buffer-quick-key">{{ buffer.$quickKey }}</span>
|
||||
<span class="buffername">{{ buffer.trimmedName || buffer.fullName }}</span>
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -4,11 +4,20 @@
|
|||
var weechat = angular.module('weechat');
|
||||
|
||||
weechat.filter('toArray', function () {
|
||||
return function (obj) {
|
||||
return function (obj, storeIdx) {
|
||||
if (!(obj instanceof Object)) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
if (storeIdx) {
|
||||
return Object.keys(obj).map(function (key, idx) {
|
||||
return Object.defineProperties(obj[key], {
|
||||
'$key' : { value: key },
|
||||
'$idx' : { value: idx, configurable: true }
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return Object.keys(obj).map(function (key) {
|
||||
return Object.defineProperty(obj[key], '$key', { value: key });
|
||||
});
|
||||
|
@ -49,4 +58,27 @@ weechat.filter('inlinecolour', ['$sce', function($sce) {
|
|||
return $sce.trustAsHtml(text.replace(hexColourRegex, substitute));
|
||||
};
|
||||
}]);
|
||||
|
||||
weechat.filter('getBufferQuickKeys', function () {
|
||||
return function (obj, $scope) {
|
||||
if (!$scope) { return obj; }
|
||||
if (($scope.search !== undefined && $scope.search.length) || $scope.onlyUnread) {
|
||||
obj.forEach(function(buf, idx) {
|
||||
buf.$quickKey = idx < 10 ? (idx + 1) % 10 : '';
|
||||
});
|
||||
} else {
|
||||
_.map(obj, function(buffer, idx) {
|
||||
return [buffer.number, buffer.$idx, idx];
|
||||
}).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] || left[1] - right[1];
|
||||
}).forEach(function(info, keyIdx) {
|
||||
obj[ info[2] ].$quickKey = keyIdx < 10 ? (keyIdx + 1) % 10 : '';
|
||||
});
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
});
|
||||
|
||||
})();
|
||||
|
|
|
@ -148,6 +148,9 @@ weechat.directive('inputBar', function() {
|
|||
// Support different browser quirks
|
||||
var code = $event.keyCode ? $event.keyCode : $event.charCode;
|
||||
|
||||
// reset quick keys display
|
||||
$rootScope.showQuickKeys = false;
|
||||
|
||||
// any other key than Tab resets nick completion iteration
|
||||
var tmpIterCandidate = $scope.iterCandidate;
|
||||
$scope.iterCandidate = null;
|
||||
|
@ -157,19 +160,28 @@ weechat.directive('inputBar', function() {
|
|||
if (code === 48) {
|
||||
code = 58;
|
||||
}
|
||||
|
||||
var bufferNumber = code - 48 - 1 ;
|
||||
// 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
|
||||
var 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];
|
||||
});
|
||||
var activeBufferId = sortedBuffers[bufferNumber];
|
||||
|
||||
var activeBufferId;
|
||||
// quick select filtered entries
|
||||
if (($scope.$parent.search.length || $scope.$parent.onlyUnread) && $scope.$parent.filteredBuffers.length) {
|
||||
var 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
|
||||
var 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();
|
||||
|
@ -350,6 +362,29 @@ weechat.directive('inputBar', function() {
|
|||
$event.preventDefault();
|
||||
return true;
|
||||
}
|
||||
// Alt key down -> display quick key legend
|
||||
if ($event.type === "keydown" && code === 18) {
|
||||
$rootScope.showQuickKeys = true;
|
||||
if ($rootScope.quickKeysTimer !== undefined) {
|
||||
clearTimeout($rootScope.quickKeysTimer);
|
||||
}
|
||||
$rootScope.quickKeysTimer = setTimeout(function() {
|
||||
if ($rootScope.showQuickKeys) {
|
||||
$rootScope.showQuickKeys = false;
|
||||
$rootScope.$apply();
|
||||
}
|
||||
delete $rootScope.quickKeysTimer;
|
||||
}, 3000);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
$rootScope.handleKeyRelease = function($event) {
|
||||
// Alt key up -> remove quick key legend
|
||||
if ($event.keyCode === 18) {
|
||||
if ($rootScope.showQuickKeys) {
|
||||
$rootScope.showQuickKeys = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
}]
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue