Reflow Navigate.node, allow navigation from backlinks and their hashes

This commit is contained in:
Zixaphir 2014-03-11 12:48:23 -07:00
parent 3f438d55ff
commit 08241a213f
4 changed files with 85 additions and 41 deletions

View File

@ -5251,7 +5251,7 @@
return $.add(this.nodes.info, container);
},
buildBacklink: function(quoted, quoter) {
var a, frag, text;
var a, frag, hash, text;
frag = QuoteBacklink.frag.cloneNode(true);
a = frag.lastElementChild;
a.href = "/" + quoter.board + "/res/" + quoter.thread + "#p" + quoter;
@ -5269,7 +5269,14 @@
if (Conf['Quote Inlining']) {
$.on(a, 'click', QuoteInline.toggle);
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;
@ -12598,22 +12605,28 @@
return $.on(replyLink, 'click', Navigate.navigate);
},
post: function() {
var boardID, hashlink, postID, postlink, threadID, _i, _len, _ref, _ref1;
if (Conf['Quote Hash Navigation']) {
_ref = $$('.hashlink', this.nodes.comment);
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);
}
}
var linktype;
if (!(g.VIEW === 'thread' && this.thread.ID === g.THREADID)) {
$.on($('a[title="Highlight this post"]', this.nodes.info), '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;
}
postlink = $('a[title="Highlight this post"]', this.nodes.info);
return $.on(postlink, 'click', Navigate.navigate);
return Navigate.quoteLink($$(linktype, this.nodes.comment));
},
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() {
g.threads.forEach(function(thread) {

View File

@ -5303,7 +5303,7 @@
return $.add(this.nodes.info, container);
},
buildBacklink: function(quoted, quoter) {
var a, frag, text;
var a, frag, hash, text;
frag = QuoteBacklink.frag.cloneNode(true);
a = frag.lastElementChild;
a.href = "/" + quoter.board + "/res/" + quoter.thread + "#p" + quoter;
@ -5321,7 +5321,14 @@
if (Conf['Quote Inlining']) {
$.on(a, 'click', QuoteInline.toggle);
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;
@ -12612,22 +12619,28 @@
return $.on(replyLink, 'click', Navigate.navigate);
},
post: function() {
var boardID, hashlink, postID, postlink, threadID, _i, _len, _ref, _ref1;
if (Conf['Quote Hash Navigation']) {
_ref = $$('.hashlink', this.nodes.comment);
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);
}
}
var linktype;
if (!(g.VIEW === 'thread' && this.thread.ID === g.THREADID)) {
$.on($('a[title="Highlight this post"]', this.nodes.info), '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;
}
postlink = $('a[title="Highlight this post"]', this.nodes.info);
return $.on(postlink, 'click', Navigate.navigate);
return Navigate.quoteLink($$(linktype, this.nodes.comment));
},
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() {
g.threads.forEach(function(thread) {

View File

@ -10,7 +10,7 @@ Navigate =
$.add Index.navLinks, Navigate.el
@title = -> return
@el = $.el 'div',
id: 'breadCrumb'
@ -28,16 +28,29 @@ Navigate =
$.on replyLink, 'click', Navigate.navigate
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
return if g.VIEW is 'thread' and @thread.ID is g.THREADID
postlink = $ 'a[title="Highlight this post"]', @nodes.info
$.on postlink, 'click', Navigate.navigate
unless g.VIEW is 'thread' and @thread.ID is g.THREADID
$.on $('a[title="Highlight this post"]', @nodes.info), '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: ->
# Garbage collection

View File

@ -68,5 +68,10 @@ QuoteBacklink =
if Conf['Quote Inlining']
$.on a, 'click', QuoteInline.toggle
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