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

Conflicts:
	src/General/Index.coffee
	src/General/Main.coffee
	src/Images/AutoGIF.coffee
This commit is contained in:
Mayhem 2014-02-04 13:51:21 +01:00 committed by ccd0
parent 78ea850517
commit 18b343671d
3 changed files with 43 additions and 7 deletions

View File

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

View File

@ -142,6 +142,42 @@ Index =
new Notice 'info', "Last page reached.", 2
setTimeout reset, 3 * $.SECOND
menu:
init: ->
return if g.VIEW isnt 'index' or !Conf['Menu'] or g.BOARD.ID is 'f'
Menu.menu.addEntry
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
Menu.menu.addEntry
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: ->
return unless data = Index.db.get {boardID: @board.ID, threadID: @ID}
@pin() if data.isPinned
@ -149,17 +185,16 @@ Index =
$.on @nodes.thumb, 'click', Index.onClick
onClick: (e) ->
return if e.button isnt 0
root = @parentNode.parentNode
thread = g.threads[root.dataset.fullID]
thread = g.threads[@parentNode.parentNode.dataset.fullID]
if e.shiftKey
Index.toggleHide thread, root
Index.toggleHide thread
else if e.altKey
Index.togglePin thread
else
return
e.preventDefault()
toggleHide: (thread, root) ->
$.rm root
toggleHide: (thread) ->
$.rm thread.catalogView.nodes.root
if Index.showHiddenThreads
ThreadHiding.show thread
return unless ThreadHiding.db.get {boardID: thread.board.ID, threadID: thread.ID}
@ -483,7 +518,7 @@ Index =
# Sticky threads
Index.sortOnTop (thread) -> thread.isSticky
# Highlighted threads
Index.sortOnTop((thread) -> thread.isOnTop) if Conf['Filter']
Index.sortOnTop (thread) -> thread.isOnTop
# Non-hidden threads
Index.sortOnTop((thread) -> !thread.isHidden) if Conf['Anchor Hidden Threads']

View File

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