Mobile view link: place it centered on its own line at the bottom of the footer
Tag: Reverted
Mobile view link: place it under the Follow Us section of the footer
Tag: Manual revert
Line 96: Line 96:


/* Mobile view switch: BharatpediaNeo does not render the
/* Mobile view switch: BharatpediaNeo does not render the
   MobileFrontend footer toggle, so add a Mobile view link.
   MobileFrontend footer toggle, so add a Mobile view link
   Also covers the main page's remix footer. The link sits on
  under the footer's Follow Us section. Pages without that
   its own line, centered at the very bottom of the footer. */
   section (the main page's remix footer) get it centered at
   the very bottom of the footer instead. */
$( function () {
$( function () {
if ( document.getElementById( 'bpneo-mobile-view-link' ) ) {
if ( document.getElementById( 'bpneo-mobile-view-link' ) ) {
return;
}
var a = document.createElement( 'a' );
a.id = 'bpneo-mobile-view-link';
a.textContent = 'Mobile view';
a.href = '/w/index.php?title=' +
encodeURIComponent( mw.config.get( 'wgPageName' ) ) +
'&mobileaction=toggle_view_mobile';
var social = document.querySelector( '.bp-footer-social' );
if ( social && social.parentNode ) {
var box = document.createElement( 'div' );
box.style.marginTop = '1em';
box.appendChild( a );
social.parentNode.appendChild( box );
return;
return;
}
}
Line 114: Line 129:
wrap.style.flex = '0 0 100%';
wrap.style.flex = '0 0 100%';
wrap.style.marginTop = '0.5em';
wrap.style.marginTop = '0.5em';
var a = document.createElement( 'a' );
a.id = 'bpneo-mobile-view-link';
a.textContent = 'Mobile view';
a.href = '/w/index.php?title=' +
encodeURIComponent( mw.config.get( 'wgPageName' ) ) +
'&mobileaction=toggle_view_mobile';
wrap.appendChild( a );
wrap.appendChild( a );
footer.appendChild( wrap );
footer.appendChild( wrap );
} );
} );

Revision as of 09:21, 1 November 2026

mw.loader.using(['mediawiki.util']).then(function () {
	if (mw.config.get('wgUserGroups').indexOf('autoconfirmed') === -1 &&
		mw.config.get('wgUserGroups').indexOf('confirmed') === -1) {
		return;
	}

	var ITEMS = [
		{ id: 'twinkle-tag', label: 'Tag', icon: 'ri-price-tag-3-line' },
		{ id: 'twinkle-csd', label: 'CSD', icon: 'ri-delete-bin-6-line' },
		{ id: 'twinkle-warn', label: 'Warn', icon: 'ri-alarm-warning-line' },
		{ id: 'twinkle-block', label: 'Block', icon: 'ri-user-unfollow-line' },
		{ id: 'twinkle-protect', label: 'Protect', icon: 'ri-shield-line' },
		{ id: 'twinkle-unlink', label: 'Unlink', icon: 'ri-link-unlink' },
		{ id: 'twinkle-xfd', label: 'XfD', icon: 'ri-chat-delete-line' },
		{ id: 'twinkle-lastdiff', label: 'Last diff', icon: 'ri-git-branch-line' }
	];

	function ready() {
		if (document.getElementById('bpneo-tw-wrap')) {
			return true;
		}
		if (typeof Twinkle !== 'object') {
			return false;
		}
		var bar = document.querySelector('.bpneo-title-actions');
		if (!bar) {
			return false;
		}

		var wrap = document.createElement('div');
		wrap.id = 'bpneo-tw-wrap';
		wrap.className = 'bpneo-action-wrap';
		wrap.style.position = 'relative';

		var btn = document.createElement('button');
		btn.type = 'button';
		btn.className = 'bpneo-title-btn';
		btn.title = 'Twinkle';
		btn.innerHTML = '<i class="ri-sparkling-2-line"></i>';

		var menu = document.createElement('div');
		menu.id = 'bpneo-tw-menu';
		menu.className = 'bpneo-action-menu';
		menu.style.display = 'none';

		var added = 0;
		ITEMS.forEach(function (item) {
			var src = document.getElementById(item.id);
			if (!src) {
				return;
			}
			var a = document.createElement('a');
			a.href = '#';
			a.innerHTML = '<i class="' + item.icon + '"></i> ' + item.label;
			a.addEventListener('click', function (e) {
				e.preventDefault();
				menu.style.display = 'none';
				src.click();
			});
			menu.appendChild(a);
			added++;
		});
		if (!added) {
			return false;
		}

		btn.addEventListener('click', function (e) {
			e.preventDefault();
			e.stopPropagation();
			menu.style.display = menu.style.display === 'none' ? 'block' : 'none';
		});
		document.addEventListener('click', function (e) {
			if (!wrap.contains(e.target)) {
				menu.style.display = 'none';
			}
		});

		wrap.appendChild(btn);
		wrap.appendChild(menu);
		bar.appendChild(wrap);
		return true;
	}

	var n = 0;
	var t = setInterval(function () {
		n++;
		if (ready()) {
			clearInterval(t);
		}
		if (n > 60) {
			clearInterval(t);
		}
	}, 250);
});


/* Mobile view switch: BharatpediaNeo does not render the
   MobileFrontend footer toggle, so add a Mobile view link
   under the footer's Follow Us section. Pages without that
   section (the main page's remix footer) get it centered at
   the very bottom of the footer instead. */
$( function () {
	if ( document.getElementById( 'bpneo-mobile-view-link' ) ) {
		return;
	}
	var a = document.createElement( 'a' );
	a.id = 'bpneo-mobile-view-link';
	a.textContent = 'Mobile view';
	a.href = '/w/index.php?title=' +
		encodeURIComponent( mw.config.get( 'wgPageName' ) ) +
		'&mobileaction=toggle_view_mobile';
	var social = document.querySelector( '.bp-footer-social' );
	if ( social && social.parentNode ) {
		var box = document.createElement( 'div' );
		box.style.marginTop = '1em';
		box.appendChild( a );
		social.parentNode.appendChild( box );
		return;
	}
	var footer = document.querySelector( 'footer.bp-footer' ) ||
		document.querySelector( 'footer.bpneo-remix-footer' ) ||
		document.querySelector( 'footer' );
	if ( !footer ) {
		return;
	}
	var wrap = document.createElement( 'div' );
	wrap.style.textAlign = 'center';
	wrap.style.width = '100%';
	wrap.style.flex = '0 0 100%';
	wrap.style.marginTop = '0.5em';
	wrap.appendChild( a );
	footer.appendChild( wrap );
} );