Mobile view link: place it under the Follow Us section of the footer
Tag: Manual revert
Mobile view link: centered at the bottom on articles, in the footer row on the main page
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.
   under the footer's Follow Us section. Pages without that
   Articles get it on its own line, centered at the very bottom
   section (the main page's remix footer) get it centered at
   of the footer; the main page's remix footer keeps it in the
   the very bottom of the footer instead. */
   links row, after Contact. */
$( function () {
$( function () {
if ( document.getElementById( 'bpneo-mobile-view-link' ) ) {
if ( document.getElementById( 'bpneo-mobile-view-link' ) ) {
Line 110: Line 110:
encodeURIComponent( mw.config.get( 'wgPageName' ) ) +
encodeURIComponent( mw.config.get( 'wgPageName' ) ) +
'&mobileaction=toggle_view_mobile';
'&mobileaction=toggle_view_mobile';
var social = document.querySelector( '.bp-footer-social' );
var links = document.querySelector( '.bpneo-remix-footer-links' );
if ( social && social.parentNode ) {
if ( links ) {
var box = document.createElement( 'div' );
a.style.marginLeft = '1em';
box.style.marginTop = '1em';
links.appendChild( a );
box.appendChild( a );
social.parentNode.appendChild( box );
return;
return;
}
}
var footer = document.querySelector( 'footer.bp-footer' ) ||
var footer = document.querySelector( 'footer.bp-footer' ) ||
document.querySelector( 'footer.bpneo-remix-footer' ) ||
document.querySelector( 'footer' );
document.querySelector( 'footer' );
if ( !footer ) {
if ( !footer ) {
Line 127: Line 124:
wrap.style.textAlign = 'center';
wrap.style.textAlign = 'center';
wrap.style.width = '100%';
wrap.style.width = '100%';
wrap.style.flex = '0 0 100%';
wrap.style.marginTop = '0.5em';
wrap.style.marginTop = '0.5em';
wrap.appendChild( a );
wrap.appendChild( a );
footer.appendChild( wrap );
footer.appendChild( wrap );
} );
} );

Revision as of 09:25, 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.
   Articles get it on its own line, centered at the very bottom
   of the footer; the main page's remix footer keeps it in the
   links row, after Contact. */
$( 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 links = document.querySelector( '.bpneo-remix-footer-links' );
	if ( links ) {
		a.style.marginLeft = '1em';
		links.appendChild( a );
		return;
	}
	var footer = document.querySelector( 'footer.bp-footer' ) ||
		document.querySelector( 'footer' );
	if ( !footer ) {
		return;
	}
	var wrap = document.createElement( 'div' );
	wrap.style.textAlign = 'center';
	wrap.style.width = '100%';
	wrap.style.marginTop = '0.5em';
	wrap.appendChild( a );
	footer.appendChild( wrap );
} );