client/posts: add keyboard shortcuts

This commit is contained in:
rr- 2016-06-11 21:37:19 +02:00
parent 56432e6089
commit 0908323290

View file

@ -1,6 +1,8 @@
'use strict';
const views = require('../util/views.js');
const keyboard = require('../util/keyboard.js');
const page = require('page');
const PostContentControl = require('../controls/post_content_control.js');
const PostNotesOverlayControl
= require('../controls/post_notes_overlay_control.js');
@ -60,8 +62,25 @@ class PostView {
ctx.post,
this._postContentControl);
}
}
keyboard.bind('e', () => {
if (ctx.editMode) {
page.show('/post/' + ctx.post.id);
} else {
page.show('/post/' + ctx.post.id + '/edit');
}
});
keyboard.bind(['a', 'left'], () => {
if (ctx.nextPostId) {
page.show('/post/' + ctx.nextPostId);
}
});
keyboard.bind(['d', 'right'], () => {
if (ctx.prevPostId) {
page.show('/post/' + ctx.prevPostId);
}
});
}
}
module.exports = PostView;