Add pin/hide/show thread menu entries for the catalog.

This commit is contained in:
Mayhem 2014-02-04 13:51:21 +01:00
parent 12ffcb3309
commit 0675146d22
4 changed files with 46 additions and 9 deletions

View File

@ -91,7 +91,7 @@ ThreadHiding =
el: div el: div
order: 20 order: 20
open: ({thread, isReply}) -> open: ({thread, isReply}) ->
if isReply or thread.isHidden if isReply or thread.isHidden or Conf['Index Mode'] is 'catalog'
return false return false
ThreadHiding.menu.thread = thread ThreadHiding.menu.thread = thread
true true

View File

@ -122,6 +122,43 @@ Index =
$.rmClass doc, 'index-loading' $.rmClass doc, 'index-loading'
$.asap (-> $('.pagelist') or d.readyState isnt 'loading'), -> $.asap (-> $('.pagelist') or d.readyState isnt 'loading'), ->
$.replace $('.pagelist'), Index.pagelist $.replace $('.pagelist'), Index.pagelist
menu:
init: ->
return if g.VIEW isnt 'index' or !Conf['Menu'] or g.BOARD.ID is 'f'
$.event 'AddMenuEntry',
type: 'post'
el: $.el 'a', href: 'javascript:;'
order: 5
open: ({thread}) ->
return false if Conf['Index Mode'] isnt 'catalog'
@el.textContent = if thread.isHidden
'Show thread'
else
'Hide thread'
$.off @el, 'click', @cb if @cb
@cb = ->
$.event 'CloseMenu'
Index.toggleHide thread
$.on @el, 'click', @cb
true
$.event 'AddMenuEntry',
type: 'post'
el: $.el 'a', href: 'javascript:;'
order: 6
open: ({thread}) ->
return false if Conf['Index Mode'] isnt 'catalog'
@el.textContent = if thread.isPinned
'Unpin thread'
else
'Pin thread'
$.off @el, 'click', @cb if @cb
@cb = ->
$.event 'CloseMenu'
Index.togglePin thread
$.on @el, 'click', @cb
true
threadNode: -> threadNode: ->
return unless data = Index.db.get {boardID: @board.ID, threadID: @ID} return unless data = Index.db.get {boardID: @board.ID, threadID: @ID}
@ -130,17 +167,16 @@ Index =
$.on @nodes.thumb, 'click', Index.onClick $.on @nodes.thumb, 'click', Index.onClick
onClick: (e) -> onClick: (e) ->
return if e.button isnt 0 return if e.button isnt 0
root = @parentNode thread = g.threads[@parentNode.dataset.fullID]
thread = g.threads[root.dataset.fullID]
if e.shiftKey if e.shiftKey
Index.toggleHide thread, root Index.toggleHide thread
else if e.altKey else if e.altKey
Index.togglePin thread Index.togglePin thread
else else
return return
e.preventDefault() e.preventDefault()
toggleHide: (thread, root) -> toggleHide: (thread) ->
$.rm root $.rm thread.catalogView.nodes.root
if Index.showHiddenThreads if Index.showHiddenThreads
ThreadHiding.show thread ThreadHiding.show thread
return unless ThreadHiding.db.get {boardID: thread.board.ID, threadID: thread.ID} return unless ThreadHiding.db.get {boardID: thread.board.ID, threadID: thread.ID}
@ -464,7 +500,7 @@ Index =
# Sticky threads # Sticky threads
Index.sortOnTop (thread) -> thread.isSticky Index.sortOnTop (thread) -> thread.isSticky
# Highlighted threads # Highlighted threads
Index.sortOnTop((thread) -> thread.isOnTop) if Conf['Filter'] Index.sortOnTop (thread) -> thread.isOnTop
# Non-hidden threads # Non-hidden threads
Index.sortOnTop((thread) -> !thread.isHidden) if Conf['Anchor Hidden Threads'] Index.sortOnTop((thread) -> !thread.isHidden) if Conf['Anchor Hidden Threads']
sortOnTop: (match) -> sortOnTop: (match) ->

View File

@ -82,6 +82,7 @@ Main =
initFeature 'Strike-through Quotes', QuoteStrikeThrough initFeature 'Strike-through Quotes', QuoteStrikeThrough
initFeature 'Quick Reply', QR initFeature 'Quick Reply', QR
initFeature 'Menu', Menu initFeature 'Menu', Menu
initFeature 'Index Generator (Menu)', Index.menu
initFeature 'Report Link', ReportLink initFeature 'Report Link', ReportLink
initFeature 'Thread Hiding (Menu)', ThreadHiding.menu initFeature 'Thread Hiding (Menu)', ThreadHiding.menu
initFeature 'Reply Hiding (Menu)', PostHiding.menu initFeature 'Reply Hiding (Menu)', PostHiding.menu

View File

@ -23,11 +23,11 @@ AutoGIF =
{URL} = OP.file {URL} = OP.file
return unless /gif$/.test URL return unless /gif$/.test URL
AutoGIF.replaceThumbnail @nodes.thumb, URL, true AutoGIF.replaceThumbnail @nodes.thumb, URL, true
replaceThumbnail: (thumb, URL, isCatalog) -> replaceThumbnail: (thumb, URL, isBackground) ->
gif = $.el 'img' gif = $.el 'img'
$.on gif, 'load', -> $.on gif, 'load', ->
# Replace the thumbnail once the GIF has finished loading. # Replace the thumbnail once the GIF has finished loading.
if isCatalog if isBackground
thumb.style.backgroundImage = "url(#{URL})" thumb.style.backgroundImage = "url(#{URL})"
else else
thumb.src = URL thumb.src = URL