MediaWiki:Citizen.js: Difference between revisions
MediaWiki interface page
More actions
Content deleted Content added
m oop |
DivošiRunner (talk | contribs) Restore theme-aware Discord and Roblox icons in Citizen navigation |
||
| 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. */ |
||
// |
// Community shortcuts using Citizen's current header button markup. |
||
$( function () { |
$( function () { |
||
const |
const drawer = document.querySelector( '.citizen-drawer' ); |
||
if ( !drawer ) { |
|||
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' } |
|||
| ⚫ | |||
].forEach( function ( service ) { |
|||
| ⚫ | |||
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 citizen-header__buttonIcon', |
|||
| ⚫ | |||
} ) |
|||
| ⚫ | |||
| ⚫ | |||
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.title = service.label; |
|||
link.setAttribute( 'aria-label', service.label ); |
|||
const icon = document.createElement( 'span' ); |
|||
icon.className = 'citizen-social__icon citizen-social__icon--' + service.name; |
|||
| ⚫ | |||
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;
} );
} );