2019-12-18 21:15:26 +00:00
|
|
|
/**
|
|
|
|
* This setups the Minerva skin.
|
|
|
|
* It should run without errors even if MobileFrontend is not installed.
|
2024-07-27 05:52:33 +00:00
|
|
|
*
|
2024-06-26 13:23:40 +00:00
|
|
|
* @ignore
|
2019-12-18 21:15:26 +00:00
|
|
|
*/
|
2024-03-24 20:53:43 +00:00
|
|
|
const ms = require( 'mobile.startup' );
|
|
|
|
const reportIfNightModeWasDisabledOnPage = require( './reportIfNightModeWasDisabledOnPage.js' );
|
|
|
|
const addPortletLink = require( './addPortletLink.js' );
|
|
|
|
const teleportTarget = require( 'mediawiki.page.ready' ).teleportTarget;
|
2019-12-18 21:15:26 +00:00
|
|
|
|
|
|
|
function init() {
|
2024-03-24 20:53:43 +00:00
|
|
|
const permissions = mw.config.get( 'wgMinervaPermissions' ) || {};
|
|
|
|
// eslint-disable-next-line no-jquery/no-global-selector
|
|
|
|
const $watch = $( '#page-actions-watch' );
|
2019-12-18 21:15:26 +00:00
|
|
|
|
2023-08-24 08:39:33 +00:00
|
|
|
if ( permissions.watch ) {
|
2020-09-14 20:46:26 +00:00
|
|
|
require( './watchstar.js' ).init( $watch );
|
2019-12-18 21:15:26 +00:00
|
|
|
}
|
|
|
|
|
2021-09-27 17:02:06 +00:00
|
|
|
addPortletLink.init();
|
|
|
|
mw.hook( 'util.addPortletLink' ).add(
|
|
|
|
addPortletLink.hookHandler
|
|
|
|
);
|
|
|
|
|
2019-12-18 21:15:26 +00:00
|
|
|
// Setup Minerva with MobileFrontend
|
|
|
|
if ( ms && !ms.stub ) {
|
|
|
|
require( './initMobile.js' )();
|
|
|
|
} else {
|
|
|
|
// MOBILEFRONTEND IS NOT INSTALLED.
|
|
|
|
// setup search for desktop Minerva at mobile resolution without MobileFrontend.
|
|
|
|
require( './searchSuggestReveal.js' )();
|
|
|
|
}
|
2021-09-23 19:47:46 +00:00
|
|
|
|
2020-10-05 18:27:53 +00:00
|
|
|
// This hot fix should be reviewed and possibly removed circa January 2021.
|
|
|
|
// It's assumed that Apple will prioritize fixing this bug in one of its next releases.
|
|
|
|
// See T264376.
|
2020-11-04 22:38:03 +00:00
|
|
|
if ( navigator.userAgent.match( /OS 14_[0-9]/ ) ) {
|
2020-10-05 18:27:53 +00:00
|
|
|
document.body.classList.add( 'hotfix-T264376' );
|
|
|
|
}
|
2023-09-28 09:28:09 +00:00
|
|
|
|
|
|
|
// Apply content styles to teleported elements
|
|
|
|
teleportTarget.classList.add( 'content' );
|
2024-02-08 22:52:46 +00:00
|
|
|
reportIfNightModeWasDisabledOnPage(
|
|
|
|
document.documentElement, mw.user.options, mw.user.isNamed()
|
|
|
|
);
|
2019-12-18 21:15:26 +00:00
|
|
|
}
|
|
|
|
|
tests: Adopt private require() for skins.minerva.scripts (take 2)
Resubmission of Ib68f45d93a (548e94da98), which caused an error due
to `require('../../`)` not working outside the module base directory.
This is fixed with regression test in T373065.
Further confirmed in this repo by viewing
`/wiki/Special:CreateAccount?campaign=loginCTA&useskin=minerva`
with this patch applied. Without the T373065 fix, the console warns:
> Error: Cannot require undefined file …/ToggleList.js
-------
Support for private require() in tests is available since MW 1.41:
https://mediawiki.org/wiki/RL/PKG#Private_export_and_import
https://mediawiki.org/wiki/RL/PKG#Virtual_files_in_traditional_modules
This fixes a confusing assertion in page-issues/index.test.js,
where for "insertBannersOrNotice()" it was asserting that the HTML
contain "⧼skin-minerva-issue-learn-more⧽", where the ⧼ character
indicates the message is not found (i.e. an error).
The test had to be written this way in order to pass, because
the skins.minerva.scripts module was not actually loaded, and thus
its templates and messages are not present either. This lack was
filled in by index.js for mw.templates, but not mw.messages.
By adopting private require(), these workarounds can all be removed.
== Motivation ==
In change I3a4024ccf90e505581, I'm working on improving the testrunner
config to enforce uselang=qqx on all tests. This is passing except
for GrowthExperiments and Minerva, both of which have the above
workarounds in place that caused a message to be undefined, and then
kept in the assertion expectation. When using uselang=qqx, values are
returned as (key) instead of ⧼key⧽, which exposes these message
existence errors.
By removing this workaround, the test will simply import the module
in the test as normal, thus the messages will exist, and thus it
will expect (key), and thus it will continue to pass even after
enforcing uselang=qqx.
Bug: T373482
Depends-On: I777f2c12e845a738edeac00e19818d4c939a1ef1
Change-Id: I6348e5ae00776c2c01d91fa90a431b6ffe3da25d
2024-08-23 04:25:52 +00:00
|
|
|
if ( !window.QUnit ) {
|
|
|
|
init();
|
|
|
|
}
|
2019-12-18 21:15:26 +00:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
// Version number allows breaking changes to be detected by other extensions
|
|
|
|
VERSION: 1
|
|
|
|
};
|