Alt+click to pin threads in the catalog.

This commit is contained in:
Mayhem 2014-01-28 10:26:46 +01:00
parent 1d43fbc498
commit 9f682bea14
6 changed files with 35 additions and 2 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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'

View File

@ -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