From 0908323290d55cf5f69218cd3f7689d55d2442b5 Mon Sep 17 00:00:00 2001 From: rr- Date: Sat, 11 Jun 2016 21:37:19 +0200 Subject: [PATCH] client/posts: add keyboard shortcuts --- client/js/views/post_view.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/client/js/views/post_view.js b/client/js/views/post_view.js index 14e24596..f8e25df8 100644 --- a/client/js/views/post_view.js +++ b/client/js/views/post_view.js @@ -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;