Hide stub link

This commit is contained in:
Jordan Bates 2013-05-08 23:15:47 -07:00
parent cc239c5a44
commit 7ea2e633ff
6 changed files with 231 additions and 26 deletions

View File

@ -2968,7 +2968,7 @@
},
menu: {
init: function() {
var apply, div, makeStub, replies, thisPost;
var apply, div, hideStubLink, makeStub, replies, thisPost;
if (g.VIEW === 'catalog' || !Conf['Menu'] || !Conf['Reply Hiding Link']) {
return;
@ -3029,7 +3029,12 @@
replies = $.el('label', {
innerHTML: "<input type=checkbox name=replies> Show replies"
});
return $.event('AddMenuEntry', {
hideStubLink = $.el('a', {
textContent: 'Hide stub',
href: 'javascript:;'
});
$.on(hideStubLink, 'click', PostHiding.menu.hideStub);
$.event('AddMenuEntry', {
type: 'post',
el: div,
order: 20,
@ -3061,6 +3066,26 @@
}
]
});
return $.event('AddMenuEntry', {
type: 'post',
el: hideStubLink,
order: 15,
open: function(post) {
var data;
if (!post.isReply || post.isClone || !post.isHidden) {
return false;
}
if (!(data = PostHiding.db.get({
boardID: post.board.ID,
threadID: post.thread.ID,
postID: post.ID
}))) {
return false;
}
return PostHiding.menu.post = post;
}
});
},
hide: function() {
var makeStub, parent, post, replies, thisPost;
@ -3104,6 +3129,13 @@
PostHiding.saveHiddenState(post, !(thisPost && replies), !thisPost, data.makeStub, !replies);
}
return $.event('CloseMenu');
},
hideStub: function() {
var post;
post = PostHiding.menu.post;
post.nodes.root.hidden = true;
$.event('CloseMenu');
}
},
makeButton: function(post, type) {
@ -3360,7 +3392,7 @@
},
menu: {
init: function() {
var apply, div, makeStub;
var apply, div, hideStubLink, makeStub;
if (g.VIEW !== 'index' || !Conf['Menu'] || !Conf['Thread Hiding Link']) {
return;
@ -3377,7 +3409,12 @@
makeStub = $.el('label', {
innerHTML: "<input type=checkbox checked=" + Conf['Stubs'] + "> Make stub"
});
return $.event('AddMenuEntry', {
hideStubLink = $.el('a', {
textContent: 'Hide stub',
href: 'javascript:;'
});
$.on(hideStubLink, 'click', ThreadHiding.menu.hideStub);
$.event('AddMenuEntry', {
type: 'post',
el: div,
order: 20,
@ -3399,6 +3436,20 @@
}
]
});
return $.event('AddMenuEntry', {
type: 'post',
el: hideStubLink,
order: 15,
open: function(_arg) {
var isReply, thread;
thread = _arg.thread, isReply = _arg.isReply;
if (isReply || !thread.isHidden) {
return false;
}
return ThreadHiding.menu.thread = thread;
}
});
},
hide: function() {
var makeStub, thread;
@ -3408,6 +3459,13 @@
ThreadHiding.hide(thread, makeStub);
ThreadHiding.saveHiddenState(thread, makeStub);
return $.event('CloseMenu');
},
hideStub: function() {
var thread;
thread = ThreadHiding.menu.thread;
ThreadHiding.hide(thread, false);
$.event('CloseMenu');
}
},
makeButton: function(thread, type) {
@ -3461,9 +3519,6 @@
if (makeStub == null) {
makeStub = Conf['Stubs'];
}
if (thread.isHidden) {
return;
}
OP = thread.OP;
threadRoot = OP.nodes.root.parentNode;
thread.isHidden = true;
@ -6605,7 +6660,7 @@
return $.event('AddMenuEntry', {
type: 'post',
el: a,
order: 70,
order: 100,
open: function(_arg) {
var file;

View File

@ -2964,7 +2964,7 @@
},
menu: {
init: function() {
var apply, div, makeStub, replies, thisPost;
var apply, div, hideStubLink, makeStub, replies, thisPost;
if (g.VIEW === 'catalog' || !Conf['Menu'] || !Conf['Reply Hiding Link']) {
return;
@ -3025,7 +3025,12 @@
replies = $.el('label', {
innerHTML: "<input type=checkbox name=replies> Show replies"
});
return $.event('AddMenuEntry', {
hideStubLink = $.el('a', {
textContent: 'Hide stub',
href: 'javascript:;'
});
$.on(hideStubLink, 'click', PostHiding.menu.hideStub);
$.event('AddMenuEntry', {
type: 'post',
el: div,
order: 20,
@ -3057,6 +3062,26 @@
}
]
});
return $.event('AddMenuEntry', {
type: 'post',
el: hideStubLink,
order: 15,
open: function(post) {
var data;
if (!post.isReply || post.isClone || !post.isHidden) {
return false;
}
if (!(data = PostHiding.db.get({
boardID: post.board.ID,
threadID: post.thread.ID,
postID: post.ID
}))) {
return false;
}
return PostHiding.menu.post = post;
}
});
},
hide: function() {
var makeStub, parent, post, replies, thisPost;
@ -3100,6 +3125,13 @@
PostHiding.saveHiddenState(post, !(thisPost && replies), !thisPost, data.makeStub, !replies);
}
return $.event('CloseMenu');
},
hideStub: function() {
var post;
post = PostHiding.menu.post;
post.nodes.root.hidden = true;
$.event('CloseMenu');
}
},
makeButton: function(post, type) {
@ -3356,7 +3388,7 @@
},
menu: {
init: function() {
var apply, div, makeStub;
var apply, div, hideStubLink, makeStub;
if (g.VIEW !== 'index' || !Conf['Menu'] || !Conf['Thread Hiding Link']) {
return;
@ -3373,7 +3405,12 @@
makeStub = $.el('label', {
innerHTML: "<input type=checkbox checked=" + Conf['Stubs'] + "> Make stub"
});
return $.event('AddMenuEntry', {
hideStubLink = $.el('a', {
textContent: 'Hide stub',
href: 'javascript:;'
});
$.on(hideStubLink, 'click', ThreadHiding.menu.hideStub);
$.event('AddMenuEntry', {
type: 'post',
el: div,
order: 20,
@ -3395,6 +3432,20 @@
}
]
});
return $.event('AddMenuEntry', {
type: 'post',
el: hideStubLink,
order: 15,
open: function(_arg) {
var isReply, thread;
thread = _arg.thread, isReply = _arg.isReply;
if (isReply || !thread.isHidden) {
return false;
}
return ThreadHiding.menu.thread = thread;
}
});
},
hide: function() {
var makeStub, thread;
@ -3404,6 +3455,13 @@
ThreadHiding.hide(thread, makeStub);
ThreadHiding.saveHiddenState(thread, makeStub);
return $.event('CloseMenu');
},
hideStub: function() {
var thread;
thread = ThreadHiding.menu.thread;
ThreadHiding.hide(thread, false);
$.event('CloseMenu');
}
},
makeButton: function(thread, type) {
@ -3457,9 +3515,6 @@
if (makeStub == null) {
makeStub = Conf['Stubs'];
}
if (thread.isHidden) {
return;
}
OP = thread.OP;
threadRoot = OP.nodes.root.parentNode;
thread.isHidden = true;
@ -6626,7 +6681,7 @@
return $.event('AddMenuEntry', {
type: 'post',
el: a,
order: 70,
order: 100,
open: function(_arg) {
var file;

View File

@ -2967,7 +2967,7 @@
},
menu: {
init: function() {
var apply, div, makeStub, replies, thisPost;
var apply, div, hideStubLink, makeStub, replies, thisPost;
if (g.VIEW === 'catalog' || !Conf['Menu'] || !Conf['Reply Hiding Link']) {
return;
@ -3028,7 +3028,12 @@
replies = $.el('label', {
innerHTML: "<input type=checkbox name=replies> Show replies"
});
return $.event('AddMenuEntry', {
hideStubLink = $.el('a', {
textContent: 'Hide stub',
href: 'javascript:;'
});
$.on(hideStubLink, 'click', PostHiding.menu.hideStub);
$.event('AddMenuEntry', {
type: 'post',
el: div,
order: 20,
@ -3060,6 +3065,26 @@
}
]
});
return $.event('AddMenuEntry', {
type: 'post',
el: hideStubLink,
order: 15,
open: function(post) {
var data;
if (!post.isReply || post.isClone || !post.isHidden) {
return false;
}
if (!(data = PostHiding.db.get({
boardID: post.board.ID,
threadID: post.thread.ID,
postID: post.ID
}))) {
return false;
}
return PostHiding.menu.post = post;
}
});
},
hide: function() {
var makeStub, parent, post, replies, thisPost;
@ -3103,6 +3128,13 @@
PostHiding.saveHiddenState(post, !(thisPost && replies), !thisPost, data.makeStub, !replies);
}
return $.event('CloseMenu');
},
hideStub: function() {
var post;
post = PostHiding.menu.post;
post.nodes.root.hidden = true;
$.event('CloseMenu');
}
},
makeButton: function(post, type) {
@ -3359,7 +3391,7 @@
},
menu: {
init: function() {
var apply, div, makeStub;
var apply, div, hideStubLink, makeStub;
if (g.VIEW !== 'index' || !Conf['Menu'] || !Conf['Thread Hiding Link']) {
return;
@ -3376,7 +3408,12 @@
makeStub = $.el('label', {
innerHTML: "<input type=checkbox checked=" + Conf['Stubs'] + "> Make stub"
});
return $.event('AddMenuEntry', {
hideStubLink = $.el('a', {
textContent: 'Hide stub',
href: 'javascript:;'
});
$.on(hideStubLink, 'click', ThreadHiding.menu.hideStub);
$.event('AddMenuEntry', {
type: 'post',
el: div,
order: 20,
@ -3398,6 +3435,20 @@
}
]
});
return $.event('AddMenuEntry', {
type: 'post',
el: hideStubLink,
order: 15,
open: function(_arg) {
var isReply, thread;
thread = _arg.thread, isReply = _arg.isReply;
if (isReply || !thread.isHidden) {
return false;
}
return ThreadHiding.menu.thread = thread;
}
});
},
hide: function() {
var makeStub, thread;
@ -3407,6 +3458,13 @@
ThreadHiding.hide(thread, makeStub);
ThreadHiding.saveHiddenState(thread, makeStub);
return $.event('CloseMenu');
},
hideStub: function() {
var thread;
thread = ThreadHiding.menu.thread;
ThreadHiding.hide(thread, false);
$.event('CloseMenu');
}
},
makeButton: function(thread, type) {
@ -3460,9 +3518,6 @@
if (makeStub == null) {
makeStub = Conf['Stubs'];
}
if (thread.isHidden) {
return;
}
OP = thread.OP;
threadRoot = OP.nodes.root.parentNode;
thread.isHidden = true;
@ -6605,7 +6660,7 @@
return $.event('AddMenuEntry', {
type: 'post',
el: a,
order: 70,
order: 100,
open: function(_arg) {
var file;

View File

@ -64,6 +64,10 @@ PostHiding =
innerHTML: '<input type=checkbox name=thisPost> This post'
replies = $.el 'label',
innerHTML: "<input type=checkbox name=replies> Show replies"
hideStubLink = $.el 'a',
textContent: 'Hide stub'
href: 'javascript:;'
$.on hideStubLink, 'click', PostHiding.menu.hideStub
$.event 'AddMenuEntry',
type: 'post'
@ -79,6 +83,18 @@ PostHiding =
replies.firstChild.checked = if data?.hideRecursively? then data.hideRecursively else Conf['Recursive Hiding']
true
subEntries: [{el: apply}, {el: thisPost}, {el: replies}]
$.event 'AddMenuEntry',
type: 'post'
el: hideStubLink
order: 15
open: (post) ->
if !post.isReply or post.isClone or !post.isHidden
return false
unless data = PostHiding.db.get {boardID: post.board.ID, threadID: post.thread.ID, postID: post.ID}
return false
PostHiding.menu.post = post
hide: ->
parent = @parentNode
thisPost = $('input[name=thisPost]', parent).checked
@ -109,6 +125,11 @@ PostHiding =
if data = PostHiding.db.get {boardID: post.board.ID, threadID: post.thread.ID, postID: post.ID}
PostHiding.saveHiddenState post, !(thisPost and replies), !thisPost, data.makeStub, !replies
$.event 'CloseMenu'
hideStub: ->
{post} = PostHiding.menu
post.nodes.root.hidden = true
$.event 'CloseMenu'
return
makeButton: (post, type) ->
a = $.el 'a',

View File

@ -71,6 +71,11 @@ ThreadHiding =
makeStub = $.el 'label',
innerHTML: "<input type=checkbox checked=#{Conf['Stubs']}> Make stub"
hideStubLink = $.el 'a',
textContent: 'Hide stub'
href: 'javascript:;'
$.on hideStubLink, 'click', ThreadHiding.menu.hideStub
$.event 'AddMenuEntry',
type: 'post'
el: div
@ -81,12 +86,27 @@ ThreadHiding =
ThreadHiding.menu.thread = thread
true
subEntries: [el: apply; el: makeStub]
$.event 'AddMenuEntry',
type: 'post'
el: hideStubLink
order: 15
open: ({thread, isReply}) ->
if isReply or !thread.isHidden
return false
ThreadHiding.menu.thread = thread
hide: ->
makeStub = $('input', @parentNode).checked
{thread} = ThreadHiding.menu
ThreadHiding.hide thread, makeStub
ThreadHiding.saveHiddenState thread, makeStub
$.event 'CloseMenu'
hideStub: ->
{thread} = ThreadHiding.menu
ThreadHiding.hide thread, false
$.event 'CloseMenu'
return
makeButton: (thread, type) ->
a = $.el 'a',
@ -122,7 +142,6 @@ ThreadHiding =
ThreadHiding.saveHiddenState thread
hide: (thread, makeStub=Conf['Stubs']) ->
return if thread.isHidden
{OP} = thread
threadRoot = OP.nodes.root.parentNode
thread.isHidden = true

View File

@ -8,7 +8,7 @@ DownloadLink =
$.event 'AddMenuEntry',
type: 'post'
el: a
order: 70
order: 100
open: ({file}) ->
return false unless file
a.href = file.URL