summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJames Campos <james.r.campos@gmail.com>2014-10-05 17:26:50 -0700
committerczaks <marcin@6irc.net>2014-10-07 03:27:36 +0200
commitfee03312d76d115e081f9a96fd95b54259579559 (patch)
tree4476800a36044d2c3650745c4d5d45f732bda3fe /js
parent0b8728d7cedb513d75fccb374814da7b23965fa5 (diff)
optional backlink hiding
Diffstat (limited to 'js')
-rw-r--r--js/inline.js34
1 files changed, 23 insertions, 11 deletions
diff --git a/js/inline.js b/js/inline.js
index e4b24381..1ce0edc3 100644
--- a/js/inline.js
+++ b/js/inline.js
@@ -51,14 +51,11 @@
var $root = $(this).closest('.post')
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 node, targetOP
- if (this.className) {// backlink
+ var isBacklink = !!this.className
+ if (isBacklink) {
node = $root.find('> .intro')
targetOP = srcOP
} else {
@@ -67,14 +64,25 @@
}
var link = {
- node: node,
- id: 'inline_' + targetNum
+ id: 'inline_' + targetNum,
+ isBacklink: isBacklink,
+ node: node
}
var selector = targetNum === targetOP
? '#op_' + srcOP
: '#reply_' + targetNum
+ var $clone = $root.find('#inline_' + targetNum)
+ if ($clone.length) {
+ $clone.remove()
+ $(selector)
+ .show()
+ .next()
+ .show()
+ return
+ }
+
if (srcOP === targetOP) {
if (targetNum === targetOP)
link.node = link.node.next()// bypass `(OP)`
@@ -97,6 +105,13 @@
var add = function(link, $target) {
var $clone = $target.clone(true)
+
+ if (link.isBacklink && App.options.get('hidePost'))
+ $target
+ .hide()
+ .next()
+ .hide()
+
$clone.find('.inline').remove()
$clone.attr({
"class": 'inline post',
@@ -106,10 +121,7 @@
$clone.insertAfter(link.node)
}
- App.options.add('inline', 'Inline quoted posts')
-
- if (!App.options.get('inline'))
- return
+ App.options.add('hidePost', 'Hide inlined backlinked posts')
$('head').append(
'<style>' +