Use our implementation of Navigating between boards

Our custom navigation should now behave similar to Mayhem's, but
with JSON.
This commit is contained in:
Zixaphir 2014-02-28 18:56:02 -07:00
parent 5a76a9109c
commit 811e3ccaf3
8 changed files with 60 additions and 44 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -49,6 +49,10 @@ Config =
true true
'Add buttons to expand threads.' 'Add buttons to expand threads.'
] ]
'Comment Expansion': [
false
'Expand Comments that are too long to display on the index. Does not work with JSON Navigation.'
]
'Index Navigation': [ 'Index Navigation': [
false false
'Add buttons to navigate between threads.' 'Add buttons to navigate between threads.'

View File

@ -144,8 +144,6 @@ Header =
id: 'board-list' id: 'board-list'
innerHTML: "<span id=custom-board-list></span><span id=full-board-list hidden><span class='hide-board-list-container brackets-wrap'><a href=javascript:; class='hide-board-list-button'>&nbsp;-&nbsp;</a></span> #{fourchannav.innerHTML}</span>" innerHTML: "<span id=custom-board-list></span><span id=full-board-list hidden><span class='hide-board-list-container brackets-wrap'><a href=javascript:; class='hide-board-list-button'>&nbsp;-&nbsp;</a></span> #{fourchannav.innerHTML}</span>"
$.on $('#custom-board-list', Header.boardList), 'click', Index.cb.headerNav if Conf['JSON Navigation']
for a in $$ 'a', boardList for a in $$ 'a', boardList
if Conf['JSON Navigation'] if Conf['JSON Navigation']
$.on a, 'click', Navigate.navigate $.on a, 'click', Navigate.navigate

View File

@ -303,11 +303,6 @@ Index =
if mode not in ['catalog', Conf['Previous Index Mode']] if mode not in ['catalog', Conf['Previous Index Mode']]
Conf['Previous Index Mode'] = mode Conf['Previous Index Mode'] = mode
$.set 'Previous Index Mode', mode $.set 'Previous Index Mode', mode
return unless QR.nodes
if mode is 'catalog'
QR.hide()
else
QR.unhide()
sort: (e) -> sort: (e) ->
Index.sort() Index.sort()

View File

@ -321,6 +321,7 @@ Main =
['Image Loading', ImageLoader] ['Image Loading', ImageLoader]
['Image Hover', ImageHover] ['Image Hover', ImageHover]
['Thread Expansion', ExpandThread] ['Thread Expansion', ExpandThread]
['Comment Expansion', ExpandComment]
['Thread Excerpt', ThreadExcerpt] ['Thread Excerpt', ThreadExcerpt]
['Favicon', Favicon] ['Favicon', Favicon]
['Unread', Unread] ['Unread', Unread]

View File

@ -166,7 +166,7 @@ Navigate =
navigate: (e) -> navigate: (e) ->
return if @hostname isnt 'boards.4chan.org' or window.location.hostname is 'rs.4chan.org' or return if @hostname isnt 'boards.4chan.org' or window.location.hostname is 'rs.4chan.org' or
(e and (e.shiftKey or (e.type is 'click' and e.button isnt 0))) # Not simply a left click (e and (e.shiftKey or e.ctrlKey or (e.type is 'click' and e.button isnt 0))) # Not simply a left click
$.addClass Index.button, 'fa-spin' $.addClass Index.button, 'fa-spin'
@ -174,7 +174,7 @@ Navigate =
path.shift() if path[0] is '' path.shift() if path[0] is ''
[boardID, view, threadID] = path [boardID, view, threadID] = path
return if view is 'catalog' or 'f' in [boardID, g.BOARD.ID] return if 'f' in [boardID, g.BOARD.ID]
e.preventDefault() if e e.preventDefault() if e
Navigate.title = -> return Navigate.title = -> return
@ -192,6 +192,18 @@ Navigate =
pageNum = view pageNum = view
view = 'index' # path is "/boardID/". See the problem? view = 'index' # path is "/boardID/". See the problem?
{indexMode, indexSort} = @dataset
if indexMode and Conf['Index Mode'] isnt indexMode
$.set 'Index Mode', indexMode
Conf['Index Mode'] = indexMode
Index.selectMode.value = indexMode
Index.cb.mode()
if indexSort and Conf['Index Sort'] isnt indexSort
$.set 'Index Sort', indexSort
Conf['Index Sort'] = indexSort
Index.selectSort.value = indexSort
Index.cb.sort()
if view is g.VIEW and boardID is g.BOARD.ID if view is g.VIEW and boardID is g.BOARD.ID
Navigate.updateContext view Navigate.updateContext view
else # We've navigated somewhere we weren't before! else # We've navigated somewhere we weren't before!

View File

@ -1,6 +1,6 @@
ExpandComment = ExpandComment =
init: -> init: ->
return if g.VIEW isnt 'index' or !Conf['Comment Expansion'] return if g.VIEW isnt 'index' or !Conf['Comment Expansion'] or Conf['JSON Navigation']
@callbacks.push Fourchan.code if g.BOARD.ID is 'g' @callbacks.push Fourchan.code if g.BOARD.ID is 'g'
@callbacks.push Fourchan.math if g.BOARD.ID is 'sci' @callbacks.push Fourchan.math if g.BOARD.ID is 'sci'