Fix keys quirks for different browsers
This commit is contained in:
parent
5838824732
commit
2ee29923c1
2 changed files with 7 additions and 5 deletions
|
@ -18,7 +18,7 @@
|
||||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||||
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body ng-controller="WeechatCtrl" ng-keypress="handleKeyPress($event)">
|
<body ng-controller="WeechatCtrl" ng-keydown="handleKeyPress($event)">
|
||||||
<div ng-hide="connected" class="container">
|
<div ng-hide="connected" class="container">
|
||||||
<h2>
|
<h2>
|
||||||
<img src="img/favicon.png">
|
<img src="img/favicon.png">
|
||||||
|
|
|
@ -497,11 +497,9 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
// Find next buffer with activity and switch to it
|
// Find next buffer with activity and switch to it
|
||||||
angular.forEach($scope.buffers, function(buffer) {
|
angular.forEach($scope.buffers, function(buffer) {
|
||||||
if(buffer.notification) {
|
if(buffer.notification) {
|
||||||
console.log('a', buffer.id);
|
|
||||||
$scope.setActiveBuffer(buffer.id);
|
$scope.setActiveBuffer(buffer.id);
|
||||||
return false;
|
return false;
|
||||||
}else if((parseInt(buffer.unread) || 0) > 0) {
|
}else if((parseInt(buffer.unread) || 0) > 0) {
|
||||||
console.log('b',buffer.id);
|
|
||||||
$scope.setActiveBuffer(buffer.id);
|
$scope.setActiveBuffer(buffer.id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -510,15 +508,19 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.handleKeyPress = function($event) {
|
$scope.handleKeyPress = function($event) {
|
||||||
|
// Support different browser quirks
|
||||||
|
var code = $event.keyCode ? $event.keyCode : $event.charCode;
|
||||||
|
|
||||||
//console.log('keypress', $event.charCode, $event.altKey);
|
//console.log('keypress', $event.charCode, $event.altKey);
|
||||||
|
|
||||||
// Handle alt-a
|
// Handle alt-a
|
||||||
if($event.altKey && $event.charCode == '97') {
|
if($event.altKey && (code == 97 || code == 65)) {
|
||||||
$event.preventDefault();
|
$event.preventDefault();
|
||||||
$rootScope.switchToActivityBuffer();
|
$rootScope.switchToActivityBuffer();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Handle ctrl-g
|
// Handle ctrl-g
|
||||||
if($event.ctrlKey && $event.charCode == '103') {
|
if($event.ctrlKey && (code == 103 || code == 71)) {
|
||||||
document.querySelector('#bufferFilter').focus();
|
document.querySelector('#bufferFilter').focus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue