Fix Navigate.navigate click event being applied to every anchor

... on the entire page.

Thanks #boardNavDesktopFoot.
This commit is contained in:
Zixaphir 2015-01-13 10:12:49 -07:00
parent 41050f516f
commit 9d45b0e5c5
5 changed files with 29 additions and 22 deletions

View File

@ -4388,7 +4388,7 @@
Header = { Header = {
init: function() { init: function() {
var barFixedToggler, barPositionToggler, box, customNavToggler, editCustomNav, headerToggler, menuButton, scrollHeaderToggler; var barFixedToggler, barPositionToggler, box, customNavToggler, editCustomNav, footer, headerToggler, menuButton, scrollHeaderToggler;
this.menu = new UI.Menu('header'); this.menu = new UI.Menu('header');
menuButton = $.el('a', { menuButton = $.el('a', {
className: 'menu-button a-icon', className: 'menu-button a-icon',
@ -4464,9 +4464,12 @@
return _this.setBarPosition(Conf['Bottom Header']); return _this.setBarPosition(Conf['Bottom Header']);
}; };
})(this)); })(this));
return $.ready(function() { footer = null;
var a, footer, _i, _len, _ref, _results; return $.asap((function() {
if (a = $("a[href*='/" + g.BOARD + "/']", footer = $.id('boardNavDesktopFoot'))) { return footer = $.id('boardNavDesktopFoot');
}), function() {
var a, _i, _len, _ref, _results;
if (a = $("a[href*='/" + g.BOARD + "/']", footer)) {
a.className = 'current'; a.className = 'current';
} }
if (Conf['JSON Navigation']) { if (Conf['JSON Navigation']) {
@ -5965,10 +5968,10 @@
switch (Conf['Index Mode']) { switch (Conf['Index Mode']) {
case 'paged': case 'paged':
case 'infinite': case 'infinite':
pageNum = Index.getCurrentPage() - 1; pageNum = Index.getCurrentPage();
threadsPerPage = Index.getThreadsNumPerPage(); threadsPerPage = Index.getThreadsNumPerPage();
threads = []; threads = [];
i = threadsPerPage * pageNum; i = threadsPerPage * (pageNum - 1);
max = i + threadsPerPage; max = i + threadsPerPage;
while (i < max && (thread = sortedThreads[i++])) { while (i < max && (thread = sortedThreads[i++])) {
threads.push(thread); threads.push(thread);
@ -5976,7 +5979,7 @@
Index.buildReplies(thread); Index.buildReplies(thread);
} }
Index.buildPagelist(); Index.buildPagelist();
Index.setPage(); Index.setPage(pageNum);
break; break;
case 'catalog': case 'catalog':
nodes = Index.buildCatalogViews(); nodes = Index.buildCatalogViews();
@ -18476,7 +18479,7 @@
if (!(g.VIEW === 'thread' && this.thread.ID === g.THREADID)) { if (!(g.VIEW === 'thread' && this.thread.ID === g.THREADID)) {
$.on($('a[title="Link to this post"]', this.nodes.info), 'click', Navigate.navigate); $.on($('a[title="Link to this post"]', this.nodes.info), 'click', Navigate.navigate);
} }
if (!(linktype = Conf['Quote Inlining'] && Conf['Quote Hash Navigation'] ? '.hashlink' : !Conf['Quote Inlining'] ? '.quotelink' : null)) { if (!(linktype = Conf['Quote Inlining'] && Conf['Quote Hash Navigation'] ? '.hashlink' : !Conf['Quote Inlining'] ? '.quotelink' : false)) {
return; return;
} }
return Navigate.quoteLink($$(linktype, this.nodes.comment)); return Navigate.quoteLink($$(linktype, this.nodes.comment));

View File

@ -4406,7 +4406,7 @@
Header = { Header = {
init: function() { init: function() {
var barFixedToggler, barPositionToggler, box, customNavToggler, editCustomNav, headerToggler, menuButton, scrollHeaderToggler; var barFixedToggler, barPositionToggler, box, customNavToggler, editCustomNav, footer, headerToggler, menuButton, scrollHeaderToggler;
this.menu = new UI.Menu('header'); this.menu = new UI.Menu('header');
menuButton = $.el('a', { menuButton = $.el('a', {
className: 'menu-button a-icon', className: 'menu-button a-icon',
@ -4482,9 +4482,12 @@
return _this.setBarPosition(Conf['Bottom Header']); return _this.setBarPosition(Conf['Bottom Header']);
}; };
})(this)); })(this));
return $.ready(function() { footer = null;
var a, footer, _i, _len, _ref, _results; return $.asap((function() {
if (a = $("a[href*='/" + g.BOARD + "/']", footer = $.id('boardNavDesktopFoot'))) { return footer = $.id('boardNavDesktopFoot');
}), function() {
var a, _i, _len, _ref, _results;
if (a = $("a[href*='/" + g.BOARD + "/']", footer)) {
a.className = 'current'; a.className = 'current';
} }
if (Conf['JSON Navigation']) { if (Conf['JSON Navigation']) {
@ -5983,10 +5986,10 @@
switch (Conf['Index Mode']) { switch (Conf['Index Mode']) {
case 'paged': case 'paged':
case 'infinite': case 'infinite':
pageNum = Index.getCurrentPage() - 1; pageNum = Index.getCurrentPage();
threadsPerPage = Index.getThreadsNumPerPage(); threadsPerPage = Index.getThreadsNumPerPage();
threads = []; threads = [];
i = threadsPerPage * pageNum; i = threadsPerPage * (pageNum - 1);
max = i + threadsPerPage; max = i + threadsPerPage;
while (i < max && (thread = sortedThreads[i++])) { while (i < max && (thread = sortedThreads[i++])) {
threads.push(thread); threads.push(thread);
@ -5994,7 +5997,7 @@
Index.buildReplies(thread); Index.buildReplies(thread);
} }
Index.buildPagelist(); Index.buildPagelist();
Index.setPage(); Index.setPage(pageNum);
break; break;
case 'catalog': case 'catalog':
nodes = Index.buildCatalogViews(); nodes = Index.buildCatalogViews();
@ -18502,7 +18505,7 @@
if (!(g.VIEW === 'thread' && this.thread.ID === g.THREADID)) { if (!(g.VIEW === 'thread' && this.thread.ID === g.THREADID)) {
$.on($('a[title="Link to this post"]', this.nodes.info), 'click', Navigate.navigate); $.on($('a[title="Link to this post"]', this.nodes.info), 'click', Navigate.navigate);
} }
if (!(linktype = Conf['Quote Inlining'] && Conf['Quote Hash Navigation'] ? '.hashlink' : !Conf['Quote Inlining'] ? '.quotelink' : null)) { if (!(linktype = Conf['Quote Inlining'] && Conf['Quote Hash Navigation'] ? '.hashlink' : !Conf['Quote Inlining'] ? '.quotelink' : false)) {
return; return;
} }
return Navigate.quoteLink($$(linktype, this.nodes.comment)); return Navigate.quoteLink($$(linktype, this.nodes.comment));

View File

@ -76,8 +76,9 @@ Header =
$.add d.body, @hover $.add d.body, @hover
@setBarPosition Conf['Bottom Header'] @setBarPosition Conf['Bottom Header']
$.ready -> footer = null
if a = $ "a[href*='/#{g.BOARD}/']", footer = $.id 'boardNavDesktopFoot' $.asap (-> footer = $.id 'boardNavDesktopFoot' ), ->
if a = $ "a[href*='/#{g.BOARD}/']", footer
a.className = 'current' a.className = 'current'
if Conf['JSON Navigation'] if Conf['JSON Navigation']
$.on a, 'click', Navigate.navigate for a in $$ 'a', footer $.on a, 'click', Navigate.navigate for a in $$ 'a', footer

View File

@ -790,11 +790,11 @@ Index =
nodes = [] nodes = []
switch Conf['Index Mode'] switch Conf['Index Mode']
when 'paged', 'infinite' when 'paged', 'infinite'
pageNum = Index.getCurrentPage() - 1 pageNum = Index.getCurrentPage()
threadsPerPage = Index.getThreadsNumPerPage() threadsPerPage = Index.getThreadsNumPerPage()
threads = [] threads = []
i = threadsPerPage * pageNum i = threadsPerPage * (pageNum - 1)
max = i + threadsPerPage max = i + threadsPerPage
while i < max and thread = sortedThreads[i++] while i < max and thread = sortedThreads[i++]
threads.push thread threads.push thread
@ -802,7 +802,7 @@ Index =
Index.buildReplies thread Index.buildReplies thread
Index.buildPagelist() Index.buildPagelist()
Index.setPage() Index.setPage pageNum
when 'catalog' when 'catalog'
nodes = Index.buildCatalogViews() nodes = Index.buildCatalogViews()

View File

@ -46,7 +46,7 @@ Navigate =
else if !Conf['Quote Inlining'] else if !Conf['Quote Inlining']
'.quotelink' '.quotelink'
else else
null false
) )
Navigate.quoteLink $$ linktype, @nodes.comment Navigate.quoteLink $$ linktype, @nodes.comment