Keybinds and navigation fixes.
This commit is contained in:
parent
af9b5139d0
commit
2af993300c
@ -1258,13 +1258,13 @@
|
|||||||
if (all) {
|
if (all) {
|
||||||
return $.id('imageExpand').click();
|
return $.id('imageExpand').click();
|
||||||
} else {
|
} else {
|
||||||
thumb = $('img[data-md5]', $('.replyhl', thread) || thread);
|
thumb = $('img[data-md5]', $('.post.highlight', thread) || thread);
|
||||||
return ImageExpand.toggle(thumb.parentNode);
|
return ImageExpand.toggle(thumb.parentNode);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
qr: function(thread, quote) {
|
qr: function(thread, quote) {
|
||||||
if (quote) {
|
if (quote) {
|
||||||
QR.quote.call($('.quotejs + .quotejs', $('.replyhl', thread) || thread));
|
QR.quote.call($('.postInfo > .postNum > a[title="Quote this post"]', $('.post.highlight', thread) || thread));
|
||||||
} else {
|
} else {
|
||||||
QR.open();
|
QR.open();
|
||||||
}
|
}
|
||||||
@ -1272,7 +1272,7 @@
|
|||||||
},
|
},
|
||||||
open: function(thread, tab) {
|
open: function(thread, tab) {
|
||||||
var id, url;
|
var id, url;
|
||||||
id = thread.firstChild.id;
|
id = thread.id.slice(1);
|
||||||
url = "//boards.4chan.org/" + g.BOARD + "/res/" + id;
|
url = "//boards.4chan.org/" + g.BOARD + "/res/" + id;
|
||||||
if (tab) {
|
if (tab) {
|
||||||
return $.open(url);
|
return $.open(url);
|
||||||
@ -1281,17 +1281,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
hl: function(delta, thread) {
|
hl: function(delta, thread) {
|
||||||
var next, rect, replies, reply, td, _i, _len;
|
var next, post, rect, replies, reply, _i, _len;
|
||||||
if (td = $('.replyhl', thread)) {
|
if (post = $('.reply.highlight', thread)) {
|
||||||
td.className = 'reply';
|
$.removeClass(post, 'highlight');
|
||||||
td.removeAttribute('tabindex');
|
post.removeAttribute('tabindex');
|
||||||
rect = td.getBoundingClientRect();
|
rect = post.getBoundingClientRect();
|
||||||
if (rect.bottom >= 0 && rect.top <= d.documentElement.clientHeight) {
|
if (rect.bottom >= 0 && rect.top <= d.documentElement.clientHeight) {
|
||||||
next = delta === +1 ? $.x('following::td[@class="reply"]', td) : $.x('preceding::td[@class="reply"]', td);
|
next = delta === +1 ? $.x('parent::div/following-sibling::div/div[contains(@class,"reply")]', post) : $.x('parent::div/preceding-sibling::div/div[contains(@class,"reply")]', post);
|
||||||
if (!next) {
|
if (!next) {
|
||||||
td.className = 'replyhl';
|
this.focus(post);
|
||||||
td.tabIndex = 0;
|
|
||||||
td.focus();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(g.REPLY || $.x('ancestor::div[@class="thread"]', next) === thread)) {
|
if (!(g.REPLY || $.x('ancestor::div[@class="thread"]', next) === thread)) {
|
||||||
@ -1301,9 +1299,7 @@
|
|||||||
if (rect.top < 0 || rect.bottom > d.documentElement.clientHeight) {
|
if (rect.top < 0 || rect.bottom > d.documentElement.clientHeight) {
|
||||||
next.scrollIntoView(delta === -1);
|
next.scrollIntoView(delta === -1);
|
||||||
}
|
}
|
||||||
next.className = 'replyhl';
|
this.focus(next);
|
||||||
next.tabIndex = 0;
|
|
||||||
next.focus();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1315,12 +1311,15 @@
|
|||||||
reply = replies[_i];
|
reply = replies[_i];
|
||||||
rect = reply.getBoundingClientRect();
|
rect = reply.getBoundingClientRect();
|
||||||
if (delta === +1 && rect.top >= 0 || delta === -1 && rect.bottom <= d.documentElement.clientHeight) {
|
if (delta === +1 && rect.top >= 0 || delta === -1 && rect.bottom <= d.documentElement.clientHeight) {
|
||||||
reply.className = 'replyhl';
|
this.focus(reply);
|
||||||
reply.tabIndex = 0;
|
|
||||||
reply.focus();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
focus: function(post) {
|
||||||
|
$.addClass(post, 'highlight');
|
||||||
|
post.tabIndex = 0;
|
||||||
|
return post.focus();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1372,7 +1371,7 @@
|
|||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $('form[name=delform]');
|
return $('.board');
|
||||||
},
|
},
|
||||||
scroll: function(delta) {
|
scroll: function(delta) {
|
||||||
var i, rect, thread, top, _ref, _ref1;
|
var i, rect, thread, top, _ref, _ref1;
|
||||||
|
|||||||
@ -944,18 +944,18 @@ Keybinds =
|
|||||||
if all
|
if all
|
||||||
$.id('imageExpand').click()
|
$.id('imageExpand').click()
|
||||||
else
|
else
|
||||||
thumb = $ 'img[data-md5]', $('.replyhl', thread) or thread
|
thumb = $ 'img[data-md5]', $('.post.highlight', thread) or thread
|
||||||
ImageExpand.toggle thumb.parentNode
|
ImageExpand.toggle thumb.parentNode
|
||||||
|
|
||||||
qr: (thread, quote) ->
|
qr: (thread, quote) ->
|
||||||
if quote
|
if quote
|
||||||
QR.quote.call $ '.quotejs + .quotejs', $('.replyhl', thread) or thread
|
QR.quote.call $ '.postInfo > .postNum > a[title="Quote this post"]', $('.post.highlight', thread) or thread
|
||||||
else
|
else
|
||||||
QR.open()
|
QR.open()
|
||||||
$('textarea', QR.el).focus()
|
$('textarea', QR.el).focus()
|
||||||
|
|
||||||
open: (thread, tab) ->
|
open: (thread, tab) ->
|
||||||
id = thread.firstChild.id
|
id = thread.id[1..]
|
||||||
url = "//boards.4chan.org/#{g.BOARD}/res/#{id}"
|
url = "//boards.4chan.org/#{g.BOARD}/res/#{id}"
|
||||||
if tab
|
if tab
|
||||||
$.open url
|
$.open url
|
||||||
@ -963,28 +963,24 @@ Keybinds =
|
|||||||
location.href = url
|
location.href = url
|
||||||
|
|
||||||
hl: (delta, thread) ->
|
hl: (delta, thread) ->
|
||||||
if td = $ '.replyhl', thread
|
if post = $ '.reply.highlight', thread
|
||||||
td.className = 'reply'
|
$.removeClass post, 'highlight'
|
||||||
td.removeAttribute 'tabindex'
|
post.removeAttribute 'tabindex'
|
||||||
rect = td.getBoundingClientRect()
|
rect = post.getBoundingClientRect()
|
||||||
if rect.bottom >= 0 and rect.top <= d.documentElement.clientHeight # We're at least partially visible
|
if rect.bottom >= 0 and rect.top <= d.documentElement.clientHeight # We're at least partially visible
|
||||||
next =
|
next =
|
||||||
if delta is +1
|
if delta is +1
|
||||||
$.x 'following::td[@class="reply"]', td
|
$.x 'parent::div/following-sibling::div/div[contains(@class,"reply")]', post
|
||||||
else
|
else
|
||||||
$.x 'preceding::td[@class="reply"]', td
|
$.x 'parent::div/preceding-sibling::div/div[contains(@class,"reply")]', post
|
||||||
unless next
|
unless next
|
||||||
td.className = 'replyhl'
|
@focus post
|
||||||
td.tabIndex = 0
|
|
||||||
td.focus()
|
|
||||||
return
|
return
|
||||||
return unless g.REPLY or $.x('ancestor::div[@class="thread"]', next) is thread
|
return unless g.REPLY or $.x('ancestor::div[@class="thread"]', next) is thread
|
||||||
rect = next.getBoundingClientRect()
|
rect = next.getBoundingClientRect()
|
||||||
if rect.top < 0 or rect.bottom > d.documentElement.clientHeight
|
if rect.top < 0 or rect.bottom > d.documentElement.clientHeight
|
||||||
next.scrollIntoView delta is -1
|
next.scrollIntoView delta is -1
|
||||||
next.className = 'replyhl'
|
@focus next
|
||||||
next.tabIndex = 0
|
|
||||||
next.focus()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
replies = $$ '.reply', thread
|
replies = $$ '.reply', thread
|
||||||
@ -992,11 +988,14 @@ Keybinds =
|
|||||||
for reply in replies
|
for reply in replies
|
||||||
rect = reply.getBoundingClientRect()
|
rect = reply.getBoundingClientRect()
|
||||||
if delta is +1 and rect.top >= 0 or delta is -1 and rect.bottom <= d.documentElement.clientHeight
|
if delta is +1 and rect.top >= 0 or delta is -1 and rect.bottom <= d.documentElement.clientHeight
|
||||||
reply.className = 'replyhl'
|
@focus reply
|
||||||
reply.tabIndex = 0
|
|
||||||
reply.focus()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
focus: (post) ->
|
||||||
|
$.addClass post, 'highlight'
|
||||||
|
post.tabIndex = 0
|
||||||
|
post.focus()
|
||||||
|
|
||||||
Nav =
|
Nav =
|
||||||
# ◀ ▶
|
# ◀ ▶
|
||||||
init: ->
|
init: ->
|
||||||
@ -1036,7 +1035,7 @@ Nav =
|
|||||||
if full
|
if full
|
||||||
return [thread, i, rect]
|
return [thread, i, rect]
|
||||||
return thread
|
return thread
|
||||||
return $ 'form[name=delform]'
|
return $ '.board'
|
||||||
|
|
||||||
scroll: (delta) ->
|
scroll: (delta) ->
|
||||||
[thread, i, rect] = Nav.getThread true
|
[thread, i, rect] = Nav.getThread true
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user