Bring back return/catalog links.

This commit is contained in:
Mayhem 2014-02-07 18:45:19 +01:00
parent 7931acd942
commit 245dfaa1f9
4 changed files with 35 additions and 14 deletions

View File

@ -378,11 +378,6 @@ a[href="javascript:;"] {
:root.index-loading .pagelist { :root.index-loading .pagelist {
display: none; 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 { #index-search {
padding-right: 1.5em; padding-right: 1.5em;
width: 100px; width: 100px;

View File

@ -1,3 +1,4 @@
[<a id="index-mode-toggle" href="./"></a>]&nbsp;
[<time id="index-last-refresh" title="Last index refresh">...</time>]&nbsp; [<time id="index-last-refresh" title="Last index refresh">...</time>]&nbsp;
<input type="search" id="index-search" class="field" placeholder="Search"> <input type="search" id="index-search" class="field" placeholder="Search">
<a id="index-search-clear" class="fa fa-times-circle" href="javascript:;"></a> <a id="index-search-clear" class="fa fa-times-circle" href="javascript:;"></a>

View File

@ -9,3 +9,6 @@
<button disabled>Next</button> <button disabled>Next</button>
</a> </a>
</div> </div>
<div class="pages cataloglink">
<a href="./">Catalog</a>
</div>

View File

@ -2,7 +2,7 @@ Index =
showHiddenThreads: false showHiddenThreads: false
init: -> init: ->
if g.VIEW isnt 'index' if g.VIEW isnt 'index'
@rmCatalogLinks() $.ready @setupNavLinks
return return
return if g.BOARD.ID is 'f' return if g.BOARD.ID is 'f'
@ -29,9 +29,13 @@ Index =
{ el: $.el 'label', innerHTML: '<input type=radio name="Index Mode" value="all pages"> All threads' } { el: $.el 'label', innerHTML: '<input type=radio name="Index Mode" value="all pages"> All threads' }
{ el: $.el 'label', innerHTML: '<input type=radio name="Index Mode" value="catalog"> Catalog' } { el: $.el 'label', innerHTML: '<input type=radio name="Index Mode" value="catalog"> Catalog' }
] ]
open: ->
for label in @subEntries
input = label.el.firstChild
input.checked = Conf['Index Mode'] is input.value
true
for label in modeEntry.subEntries for label in modeEntry.subEntries
input = label.el.firstChild input = label.el.firstChild
input.checked = Conf['Index Mode'] is input.value
$.on input, 'change', $.cb.value $.on input, 'change', $.cb.value
$.on input, 'change', @cb.mode $.on input, 'change', @cb.mode
@ -99,11 +103,13 @@ Index =
@navLinks = $.el 'div', @navLinks = $.el 'div',
className: 'navLinks' className: 'navLinks'
innerHTML: <%= importHTML('General/Index-navlinks') %> innerHTML: <%= importHTML('General/Index-navlinks') %>
@indexModeToggle = $ '#index-mode-toggle', @navLinks
@searchInput = $ '#index-search', @navLinks @searchInput = $ '#index-search', @navLinks
@hideLabel = $ '#hidden-label', @navLinks @hideLabel = $ '#hidden-label', @navLinks
@currentPage = @getCurrentPage() @currentPage = @getCurrentPage()
$.on window, 'popstate', @cb.popstate $.on window, 'popstate', @cb.popstate
$.on @pagelist, 'click', @cb.pageNav $.on @pagelist, 'click', @cb.pageNav
$.on @indexModeToggle, '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
$.on $('#hidden-toggle a', @navLinks), 'click', @cb.toggleHiddenThreads $.on $('#hidden-toggle a', @navLinks), 'click', @cb.toggleHiddenThreads
@ -211,20 +217,26 @@ Index =
$.set 'Index Mode', 'catalog' $.set 'Index Mode', 'catalog'
window.location = './' window.location = './'
$.add $.id('info'), a $.add $.id('info'), a
rmCatalogLinks: -> setupNavLinks: ->
$.addClass doc, 'removing-catalog-links' for el in $$ '.navLinks.desktop > a'
$.ready -> if el.getAttribute('href') is '.././catalog'
for el in $$ '.navLinks.desktop a[href$=catalog]' el.href = '.././'
$.rm el.previousSibling $.on el, 'click', ->
$.rm el switch @textContent
$.rmClass doc, 'removing-catalog-links' when 'Return'
$.set 'Index Mode', 'paged'
when 'Catalog'
$.set 'Index Mode', 'catalog'
return
cb: cb:
toggleCatalogMode: -> toggleCatalogMode: ->
if Conf['Index Mode'] is 'catalog' if Conf['Index Mode'] is 'catalog'
Index.indexModeToggle.textContent = 'Return'
$.addClass Index.root, 'catalog-mode' $.addClass Index.root, 'catalog-mode'
$('#hidden-toggle', Index.navLinks).hidden = false $('#hidden-toggle', Index.navLinks).hidden = false
else else
Index.indexModeToggle.textContent = 'Catalog'
$.rmClass Index.root, 'catalog-mode' $.rmClass Index.root, 'catalog-mode'
$('#hidden-toggle', Index.navLinks).hidden = true $('#hidden-toggle', Index.navLinks).hidden = true
toggleHiddenThreads: -> toggleHiddenThreads: ->
@ -263,6 +275,16 @@ Index =
else else
return return
e.preventDefault() 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] Index.userPageNav +a.pathname.split('/')[2]
scrollToIndex: -> scrollToIndex: ->