hide links on embed instead of recreating them on unembed
This commit is contained in:
parent
c06a24742f
commit
589b462f84
@ -156,7 +156,6 @@ Linkify =
|
|||||||
textContent: '(embed)'
|
textContent: '(embed)'
|
||||||
|
|
||||||
embed.dataset[name] = value for name, value of {key, href, uid, options}
|
embed.dataset[name] = value for name, value of {key, href, uid, options}
|
||||||
embed.dataset.nodedata = link.innerHTML
|
|
||||||
|
|
||||||
$.addClass link, "#{embed.dataset.key}"
|
$.addClass link, "#{embed.dataset.key}"
|
||||||
|
|
||||||
@ -172,27 +171,25 @@ Linkify =
|
|||||||
return unless service = Linkify.types[key].title
|
return unless service = Linkify.types[key].title
|
||||||
titles = Conf['CachedTitles']
|
titles = Conf['CachedTitles']
|
||||||
if title = titles[uid]
|
if title = titles[uid]
|
||||||
# Auto-embed may destroy our links.
|
link.textContent = title[0]
|
||||||
if link
|
|
||||||
link.textContent = title[0]
|
|
||||||
if Conf['Embedding']
|
|
||||||
embed.dataset.title = title[0]
|
|
||||||
else
|
else
|
||||||
try
|
try
|
||||||
$.cache service.api(uid), (-> Linkify.cb.title @, data), responseType: 'json'
|
$.cache service.api(uid), (-> Linkify.cb.title @, data), responseType: 'json'
|
||||||
catch err
|
catch err
|
||||||
if link
|
link.innerHTML = '<span class="warning">Title Link Blocked</span> (are you using NoScript?)</a>'
|
||||||
link.innerHTML = '<span class="warning">Title Link Blocked</span> (are you using NoScript?)</a>'
|
$.prepend link, $.tn "[#{key}] "
|
||||||
$.prepend link, $.tn "[#{key}] "
|
|
||||||
return
|
return
|
||||||
|
|
||||||
cb:
|
cb:
|
||||||
toggle: ->
|
toggle: ->
|
||||||
[string, @textContent] = if $.hasClass @, "embedded"
|
if $.hasClass @, "embedded"
|
||||||
['unembed', '(embed)']
|
$.rm @previousElementSibling
|
||||||
|
@previousElementSibling.hidden = false
|
||||||
|
@textContent = '(embed)'
|
||||||
else
|
else
|
||||||
['embed', '(unembed)']
|
@previousElementSibling.hidden = true
|
||||||
$.replace @previousElementSibling, Linkify.cb[string] @
|
$.before @, Linkify.cb.embed @
|
||||||
|
@textContent = '(unembed)'
|
||||||
$.toggleClass @, 'embedded'
|
$.toggleClass @, 'embedded'
|
||||||
|
|
||||||
embed: (a) ->
|
embed: (a) ->
|
||||||
@ -207,28 +204,12 @@ Linkify =
|
|||||||
|
|
||||||
return el
|
return el
|
||||||
|
|
||||||
unembed: (a) ->
|
|
||||||
# Recreate the original link.
|
|
||||||
el = $.el 'a',
|
|
||||||
rel: 'nofollow noreferrer'
|
|
||||||
target: 'blank'
|
|
||||||
className: 'linkify'
|
|
||||||
href: a.dataset.href
|
|
||||||
if a.dataset.title
|
|
||||||
el.textContent = a.dataset.title
|
|
||||||
else
|
|
||||||
el.innerHTML = a.dataset.nodedata
|
|
||||||
|
|
||||||
$.addClass el, a.dataset.key
|
|
||||||
|
|
||||||
return el
|
|
||||||
|
|
||||||
title: (req, data) ->
|
title: (req, data) ->
|
||||||
[key, uid, options, link, embed] = data
|
[key, uid, options, link, embed] = data
|
||||||
{status} = req
|
{status} = req
|
||||||
service = Linkify.types[key].title
|
service = Linkify.types[key].title
|
||||||
|
|
||||||
text = "[#{key}] #{switch status
|
link.textContent = "[#{key}] #{switch status
|
||||||
when 200, 304
|
when 200, 304
|
||||||
service.text req.response
|
service.text req.response
|
||||||
when 404
|
when 404
|
||||||
@ -239,9 +220,6 @@ Linkify =
|
|||||||
"#{status}'d"
|
"#{status}'d"
|
||||||
}"
|
}"
|
||||||
|
|
||||||
embed.dataset.title = text if Conf['Embedding'] and status in [200, 304]
|
|
||||||
link.textContent = text if link
|
|
||||||
|
|
||||||
ordered_types: [
|
ordered_types: [
|
||||||
key: 'audio'
|
key: 'audio'
|
||||||
regExp: /(.*\.(mp3|ogg|wav))$/
|
regExp: /(.*\.(mp3|ogg|wav))$/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user