Fix a couple things with thread hiding

This commit is contained in:
Zixaphir 2015-01-22 09:36:48 -07:00
parent 27aa4e6a16
commit 7729784ee7
6 changed files with 46 additions and 40 deletions

View File

@ -3315,7 +3315,9 @@
return; return;
} }
this.isHidden = true; this.isHidden = true;
this.OP.nodes.root.parentElement.hidden = true; if (!Conf['JSON Navigation']) {
this.OP.nodes.root.parentElement.hidden = true;
}
if (button = $('.hide-post-button', this.OP.nodes.root)) { if (button = $('.hide-post-button', this.OP.nodes.root)) {
return $.replace(button, PostHiding.makeButton(false)); return $.replace(button, PostHiding.makeButton(false));
} }
@ -5663,7 +5665,7 @@
}), 3 * $.SECOND - (Date.now() - now)); }), 3 * $.SECOND - (Date.now() - now));
}); });
if (typeof pageNum !== 'number') { if (typeof pageNum !== 'number') {
pageNum = null; pageNum = '';
} }
onload = function(e) { onload = function(e) {
return Index.load(e, pageNum); return Index.load(e, pageNum);
@ -5969,7 +5971,7 @@
return Index.sortedThreads = topThreads.concat(bottomThreads); return Index.sortedThreads = topThreads.concat(bottomThreads);
}, },
buildIndex: function(infinite) { buildIndex: function(infinite) {
var i, max, nodes, pageNum, sortedThreads, thread, threads, threadsPerPage; var i, max, nodes, pageNum, sortedThreads, threadsPerPage;
sortedThreads = Index.sortedThreads; sortedThreads = Index.sortedThreads;
nodes = []; nodes = [];
switch (Conf['Index Mode']) { switch (Conf['Index Mode']) {
@ -5977,14 +5979,9 @@
case 'infinite': case 'infinite':
pageNum = Index.getCurrentPage(); pageNum = Index.getCurrentPage();
threadsPerPage = Index.getThreadsNumPerPage(); threadsPerPage = Index.getThreadsNumPerPage();
threads = [];
i = threadsPerPage * (pageNum - 1); i = threadsPerPage * (pageNum - 1);
max = i + threadsPerPage; max = i + threadsPerPage;
while (i < max && (thread = sortedThreads[i++])) { nodes = Index.processThreads(sortedThreads, i, max);
threads.push(thread);
nodes.push(thread.OP.nodes.root.parentNode, $.el('hr'));
Index.buildReplies(thread);
}
Index.buildPagelist(); Index.buildPagelist();
Index.setPage(pageNum); Index.setPage(pageNum);
break; break;
@ -5992,17 +5989,22 @@
nodes = Index.buildCatalogViews(); nodes = Index.buildCatalogViews();
break; break;
default: default:
i = 0; nodes = Index.processThreads(sortedThreads, 0, sortedThreads.length);
while (thread = sortedThreads[i++]) {
nodes.push(thread.OP.nodes.root.parentNode, $.el('hr'));
Index.buildReplies(thread);
}
} }
if (!infinite) { if (!infinite) {
$.rmAll(Index.root); $.rmAll(Index.root);
} }
return $.add(Index.root, nodes); return $.add(Index.root, nodes);
}, },
processThreads: function(threads, i, max) {
var nodes, thread;
nodes = [];
while (i < max && (thread = threads[i++])) {
nodes.push(thread.OP.nodes.root.parentNode, $.el('hr'));
Index.buildReplies(thread);
}
return nodes;
},
isSearching: false, isSearching: false,
clearSearch: function() { clearSearch: function() {
Index.searchInput.value = null; Index.searchInput.value = null;

View File

@ -3340,7 +3340,9 @@
return; return;
} }
this.isHidden = true; this.isHidden = true;
this.OP.nodes.root.parentElement.hidden = true; if (!Conf['JSON Navigation']) {
this.OP.nodes.root.parentElement.hidden = true;
}
if (button = $('.hide-post-button', this.OP.nodes.root)) { if (button = $('.hide-post-button', this.OP.nodes.root)) {
return $.replace(button, PostHiding.makeButton(false)); return $.replace(button, PostHiding.makeButton(false));
} }
@ -5688,7 +5690,7 @@
}), 3 * $.SECOND - (Date.now() - now)); }), 3 * $.SECOND - (Date.now() - now));
}); });
if (typeof pageNum !== 'number') { if (typeof pageNum !== 'number') {
pageNum = null; pageNum = '';
} }
onload = function(e) { onload = function(e) {
return Index.load(e, pageNum); return Index.load(e, pageNum);
@ -5994,7 +5996,7 @@
return Index.sortedThreads = topThreads.concat(bottomThreads); return Index.sortedThreads = topThreads.concat(bottomThreads);
}, },
buildIndex: function(infinite) { buildIndex: function(infinite) {
var i, max, nodes, pageNum, sortedThreads, thread, threads, threadsPerPage; var i, max, nodes, pageNum, sortedThreads, threadsPerPage;
sortedThreads = Index.sortedThreads; sortedThreads = Index.sortedThreads;
nodes = []; nodes = [];
switch (Conf['Index Mode']) { switch (Conf['Index Mode']) {
@ -6002,14 +6004,9 @@
case 'infinite': case 'infinite':
pageNum = Index.getCurrentPage(); pageNum = Index.getCurrentPage();
threadsPerPage = Index.getThreadsNumPerPage(); threadsPerPage = Index.getThreadsNumPerPage();
threads = [];
i = threadsPerPage * (pageNum - 1); i = threadsPerPage * (pageNum - 1);
max = i + threadsPerPage; max = i + threadsPerPage;
while (i < max && (thread = sortedThreads[i++])) { nodes = Index.processThreads(sortedThreads, i, max);
threads.push(thread);
nodes.push(thread.OP.nodes.root.parentNode, $.el('hr'));
Index.buildReplies(thread);
}
Index.buildPagelist(); Index.buildPagelist();
Index.setPage(pageNum); Index.setPage(pageNum);
break; break;
@ -6017,17 +6014,22 @@
nodes = Index.buildCatalogViews(); nodes = Index.buildCatalogViews();
break; break;
default: default:
i = 0; nodes = Index.processThreads(sortedThreads, 0, sortedThreads.length);
while (thread = sortedThreads[i++]) {
nodes.push(thread.OP.nodes.root.parentNode, $.el('hr'));
Index.buildReplies(thread);
}
} }
if (!infinite) { if (!infinite) {
$.rmAll(Index.root); $.rmAll(Index.root);
} }
return $.add(Index.root, nodes); return $.add(Index.root, nodes);
}, },
processThreads: function(threads, i, max) {
var nodes, thread;
nodes = [];
while (i < max && (thread = threads[i++])) {
nodes.push(thread.OP.nodes.root.parentNode, $.el('hr'));
Index.buildReplies(thread);
}
return nodes;
},
isSearching: false, isSearching: false,
clearSearch: function() { clearSearch: function() {
Index.searchInput.value = null; Index.searchInput.value = null;

View File

@ -56,7 +56,7 @@ PostHiding =
Index.updateHideLabel() Index.updateHideLabel()
if Conf['Index Mode'] is 'all pages' or !Conf['JSON Navigation'] # ssllooooww if Conf['Index Mode'] is 'all pages' or !Conf['JSON Navigation'] # ssllooooww
root = post.nodes.root.parentNode root = post.nodes.root.parentNode
$.rm root.nextElementSibling $.rm root.nextElementSibling # HR element
$.rm root $.rm root
return return
Index.sort() Index.sort()

View File

@ -555,7 +555,7 @@ Index =
Index.notice = new Notice 'info', 'Refreshing index...', 2 Index.notice = new Notice 'info', 'Refreshing index...', 2
), 3 * $.SECOND - (Date.now() - now) ), 3 * $.SECOND - (Date.now() - now)
pageNum = null if typeof pageNum isnt 'number' # event pageNum = '' if typeof pageNum isnt 'number' # event
onload = (e) -> Index.load e, pageNum onload = (e) -> Index.load e, pageNum
Index.req = $.ajax "//a.4cdn.org/#{g.BOARD.ID}/catalog.json", Index.req = $.ajax "//a.4cdn.org/#{g.BOARD.ID}/catalog.json",
onabort: onload onabort: onload
@ -793,13 +793,9 @@ Index =
pageNum = Index.getCurrentPage() pageNum = Index.getCurrentPage()
threadsPerPage = Index.getThreadsNumPerPage() threadsPerPage = Index.getThreadsNumPerPage()
threads = []
i = threadsPerPage * (pageNum - 1) i = threadsPerPage * (pageNum - 1)
max = i + threadsPerPage max = i + threadsPerPage
while i < max and thread = sortedThreads[i++] nodes = Index.processThreads sortedThreads, i, max
threads.push thread
nodes.push thread.OP.nodes.root.parentNode, $.el 'hr'
Index.buildReplies thread
Index.buildPagelist() Index.buildPagelist()
Index.setPage pageNum Index.setPage pageNum
@ -808,14 +804,18 @@ Index =
nodes = Index.buildCatalogViews() nodes = Index.buildCatalogViews()
else else
i = 0 nodes = Index.processThreads sortedThreads, 0, sortedThreads.length
while thread = sortedThreads[i++]
nodes.push thread.OP.nodes.root.parentNode, $.el 'hr'
Index.buildReplies thread
$.rmAll Index.root unless infinite $.rmAll Index.root unless infinite
$.add Index.root, nodes $.add Index.root, nodes
processThreads: (threads, i, max) ->
nodes = []
while i < max and thread = threads[i++]
nodes.push thread.OP.nodes.root.parentNode, $.el 'hr'
Index.buildReplies thread
nodes
isSearching: false isSearching: false
clearSearch: -> clearSearch: ->

View File

@ -209,6 +209,7 @@ class Post
] ]
$.add @nodes.stub, Menu.makeButton @ if Conf['Menu'] $.add @nodes.stub, Menu.makeButton @ if Conf['Menu']
$.prepend @nodes.root, @nodes.stub $.prepend @nodes.root, @nodes.stub
show: (showRecursively=Conf['Recursive Hiding']) -> show: (showRecursively=Conf['Recursive Hiding']) ->
return if !@isHidden return if !@isHidden
@isHidden = false @isHidden = false
@ -229,6 +230,7 @@ class Post
unless @nodes.stub unless @nodes.stub
@nodes.root.hidden = false @nodes.root.hidden = false
return return
@nodes.post.hidden = false @nodes.post.hidden = false
@nodes.post.previousElementSibling.hidden = false @nodes.post.previousElementSibling.hidden = false
$.rm @nodes.stub $.rm @nodes.stub

View File

@ -82,7 +82,7 @@ class Thread
hide: -> hide: ->
return if @isHidden return if @isHidden
@isHidden = true @isHidden = true
@OP.nodes.root.parentElement.hidden = true @OP.nodes.root.parentElement.hidden = true unless Conf['JSON Navigation']
if button = $ '.hide-post-button', @OP.nodes.root if button = $ '.hide-post-button', @OP.nodes.root
$.replace button, PostHiding.makeButton false $.replace button, PostHiding.makeButton false