mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-14 19:26:42 +00:00
Update pinnableHeader class when moving pinnableElement.
Adds functionality to update the pinnable header class (pinned or unpinned) after is has been moved via movePinnableElement(). Bug: T348039 Change-Id: I23552bdbb3390222c2c8efbd5f9122a4d5021a00
This commit is contained in:
parent
1eb75ab7b1
commit
f59ceb4390
|
@ -193,6 +193,29 @@ function isPinned( header ) {
|
|||
return features.isEnabled( featureName );
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures the header classes are in sync with the pinnable headers state
|
||||
* in the case that it's moved via movePinnableElement().
|
||||
* @param {HTMLElement} pinnableElement
|
||||
*/
|
||||
function updatePinnableHeaderClass( pinnableElement ) {
|
||||
const header = pinnableElement.querySelector( '.vector-pinnable-header' );
|
||||
|
||||
// Because Typescript
|
||||
if ( !header || !( header instanceof HTMLElement ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Toggle header classes
|
||||
if ( isPinned( header ) ) {
|
||||
header.classList.add( PINNED_HEADER_CLASS );
|
||||
header.classList.remove( UNPINNED_HEADER_CLASS );
|
||||
} else {
|
||||
header.classList.remove( PINNED_HEADER_CLASS );
|
||||
header.classList.add( UNPINNED_HEADER_CLASS );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} pinnableElementId
|
||||
* @param {string} newContainerId
|
||||
|
@ -209,6 +232,7 @@ function movePinnableElement( pinnableElementId, newContainerId ) {
|
|||
// Avoid moving element if unnecessary
|
||||
if ( currContainer.id !== newContainerId ) {
|
||||
newContainer.insertAdjacentElement( 'beforeend', pinnableElem );
|
||||
updatePinnableHeaderClass( pinnableElem );
|
||||
}
|
||||
|
||||
popupNotification.hideAll();
|
||||
|
|
Loading…
Reference in a new issue