Finally fix Index from Thread navigation
This commit is contained in:
parent
3327c9cf36
commit
22c244ce69
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -66,13 +66,7 @@ Index =
|
|||||||
order: 98
|
order: 98
|
||||||
subEntries: [repliesEntry, anchorEntry, refNavEntry, modeEntry, sortEntry]
|
subEntries: [repliesEntry, anchorEntry, refNavEntry, modeEntry, sortEntry]
|
||||||
|
|
||||||
return if g.VIEW isnt 'index'
|
|
||||||
|
|
||||||
@connect.call @
|
|
||||||
|
|
||||||
connect: ->
|
|
||||||
$.addClass doc, 'index-loading'
|
$.addClass doc, 'index-loading'
|
||||||
@update()
|
|
||||||
@root = $.el 'div', className: 'board'
|
@root = $.el 'div', className: 'board'
|
||||||
@pagelist = $.el 'div',
|
@pagelist = $.el 'div',
|
||||||
className: 'pagelist'
|
className: 'pagelist'
|
||||||
@ -83,31 +77,34 @@ Index =
|
|||||||
innerHTML: <%= importHTML('Features/Index-navlinks') %>
|
innerHTML: <%= importHTML('Features/Index-navlinks') %>
|
||||||
@searchInput = $ '#index-search', @navLinks
|
@searchInput = $ '#index-search', @navLinks
|
||||||
@currentPage = @getCurrentPage()
|
@currentPage = @getCurrentPage()
|
||||||
$.on window, 'popstate', @cb.popstate
|
|
||||||
$.on @pagelist, 'click', @cb.pageNav
|
$.on @pagelist, 'click', @cb.pageNav
|
||||||
$.on @searchInput, 'input', @onSearchInput
|
$.on @searchInput, 'input', @onSearchInput
|
||||||
$.on $('#index-search-clear', @navLinks), 'click', @clearSearch
|
$.on $('#index-search-clear', @navLinks), 'click', @clearSearch
|
||||||
$.asap (-> $('.board', doc) or d.readyState isnt 'loading'), ->
|
|
||||||
board = $ '.board'
|
|
||||||
$.replace board, Index.root
|
|
||||||
# Hacks:
|
|
||||||
# - When removing an element from the document during page load,
|
|
||||||
# its ancestors will still be correctly created inside of it.
|
|
||||||
# - Creating loadable elements inside of an origin-less document
|
|
||||||
# will not download them.
|
|
||||||
# - Combine the two and you get a download canceller!
|
|
||||||
# Does not work on Firefox unfortunately. bugzil.la/939713
|
|
||||||
d.implementation.createDocument(null, null, null).appendChild board
|
|
||||||
|
|
||||||
for navLink in $$ '.navLinks'
|
@update() if g.VIEW is 'index'
|
||||||
$.rm navLink
|
$.asap (-> $('.board', doc) or d.readyState isnt 'loading'), ->
|
||||||
|
if g.VIEW is 'index'
|
||||||
|
board = $ '.board'
|
||||||
|
$.replace board, Index.root
|
||||||
|
# Hacks:
|
||||||
|
# - When removing an element from the document during page load,
|
||||||
|
# its ancestors will still be correctly created inside of it.
|
||||||
|
# - Creating loadable elements inside of an origin-less document
|
||||||
|
# will not download them.
|
||||||
|
# - Combine the two and you get a download canceller!
|
||||||
|
# Does not work on Firefox unfortunately. bugzil.la/939713
|
||||||
|
d.implementation.createDocument(null, null, null).appendChild board
|
||||||
|
|
||||||
|
$.rm navLink for navLink in $$ '.navLinks'
|
||||||
$.after $.x('child::form/preceding-sibling::hr[1]'), Index.navLinks
|
$.after $.x('child::form/preceding-sibling::hr[1]'), Index.navLinks
|
||||||
$.rmClass doc, 'index-loading'
|
$.rmClass doc, 'index-loading'
|
||||||
$.asap (-> $('.pagelist') or d.readyState isnt 'loading'), ->
|
|
||||||
if pagelist = $('.pagelist')
|
$.asap (-> $('.pagelist', doc) or d.readyState isnt 'loading'), ->
|
||||||
$.replace pagelist, Index.pagelist
|
if pagelist = $('.pagelist')
|
||||||
else
|
$.replace pagelist, Index.pagelist
|
||||||
$.after $.id('delform'), Index.pagelist
|
else
|
||||||
|
$.after $.id('delform'), Index.pagelist
|
||||||
|
|
||||||
cb:
|
cb:
|
||||||
mode: ->
|
mode: ->
|
||||||
@ -120,9 +117,6 @@ Index =
|
|||||||
Index.buildThreads()
|
Index.buildThreads()
|
||||||
Index.sort()
|
Index.sort()
|
||||||
Index.buildIndex()
|
Index.buildIndex()
|
||||||
popstate: (e) ->
|
|
||||||
pageNum = Index.getCurrentPage()
|
|
||||||
Index.pageLoad pageNum if Index.currentPage isnt pageNum
|
|
||||||
pageNav: (e) ->
|
pageNav: (e) ->
|
||||||
return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0
|
return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0
|
||||||
switch e.target.nodeName
|
switch e.target.nodeName
|
||||||
@ -209,6 +203,9 @@ Index =
|
|||||||
|
|
||||||
update: (pageNum) ->
|
update: (pageNum) ->
|
||||||
return unless navigator.onLine
|
return unless navigator.onLine
|
||||||
|
unless Index.root.parentElement
|
||||||
|
board = $ '.board'
|
||||||
|
$.replace board, Index.root
|
||||||
Index.req?.abort()
|
Index.req?.abort()
|
||||||
Index.notice?.close()
|
Index.notice?.close()
|
||||||
|
|
||||||
|
|||||||
@ -327,8 +327,10 @@ Main =
|
|||||||
{posts, threads} = g
|
{posts, threads} = g
|
||||||
|
|
||||||
# Garbage collection
|
# Garbage collection
|
||||||
delete posts[id] for id of posts when posts.hasOwnProperty id
|
g.posts = {}
|
||||||
delete threads[id] for id of threads when threads.hasOwnProperty id
|
g.threads = {}
|
||||||
|
g.BOARD.posts = {}
|
||||||
|
g.BOARD.threads = {}
|
||||||
|
|
||||||
# Delete nodes
|
# Delete nodes
|
||||||
$.rmAll $ '.board'
|
$.rmAll $ '.board'
|
||||||
@ -351,10 +353,8 @@ Main =
|
|||||||
error: err
|
error: err
|
||||||
|
|
||||||
Main.handleErrors errors if errors
|
Main.handleErrors errors if errors
|
||||||
|
|
||||||
# Clean Post and Thread callbacks
|
return
|
||||||
# Post.callbacks.clear()
|
|
||||||
# Thread.callbacks.clear()
|
|
||||||
|
|
||||||
navigate: (e) ->
|
navigate: (e) ->
|
||||||
return if @hostname isnt 'boards.4chan.org'
|
return if @hostname isnt 'boards.4chan.org'
|
||||||
@ -380,13 +380,9 @@ Main =
|
|||||||
|
|
||||||
if view is 'index'
|
if view is 'index'
|
||||||
Main.updateBoard boardID unless boardID is g.BOARD.ID
|
Main.updateBoard boardID unless boardID is g.BOARD.ID
|
||||||
|
Index.update()
|
||||||
|
|
||||||
if Index.root
|
# Moving from index to thread or thread to thread
|
||||||
Index.connect()
|
|
||||||
else
|
|
||||||
Index.update()
|
|
||||||
|
|
||||||
# Moving from thread to thread or index to index.
|
|
||||||
else
|
else
|
||||||
c.error 'How?'
|
c.error 'How?'
|
||||||
Main.refresh {boardID, view, threadID}
|
Main.refresh {boardID, view, threadID}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user