mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-24 07:43:47 +00:00
Replace body:not( .vector-toc-collapsed ) with .vector-toc-not-collapsed class
Follow up to Ibf837775d972deb29e9619cc6c12c919aae5155a Change-Id: Ib50f6e4a61a09f54763a740bd12cdae3ee63abef
This commit is contained in:
parent
b6a6296636
commit
1c8af16dfb
|
@ -120,9 +120,8 @@ const updateTocLocation = () => {
|
||||||
const isTocCollapsed = document.body.classList.contains( TOC_COLLAPSED_CLASS );
|
const isTocCollapsed = document.body.classList.contains( TOC_COLLAPSED_CLASS );
|
||||||
const isStickyHeaderVisible = document.body.classList.contains( STICKY_HEADER_VISIBLE_CLASS );
|
const isStickyHeaderVisible = document.body.classList.contains( STICKY_HEADER_VISIBLE_CLASS );
|
||||||
const isBelowDesktop = belowDesktopMedia.matches;
|
const isBelowDesktop = belowDesktopMedia.matches;
|
||||||
if ( isTocCollapsed ) {
|
if ( isTocCollapsed && isStickyHeaderVisible && !isBelowDesktop ) {
|
||||||
const tocLocation = isStickyHeaderVisible && !isBelowDesktop ? 'stickyheader' : 'sidebar';
|
stickyHeader.moveToc( 'stickyheader' );
|
||||||
stickyHeader.moveToc( tocLocation );
|
|
||||||
} else {
|
} else {
|
||||||
stickyHeader.moveToc( 'sidebar' );
|
stickyHeader.moveToc( 'sidebar' );
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ const PARENT_SECTION_CLASS = 'sidebar-toc-level-1';
|
||||||
const LINK_CLASS = 'sidebar-toc-link';
|
const LINK_CLASS = 'sidebar-toc-link';
|
||||||
const TOGGLE_CLASS = 'sidebar-toc-toggle';
|
const TOGGLE_CLASS = 'sidebar-toc-toggle';
|
||||||
const TOC_COLLAPSED_CLASS = 'vector-toc-collapsed';
|
const TOC_COLLAPSED_CLASS = 'vector-toc-collapsed';
|
||||||
|
const TOC_NOT_COLLAPSED_CLASS = 'vector-toc-not-collapsed';
|
||||||
const TOC_ID = 'mw-panel-toc';
|
const TOC_ID = 'mw-panel-toc';
|
||||||
/**
|
/**
|
||||||
* TableOfContents Mustache templates
|
* TableOfContents Mustache templates
|
||||||
|
@ -332,10 +333,15 @@ module.exports = function tableOfContents( props ) {
|
||||||
* Bind event listener for clicking on show/hide Table of Contents links.
|
* Bind event listener for clicking on show/hide Table of Contents links.
|
||||||
*/
|
*/
|
||||||
function bindCollapseToggleListeners() {
|
function bindCollapseToggleListeners() {
|
||||||
|
// Initialize toc collapsed status
|
||||||
|
document.body.classList.add( TOC_NOT_COLLAPSED_CLASS );
|
||||||
|
|
||||||
const showHideTocElement = document.querySelectorAll( '#sidebar-toc-label button' );
|
const showHideTocElement = document.querySelectorAll( '#sidebar-toc-label button' );
|
||||||
showHideTocElement.forEach( function ( btn ) {
|
showHideTocElement.forEach( function ( btn ) {
|
||||||
btn.addEventListener( 'click', () => {
|
btn.addEventListener( 'click', () => {
|
||||||
document.body.classList.toggle( TOC_COLLAPSED_CLASS );
|
document.body.classList.toggle( TOC_COLLAPSED_CLASS );
|
||||||
|
document.body.classList.toggle( TOC_NOT_COLLAPSED_CLASS );
|
||||||
|
|
||||||
props.onToggleCollapse();
|
props.onToggleCollapse();
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -79,18 +79,16 @@
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hide TOC in sticky header by default
|
||||||
&-toc-container {
|
&-toc-container {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vector-toc-collapsed &-toc-container {
|
||||||
|
display: block;
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-left: -@icon-padding-md;
|
margin-left: -@icon-padding-md;
|
||||||
|
|
||||||
.vector-menu-heading {
|
|
||||||
display: none;
|
|
||||||
|
|
||||||
.vector-toc-collapsed & {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar-toc {
|
.sidebar-toc {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
// Needed to align TOC with bottom of title
|
// Needed to align TOC with bottom of title
|
||||||
// 1.5em from .mw-table-of-contents-container + 1.5em from .sidebar-toc = 3em
|
// 1.5em from .mw-table-of-contents-container + 1.5em from .sidebar-toc = 3em
|
||||||
@media ( min-width: @min-width-desktop ) {
|
@media ( min-width: @min-width-desktop ) {
|
||||||
body:not(.vector-toc-collapsed) @{selector-main-menu-closed} ~ & {
|
.vector-toc-not-collapsed @{selector-main-menu-closed} ~ & {
|
||||||
margin-top: 1.5em;
|
margin-top: 1.5em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,9 +105,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// T302076: Add fade scrollable indicator when TOC is in sidebar
|
// T302076: Add fade scrollable indicator when TOC is in sidebar
|
||||||
// Avoid showing indicator when the TOC is collapsed in the page title, sticky header, or floating
|
// Avoid showing indicator when the TOC is floating, or collapsed in the page title/sticky header
|
||||||
@media ( min-width: @min-width-desktop ) {
|
@media ( min-width: @min-width-desktop ) {
|
||||||
@{sidebar-toc-selector}:after {
|
.vector-toc-not-collapsed .sidebar-toc:after {
|
||||||
content: '';
|
content: '';
|
||||||
display: block;
|
display: block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -119,10 +119,6 @@
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: -@sidebar-toc-right-padding; // T311436 Hacky way to prevent the fade from covering the scrollbar
|
background-position: -@sidebar-toc-right-padding; // T311436 Hacky way to prevent the fade from covering the scrollbar
|
||||||
pointer-events: none; // Make the link below the fade clickable
|
pointer-events: none; // Make the link below the fade clickable
|
||||||
|
|
||||||
.vector-toc-collapsed & {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
body:not( .vector-toc-collapsed ) {
|
.vector-toc-not-collapsed {
|
||||||
.vector-toc-collapse-button {
|
.vector-toc-collapse-button {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue