diff --git a/src/Filtering/ThreadHiding.coffee b/src/Filtering/ThreadHiding.coffee index 39397d999..566abdd02 100644 --- a/src/Filtering/ThreadHiding.coffee +++ b/src/Filtering/ThreadHiding.coffee @@ -91,7 +91,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 diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 7a1be3991..78df3322a 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -122,6 +122,43 @@ Index = $.rmClass doc, 'index-loading' $.asap (-> $('.pagelist') or d.readyState isnt 'loading'), -> $.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: -> return unless data = Index.db.get {boardID: @board.ID, threadID: @ID} @@ -130,17 +167,16 @@ Index = $.on @nodes.thumb, 'click', Index.onClick onClick: (e) -> return if e.button isnt 0 - root = @parentNode - thread = g.threads[root.dataset.fullID] + thread = g.threads[@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} @@ -464,7 +500,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'] sortOnTop: (match) -> diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 254d2cba4..87db28ba8 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -82,6 +82,7 @@ Main = initFeature 'Strike-through Quotes', QuoteStrikeThrough initFeature 'Quick Reply', QR initFeature 'Menu', Menu + initFeature 'Index Generator (Menu)', Index.menu initFeature 'Report Link', ReportLink initFeature 'Thread Hiding (Menu)', ThreadHiding.menu initFeature 'Reply Hiding (Menu)', PostHiding.menu diff --git a/src/Images/AutoGIF.coffee b/src/Images/AutoGIF.coffee index 572e977de..3aca0319c 100644 --- a/src/Images/AutoGIF.coffee +++ b/src/Images/AutoGIF.coffee @@ -23,11 +23,11 @@ AutoGIF = {URL} = OP.file return unless /gif$/.test URL AutoGIF.replaceThumbnail @nodes.thumb, URL, true - replaceThumbnail: (thumb, URL, isCatalog) -> + replaceThumbnail: (thumb, URL, isBackground) -> gif = $.el 'img' $.on gif, 'load', -> # Replace the thumbnail once the GIF has finished loading. - if isCatalog + if isBackground thumb.style.backgroundImage = "url(#{URL})" else thumb.src = URL