diff --git a/css/style.css b/css/style.css index 41991048a..5abad3b16 100644 --- a/css/style.css +++ b/css/style.css @@ -649,6 +649,7 @@ a.hide-announcement { .filter-highlight > .reply { box-shadow: -5px 0 rgba(255, 0, 0, .5); } +.pinned .thumb, .filter-highlight .thumb { border: 2px solid rgba(255, 0, 0, .5); } diff --git a/src/Filtering/Filter.coffee b/src/Filtering/Filter.coffee index b24b06238..85c86d215 100644 --- a/src/Filtering/Filter.coffee +++ b/src/Filtering/Filter.coffee @@ -110,7 +110,7 @@ Filter = # Highlight $.addClass @nodes.root, result.class - unless result.class in @highlights + unless @highlights and result.class in @highlights (@highlights or= []).push result.class if !@isReply and result.top @thread.isOnTop = true diff --git a/src/General/Build.coffee b/src/General/Build.coffee index b257ae628..cbcb86b06 100644 --- a/src/General/Build.coffee +++ b/src/General/Build.coffee @@ -297,6 +297,7 @@ Build = className: 'catalog-thread' innerHTML: <%= importHTML('General/Thread-catalog-view') %> + $.addClass root, 'pinned' if thread.isPinned $.addClass root, thread.OP.highlights... if thread.OP.highlights if thread.isSticky diff --git a/src/General/DataBoard.coffee b/src/General/DataBoard.coffee index aba14d68d..dc4319816 100644 --- a/src/General/DataBoard.coffee +++ b/src/General/DataBoard.coffee @@ -1,5 +1,5 @@ class DataBoard - @keys = ['hiddenThreads', 'hiddenPosts', 'lastReadPosts', 'yourPosts', 'watchedThreads'] + @keys = ['pinnedThreads', 'hiddenThreads', 'hiddenPosts', 'lastReadPosts', 'yourPosts', 'watchedThreads'] constructor: (@key, sync, dontClean) -> @data = Conf[key] diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 13be9c5d7..54386601b 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -12,6 +12,11 @@ Index = return if g.VIEW isnt 'index' or g.BOARD.ID is 'f' + @db = new DataBoard 'pinnedThreads' + Thread.callbacks.push + name: 'Thread Pinning' + cb: @node + @button = $.el 'a', className: 'index-refresh-shortcut fa fa-refresh' title: 'Refresh Index' @@ -112,6 +117,24 @@ Index = $.asap (-> $('.pagelist') or d.readyState isnt 'loading'), -> $.replace $('.pagelist'), Index.pagelist + node: -> + return unless data = Index.db.get {boardID: @board.ID, threadID: @ID} + @pin() if data.isPinned + togglePin: (thread) -> + if thread.isPinned + thread.unpin() + Index.db.delete + boardID: thread.board.ID + threadID: thread.ID + else + thread.pin() + Index.db.set + boardID: thread.board.ID + threadID: thread.ID + val: isPinned: thread.isPinned + Index.sort() + Index.buildIndex() + cb: rootClass: -> (if Conf['Index Mode'] is 'catalog' then $.addClass else $.rmClass) Index.root, 'catalog-mode' diff --git a/src/General/Thread.coffee b/src/General/Thread.coffee index 0051c3f21..3103d08f1 100644 --- a/src/General/Thread.coffee +++ b/src/General/Thread.coffee @@ -61,9 +61,17 @@ class Thread $.rm @catalogView ThreadHiding.hide @ ThreadHiding.saveHiddenState @ + else if e.altKey + Index.togglePin @ else return e.preventDefault() + pin: -> + @isOnTop = @isPinned = true + $.addClass @catalogView, 'pinned' if @catalogView + unpin: -> + @isOnTop = @isPinned = false + $.rmClass @catalogView, 'pinned' if @catalogView kill: -> @isDead = true