Jump to content
Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Citizen.js: Difference between revisions

MediaWiki interface page
Content deleted Content added
Fix URL
DivošiRunner (talk | contribs)
Restore theme-aware Discord and Roblox icons in Citizen navigation
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
/* All JavaScript here will be loaded for users of the Citizen skin */
/* All JavaScript here will be loaded for users of the Citizen skin. */


// Discord button in Citizen header
// Community shortcuts using Citizen's current header button markup.
$( function () {
$( function () {
const $drawer = $( '.citizen-drawer' );
const drawer = document.querySelector( '.citizen-drawer' );
if ( !drawer ) {

// Abort if header isn't present or button already exists
if ( !$drawer.length || $( '.citizen-discord' ).length ) {
return;
return;
}
}


let previous = drawer;
const $button = $( '<a>', {
[
class: 'citizen-discord citizen-header__item',
href: 'https://discord.gg/sarkic',
{ name: 'discord', label: 'Join us on Discord!', href: 'https://discord.gg/sarkic' },
{ name: 'roblox', label: 'Sarkic Cults on Roblox', href: 'https://www.roblox.com/groups/3388048' }
⚫
target: '_blank',
].forEach( function ( service ) {
⚫
rel: 'noopener noreferrer',
const existing = document.querySelector( '.citizen-social--' + service.name );
title: 'Join us on Discord!',
if ( existing ) {
'aria-label': 'Join us on Discord!'
previous = existing;
} ).append(
return;
$( '<div>', { class: 'citizen-discord__button citizen-header__button' } ).append(
⚫
}
$( '<span>', { class: 'disc-icon', 'aria-hidden': 'true' } ),
$( '<span>', { class: 'citizen-discord__text', text: 'Discord' } )
⚫
)
⚫
);


const item = document.createElement( 'div' );
$drawer.after( $button );
item.className = 'citizen-social citizen-social--' + service.name + ' citizen-header__item';
const link = document.createElement( 'a' );
link.className = 'citizen-' + service.name + ' citizen-cdx-button--size-large cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet';
link.href = service.href;
⚫
link.target = '_blank';
⚫
link.rel = 'noopener noreferrer';
link.title = service.label;
link.setAttribute( 'aria-label', service.label );
const icon = document.createElement( 'span' );
icon.className = 'citizen-social__icon citizen-social__icon--' + service.name;
icon.setAttribute( 'aria-hidden', 'true' );
link.appendChild( icon );
item.appendChild( link );
previous.insertAdjacentElement( 'afterend', item );
previous = item;
⚫
} );
} );
} );

Latest revision as of 15:40, 5 October 2026

/* All JavaScript here will be loaded for users of the Citizen skin. */

// Community shortcuts using Citizen's current header button markup.
$( function () {
	const drawer = document.querySelector( '.citizen-drawer' );
	if ( !drawer ) {
		return;
	}

	let previous = drawer;
	[
		{ name: 'discord', label: 'Join us on Discord!', href: 'https://discord.gg/sarkic' },
		{ name: 'roblox', label: 'Sarkic Cults on Roblox', href: 'https://www.roblox.com/groups/3388048' }
	].forEach( function ( service ) {
		const existing = document.querySelector( '.citizen-social--' + service.name );
		if ( existing ) {
			previous = existing;
			return;
		}

		const item = document.createElement( 'div' );
		item.className = 'citizen-social citizen-social--' + service.name + ' citizen-header__item';
		const link = document.createElement( 'a' );
		link.className = 'citizen-' + service.name + ' citizen-cdx-button--size-large cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet';
		link.href = service.href;
		link.target = '_blank';
		link.rel = 'noopener noreferrer';
		link.title = service.label;
		link.setAttribute( 'aria-label', service.label );
		const icon = document.createElement( 'span' );
		icon.className = 'citizen-social__icon citizen-social__icon--' + service.name;
		icon.setAttribute( 'aria-hidden', 'true' );
		link.appendChild( icon );
		item.appendChild( link );
		previous.insertAdjacentElement( 'afterend', item );
		previous = item;
	} );
} );