diff options
| author | Hunternif | 2019-04-13 19:08:14 +0700 |
|---|---|---|
| committer | Hunternif | 2019-04-13 19:28:32 +0700 |
| commit | 55a7a96305dd9923f86f913ed4dea48b746685a1 (patch) | |
| tree | 0eac4a43aad495d6eccd7cb51399823754f04663 /client/js | |
| parent | 9a8f4e31046f197326cacbdd141b6abf07b2a078 (diff) | |
Add keyboard shortcuts for random post, focus tags input and save post
Diffstat (limited to 'client/js')
| -rw-r--r-- | client/js/controls/post_edit_sidebar_control.js | 11 | ||||
| -rw-r--r-- | client/js/views/post_main_view.js | 11 |
2 files changed, 20 insertions, 2 deletions
diff --git a/client/js/controls/post_edit_sidebar_control.js b/client/js/controls/post_edit_sidebar_control.js index b920896..dd62355 100644 --- a/client/js/controls/post_edit_sidebar_control.js +++ b/client/js/controls/post_edit_sidebar_control.js @@ -67,7 +67,7 @@ class PostEditSidebarControl extends events.EventTarget { this._syncExpanderTitles(); if (this._formNode) { - this._formNode.addEventListener('submit', e => this._evtSubmit(e)); + this._formNode.addEventListener('submit', e => this.submit(e)); } if (this._tagInputNode) { @@ -319,7 +319,7 @@ class PostEditSidebarControl extends events.EventTarget { this._postNotesOverlayControl.switchToPassiveEdit(); } - _evtSubmit(e) { + submit(e) { e.preventDefault(); this.dispatchEvent(new CustomEvent('submit', { detail: { @@ -465,6 +465,13 @@ class PostEditSidebarControl extends events.EventTarget { showError(message) { views.showError(this._hostNode, message); } + + focusTagInput() { + const realTagInput = this._formNode.querySelector('.tag-input input'); + if (realTagInput) { + realTagInput.focus(); + } + } }; module.exports = PostEditSidebarControl; diff --git a/client/js/views/post_main_view.js b/client/js/views/post_main_view.js index 55b57cc..7718dea 100644 --- a/client/js/views/post_main_view.js +++ b/client/js/views/post_main_view.js @@ -81,11 +81,22 @@ class PostMainView { }); keyboard.bind(['a', 'left'], showPreviousImage); keyboard.bind(['d', 'right'], showNextImage); + keyboard.bind('r', showRandomImage); keyboard.bind('del', (e) => { if (ctx.editMode) { this.sidebarControl._evtDeleteClick(e); } }); + keyboard.bind('t', () => { + if (ctx.editMode) { + this.sidebarControl.focusTagInput(); + } + }); + keyboard.bind(['command+s', 'ctrl+s'], (e) => { + if (ctx.editMode) { + this.sidebarControl.submit(e); + } + }); new Touch( postContainerNode, |