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

fix: Hotkey of switching post is invalid

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