Fix threads highlighted by the filter not being put on top.
This commit is contained in:
parent
11c3b0018a
commit
f0d19e6a5c
@ -110,13 +110,8 @@ Filter =
|
||||
|
||||
# Highlight
|
||||
$.addClass @nodes.root, result.class
|
||||
if !@isReply and result.top and g.VIEW is 'index'
|
||||
# Put the highlighted OPs' thread on top of the board page...
|
||||
thisThread = @nodes.root.parentNode
|
||||
# ...before the first non highlighted thread.
|
||||
if firstThread = $ 'div[class="postContainer opContainer"]'
|
||||
unless firstThread is @nodes.root
|
||||
$.before firstThread.parentNode, [thisThread, thisThread.nextElementSibling]
|
||||
if !@isReply and result.top
|
||||
@thread.isOnTop = true
|
||||
|
||||
name: (post) ->
|
||||
if 'name' of post.info
|
||||
|
||||
@ -28,6 +28,8 @@ Index =
|
||||
|
||||
initReady: ->
|
||||
$.off d, '4chanXInitFinished', Index.initReady
|
||||
Index.root = $ '.board'
|
||||
Index.setIndex $$ '.board > .thread, .board > hr', Index.root
|
||||
return if Conf['Index Mode'] is 'paged'
|
||||
Index.update()
|
||||
|
||||
@ -100,8 +102,20 @@ Index =
|
||||
Main.callbackNodes Thread, threads
|
||||
Main.callbackNodes Post, posts
|
||||
|
||||
board = $ '.board'
|
||||
$.rmAll board
|
||||
$.add board, nodes
|
||||
$('.pagelist').hidden = Conf['Index Mode'] isnt 'paged'
|
||||
Index.setIndex nodes
|
||||
$.event 'IndexRefresh'
|
||||
setIndex: (nodes) ->
|
||||
$.rmAll Index.root
|
||||
$.add Index.root, Index.sort nodes
|
||||
$('.pagelist').hidden = Conf['Index Mode'] isnt 'paged'
|
||||
sort: (nodes) ->
|
||||
return nodes unless Conf['Filter']
|
||||
# Put the highlighted thread on top of the index
|
||||
# while keeping the original order they appear in.
|
||||
tops = []
|
||||
for threadRoot in nodes by 2 when Get.threadFromRoot(threadRoot).isOnTop
|
||||
tops.push threadRoot
|
||||
for top, i in tops
|
||||
arr = nodes.splice nodes.indexOf(top), 2
|
||||
nodes.splice i * 2, 0, arr...
|
||||
nodes
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user