mediawiki-skins-Insurgency/resources/mobile-uls.js
jdlrobson 3bed284b37 Refactor: Simplify responsive Monobook's optional dependencies
Having module definitions living inside SkinMonobook makes them
less discoverable. It also shouldn't be necessary - even if there
are soft dependencies on other modules.

A new file resources/optional-enhancements.js is added which will
load the two optional dependencies based on whether they have been
installed on the client.

Bug: T203023
Change-Id: If9a88db52deb0cc91d58cbb40693d4cd448eabbc
2020-09-04 15:53:28 +00:00

23 lines
622 B
JavaScript

/* eslint-disable no-jquery/no-global-selector */
mw.loader.using( [ 'ext.uls.interface' ] ).then( function () {
var mobileMediaQuery = window.matchMedia( 'screen and (max-width: 550px)' ),
$ULSTrigger = $( '#pt-uls' ),
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();
} );