Only activate Catalog Hover Expand when catalog is clicked. Deactivate on second click. #489
This commit is contained in:
parent
c2a2dafe7f
commit
2cc3fc4572
@ -18,7 +18,7 @@ Get =
|
|||||||
index = root.dataset.clone
|
index = root.dataset.clone
|
||||||
if index then post.clones[index] else post
|
if index then post.clones[index] else post
|
||||||
postFromNode: (root) ->
|
postFromNode: (root) ->
|
||||||
Get.postFromRoot $.x '(ancestor::div[contains(@class,"postContainer")][1]|following::div[contains(@class,"postContainer")][1])', root
|
Get.postFromRoot $.x '(ancestor-or-self::div[contains(@class,"postContainer")][1]|following::div[contains(@class,"postContainer")][1])', root
|
||||||
postDataFromLink: (link) ->
|
postDataFromLink: (link) ->
|
||||||
if link.hostname is 'boards.4chan.org'
|
if link.hostname is 'boards.4chan.org'
|
||||||
path = link.pathname.split /\/+/
|
path = link.pathname.split /\/+/
|
||||||
|
|||||||
@ -109,8 +109,8 @@ Index =
|
|||||||
|
|
||||||
# Thread container
|
# Thread container
|
||||||
@root = $.el 'div', className: 'board json-index'
|
@root = $.el 'div', className: 'board json-index'
|
||||||
|
$.on @root, 'click', @cb.hoverToggle
|
||||||
@cb.size()
|
@cb.size()
|
||||||
@cb.hover()
|
|
||||||
|
|
||||||
# Page list
|
# Page list
|
||||||
@pagelist = $.el 'div', className: 'pagelist json-index'
|
@pagelist = $.el 'div', className: 'pagelist json-index'
|
||||||
@ -278,9 +278,14 @@ Index =
|
|||||||
replies: ->
|
replies: ->
|
||||||
Index.buildIndex()
|
Index.buildIndex()
|
||||||
|
|
||||||
hover: (e) ->
|
hover: ->
|
||||||
doc.classList.toggle 'catalog-hover-expand', Conf['Catalog Hover Expand']
|
$.rmClass doc, 'catalog-hover-expand' unless Conf['Catalog Hover Expand']
|
||||||
Index.cb.replies() if e and Conf['Show Replies'] and Conf['Catalog Hover Expand']
|
|
||||||
|
hoverToggle: (e) ->
|
||||||
|
if Conf['Catalog Hover Expand'] and !$.modifiedClick(e) and !$.x('ancestor-or-self::a', e.target)
|
||||||
|
$.toggleClass doc, 'catalog-hover-expand'
|
||||||
|
if (post = Get.postFromNode e.target)
|
||||||
|
Index.cb.hoverAdjust.call post.nodes
|
||||||
|
|
||||||
popstate: (e) ->
|
popstate: (e) ->
|
||||||
if e?.state
|
if e?.state
|
||||||
@ -315,13 +320,13 @@ Index =
|
|||||||
Index.update()
|
Index.update()
|
||||||
|
|
||||||
catalogReplies: ->
|
catalogReplies: ->
|
||||||
$.off @, 'mouseover', Index.cb.catalogReplies
|
return unless Conf['Show Replies'] and $.hasClass(doc, 'catalog-hover-expand')
|
||||||
return unless Conf['Show Replies'] and Conf['Catalog Hover Expand'] and @parentNode
|
$.off @, 'mouseenter', Index.cb.catalogReplies
|
||||||
Index.buildCatalogReplies Get.threadFromRoot @
|
Index.buildCatalogReplies Get.threadFromRoot @
|
||||||
|
|
||||||
hoverAdjust: ->
|
hoverAdjust: ->
|
||||||
# Prevent hovered catalog threads from going offscreen.
|
# Prevent hovered catalog threads from going offscreen.
|
||||||
return unless Conf['Catalog Hover Expand']
|
return unless $.hasClass(doc, 'catalog-hover-expand')
|
||||||
rect = @post.getBoundingClientRect()
|
rect = @post.getBoundingClientRect()
|
||||||
if (x = $.minmax 0, -rect.left, doc.clientWidth - rect.right)
|
if (x = $.minmax 0, -rect.left, doc.clientWidth - rect.right)
|
||||||
{style} = @post
|
{style} = @post
|
||||||
@ -852,8 +857,7 @@ Index =
|
|||||||
thread.OP.setCatalogOP true
|
thread.OP.setCatalogOP true
|
||||||
$.add thread.catalogView.nodes.root, thread.OP.nodes.root
|
$.add thread.catalogView.nodes.root, thread.OP.nodes.root
|
||||||
nodes.push thread.catalogView.nodes.root
|
nodes.push thread.catalogView.nodes.root
|
||||||
if Conf['Show Replies'] and Conf['Catalog Hover Expand']
|
$.on thread.catalogView.nodes.root, 'mouseenter', Index.cb.catalogReplies
|
||||||
$.on thread.catalogView.nodes.root, 'mouseover', Index.cb.catalogReplies
|
|
||||||
$.on thread.OP.nodes.root, 'mouseenter', Index.cb.hoverAdjust.bind(thread.OP.nodes)
|
$.on thread.OP.nodes.root, 'mouseenter', Index.cb.hoverAdjust.bind(thread.OP.nodes)
|
||||||
$.add Index.root, nodes
|
$.add Index.root, nodes
|
||||||
nodes
|
nodes
|
||||||
|
|||||||
@ -272,3 +272,4 @@ class Post
|
|||||||
@nodes.root.classList.toggle 'opContainer', !isCatalogOP
|
@nodes.root.classList.toggle 'opContainer', !isCatalogOP
|
||||||
@nodes.post.classList.toggle 'catalog-post', isCatalogOP
|
@nodes.post.classList.toggle 'catalog-post', isCatalogOP
|
||||||
@nodes.post.classList.toggle 'op', !isCatalogOP
|
@nodes.post.classList.toggle 'op', !isCatalogOP
|
||||||
|
@nodes.post.style.left = @nodes.post.style.right = null
|
||||||
|
|||||||
@ -737,7 +737,7 @@ Config =
|
|||||||
'Previous Index Mode': 'paged'
|
'Previous Index Mode': 'paged'
|
||||||
'Index Size': 'small'
|
'Index Size': 'small'
|
||||||
'Show Replies': [true, 'Show replies in the index, and also in the catalog if "Catalog hover expand" is checked.']
|
'Show Replies': [true, 'Show replies in the index, and also in the catalog if "Catalog hover expand" is checked.']
|
||||||
'Catalog Hover Expand': [true, 'Expand the comment and show more details when you hover over a thread in the catalog.']
|
'Catalog Hover Expand': [true, 'Clicking in the catalog shows more details in the thread you are hovering over.']
|
||||||
'Pin Watched Threads': [false, 'Move watched threads to the start of the index.']
|
'Pin Watched Threads': [false, 'Move watched threads to the start of the index.']
|
||||||
'Anchor Hidden Threads': [true, 'Move hidden threads to the end of the index.']
|
'Anchor Hidden Threads': [true, 'Move hidden threads to the end of the index.']
|
||||||
'Refreshed Navigation': [false, 'Refresh index when navigating through pages.']
|
'Refreshed Navigation': [false, 'Refresh index when navigating through pages.']
|
||||||
|
|||||||
@ -760,6 +760,11 @@ div[data-checked="false"] > .suboption-list {
|
|||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
padding-top: 20px;
|
padding-top: 20px;
|
||||||
}
|
}
|
||||||
|
/* overrides inline CSS from Index.cb.hoverAdjust */
|
||||||
|
:root:not(.catalog-hover-expand) .catalog-post {
|
||||||
|
left: 0 !important;
|
||||||
|
right: 0 !important;
|
||||||
|
}
|
||||||
/* overrides 4chan CSS on div.post */
|
/* overrides 4chan CSS on div.post */
|
||||||
.catalog-post.catalog-post {
|
.catalog-post.catalog-post {
|
||||||
margin: -21px -1px -1px;
|
margin: -21px -1px -1px;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user