Mobile - reorganise and clean up p-personal js dropdown

* Reorder ULS and Echo links
* Rename conditional module load hook to be more generic, and add
  ULS module
* Remove .active bolding from dropdown

Change-Id: I7e746e7c5af8ffd7c4ca06742ab1fe6bc94ba531
This commit is contained in:
Isarra 2018-05-20 10:29:50 +00:00
parent ef1f98e7bd
commit ca53e721ab
5 changed files with 42 additions and 8 deletions

View file

@ -57,6 +57,10 @@ class SkinMonoBook extends SkinTemplate {
if ( ExtensionRegistry::getInstance()->isLoaded( 'Echo' ) && $out->getUser()->isLoggedIn() ) { if ( ExtensionRegistry::getInstance()->isLoaded( 'Echo' ) && $out->getUser()->isLoggedIn() ) {
$out->addModules( [ 'skins.monobook.mobile.echohack' ] ); $out->addModules( [ 'skins.monobook.mobile.echohack' ] );
} }
if ( ExtensionRegistry::getInstance()->isLoaded( 'UniversalLanguageSelector' ) ) {
$out->addModules( [ 'skins.monobook.mobile.uls' ] );
}
// TODO: Migrate all of these (get RL support for conditional IE) // TODO: Migrate all of these (get RL support for conditional IE)
// Force desktop styles in IE 8-; no support for @media widths // Force desktop styles in IE 8-; no support for @media widths
$out->addStyle( $this->stylename . '/resources/screen-desktop.css', 'screen', 'lt IE 9' ); $out->addStyle( $this->stylename . '/resources/screen-desktop.css', 'screen', 'lt IE 9' );
@ -67,11 +71,11 @@ class SkinMonoBook extends SkinTemplate {
/** /**
* Handler for ResourceLoaderRegisterModules hook * Handler for ResourceLoaderRegisterModules hook
* Check if extensions are loaded
* *
* @param ResourceLoader $resourceLoader * @param ResourceLoader $resourceLoader
*/ */
static function registerEchoHack( ResourceLoader $resourceLoader ) { static function registerMobileExtensionStyles( ResourceLoader $resourceLoader ) {
// Check if echo is loaded, and if so duplicate echo load check for hacks
if ( ExtensionRegistry::getInstance()->isLoaded( 'Echo' ) ) { if ( ExtensionRegistry::getInstance()->isLoaded( 'Echo' ) ) {
$resourceLoader->register( 'skins.monobook.mobile.echohack', [ $resourceLoader->register( 'skins.monobook.mobile.echohack', [
'localBasePath' => __DIR__ . '/..', 'localBasePath' => __DIR__ . '/..',
@ -86,5 +90,16 @@ class SkinMonoBook extends SkinTemplate {
'messages' => [ 'monobook-notifications-link', 'monobook-notifications-link-none' ] 'messages' => [ 'monobook-notifications-link', 'monobook-notifications-link-none' ]
] ); ] );
} }
if ( ExtensionRegistry::getInstance()->isLoaded( 'UniversalLanguageSelector' ) ) {
$resourceLoader->register( 'skins.monobook.mobile.uls', [
'localBasePath' => __DIR__ . '/..',
'remoteSkinPath' => 'MonoBook/resources',
'targets' => [ 'desktop', 'mobile' ],
'scripts' => [ 'resources/mobile-uls.js' ],
'dependencies' => [ 'ext.uls.interface' ],
] );
}
} }
} }

View file

@ -39,8 +39,9 @@
'pt-notifications', 'pt-notifications',
$( '#pt-notifications-notice' ).attr( 'tooltip' ), $( '#pt-notifications-notice' ).attr( 'tooltip' ),
null, null,
'#pt-userpage' '#pt-preferences'
); );
$( '#p-personal-toggle' ).append( $( '<ul>' ).attr( 'id', 'echo-hack-badges' ) ); $( '#p-personal-toggle' ).append( $( '<ul>' ).attr( 'id', 'echo-hack-badges' ) );
echoHacked = true; echoHacked = true;

22
resources/mobile-uls.js Normal file
View file

@ -0,0 +1,22 @@
$( function () {
var mobileCutoffWidth = 850,
ULSTrigger = $( '#pt-uls' ),
ULSMoved = false;
function moveULS() {
if ( ULSTrigger.length ) {
if ( !ULSMoved && $( window ).width() <= mobileCutoffWidth ) {
ULSTrigger.insertBefore( $( '#pt-preferences' ) );
ULSMoved = true;
} else if ( ULSMoved && $( window ).width() > mobileCutoffWidth ) {
ULSTrigger.prepend( $( '#p-preferences' ) );
ULSMoved = false;
}
}
}
$( window ).resize( moveULS );
moveULS();
} );

View file

@ -209,10 +209,6 @@ table.rimage {
/* /*
** the personal toolbar ** the personal toolbar
*/ */
#p-personal li.active {
font-weight: bold;
}
/* "Not logged in" text in gray */ /* "Not logged in" text in gray */
li#pt-anonuserpage { li#pt-anonuserpage {
color: @text-grey; color: @text-grey;

View file

@ -20,7 +20,7 @@
"monobook": "Apex" "monobook": "Apex"
}, },
"Hooks": { "Hooks": {
"ResourceLoaderRegisterModules": "SkinMonoBook::registerEchoHack" "ResourceLoaderRegisterModules": "SkinMonoBook::registerMobileExtensionStyles"
}, },
"MessagesDirs": { "MessagesDirs": {
"MonoBook": [ "MonoBook": [