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

View File

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

View File

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

View File

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

View File

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

View File

@ -82,7 +82,7 @@ class Thread
hide: ->
return if @isHidden
@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
$.replace button, PostHiding.makeButton false