Relative Date Title #161
This commit is contained in:
parent
c5c6896c53
commit
ca4339a57d
@ -42,9 +42,13 @@ Config =
|
|||||||
'Localize and format timestamps.'
|
'Localize and format timestamps.'
|
||||||
]
|
]
|
||||||
'Relative Post Dates': [
|
'Relative Post Dates': [
|
||||||
false
|
true
|
||||||
'Display dates like "3 minutes ago". Tooltip shows the timestamp.'
|
'Display dates like "3 minutes ago". Tooltip shows the timestamp.'
|
||||||
]
|
]
|
||||||
|
'Relative Date Title': [
|
||||||
|
true
|
||||||
|
'Show relative post date as the tooltip.'
|
||||||
|
]
|
||||||
'Comment Expansion': [
|
'Comment Expansion': [
|
||||||
true
|
true
|
||||||
'Add buttons to expand too long comments.'
|
'Add buttons to expand too long comments.'
|
||||||
|
|||||||
@ -16,13 +16,19 @@ RelativeDates =
|
|||||||
Post.callbacks.push
|
Post.callbacks.push
|
||||||
name: 'Relative Post Dates'
|
name: 'Relative Post Dates'
|
||||||
cb: @node
|
cb: @node
|
||||||
|
|
||||||
node: ->
|
node: ->
|
||||||
|
dateEl = @nodes.date
|
||||||
|
if Conf['Relative Date Title']
|
||||||
|
$.on dateEl, 'mouseover', =>
|
||||||
|
RelativeDates.hover @
|
||||||
|
return
|
||||||
|
|
||||||
return if @isClone
|
return if @isClone
|
||||||
|
|
||||||
# Show original absolute time as tooltip so users can still know exact times
|
# Show original absolute time as tooltip so users can still know exact times
|
||||||
# Since "Time Formatting" runs its `node` before us, the title tooltip will
|
# Since "Time Formatting" runs its `node` before us, the title tooltip will
|
||||||
# pick up the user-formatted time instead of 4chan time when enabled.
|
# pick up the user-formatted time instead of 4chan time when enabled.
|
||||||
dateEl = @nodes.date
|
|
||||||
dateEl.title = dateEl.textContent
|
dateEl.title = dateEl.textContent
|
||||||
|
|
||||||
RelativeDates.update @
|
RelativeDates.update @
|
||||||
@ -82,6 +88,13 @@ RelativeDates =
|
|||||||
clearTimeout RelativeDates.timeout
|
clearTimeout RelativeDates.timeout
|
||||||
RelativeDates.timeout = setTimeout RelativeDates.flush, RelativeDates.INTERVAL
|
RelativeDates.timeout = setTimeout RelativeDates.flush, RelativeDates.INTERVAL
|
||||||
|
|
||||||
|
# Relative Date Title
|
||||||
|
hover: (post) ->
|
||||||
|
{date} = post.info
|
||||||
|
now = new Date()
|
||||||
|
diff = now - date
|
||||||
|
post.nodes.date.title = RelativeDates.relative diff, now, date
|
||||||
|
|
||||||
# `update()`, when called from `flush()`, updates the elements,
|
# `update()`, when called from `flush()`, updates the elements,
|
||||||
# and re-calls `setOwnTimeout()` to re-add `data` to the stale list later.
|
# and re-calls `setOwnTimeout()` to re-add `data` to the stale list later.
|
||||||
update: (data, now) ->
|
update: (data, now) ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user