Reflow Navigate.node, allow navigation from backlinks and their hashes
This commit is contained in:
parent
3f438d55ff
commit
08241a213f
@ -5251,7 +5251,7 @@
|
|||||||
return $.add(this.nodes.info, container);
|
return $.add(this.nodes.info, container);
|
||||||
},
|
},
|
||||||
buildBacklink: function(quoted, quoter) {
|
buildBacklink: function(quoted, quoter) {
|
||||||
var a, frag, text;
|
var a, frag, hash, text;
|
||||||
frag = QuoteBacklink.frag.cloneNode(true);
|
frag = QuoteBacklink.frag.cloneNode(true);
|
||||||
a = frag.lastElementChild;
|
a = frag.lastElementChild;
|
||||||
a.href = "/" + quoter.board + "/res/" + quoter.thread + "#p" + quoter;
|
a.href = "/" + quoter.board + "/res/" + quoter.thread + "#p" + quoter;
|
||||||
@ -5269,7 +5269,14 @@
|
|||||||
if (Conf['Quote Inlining']) {
|
if (Conf['Quote Inlining']) {
|
||||||
$.on(a, 'click', QuoteInline.toggle);
|
$.on(a, 'click', QuoteInline.toggle);
|
||||||
if (Conf['Quote Hash Navigation']) {
|
if (Conf['Quote Hash Navigation']) {
|
||||||
QuoteInline.qiQuote(a, quoter.isHidden);
|
hash = QuoteInline.qiQuote(a, quoter.isHidden);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Conf['JSON Navigation']) {
|
||||||
|
if (hash) {
|
||||||
|
Navigate.singleQuoteLink(hash);
|
||||||
|
} else if (!Conf['Quote Inlining']) {
|
||||||
|
Navigate.singleQuoteLink(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return frag;
|
return frag;
|
||||||
@ -12598,22 +12605,28 @@
|
|||||||
return $.on(replyLink, 'click', Navigate.navigate);
|
return $.on(replyLink, 'click', Navigate.navigate);
|
||||||
},
|
},
|
||||||
post: function() {
|
post: function() {
|
||||||
var boardID, hashlink, postID, postlink, threadID, _i, _len, _ref, _ref1;
|
var linktype;
|
||||||
if (Conf['Quote Hash Navigation']) {
|
if (!(g.VIEW === 'thread' && this.thread.ID === g.THREADID)) {
|
||||||
_ref = $$('.hashlink', this.nodes.comment);
|
$.on($('a[title="Highlight this post"]', this.nodes.info), 'click', Navigate.navigate);
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
||||||
hashlink = _ref[_i];
|
|
||||||
_ref1 = Get.postDataFromLink(hashlink), boardID = _ref1.boardID, threadID = _ref1.threadID, postID = _ref1.postID;
|
|
||||||
if (boardID !== g.BOARD.ID || (threadID !== g.THREADID)) {
|
|
||||||
$.on(hashlink, 'click', Navigate.navigate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (g.VIEW === 'thread' && this.thread.ID === g.THREADID) {
|
if (!(linktype = Conf['Quote Inlining'] && Conf['Quote Hash Navigation'] ? '.hashlink' : !Conf['Quote Inlining'] ? '.quotelink' : null)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
postlink = $('a[title="Highlight this post"]', this.nodes.info);
|
return Navigate.quoteLink($$(linktype, this.nodes.comment));
|
||||||
return $.on(postlink, 'click', Navigate.navigate);
|
},
|
||||||
|
quoteLink: function(links) {
|
||||||
|
var link, _i, _len;
|
||||||
|
for (_i = 0, _len = links.length; _i < _len; _i++) {
|
||||||
|
link = links[_i];
|
||||||
|
Navigate.singleQuoteLink(link);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
singleQuoteLink: function(link) {
|
||||||
|
var boardID, threadID, _ref;
|
||||||
|
_ref = Get.postDataFromLink(link), boardID = _ref.boardID, threadID = _ref.threadID;
|
||||||
|
if (g.VIEW === 'index' || boardID !== g.BOARD.ID || threadID !== g.THREADID) {
|
||||||
|
return $.on(link, 'click', Navigate.navigate);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
clean: function() {
|
clean: function() {
|
||||||
g.threads.forEach(function(thread) {
|
g.threads.forEach(function(thread) {
|
||||||
|
|||||||
@ -5303,7 +5303,7 @@
|
|||||||
return $.add(this.nodes.info, container);
|
return $.add(this.nodes.info, container);
|
||||||
},
|
},
|
||||||
buildBacklink: function(quoted, quoter) {
|
buildBacklink: function(quoted, quoter) {
|
||||||
var a, frag, text;
|
var a, frag, hash, text;
|
||||||
frag = QuoteBacklink.frag.cloneNode(true);
|
frag = QuoteBacklink.frag.cloneNode(true);
|
||||||
a = frag.lastElementChild;
|
a = frag.lastElementChild;
|
||||||
a.href = "/" + quoter.board + "/res/" + quoter.thread + "#p" + quoter;
|
a.href = "/" + quoter.board + "/res/" + quoter.thread + "#p" + quoter;
|
||||||
@ -5321,7 +5321,14 @@
|
|||||||
if (Conf['Quote Inlining']) {
|
if (Conf['Quote Inlining']) {
|
||||||
$.on(a, 'click', QuoteInline.toggle);
|
$.on(a, 'click', QuoteInline.toggle);
|
||||||
if (Conf['Quote Hash Navigation']) {
|
if (Conf['Quote Hash Navigation']) {
|
||||||
QuoteInline.qiQuote(a, quoter.isHidden);
|
hash = QuoteInline.qiQuote(a, quoter.isHidden);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Conf['JSON Navigation']) {
|
||||||
|
if (hash) {
|
||||||
|
Navigate.singleQuoteLink(hash);
|
||||||
|
} else if (!Conf['Quote Inlining']) {
|
||||||
|
Navigate.singleQuoteLink(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return frag;
|
return frag;
|
||||||
@ -12612,22 +12619,28 @@
|
|||||||
return $.on(replyLink, 'click', Navigate.navigate);
|
return $.on(replyLink, 'click', Navigate.navigate);
|
||||||
},
|
},
|
||||||
post: function() {
|
post: function() {
|
||||||
var boardID, hashlink, postID, postlink, threadID, _i, _len, _ref, _ref1;
|
var linktype;
|
||||||
if (Conf['Quote Hash Navigation']) {
|
if (!(g.VIEW === 'thread' && this.thread.ID === g.THREADID)) {
|
||||||
_ref = $$('.hashlink', this.nodes.comment);
|
$.on($('a[title="Highlight this post"]', this.nodes.info), 'click', Navigate.navigate);
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
||||||
hashlink = _ref[_i];
|
|
||||||
_ref1 = Get.postDataFromLink(hashlink), boardID = _ref1.boardID, threadID = _ref1.threadID, postID = _ref1.postID;
|
|
||||||
if (boardID !== g.BOARD.ID || (threadID !== g.THREADID)) {
|
|
||||||
$.on(hashlink, 'click', Navigate.navigate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (g.VIEW === 'thread' && this.thread.ID === g.THREADID) {
|
if (!(linktype = Conf['Quote Inlining'] && Conf['Quote Hash Navigation'] ? '.hashlink' : !Conf['Quote Inlining'] ? '.quotelink' : null)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
postlink = $('a[title="Highlight this post"]', this.nodes.info);
|
return Navigate.quoteLink($$(linktype, this.nodes.comment));
|
||||||
return $.on(postlink, 'click', Navigate.navigate);
|
},
|
||||||
|
quoteLink: function(links) {
|
||||||
|
var link, _i, _len;
|
||||||
|
for (_i = 0, _len = links.length; _i < _len; _i++) {
|
||||||
|
link = links[_i];
|
||||||
|
Navigate.singleQuoteLink(link);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
singleQuoteLink: function(link) {
|
||||||
|
var boardID, threadID, _ref;
|
||||||
|
_ref = Get.postDataFromLink(link), boardID = _ref.boardID, threadID = _ref.threadID;
|
||||||
|
if (g.VIEW === 'index' || boardID !== g.BOARD.ID || threadID !== g.THREADID) {
|
||||||
|
return $.on(link, 'click', Navigate.navigate);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
clean: function() {
|
clean: function() {
|
||||||
g.threads.forEach(function(thread) {
|
g.threads.forEach(function(thread) {
|
||||||
|
|||||||
@ -28,16 +28,29 @@ Navigate =
|
|||||||
$.on replyLink, 'click', Navigate.navigate
|
$.on replyLink, 'click', Navigate.navigate
|
||||||
|
|
||||||
post: -> # Allows us to navigate via JSON from thread to thread by hashes and quote highlights.
|
post: -> # Allows us to navigate via JSON from thread to thread by hashes and quote highlights.
|
||||||
if Conf['Quote Hash Navigation']
|
|
||||||
for hashlink in $$ '.hashlink', @nodes.comment
|
|
||||||
{boardID, threadID, postID} = Get.postDataFromLink hashlink
|
|
||||||
if boardID isnt g.BOARD.ID or (threadID isnt g.THREADID)
|
|
||||||
$.on hashlink, 'click', Navigate.navigate
|
|
||||||
|
|
||||||
# We don't need to reload the thread inside the thread
|
# We don't need to reload the thread inside the thread
|
||||||
return if g.VIEW is 'thread' and @thread.ID is g.THREADID
|
unless g.VIEW is 'thread' and @thread.ID is g.THREADID
|
||||||
postlink = $ 'a[title="Highlight this post"]', @nodes.info
|
$.on $('a[title="Highlight this post"]', @nodes.info), 'click', Navigate.navigate
|
||||||
$.on postlink, 'click', Navigate.navigate
|
|
||||||
|
return unless (linktype = if Conf['Quote Inlining'] and Conf['Quote Hash Navigation']
|
||||||
|
'.hashlink'
|
||||||
|
else if !Conf['Quote Inlining']
|
||||||
|
'.quotelink'
|
||||||
|
else
|
||||||
|
null
|
||||||
|
)
|
||||||
|
|
||||||
|
Navigate.quoteLink $$ linktype, @nodes.comment
|
||||||
|
|
||||||
|
quoteLink: (links) ->
|
||||||
|
for link in links
|
||||||
|
Navigate.singleQuoteLink link
|
||||||
|
return
|
||||||
|
|
||||||
|
singleQuoteLink: (link) ->
|
||||||
|
{boardID, threadID} = Get.postDataFromLink link
|
||||||
|
if g.VIEW is 'index' or boardID isnt g.BOARD.ID or threadID isnt g.THREADID
|
||||||
|
$.on link, 'click', Navigate.navigate
|
||||||
|
|
||||||
clean: ->
|
clean: ->
|
||||||
# Garbage collection
|
# Garbage collection
|
||||||
|
|||||||
@ -68,5 +68,10 @@ QuoteBacklink =
|
|||||||
if Conf['Quote Inlining']
|
if Conf['Quote Inlining']
|
||||||
$.on a, 'click', QuoteInline.toggle
|
$.on a, 'click', QuoteInline.toggle
|
||||||
if Conf['Quote Hash Navigation']
|
if Conf['Quote Hash Navigation']
|
||||||
QuoteInline.qiQuote a, quoter.isHidden
|
hash = QuoteInline.qiQuote a, quoter.isHidden
|
||||||
|
if Conf['JSON Navigation']
|
||||||
|
if hash
|
||||||
|
Navigate.singleQuoteLink hash
|
||||||
|
else unless Conf['Quote Inlining']
|
||||||
|
Navigate.singleQuoteLink a
|
||||||
frag
|
frag
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user