MediaWiki:Common.js: Difference between revisions
No edit summary Tag: Reverted |
Tag: Undo |
||
| Line 892: | Line 892: | ||
new MutationObserver( function () { if ( document.body.style.paddingTop && document.body.style.paddingTop !== '0px' ) document.body.style.paddingTop = ''; } ).observe( document.body, { attributes:true, attributeFilter:['style'] } ); | new MutationObserver( function () { if ( document.body.style.paddingTop && document.body.style.paddingTop !== '0px' ) document.body.style.paddingTop = ''; } ).observe( document.body, { attributes:true, attributeFilter:['style'] } ); | ||
} | } | ||
function injectMenuLinks() { | |||
if ( document.getElementById( 'gr-mob-menu-items' ) ) return; | if ( document.getElementById( 'gr-mob-menu-items' ) ) return; | ||
var navDrawer = document.querySelector( '.navigation-drawer' ); | var navDrawer = document.querySelector( '.navigation-drawer' ); | ||
| Line 899: | Line 899: | ||
var itemStyle = 'display:flex;align-items:center;gap:14px;padding:15px 20px;font-size:16px;color:#2c1810;text-decoration:none;font-family:system-ui,sans-serif;border-bottom:1px solid #f0ebe6;background:#fff;'; | var itemStyle = 'display:flex;align-items:center;gap:14px;padding:15px 20px;font-size:16px;color:#2c1810;text-decoration:none;font-family:system-ui,sans-serif;border-bottom:1px solid #f0ebe6;background:#fff;'; | ||
function makeItem( href, label ) { var a = document.createElement( 'a' ); a.href = href; a.style.cssText = itemStyle; a.innerHTML = '<span>' + label + '</span>'; return a; } | function makeItem( href, label ) { var a = document.createElement( 'a' ); a.href = href; a.style.cssText = itemStyle; a.innerHTML = '<span>' + label + '</span>'; return a; } | ||
wrap.appendChild( makeItem( '/Main_Page', 'Home' ) ); | wrap.appendChild( makeItem( '/Main_Page', 'Home' ) ); | ||
wrap.appendChild( makeItem( '/My_wiki:Help', 'Help' ) ); | wrap.appendChild( makeItem( '/My_wiki:Help', 'Help' ) ); | ||
| Line 905: | Line 904: | ||
var userName = window.mw ? mw.config.get( 'wgUserName' ) : null; | var userName = window.mw ? mw.config.get( 'wgUserName' ) : null; | ||
if ( userName ) { | if ( userName ) { | ||
wrap.appendChild( makeItem( ( window.mw && mw.util && mw.util.getUrl ) ? mw.util.getUrl( 'Special:Profile' ) : '/Special:Profile', 'Profile' ) ); | |||
var la = document.querySelector( 'a[href*="action=logout"]' ); | var la = document.querySelector( 'a[href*="action=logout"]' ); | ||
wrap.appendChild( makeItem( la ? la.href : '/index.php?title=Special:UserLogout', 'Log out' ) ); | |||
} | } | ||
else wrap.appendChild( makeItem( '/index.php?title=Special:UserLogin', 'Log in' ) ); | else wrap.appendChild( makeItem( '/index.php?title=Special:UserLogin', 'Log in' ) ); | ||