From 1e682f930693543cac5685414cb0a427c5cbcebb Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sat, 1 Mar 2014 14:46:37 -0700 Subject: [PATCH] Navigate.coffee refactoring from commit a0c24fd06dc14e55908ea1531a8e967713131a7c Fix some stupid threadupdater issues, more navigate from catalog js --- src/General/Navigate.coffee | 43 ++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/General/Navigate.coffee b/src/General/Navigate.coffee index d4603a958..5ca08e206 100644 --- a/src/General/Navigate.coffee +++ b/src/General/Navigate.coffee @@ -3,7 +3,7 @@ Navigate = init: -> return if g.VIEW is 'catalog' or g.BOARD.ID is 'f' or !Conf['JSON Navigation'] - $.ready -> + $.ready -> # blink/webkit throw a popstate on page load. Not what we want. $.on window, 'popstate', Navigate.popstate @@ -38,7 +38,7 @@ Navigate = g.threads.forEach (thread) -> thread.collect() QuoteBacklink.containers = {} - $.rmAll $('.board') + $.rmAll $ '.board' features: [ ['Thread Excerpt', ThreadExcerpt] @@ -150,10 +150,10 @@ Navigate = style = d.cookie.match new RegExp "\b#{type}\_style\=([^;]+);\b" return ["#{type}_style", (if style then style[1] else base)] - style = findStyle (if sfw - ['ws', 'Yotsuba B New'] + style = if sfw + findStyle 'ws', 'Yotsuba B New' else - ['nws', 'Yotsuba New'])... + findStyle 'nws', 'Yotsuba New' $.globalEval "var style_group = '#{style[0]}'" @@ -166,20 +166,19 @@ Navigate = $('.boardTitle').textContent = d.title = "/#{board}/ - #{title}" navigate: (e) -> - return if @hostname isnt 'boards.4chan.org' or window.location.hostname is 'rs.4chan.org' or - (e and (e.shiftKey or e.ctrlKey or (e.type is 'click' and e.button isnt 0))) # Not simply a left click + return if @hostname isnt 'boards.4chan.org' or window.location.hostname is 'rs.4chan.org' + return if 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' - path = @pathname.split '/' - path.shift() if path[0] is '' - [boardID, view, threadID] = path + [_, boardID, view, threadID] = @pathname.split '/' return if view is 'catalog' or 'f' in [boardID, g.BOARD.ID] e.preventDefault() if e Navigate.title = -> return delete Index.pageNum + $.rmAll Header.hover path = @pathname path += @hash if @hash @@ -195,6 +194,7 @@ Navigate = if view is g.VIEW and boardID is g.BOARD.ID Navigate.updateContext view + else # We've navigated somewhere we weren't before! Navigate.disconnect() Navigate.updateContext view @@ -208,20 +208,19 @@ Navigate = Navigate.title = -> Navigate.updateBoard boardID if view is 'index' - Index.update pageNum - + return Index.update pageNum + # Moving from index to thread or thread to thread - else - Navigate.updateSFW Favicon.SFW - {load} = Navigate - Navigate.req = $.ajax "//a.4cdn.org/#{boardID}/thread/#{threadID}.json", - onabort: load - onloadend: load + Navigate.updateSFW Favicon.SFW + {load} = Navigate + Navigate.req = $.ajax "//a.4cdn.org/#{boardID}/thread/#{threadID}.json", + onabort: load + onloadend: load - setTimeout (-> - if Navigate.req and !Navigate.notice - Navigate.notice = new Notice 'info', 'Loading thread...' - ), 3 * $.SECOND + setTimeout (-> + if Navigate.req and !Navigate.notice + Navigate.notice = new Notice 'info', 'Loading thread...' + ), 3 * $.SECOND load: (e) -> $.rmClass Index.button, 'fa-spin'