Fix threads highlighted by the filter not being put on top.

This commit is contained in:
Mayhem 2013-10-30 16:49:42 +01:00
parent 11c3b0018a
commit f0d19e6a5c
2 changed files with 20 additions and 11 deletions

View File

@ -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

View File

@ -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