git ssb

16+

Dominic / patchbay



Commit e757955e84bfb9e170ad69e986a9042e6a83851b

add `o` and `gg` as keyboard nav options

mix irving committed on 2/2/2017, 1:08:24 PM
Parent: d3402b2efe4dd4193ad3d0af357c92494b7da75a

Files changed

keyscroll.jschanged
modules_basic/message/render.jschanged
modules_core/tabs.jschanged
keyscroll.jsView
@@ -24,9 +24,10 @@
2424 }
2525
2626 return function scroll(d) {
2727 selectChild(!curMsgEl ? container.firstChild
28 + : d === 'first' ? container.firstChild
29 + : d < 0 ? curMsgEl.previousElementSibling || container.firstChild
2830 : d > 0 ? curMsgEl.nextElementSibling || container.lastChild
29- : d < 0 ? curMsgEl.previousElementSibling || container.firstChild
3031 : curMsgEl)
3132 }
3233 }
modules_basic/message/render.jsView
@@ -47,10 +47,10 @@
4747 ])
4848 return msgEl
4949
5050 function navigateToMessageOnEnter (ev) {
51- // on enter, hit first meta.
52- if(ev.keyCode == 13) {
51 + // on enter (or 'o'), hit first meta.
52 + if(ev.keyCode == 13 || ev.keyCode == 79) {
5353
5454 // unless in an input
5555 if (ev.target.nodeName === 'INPUT'
5656 || ev.target.nodeName === 'TEXTAREA') return
modules_core/tabs.jsView
@@ -109,24 +109,35 @@
109109
110110 return false
111111 }
112112
113 + var gPressed = false
113114 window.addEventListener('keydown', function (ev) {
114115 if (ev.target.nodeName === 'INPUT' || ev.target.nodeName === 'TEXTAREA')
115116 return
117 +
118 + // scroll to top
119 + if (ev.keyCode == 71) { // g
120 + if (!gPressed) return gPressed = true
121 +
122 + var el = tabs.get(tabs.selected[0]).firstChild.scroll('first')
123 + gPressed = false
124 + } else {
125 + gPressed = false
126 + }
127 +
116128 switch(ev.keyCode) {
117-
118129 // scroll through tabs
119130 case 72: // h
120131 return tabs.selectRelative(-1)
121132 case 76: // l
122133 return tabs.selectRelative(1)
123134
124135 // scroll through messages
125136 case 74: // j
126- return tabs.get(tabs.selected[0]).scroll(1)
137 + return tabs.get(tabs.selected[0]).firstChild.scroll(1)
127138 case 75: // k
128- return tabs.get(tabs.selected[0]).scroll(-1)
139 + return tabs.get(tabs.selected[0]).firstChild.scroll(-1)
129140
130141 // close a tab
131142 case 88: // x
132143 if (tabs.selected) {

Built with git-ssb-web