Commit 0deca1a2dd623557c84798484b3fcdedb6a923cb
make messages focusable - when hit enter, search for the next item under current and click it
Dominic Tarr committed on 6/18/2016, 10:15:35 AMParent: d0145eaaeadda8e425fdf9f4bca039dbc19b9ec5
Files changed
modules/message.js | changed |
modules/timestamp.js | changed |
modules/message.js | ||
---|---|---|
@@ -30,20 +30,32 @@ | ||
30 | 30 | )) |
31 | 31 | }) |
32 | 32 | ) |
33 | 33 | |
34 | - return h('div.message.column', | |
34 | + var msg = h('div.message.column', | |
35 | 35 | h('div.title.row', |
36 | 36 | h('div.avatar', avatar(msg.value.author)), |
37 | 37 | h('div.message_meta.row', message_meta(msg)) |
38 | 38 | ), |
39 | 39 | h('div.message_content', el), |
40 | 40 | h('div.message_actions.row', |
41 | 41 | h('div.actions', message_action(msg)) |
42 | 42 | ), |
43 | - backlinks | |
43 | + backlinks, | |
44 | + {onkeydown: function (ev) { | |
45 | + //on enter, hit first meta. | |
46 | + if(ev.keyCode == 13) { | |
47 | + msg.querySelector('.enter').click() | |
48 | + } | |
49 | + }} | |
44 | 50 | ) |
51 | + | |
52 | + // ); hyperscript does not seem to set attributes correctly. | |
53 | + msg.setAttribute('tabindex', '0') | |
54 | + | |
55 | + return msg | |
45 | 56 | } |
46 | 57 | |
47 | 58 | |
48 | 59 | |
49 | 60 | |
61 | + |
modules/timestamp.js | ||
---|---|---|
@@ -1,6 +1,6 @@ | ||
1 | 1 | var h = require('hyperscript') |
2 | 2 | var moment = require('moment') |
3 | 3 | |
4 | 4 | exports.message_meta = function (msg) { |
5 | - return h('a', {href: '#'+msg.key}, moment(msg.value.timestamp).fromNow()) | |
5 | + return h('a.enter', {href: '#'+msg.key}, moment(msg.value.timestamp).fromNow()) | |
6 | 6 | } |
Built with git-ssb-web