From 5c315748834d18181ad6b6a0308747173bd9c559 Mon Sep 17 00:00:00 2001 From: Abel 'Akronix' Serrano Juste Date: Tue, 21 Apr 2015 22:19:08 +0200 Subject: [PATCH] alt + shift + # switchs dialogs. Improved scrollToDialog. Fix #768. --- app/js/directives.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/app/js/directives.js b/app/js/directives.js index 26be777f..ed7bd75b 100755 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -588,7 +588,22 @@ angular.module('myApp.directives', ['myApp.filters']) } return cancelEvent(e); } + + 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] + + var dialogNumber = e.keyCode - 49, + dialogWraps = $(scrollableWrap).find('.im_dialog_wrap'), + nextDialogWrap = dialogWraps[dialogNumber]; + if (nextDialogWrap) { + $(nextDialogWrap).find('a').trigger('mousedown'); + scrollToDialog(nextDialogWrap); + } + + return cancelEvent(e); + } + var next, prev, skip, ctrlTabSupported = Config.Modes.packed; if (e.keyCode == 40 || e.keyCode == 38) { // UP, DOWN next = e.keyCode == 40; @@ -600,6 +615,7 @@ angular.module('myApp.directives', ['myApp.filters']) prev = !next; skip = true; } + if (next || prev) { if (!skip && (!searchFocused || e.metaKey)) { return true; @@ -650,16 +666,16 @@ angular.module('myApp.directives', ['myApp.filters']) } function scrollToDialog(dialogWrap) { - var elTop = dialogWrap.offsetTop, - elHeight = dialogWrap.offsetHeight, + var elTop = dialogWrap.offsetTop - 15, + elHeight = dialogWrap.offsetHeight + 30, scrollTop = scrollableWrap.scrollTop, viewportHeight = scrollableWrap.clientHeight; - if (scrollTop > elTop) { + if (scrollTop > elTop) { // we are below the dialog to scroll scrollableWrap.scrollTop = elTop; $(dialogsWrap).nanoScroller({flash: true}); } - else if (scrollTop < elTop + elHeight - viewportHeight) { + else if (scrollTop < elTop + elHeight - viewportHeight) { // we are over the dialog to scroll scrollableWrap.scrollTop = elTop + elHeight - viewportHeight; $(dialogsWrap).nanoScroller({flash: true}); } @@ -2932,4 +2948,4 @@ angular.module('myApp.directives', ['myApp.filters']) } }; - }) \ No newline at end of file + })