Merge branch 'reverse' into next

This commit is contained in:
ccd0 2016-10-30 21:35:15 -07:00
commit aa7a35307a
4 changed files with 23 additions and 14 deletions

View File

@ -95,17 +95,20 @@ Index =
@hideLabel = $ '#hidden-label', @navLinks @hideLabel = $ '#hidden-label', @navLinks
$.on $('#hidden-toggle a', @navLinks), 'click', @cb.toggleHiddenThreads $.on $('#hidden-toggle a', @navLinks), 'click', @cb.toggleHiddenThreads
# Drop-down menus # Drop-down menus and reverse sort toggle
@selectRev = $ '#index-rev', @navLinks
@selectMode = $ '#index-mode', @navLinks @selectMode = $ '#index-mode', @navLinks
@selectSort = $ '#index-sort', @navLinks @selectSort = $ '#index-sort', @navLinks
@selectSize = $ '#index-size', @navLinks @selectSize = $ '#index-size', @navLinks
$.on @selectRev, 'change', @cb.sort
$.on @selectMode, 'change', @cb.mode $.on @selectMode, 'change', @cb.mode
$.on @selectSort, 'change', @cb.sort $.on @selectSort, 'change', @cb.sort
$.on @selectSize, 'change', $.cb.value $.on @selectSize, 'change', $.cb.value
$.on @selectSize, 'change', @cb.size $.on @selectSize, 'change', @cb.size
for select in [@selectMode, @selectSize] for select in [@selectMode, @selectSize]
select.value = Conf[select.name] select.value = Conf[select.name]
@selectSort.value = Index.currentSort @selectRev.checked = /-rev$/.test Index.currentSort
@selectSort.value = Index.currentSort.replace /-rev$/, ''
# Thread container # Thread container
@root = $.el 'div', className: 'board json-index' @root = $.el 'div', className: 'board json-index'
@ -252,7 +255,8 @@ Index =
Index.pageLoad false Index.pageLoad false
sort: -> sort: ->
Index.pushState {sort: @value} value = if Index.selectRev.checked then Index.selectSort.value + "-rev" else Index.selectSort.value
Index.pushState {sort: value}
Index.pageLoad false Index.pageLoad false
resort: (e) -> resort: (e) ->
@ -342,12 +346,12 @@ Index =
'all-pages': 'all pages' 'all-pages': 'all pages'
'catalog': 'catalog' 'catalog': 'catalog'
sort: sort:
'bump-order': 'bump' 'bump-order': 'bump'
'last-reply': 'lastreply' 'last-reply': 'lastreply'
'last-long-reply': 'lastlong' 'last-long-reply': 'lastlong'
'creation-date': 'birth' 'creation-date': 'birth'
'reply-count': 'replycount' 'reply-count': 'replycount'
'file-count': 'filecount' 'file-count': 'filecount'
processHash: -> processHash: ->
# XXX https://bugzilla.mozilla.org/show_bug.cgi?id=483304 # XXX https://bugzilla.mozilla.org/show_bug.cgi?id=483304
@ -362,8 +366,9 @@ Index =
else if command is 'index' else if command is 'index'
state.mode = Conf['Previous Index Mode'] state.mode = Conf['Previous Index Mode']
state.page = 1 state.page = 1
else if (sort = Index.hashCommands.sort[command]) else if (sort = Index.hashCommands.sort[command.replace(/-rev$/, '')])
state.sort = sort state.sort = sort
state.sort += '-rev' if /-rev$/.test(command)
else if /^s=/.test command else if /^s=/.test command
state.search = decodeURIComponent(command[2..]).replace(/\+/g, ' ').trim() state.search = decodeURIComponent(command[2..]).replace(/\+/g, ' ').trim()
else else
@ -446,7 +451,8 @@ Index =
$('#hidden-toggle a', Index.navLinks).textContent = 'Show' $('#hidden-toggle a', Index.navLinks).textContent = 'Show'
setupSort: -> setupSort: ->
Index.selectSort.value = Index.currentSort Index.selectRev.checked = /-rev$/.test Index.currentSort
Index.selectSort.value = Index.currentSort.replace /-rev$/, ''
getPagesNum: -> getPagesNum: ->
if Index.search if Index.search
@ -744,7 +750,7 @@ Index =
sort: -> sort: ->
{liveThreadIDs, liveThreadData} = Index {liveThreadIDs, liveThreadData} = Index
return unless liveThreadData return unless liveThreadData
Index.sortedThreadIDs = switch Index.currentSort Index.sortedThreadIDs = switch Index.currentSort.replace(/-rev$/, '')
when 'lastreply' when 'lastreply'
[liveThreadData...].sort((a, b) -> [liveThreadData...].sort((a, b) ->
a = num[num.length - 1] if (num = a.last_replies) a = num[num.length - 1] if (num = a.last_replies)
@ -764,6 +770,8 @@ Index =
when 'replycount' then [liveThreadData...].sort((a, b) -> b.replies - a.replies).map (post) -> post.no when 'replycount' then [liveThreadData...].sort((a, b) -> b.replies - a.replies).map (post) -> post.no
when 'filecount' then [liveThreadData...].sort((a, b) -> b.images - a.images ).map (post) -> post.no when 'filecount' then [liveThreadData...].sort((a, b) -> b.images - a.images ).map (post) -> post.no
else liveThreadIDs else liveThreadIDs
if /-rev$/.test(Index.currentSort)
Index.sortedThreadIDs = [Index.sortedThreadIDs...].reverse()
if Index.search and (threadIDs = Index.querySearch Index.search) if Index.search and (threadIDs = Index.querySearch Index.search)
Index.sortedThreadIDs = threadIDs Index.sortedThreadIDs = threadIDs
# Sticky threads # Sticky threads

View File

@ -6,6 +6,7 @@
<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" href="javascript:;" title="Clear search">×</a> <a id="index-search-clear" href="javascript:;" title="Clear search">×</a>
<span id="hidden-label" hidden> &mdash; <span id="hidden-count"></span> <span id="hidden-toggle">[<a href="javascript:;">Show</a>]</span></span> <span id="hidden-label" hidden> &mdash; <span id="hidden-count"></span> <span id="hidden-toggle">[<a href="javascript:;">Show</a>]</span></span>
<input type="checkbox" id="index-rev" name="Reverse Sort" title="Reverse sort order">
<select id="index-mode" name="Index Mode"> <select id="index-mode" name="Index Mode">
<option disabled>Index Mode</option> <option disabled>Index Mode</option>
<option value="paged">Paged</option> <option value="paged">Paged</option>

View File

@ -40,7 +40,7 @@
<div>Index-only link: <code>g-index</code></div> <div>Index-only link: <code>g-index</code></div>
<div>Catalog-only link: <code>g-catalog</code></div> <div>Catalog-only link: <code>g-catalog</code></div>
<div>Index mode: <code>g-mode:&quot;infinite scrolling&quot;</code></div> <div>Index mode: <code>g-mode:&quot;infinite scrolling&quot;</code></div>
<div>Index sort: <code>g-sort:&quot;creation date&quot;</code></div> <div>Index sort: <code>g-sort:&quot;creation date rev&quot;</code></div>
<div>External link: <code>external-text:&quot;Google&quot;,&quot;http://www.google.com&quot;</code></div> <div>External link: <code>external-text:&quot;Google&quot;,&quot;http://www.google.com&quot;</code></div>
<div>Combinations are possible: <code>g-index-text:&quot;Technology Index&quot;</code></div> <div>Combinations are possible: <code>g-index-text:&quot;Technology Index&quot;</code></div>
<div>Full board list toggle: <code>toggle-all</code></div> <div>Full board list toggle: <code>toggle-all</code></div>

View File

@ -706,7 +706,7 @@ div[data-checked="false"] > .suboption-list {
#index-search:not([data-searching]) + #index-search-clear { #index-search:not([data-searching]) + #index-search-clear {
display: none; display: none;
} }
#index-mode, #index-sort, #index-size { #index-rev, #index-mode, #index-sort, #index-size {
float: right; float: right;
} }
.summary { .summary {