Improved repeating esc behaviour

This commit is contained in:
Igor Zhukov 2015-05-01 17:53:39 +03:00
parent da77701558
commit a0f4949807

View File

@ -595,6 +595,11 @@ angular.module('myApp.directives', ['myApp.filters'])
} }
else { else {
$scope.$emit('esc_no_more'); $scope.$emit('esc_no_more');
// Strange Chrome bug, when field doesn't get blur, but becomes inactive after location change
setTimeout(function () {
searchField.blur();
searchField.focus();
}, 100);
} }
return cancelEvent(e); return cancelEvent(e);
} }
@ -606,10 +611,10 @@ angular.module('myApp.directives', ['myApp.filters'])
} }
return cancelEvent(e); return cancelEvent(e);
} }
if ( e.altKey && e.shiftKey && !e.ctrlKey && !e.metaKey && if ( e.altKey && e.shiftKey && !e.ctrlKey && !e.metaKey &&
e.keyCode >= 49 && e.keyCode <= 57 ) { // Alt + Shift + # , switch to conversation # where # is in [1..9] e.keyCode >= 49 && e.keyCode <= 57 ) { // Alt + Shift + # , switch to conversation # where # is in [1..9]
var dialogNumber = e.keyCode - 49, var dialogNumber = e.keyCode - 49,
dialogWraps = $(scrollableWrap).find('.im_dialog_wrap'), dialogWraps = $(scrollableWrap).find('.im_dialog_wrap'),
nextDialogWrap = dialogWraps[dialogNumber]; nextDialogWrap = dialogWraps[dialogNumber];
@ -618,10 +623,10 @@ angular.module('myApp.directives', ['myApp.filters'])
$(nextDialogWrap).find('a').trigger('mousedown'); $(nextDialogWrap).find('a').trigger('mousedown');
scrollToDialog(nextDialogWrap); scrollToDialog(nextDialogWrap);
} }
return cancelEvent(e); return cancelEvent(e);
} }
var next, prev, skip, ctrlTabSupported = Config.Modes.packed; var next, prev, skip, ctrlTabSupported = Config.Modes.packed;
if (e.keyCode == 40 || e.keyCode == 38) { // UP, DOWN if (e.keyCode == 40 || e.keyCode == 38) { // UP, DOWN
next = e.keyCode == 40; next = e.keyCode == 40;
@ -633,7 +638,7 @@ angular.module('myApp.directives', ['myApp.filters'])
prev = !next; prev = !next;
skip = true; skip = true;
} }
if (next || prev) { if (next || prev) {
if (!skip && (!searchFocused || e.metaKey)) { if (!skip && (!searchFocused || e.metaKey)) {
return true; return true;
@ -689,7 +694,7 @@ angular.module('myApp.directives', ['myApp.filters'])
scrollTop = scrollableWrap.scrollTop, scrollTop = scrollableWrap.scrollTop,
viewportHeight = scrollableWrap.clientHeight; viewportHeight = scrollableWrap.clientHeight;
if (scrollTop > elTop) { // we are below the dialog to scroll if (scrollTop > elTop) { // we are below the dialog to scroll
scrollableWrap.scrollTop = elTop; scrollableWrap.scrollTop = elTop;
$(dialogsWrap).nanoScroller({flash: true}); $(dialogsWrap).nanoScroller({flash: true});
} }