2020-06-09 04:30:24 +00:00
|
|
|
/*
|
2020-08-12 16:37:43 +00:00
|
|
|
* Citizen - Core JS
|
2020-06-09 04:30:24 +00:00
|
|
|
* https://starcitizen.tools
|
|
|
|
*/
|
|
|
|
|
|
|
|
var searchToggle = document.getElementById( 'search-toggle' ),
|
2020-10-16 19:23:15 +00:00
|
|
|
searchInput = document.getElementById( 'searchInput' ),
|
|
|
|
pageReady = require( ( 'mediawiki.page.ready' ) );
|
2020-06-09 04:30:24 +00:00
|
|
|
|
2020-06-17 03:16:45 +00:00
|
|
|
/**
|
|
|
|
* Focus in search box when search toggle checkbox is checked.
|
2020-07-05 21:07:36 +00:00
|
|
|
*
|
2020-06-17 03:16:45 +00:00
|
|
|
* @constructor
|
|
|
|
*/
|
2020-06-09 04:30:24 +00:00
|
|
|
function searchInputFocus() {
|
|
|
|
if ( searchToggle.checked !== false ) {
|
|
|
|
searchInput.focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-17 03:16:45 +00:00
|
|
|
/**
|
|
|
|
* Check search toggle checkbox when search box is in focus.
|
2020-07-05 21:07:36 +00:00
|
|
|
*
|
2020-06-17 03:16:45 +00:00
|
|
|
* @constructor
|
|
|
|
*/
|
2020-06-09 04:30:24 +00:00
|
|
|
function searchToggleCheck() {
|
|
|
|
if ( searchToggle.checked === false ) {
|
|
|
|
searchToggle.checked = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-12 16:37:43 +00:00
|
|
|
function main() {
|
|
|
|
searchToggle.addEventListener( 'click', searchInputFocus );
|
|
|
|
searchInput.addEventListener( 'focus', searchToggleCheck );
|
2020-10-16 19:23:15 +00:00
|
|
|
pageReady.loadSearchModule(
|
|
|
|
// Decide between new Citizen implementation or core
|
|
|
|
mw.config.get( 'wgCitizenEnableSearch' ) ?
|
|
|
|
'skins.citizen.scripts.search' : 'mediawiki.searchSuggest'
|
|
|
|
);
|
2020-08-12 16:37:43 +00:00
|
|
|
}
|
|
|
|
|
2020-08-12 16:39:22 +00:00
|
|
|
main();
|
2021-01-11 17:13:59 +00:00
|
|
|
|
|
|
|
( function () {
|
|
|
|
var theme = window.mw.cookie.get( 'skin-citizen-theme' );
|
|
|
|
var toggleBtn = document.getElementById( 'theme-toggle' );
|
|
|
|
|
|
|
|
// * theme-toggle-light
|
|
|
|
// * theme-toggle-dark
|
|
|
|
toggleBtn.classList.add( 'theme-toggle-' + theme );
|
|
|
|
|
|
|
|
toggleBtn.addEventListener( 'click', function ( clickEvent ) {
|
|
|
|
try {
|
|
|
|
theme = theme === 'dark' ? 'light' : 'dark';
|
|
|
|
|
|
|
|
clickEvent.target.classList.remove( 'theme-toggle-light', 'theme-toggle-dark' );
|
|
|
|
// * theme-toggle-light
|
|
|
|
// * theme-toggle-dark
|
|
|
|
clickEvent.target.classList.add( 'theme-toggle-' + theme );
|
|
|
|
|
|
|
|
try {
|
|
|
|
window.mw.cookie.set( 'skin-citizen-theme', null );
|
|
|
|
window.mw.cookie.set( 'skin-citizen-theme', theme );
|
|
|
|
window.mw.cookie.set( 'skin-citizen-theme-override', '1' );
|
|
|
|
} catch ( e ) {
|
|
|
|
}
|
|
|
|
|
2021-01-11 22:13:01 +00:00
|
|
|
window.switchTheme();
|
2021-01-11 17:13:59 +00:00
|
|
|
} catch ( e ) {
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
}() );
|