Add Show Reply menu enty. #932

This commit is contained in:
Nicolas Stepien 2013-03-07 19:14:31 +01:00
parent a45a9fe641
commit e0600eb02e
5 changed files with 124 additions and 12 deletions

File diff suppressed because one or more lines are too long

View File

@ -56,7 +56,7 @@ module.exports = function(grunt) {
stdout: true stdout: true
}, },
push: { push: {
command: 'git push && git push --tags', command: 'git push origin --all && git push origin --tags',
stdout: true stdout: true
} }
}, },

View File

@ -459,6 +459,9 @@ a[href="javascript:;"] {
.stub ~ .post { .stub ~ .post {
display: none !important; display: none !important;
} }
.stub input {
display: inline-block;
}
/* QR */ /* QR */
.hide-original-post-form #postForm, .hide-original-post-form #postForm,

View File

@ -12,11 +12,11 @@
"userjs": "4chan_x.user.js" "userjs": "4chan_x.user.js"
} }
}, },
"dependencies": { "devDependencies": {
"grunt": "~0.4.0", "grunt": "~0.4.0",
"grunt-bump": "~0.0.0", "grunt-bump": "~0.0.0",
"grunt-contrib-clean": "~0.4.0", "grunt-contrib-clean": "~0.4.0",
"grunt-contrib-coffee": "~0.5.0", "grunt-contrib-coffee": "~0.6.0",
"grunt-contrib-concat": "~0.1.0", "grunt-contrib-concat": "~0.1.0",
"grunt-contrib-watch": "~0.3.0", "grunt-contrib-watch": "~0.3.0",
"grunt-exec": "~0.4.0" "grunt-exec": "~0.4.0"

View File

@ -1076,6 +1076,7 @@ ReplyHiding =
init: -> init: ->
return if g.VIEW is 'catalog' or !Conf['Menu'] or !Conf['Reply Hiding'] return if g.VIEW is 'catalog' or !Conf['Menu'] or !Conf['Reply Hiding']
# Hide
div = $.el 'div', div = $.el 'div',
className: 'hide-reply-link' className: 'hide-reply-link'
textContent: 'Hide reply' textContent: 'Hide reply'
@ -1097,11 +1098,42 @@ ReplyHiding =
el: div el: div
order: 20 order: 20
open: (post) -> open: (post) ->
if !post.isReply or post.isClone if !post.isReply or post.isClone or post.isHidden
return false return false
ReplyHiding.menu.post = post ReplyHiding.menu.post = post
true true
subEntries: [{el: apply}, {el: thisPost}, {el: replies}, {el: makeStub}] subEntries: [{el: apply}, {el: thisPost}, {el: replies}, {el: makeStub}]
# Show
div = $.el 'div',
className: 'show-reply-link'
textContent: 'Show reply'
apply = $.el 'a',
textContent: 'Apply'
href: 'javascript:;'
$.on apply, 'click', ReplyHiding.menu.show
thisPost = $.el 'label',
innerHTML: '<input type=checkbox name=thisPost> This post'
replies = $.el 'label',
innerHTML: "<input type=checkbox name=replies> Show replies"
$.event 'AddMenuEntry',
type: 'post'
el: div
order: 20
open: (post) ->
if !post.isReply or post.isClone
return false
thread = ReplyHiding.getHiddenPosts().threads[post.thread]
unless post.isHidden or data = thread?[post]
return false
ReplyHiding.menu.post = post
thisPost.firstChild.checked = post.isHidden
replies.firstChild.checked = if data?.hideRecursively? then data.hideRecursively else Conf['Recursive Hiding']
true
subEntries: [{el: apply}, {el: thisPost}, {el: replies}]
hide: -> hide: ->
parent = @parentNode parent = @parentNode
thisPost = $('input[name=thisPost]', parent).checked thisPost = $('input[name=thisPost]', parent).checked
@ -1117,6 +1149,23 @@ ReplyHiding =
return return
ReplyHiding.saveHiddenState post, true, thisPost, makeStub, replies ReplyHiding.saveHiddenState post, true, thisPost, makeStub, replies
$.event 'CloseMenu' $.event 'CloseMenu'
show: ->
parent = @parentNode
thisPost = $('input[name=thisPost]', parent).checked
replies = $('input[name=replies]', parent).checked
{post} = ReplyHiding.menu
thread = ReplyHiding.getHiddenPosts().threads[post.thread]
data = thread?[post]
if thisPost
ReplyHiding.show post, replies
else if replies
Recursive.apply ReplyHiding.show, post, true
Recursive.rm ReplyHiding.hide, post, true
else
return
if data
ReplyHiding.saveHiddenState post, !(thisPost and replies), !thisPost, data.makeStub, !replies
$.event 'CloseMenu'
makeButton: (post, type) -> makeButton: (post, type) ->
a = $.el 'a', a = $.el 'a',
@ -1198,8 +1247,6 @@ Recursive =
recursives: {} recursives: {}
init: -> init: ->
return if g.VIEW is 'catalog' return if g.VIEW is 'catalog'
$.unsafeWindow.Recursive = @
$.unsafeWindow.ReplyHiding = ReplyHiding
Post::callbacks.push Post::callbacks.push
name: 'Recursive' name: 'Recursive'