mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-09-24 18:59:24 +00:00
Add new utility function for detecting pinned elements
* Introduces a new utility function, `hasPinnedElements()`, that allows us to check whether there are any pinned elements in the HTML document based on their CSS class names. * This function will be useful for detecting pinned elements and can be used within WikimediaEvents. Bug: T346106 Change-Id: I4283cd234ba71acce1e5cbadabf8aeb17cd8d86e
This commit is contained in:
parent
507de0f4e2
commit
a1c2d5ca35
|
@ -224,7 +224,22 @@ function initPinnableElement() {
|
|||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if at least one of the elements in the HTML document is pinned based on CSS class names.
|
||||
*
|
||||
* @function
|
||||
* @return {boolean} True if at least one pinned element is found, otherwise false.
|
||||
*/
|
||||
function hasPinnedElements() {
|
||||
const suffixesToCheck = [ 'pinned-clientpref-1', 'pinned-enabled' ];
|
||||
const htmlElement = document.documentElement;
|
||||
return Array.from( htmlElement.classList ).some( ( className ) => {
|
||||
return suffixesToCheck.some( ( suffix ) => className.endsWith( suffix ) );
|
||||
} );
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
hasPinnedElements,
|
||||
initPinnableElement,
|
||||
movePinnableElement,
|
||||
setFocusAfterToggle,
|
||||
|
|
|
@ -142,3 +142,10 @@ if ( document.readyState === 'interactive' || document.readyState === 'complete'
|
|||
main( window );
|
||||
} );
|
||||
}
|
||||
|
||||
// Provider of skins.vector.js module:
|
||||
/**
|
||||
* skins.vector.js
|
||||
* @stable for use inside WikimediaEvents ONLY.
|
||||
*/
|
||||
module.exports = { pinnableElement };
|
||||
|
|
Loading…
Reference in a new issue