JSON Index: Support multiple commands in hash by separating with slashes.
Also generalize Header.hashScroll to support scrolling to last item in list as well as scrolling to non-post elements.
This commit is contained in:
parent
60a4513717
commit
0ea4509d3a
@ -427,10 +427,9 @@ Header =
|
|||||||
return if e.state
|
return if e.state
|
||||||
history.replaceState {}, '' unless history.state
|
history.replaceState {}, '' unless history.state
|
||||||
|
|
||||||
hash = @location.hash[1..]
|
hash = location.hash.match /[^#/]*$/
|
||||||
return unless /^\d*p\d+$/.test(hash) and (post = $.id hash)
|
if (el = $.id hash) and el.offsetParent # not hidden
|
||||||
return if !post.getBoundingClientRect().height
|
$.queueTask -> Header.scrollTo el
|
||||||
$.queueTask -> Header.scrollTo post
|
|
||||||
|
|
||||||
scrollTo: (root, down, needed) ->
|
scrollTo: (root, down, needed) ->
|
||||||
if down
|
if down
|
||||||
|
|||||||
@ -284,20 +284,21 @@ Index =
|
|||||||
processHash: ->
|
processHash: ->
|
||||||
# XXX https://bugzilla.mozilla.org/show_bug.cgi?id=483304
|
# XXX https://bugzilla.mozilla.org/show_bug.cgi?id=483304
|
||||||
hash = location.href.match(/#.*/)?[0] or ''
|
hash = location.href.match(/#.*/)?[0] or ''
|
||||||
command = hash[1..]
|
|
||||||
state =
|
state =
|
||||||
replace: true
|
replace: true
|
||||||
if command in ['paged', 'infinite', 'all-pages', 'catalog']
|
commands = hash[1..].split '/'
|
||||||
state.mode = command.replace /-/g, ' '
|
for command, i in commands
|
||||||
else if command is 'index'
|
if command in ['paged', 'infinite', 'all-pages', 'catalog']
|
||||||
state.mode = Conf['Previous Index Mode']
|
state.mode = command.replace /-/g, ' '
|
||||||
state.page = 1
|
else if command is 'index'
|
||||||
else if /^s=/.test command
|
state.mode = Conf['Previous Index Mode']
|
||||||
state.search = decodeURIComponent(command[2..]).replace(/\+/g, ' ').trim()
|
state.page = 1
|
||||||
else
|
else if /^s=/.test command
|
||||||
state.hash = hash
|
state.search = decodeURIComponent(command[2..]).replace(/\+/g, ' ').trim()
|
||||||
|
else if i is commands.length - 1
|
||||||
|
state.hash = if command then "##{command}" else ''
|
||||||
Index.pushState state
|
Index.pushState state
|
||||||
!state.hash?
|
hash isnt state.hash
|
||||||
|
|
||||||
pushState: (state) ->
|
pushState: (state) ->
|
||||||
{search, hash, replace} = state
|
{search, hash, replace} = state
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user