Disable transformation of full board list except on 4chan.

This commit is contained in:
ccd0 2019-12-16 23:47:40 -08:00
parent 6a21dc6644
commit a5099f0b20
3 changed files with 36 additions and 28 deletions

View File

@ -165,25 +165,14 @@ Header =
$.sync 'boardnav', Header.generateBoardList
generateFullBoardList: ->
nodes = []
spacer = -> $.el 'span', className: 'spacer'
items = $.X './/a|.//text()[not(ancestor::a)]', $(g.SITE.selectors.boardList)
i = 0
while node = items.snapshotItem i++
switch node.nodeName
when '#text'
for chr in node.nodeValue
span = $.el 'span', textContent: chr
span.className = 'space' if chr is ' '
nodes.push spacer() if chr is ']'
nodes.push span
nodes.push spacer() if chr is '['
when 'A'
a = node.cloneNode true
a.className = 'current' if a.hostname is location.hostname and a.pathname.split('/')[1] is g.BOARD.ID
nodes.push a
if g.SITE.transformBoardList
nodes = g.SITE.transformBoardList()
else
nodes = [$(g.SITE.selectors.boardList).cloneNode(true).childNodes...]
fullBoardList = $ '.boardList', Header.boardList
$.add fullBoardList, nodes
for a in $$ 'a', fullBoardList
a.className = 'current' if a.hostname is location.hostname and a.pathname.split('/')[1] is g.BOARD.ID
CatalogLinks.setLinks fullBoardList
generateBoardList: (boardnav) ->

View File

@ -379,52 +379,52 @@ audio.controls-added {
font-weight: bold;
}
@media (min-width: 1300px) {
:root.fixed:not(.centered-links) #header-bar {
:root.sw-yotsuba.fixed:not(.centered-links) #header-bar {
white-space: nowrap;
display: -webkit-flex;
display: flex;
-webkit-align-items: center;
align-items: center;
}
:root.fixed:not(.centered-links) #board-list {
:root.sw-yotsuba.fixed:not(.centered-links) #board-list {
-webkit-flex: auto;
flex: auto;
}
:root.fixed:not(.centered-links) #full-board-list {
:root.sw-yotsuba.fixed:not(.centered-links) #full-board-list {
display: -webkit-flex;
display: flex;
}
:root.fixed:not(.centered-links) .hide-board-list-container {
:root.sw-yotsuba.fixed:not(.centered-links) .hide-board-list-container {
-webkit-flex: none;
flex: none;
margin-right: 5px;
}
:root.fixed:not(.centered-links) #full-board-list > .boardList {
:root.sw-yotsuba.fixed:not(.centered-links) #full-board-list > .boardList {
-webkit-flex: auto;
flex: auto;
display: -webkit-flex;
display: flex;
width: 0px; /* XXX Fixes Edge not shrinking the board list below default size when needed */
}
:root.fixed:not(.centered-links) #full-board-list > .boardList > a,
:root.fixed:not(.centered-links) #full-board-list > .boardList > span:not(.space):not(.spacer) {
:root.sw-yotsuba.fixed:not(.centered-links) #full-board-list > .boardList > a,
:root.sw-yotsuba.fixed:not(.centered-links) #full-board-list > .boardList > span:not(.space):not(.spacer) {
-webkit-flex: none;
flex: none;
padding: .17em;
margin: -.17em -.32em;
}
:root.fixed:not(.centered-links) #full-board-list > .boardList > span {
:root.sw-yotsuba.fixed:not(.centered-links) #full-board-list > .boardList > span {
pointer-events: none;
}
:root.fixed:not(.centered-links) #full-board-list > .boardList > span.space {
:root.sw-yotsuba.fixed:not(.centered-links) #full-board-list > .boardList > span.space {
-webkit-flex: 0 .63 .63em;
flex: 0 .63 .63em;
}
:root.fixed:not(.centered-links) #full-board-list > .boardList > span.spacer {
:root.sw-yotsuba.fixed:not(.centered-links) #full-board-list > .boardList > span.spacer {
-webkit-flex: 0 .38 .38em;
flex: 0 .38 .38em;
}
:root.fixed:not(.centered-links) #shortcuts {
:root.sw-yotsuba.fixed:not(.centered-links) #shortcuts {
float: initial;
-webkit-flex: none;
flex: none;

View File

@ -239,3 +239,22 @@ SW.yotsuba =
testNativeExtension: ->
$.global ->
@enabled = 'true' if window.Parser.postMenuIcon
transformBoardList: ->
nodes = []
spacer = -> $.el 'span', className: 'spacer'
items = $.X './/a|.//text()[not(ancestor::a)]', $(SW.yotsuba.selectors.boardList)
i = 0
while node = items.snapshotItem i++
switch node.nodeName
when '#text'
for chr in node.nodeValue
span = $.el 'span', textContent: chr
span.className = 'space' if chr is ' '
nodes.push spacer() if chr is ']'
nodes.push span
nodes.push spacer() if chr is '['
when 'A'
a = node.cloneNode true
nodes.push a
return nodes