Reflow a ton of navigate and index shit to fix broken shit

Conflicts:
	builds/4chan-X.user.js
	builds/crx/script.js
	src/General/Index.coffee
	src/General/Navigate.coffee
	src/Posting/QR.coffee
This commit is contained in:
Zixaphir 2014-03-02 21:04:14 -07:00 committed by ccd0
parent 1e682f9306
commit 298bed6336
2 changed files with 27 additions and 30 deletions

View File

@ -84,31 +84,26 @@ Navigate =
error: err error: err
] ]
Main.handleErrors error if error Main.handleErrors error if error
QR.generatePostableThreadsList()
updateContext: (view) -> updateContext: (view) ->
g.DEAD = false g.DEAD = false
g.THREADID = +window.location.pathname.split('/')[3] if view is 'thread'
unless view is g.VIEW return if view is g.VIEW
$.rmClass doc, g.VIEW
$.addClass doc, view $.rmClass doc, g.VIEW
$.addClass doc, view
oldView = g.VIEW
g.VIEW = view
{ {
index: -> index: ->
return if oldView is g.VIEW
delete g.THREADID delete g.THREADID
QR.link.textContent = 'Start a Thread' QR.link.textContent = 'Start a Thread'
$.off d, 'ThreadUpdate', QR.statusCheck
$.on d, 'IndexRefresh', QR.generatePostableThreadsList
thread: -> thread: ->
g.THREADID = +window.location.pathname.split('/')[3]
return if oldView is g.VIEW
QR.link.textContent = 'Reply to Thread' QR.link.textContent = 'Reply to Thread'
$.on d, 'ThreadUpdate', QR.statusCheck }[view]()
$.off d, 'IndexRefresh', QR.generatePostableThreadsList
}[g.VIEW]() g.VIEW = view
updateBoard: (boardID) -> updateBoard: (boardID) ->
fullBoardList = $ '#full-board-list', Header.boardList fullBoardList = $ '#full-board-list', Header.boardList
@ -138,14 +133,16 @@ Navigate =
Navigate.updateSFW !!board.ws_board Navigate.updateSFW !!board.ws_board
updateSFW: (sfw) -> updateSFW: (sfw) ->
# TODO: think of a better name for this. Changes style, too. Favicon.el.href = Favicon.default = "//s.4cdn.org/image/favicon#{if sfw then '-ws' else ''}.ico"
Favicon.el.href = "//s.4cdn.org/image/favicon#{if sfw then '-ws' else ''}.ico"
$.add d.head, Favicon.el # Changing the href alone doesn't update the icon on Firefox # Changing the href alone doesn't update the icon on Firefox
$.add d.head, Favicon.el
return if Favicon.SFW is sfw # Board SFW status hasn't changed return if Favicon.SFW is sfw # Board SFW status hasn't changed
Favicon.SFW = sfw Favicon.SFW = sfw
Favicon.update() Favicon.update()
findStyle = (type, base) -> findStyle = (type, base) ->
style = d.cookie.match new RegExp "\b#{type}\_style\=([^;]+);\b" style = d.cookie.match new RegExp "\b#{type}\_style\=([^;]+);\b"
return ["#{type}_style", (if style then style[1] else base)] return ["#{type}_style", (if style then style[1] else base)]
@ -207,11 +204,12 @@ Navigate =
g.BOARD = new Board boardID g.BOARD = new Board boardID
Navigate.title = -> Navigate.updateBoard boardID Navigate.title = -> Navigate.updateBoard boardID
Navigate.updateSFW Favicon.SFW
if view is 'index' if view is 'index'
return Index.update pageNum return Index.update pageNum
# Moving from index to thread or thread to thread # Moving from index to thread or thread to thread
Navigate.updateSFW Favicon.SFW
{load} = Navigate {load} = Navigate
Navigate.req = $.ajax "//a.4cdn.org/#{boardID}/thread/#{threadID}.json", Navigate.req = $.ajax "//a.4cdn.org/#{boardID}/thread/#{threadID}.json",
onabort: load onabort: load
@ -283,6 +281,7 @@ Navigate =
Navigate.ready 'Quote Threading', QuoteThreading.force, Conf['Quote Threading'] and not Conf['Unread Count'] Navigate.ready 'Quote Threading', QuoteThreading.force, Conf['Quote Threading'] and not Conf['Unread Count']
Navigate.buildThread() Navigate.buildThread()
QR.generatePostableThreadsList()
Header.hashScroll.call window Header.hashScroll.call window
buildThread: -> buildThread: ->

View File

@ -15,7 +15,6 @@ QR =
href: 'javascript:;' href: 'javascript:;'
$.on sc, 'click', -> $.on sc, 'click', ->
if Conf['Persistent QR'] or !QR.nodes or QR.nodes.el.hidden if Conf['Persistent QR'] or !QR.nodes or QR.nodes.el.hidden
$.event 'CloseMenu'
QR.open() QR.open()
QR.nodes.com.focus() QR.nodes.com.focus()
$.rmClass @, 'disabled' $.rmClass @, 'disabled'
@ -70,15 +69,14 @@ QR =
$.on d, 'dragover', QR.dragOver $.on d, 'dragover', QR.dragOver
$.on d, 'drop', QR.dropFile $.on d, 'drop', QR.dropFile
$.on d, 'dragstart dragend', QR.drag $.on d, 'dragstart dragend', QR.drag
{
catalog: -> # We can thread update and index refresh without loading a new page, so...
QR.open() if Conf["Persistent QR"] $.on d, 'IndexRefresh', QR.generatePostableThreadsList
QR.hide() if Conf['Auto Hide QR'] $.on d, 'ThreadUpdate', QR.statusCheck
index: ->
$.on d, 'IndexRefresh', QR.generatePostableThreadsList return if !Conf['Persistent QR']
thread: -> QR.open()
$.on d, 'ThreadUpdate', QR.statusCheck QR.hide() if Conf['Auto-Hide QR']
}[g.VIEW]()
statusCheck: -> statusCheck: ->
if g.DEAD if g.DEAD