diff --git a/src/Filtering/Filter.coffee b/src/Filtering/Filter.coffee
index ca3551f36..3ea85bd72 100755
--- a/src/Filtering/Filter.coffee
+++ b/src/Filtering/Filter.coffee
@@ -113,7 +113,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 c74bf8dc2..2ae0788b2 100755
--- a/src/General/Build.coffee
+++ b/src/General/Build.coffee
@@ -363,6 +363,7 @@ Build =
'
'
) %>
+ $.addClass root, 'pinned' if thread.isPinned
$.addClass root, thread.OP.highlights... if thread.OP.highlights
if thread.isSticky
diff --git a/src/General/Index.coffee b/src/General/Index.coffee
index 9de94365c..da390b367 100644
--- a/src/General/Index.coffee
+++ b/src/General/Index.coffee
@@ -4,6 +4,11 @@ Index =
@board = "#{g.BOARD}"
+ @db = new DataBoard 'pinnedThreads'
+ Thread.callbacks.push
+ name: 'Thread Pinning'
+ cb: @node
+
@button = $.el 'a',
className: 'index-refresh-shortcut fa fa-refresh'
title: 'Refresh'
@@ -131,6 +136,24 @@ Index =
new Notice 'info', "Last page reached.", 2
setTimeout reset, 3 * $.SECOND
+ 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/css/style.css b/src/General/css/style.css
index a74e37423..0de359872 100755
--- a/src/General/css/style.css
+++ b/src/General/css/style.css
@@ -824,6 +824,7 @@ span.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/General/lib/databoard.class b/src/General/lib/databoard.class
index 5489e6867..3971006c3 100755
--- a/src/General/lib/databoard.class
+++ b/src/General/lib/databoard.class
@@ -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/lib/thread.class b/src/General/lib/thread.class
index f351c5257..b34a8fa6e 100755
--- a/src/General/lib/thread.class
+++ b/src/General/lib/thread.class
@@ -63,9 +63,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