mediawiki-skins-Insurgency/resources/mobile-uls.js
Ed Sanders c1d97fe834 ESLint: Manually enforce prefer-const
Change-Id: Id35fb62915e8067deaa1eb412ab3cb9d9353b9e8
2024-11-15 19:58:16 +00:00

25 lines
673 B
JavaScript

/* eslint-disable no-jquery/no-global-selector */
module.exports = function () {
mw.loader.using( [ 'ext.uls.interface' ] ).then( () => {
const mobileMediaQuery = window.matchMedia( 'screen and (max-width: 550px)' ),
$ULSTrigger = $( '#pt-uls' );
let ULSMoved = false;
function moveULS() {
if ( $ULSTrigger.length ) {
if ( !ULSMoved && mobileMediaQuery.matches ) {
$ULSTrigger.insertBefore( $( '#pt-preferences' ) );
ULSMoved = true;
} else if ( ULSMoved && !mobileMediaQuery.matches ) {
$ULSTrigger.prepend( $( '#p-preferences' ) );
ULSMoved = false;
}
}
}
$( window ).on( 'resize', moveULS );
moveULS();
} );
};