mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-12-01 01:06:31 +00:00
a8aecda711
Depends-On: Ic3861870c10f64d7f5414669a9d25b8ffb4c79a4 Change-Id: I6750e9bb6d5409e497b5605e3a4660734f5677ab
35 lines
1 KiB
JavaScript
35 lines
1 KiB
JavaScript
( function () {
|
|
var
|
|
checkboxHack = require( ( 'mediawiki.page.ready' ) ).checkboxHack,
|
|
CHECKBOX_HACK_CONTAINER_SELECTOR = '.toggle-list',
|
|
CHECKBOX_HACK_CHECKBOX_SELECTOR = '.toggle-list__checkbox',
|
|
CHECKBOX_HACK_BUTTON_SELECTOR = '.toggle-list__toggle',
|
|
CHECKBOX_HACK_TARGET_SELECTOR = '.toggle-list__list';
|
|
|
|
/**
|
|
* Automatically dismiss the list when clicking or focusing elsewhere and update the
|
|
* aria-expanded attribute based on list visibility.
|
|
*
|
|
* @param {Window} window
|
|
* @param {HTMLElement} component
|
|
*/
|
|
function bind( window, component ) {
|
|
var
|
|
checkbox = /** @type {HTMLInputElement} */ (
|
|
component.querySelector( CHECKBOX_HACK_CHECKBOX_SELECTOR )
|
|
),
|
|
button = component.querySelector( CHECKBOX_HACK_BUTTON_SELECTOR ),
|
|
target = component.querySelector( CHECKBOX_HACK_TARGET_SELECTOR );
|
|
|
|
if ( !( checkbox && button && target ) ) {
|
|
return;
|
|
}
|
|
checkboxHack.bind( window, checkbox, button, target );
|
|
}
|
|
|
|
module.exports = Object.freeze( {
|
|
selector: CHECKBOX_HACK_CONTAINER_SELECTOR,
|
|
bind: bind
|
|
} );
|
|
}() );
|