提交 e77f00ba 编写于 作者: EvanOne(文一)'s avatar EvanOne(文一)

fix: Hotkey of switching post is invalid

上级 79ae4ff7
...@@ -2,7 +2,7 @@ $(document).ready(function () { ...@@ -2,7 +2,7 @@ $(document).ready(function () {
Stun.utils.showThemeInConsole(); Stun.utils.showThemeInConsole();
if (CONFIG.shortcuts && CONFIG.shortcuts.switch_post) { if (CONFIG.shortcuts && CONFIG.shortcuts.switch_post) {
Stun.utils.registerHotkeyToSwitchPost(); Stun.utils.registerSwitchPost();
} }
// Not reload this, because it's changeless. // Not reload this, because it's changeless.
......
...@@ -393,18 +393,20 @@ Stun.utils = Stun.$u = { ...@@ -393,18 +393,20 @@ Stun.utils = Stun.$u = {
.append($icon); .append($icon);
}, },
// Switch to the prev / next post by shortcuts. // Switch to the prev / next post by shortcuts.
registerHotkeyToSwitchPost: function () { registerSwitchPost: function () {
var _this = this; var keyLeft = this.codeToKeyCode('ArrowLeft');
var keyRight = this.codeToKeyCode('ArrowRight');
$(document).on('keydown', function (e) { $(document).on('keydown', function (e) {
var isPrev = e.keyCode === _this.codeToKeyCode('ArrowLeft'); var isPrev = e.keyCode === keyLeft;
var isNext = e.keyCode === _this.codeToKeyCode('ArrowRight'); var isNext = e.keyCode === keyRight;
if (e.ctrlKey && isPrev) { if (e.ctrlKey) {
var prev = $('.paginator-post-prev').find('a')[0]; if (isPrev) {
prev && prev.click(); $('.paginator-prev a')[0].click();
} else if (e.ctrlKey && isNext) { } else if (isNext) {
var next = $('.paginator-post-next').find('a')[0]; $('.paginator-next a')[0].click();
next && next.click(); }
} }
}); });
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册