From 245dfaa1f935ee97856f7c5f718d6af774c078e5 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Fri, 7 Feb 2014 18:45:19 +0100 Subject: [PATCH] Bring back return/catalog links. --- css/style.css | 5 ---- html/General/Index-navlinks.html | 1 + html/General/Index-pagelist.html | 3 +++ src/General/Index.coffee | 40 +++++++++++++++++++++++++------- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/css/style.css b/css/style.css index cb5c54183..fd967d398 100644 --- a/css/style.css +++ b/css/style.css @@ -378,11 +378,6 @@ a[href="javascript:;"] { :root.index-loading .pagelist { display: none; } -:root.removing-catalog-links .navLinks { - /* can't `display:none;` the text node next to the link, - so we hide the container instead. */ - visibility: hidden; -} #index-search { padding-right: 1.5em; width: 100px; diff --git a/html/General/Index-navlinks.html b/html/General/Index-navlinks.html index f322941a7..da5b9bbaf 100644 --- a/html/General/Index-navlinks.html +++ b/html/General/Index-navlinks.html @@ -1,3 +1,4 @@ +[]  [ diff --git a/html/General/Index-pagelist.html b/html/General/Index-pagelist.html index e6923bb7a..803cdca54 100644 --- a/html/General/Index-pagelist.html +++ b/html/General/Index-pagelist.html @@ -9,3 +9,6 @@ + diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 410f6edea..888d3a552 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -2,7 +2,7 @@ Index = showHiddenThreads: false init: -> if g.VIEW isnt 'index' - @rmCatalogLinks() + $.ready @setupNavLinks return return if g.BOARD.ID is 'f' @@ -29,9 +29,13 @@ Index = { el: $.el 'label', innerHTML: ' All threads' } { el: $.el 'label', innerHTML: ' Catalog' } ] + open: -> + for label in @subEntries + input = label.el.firstChild + input.checked = Conf['Index Mode'] is input.value + true for label in modeEntry.subEntries input = label.el.firstChild - input.checked = Conf['Index Mode'] is input.value $.on input, 'change', $.cb.value $.on input, 'change', @cb.mode @@ -99,11 +103,13 @@ Index = @navLinks = $.el 'div', className: 'navLinks' innerHTML: <%= importHTML('General/Index-navlinks') %> + @indexModeToggle = $ '#index-mode-toggle', @navLinks @searchInput = $ '#index-search', @navLinks @hideLabel = $ '#hidden-label', @navLinks @currentPage = @getCurrentPage() $.on window, 'popstate', @cb.popstate $.on @pagelist, 'click', @cb.pageNav + $.on @indexModeToggle, 'click', @cb.pageNav $.on @searchInput, 'input', @onSearchInput $.on $('#index-search-clear', @navLinks), 'click', @clearSearch $.on $('#hidden-toggle a', @navLinks), 'click', @cb.toggleHiddenThreads @@ -211,20 +217,26 @@ Index = $.set 'Index Mode', 'catalog' window.location = './' $.add $.id('info'), a - rmCatalogLinks: -> - $.addClass doc, 'removing-catalog-links' - $.ready -> - for el in $$ '.navLinks.desktop a[href$=catalog]' - $.rm el.previousSibling - $.rm el - $.rmClass doc, 'removing-catalog-links' + setupNavLinks: -> + for el in $$ '.navLinks.desktop > a' + if el.getAttribute('href') is '.././catalog' + el.href = '.././' + $.on el, 'click', -> + switch @textContent + when 'Return' + $.set 'Index Mode', 'paged' + when 'Catalog' + $.set 'Index Mode', 'catalog' + return cb: toggleCatalogMode: -> if Conf['Index Mode'] is 'catalog' + Index.indexModeToggle.textContent = 'Return' $.addClass Index.root, 'catalog-mode' $('#hidden-toggle', Index.navLinks).hidden = false else + Index.indexModeToggle.textContent = 'Catalog' $.rmClass Index.root, 'catalog-mode' $('#hidden-toggle', Index.navLinks).hidden = true toggleHiddenThreads: -> @@ -263,6 +275,16 @@ Index = else return e.preventDefault() + switch a.textContent + when 'Catalog' + mode = 'catalog' + when 'Return' + mode = 'paged' + if mode + $.set 'Index Mode', mode + Conf['Index Mode'] = mode + Index.cb.mode() + Index.scrollToIndex() Index.userPageNav +a.pathname.split('/')[2] scrollToIndex: ->