Module Configuration
Module Name:skins.citizen.scripts
Dependencies:
mediawiki.storagemediawiki.page.readymediawiki.util
resources/skins.citizen.scripts/skin.js
Package Files (from skin.json):
- skin.js
- config.json (dynamic)
- contentEnhancements.js
- deferUntilFrame.js
- dropdown.js
- echo.js
- lastModified.js
- overflowElements/*
- performance.js
- resizeObserver.js
- scrollObserver.js
- sectionObserver.js
- search.js
- sections.js
- serviceWorker.js
- setupObservers.js
- share.js
- speculationRules.js
- stickyHeader.js
- tableOfContents.js
- tableOfContentsSections.js
- tableOfContentsConfig.json (dynamic)
- templates/*.mustache
Main Entry Point
Fromskin.js:
Table of Contents
FromtableOfContents.js:
TableOfContents Class
Manages the sidebar table of contents.Constructor
Properties
activeTopSection(HTMLElement | undefined) - Active top-level sectionactiveSubSection(HTMLElement | undefined) - Active subsectionexpandedSections(Array<HTMLElement>) - Expanded sections
Methods
getActiveSectionIds() Gets IDs of active sections. Returns:id(string) - Section element ID
id(string) - Section element ID
id(string) - Section element ID
selectedIds(Array<string>) - Optional specific IDs to collapse
id(string) - Section element ID
id(string) - Section element ID
sections(Array<Section>) - Section data array
CSS Classes
Static properties:TableOfContents.ACTIVE_SECTION_CLASS='citizen-toc-list-item--active'TableOfContents.ACTIVE_TOP_SECTION_CLASS='citizen-toc-level-1--active'TableOfContents.EXPANDED_SECTION_CLASS='citizen-toc-list-item--expanded'TableOfContents.LINK_CLASS='citizen-toc-link'TableOfContents.TOGGLE_CLASS='citizen-toc-toggle'
Section Type
Sticky Header
FromstickyHeader.js:
StickyHeader Class
Manages sticky header behavior.Constructor
Methods
init() Initializes sticky header components.--height-sticky-header CSS variable.
Parameters:
value(number) - Height in pixels
Constants
Collapsible Sections
Fromsections.js:
createSections()
Factory function for collapsible sections. Returns: Object withinit() method
Usage:
- Toggles section visibility on heading click
- Uses
hidden="until-found"attribute - Excludes edit section links from toggle
- Only active if
citizen-sections-enabledclass on body
.citizen-section-heading- Clickable heading.citizen-section- Collapsible section content
Content Enhancements
FromcontentEnhancements.js:
createContentEnhancements()
Factory for content enhancements. Returns: Object withinit() method
Features:
- External link icons
- Link formatting
- Media enhancements
Observers
FromsetupObservers.js:
setupObservers.init()
Sets up page observers. Observers:- Scroll observer for sticky header
- Section observer for TOC highlighting
- Resize observer for responsive behavior
Dropdown
Fromdropdown.js:
dropdown.init()
Initializes dropdown menus. Features:- Click outside to close
- Keyboard navigation
- Multiple dropdown support
Last Modified
FromlastModified.js:
createLastModified()
Factory for last modified date formatter. Returns: Object withinit() method
Features:
- Formats last modified timestamp
- Uses Intl.DateTimeFormat for localization
- Displays relative time
Share
Fromshare.js:
createShare()
Factory for share functionality. Returns: Object withinit() method
Features:
- Native Web Share API when available
- Fallback to clipboard copy
- Share button integration
Performance Mode
Fromperformance.js:
createPerformanceMode()
Factory for performance mode. Returns: Object withinit() method
Features:
- Reduces animations when enabled
- Manages CSS classes
- Syncs with preference system
Service Worker
FromserviceWorker.js:
createServiceWorker()
Factory for service worker registration. Returns: Object withregister() method
Usage:
Speculation Rules
FromspeculationRules.js:
createSpeculationRules()
Factory for Speculation Rules API. Returns: Object withinit() method
Features:
- Prefetches likely navigation targets
- Uses Speculation Rules API when available
Utility Functions
deferUntilFrame(callback, frameCount)
Defers callback execution until specified frame. Parameters:callback(Function) - Function to executeframeCount(number) - Number of frames to wait (default: 1)
Configuration
Dynamic configuration injected via ResourceLoader: config.json:wgCitizenEnablePreferences(boolean)- Other skin configuration values
CitizenTableOfContentsCollapseAtCount(number) - Headings threshold for collapse
Hooks
The module uses MediaWiki hooks:wikipage.content
Fired when content is added/updated. Usage:Overflow Elements
FromoverflowElements/index.js:
overflowElements.init()
Handles responsive overflow for tables and elements. Features:- Wraps overflowing elements
- Fade indicators
- Scroll behavior
- Inherited classes from config
wgCitizenOverflowInheritedClasses- CSS classes to inheritwgCitizenOverflowNowrapClasses- CSS classes to skip
Echo Integration
Fromecho.js:
createEchoUpgrade()
Factory for Echo (notifications) integration. Returns: Object withinit() method
Features:
- Upgrades Echo badge display
- Syncs notification state
Loading States
The skin manages loading states: Classes:.citizen-loading- Added on page unload start.citizen-animations-ready- Added when animations ready
beforeunload- Adds loading classpagehide- Removes loading class
Related Modules
- Search - Search typeahead
- Command Palette - Command palette interface
- Preferences - User preferences panel