optional backlink hiding

This commit is contained in:
James Campos 2014-10-05 17:26:50 -07:00 committed by czaks
parent 0b8728d7ce
commit fee03312d7

View File

@ -51,14 +51,11 @@
var $root = $(this).closest('.post') var $root = $(this).closest('.post')
var targetNum = this.textContent.slice(2) var targetNum = this.textContent.slice(2)
var $clone = $root.find('#inline_' + targetNum)
if ($clone.length)
return $clone.remove()
var srcOP = $root.closest('[id^=thread]').attr('id').match(/\d+/)[0] var srcOP = $root.closest('[id^=thread]').attr('id').match(/\d+/)[0]
var node, targetOP var node, targetOP
if (this.className) {// backlink var isBacklink = !!this.className
if (isBacklink) {
node = $root.find('> .intro') node = $root.find('> .intro')
targetOP = srcOP targetOP = srcOP
} else { } else {
@ -67,14 +64,25 @@
} }
var link = { var link = {
node: node, id: 'inline_' + targetNum,
id: 'inline_' + targetNum isBacklink: isBacklink,
node: node
} }
var selector = targetNum === targetOP var selector = targetNum === targetOP
? '#op_' + srcOP ? '#op_' + srcOP
: '#reply_' + targetNum : '#reply_' + targetNum
var $clone = $root.find('#inline_' + targetNum)
if ($clone.length) {
$clone.remove()
$(selector)
.show()
.next()
.show()
return
}
if (srcOP === targetOP) { if (srcOP === targetOP) {
if (targetNum === targetOP) if (targetNum === targetOP)
link.node = link.node.next()// bypass `(OP)` link.node = link.node.next()// bypass `(OP)`
@ -97,6 +105,13 @@
var add = function(link, $target) { var add = function(link, $target) {
var $clone = $target.clone(true) var $clone = $target.clone(true)
if (link.isBacklink && App.options.get('hidePost'))
$target
.hide()
.next()
.hide()
$clone.find('.inline').remove() $clone.find('.inline').remove()
$clone.attr({ $clone.attr({
"class": 'inline post', "class": 'inline post',
@ -106,10 +121,7 @@
$clone.insertAfter(link.node) $clone.insertAfter(link.node)
} }
App.options.add('inline', 'Inline quoted posts') App.options.add('hidePost', 'Hide inlined backlinked posts')
if (!App.options.get('inline'))
return
$('head').append( $('head').append(
'<style>' + '<style>' +