mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-12 09:21:11 +00:00
7b8bad23f2
Add onSkinPageReadyConfig hook that overrides module after page loaded The new module is currently empty pending further work in the feature branch. Depends-On: I0dc38e74052027f26a70d58b5f520e5830e0d55d Bug: T257706 Change-Id: Ib6c8f890fb3d6e751f5f01a6576614b9cc9b440c
61 lines
2 KiB
JavaScript
61 lines
2 KiB
JavaScript
/** @interface VectorResourceLoaderVirtualConfig */
|
|
/** @interface MediaWikiPageReadyModule */
|
|
|
|
var collapsibleTabs = require( '../skins.vector.legacy.js/collapsibleTabs.js' ),
|
|
vector = require( '../skins.vector.legacy.js/vector.js' ),
|
|
/** @type {VectorResourceLoaderVirtualConfig} */
|
|
config = require( /** @type {string} */ ( './config.json' ) ),
|
|
/** @type {MediaWikiPageReadyModule} */
|
|
pageReady = require( /** @type {string} */( 'mediawiki.page.ready' ) ),
|
|
sidebar = require( './sidebar.js' );
|
|
|
|
/**
|
|
* Wait for first paint before calling this function. That's its whole purpose.
|
|
*
|
|
* Some CSS animations and transitions are "disabled" by default as a workaround to this old Chrome
|
|
* bug, https://bugs.chromium.org/p/chromium/issues/detail?id=332189, which otherwise causes them to
|
|
* render in their terminal state on page load. By adding the `vector-animations-ready` class to the
|
|
* `html` root element **after** first paint, the animation selectors suddenly match causing the
|
|
* animations to become "enabled" when they will work properly. A similar pattern is used in Minerva
|
|
* (see T234570#5779890, T246419).
|
|
*
|
|
* Example usage in Less:
|
|
*
|
|
* ```less
|
|
* .foo {
|
|
* color: #f00;
|
|
* .transform( translateX( -100% ) );
|
|
* }
|
|
*
|
|
* // This transition will be disabled initially for JavaScript users. It will never be enabled for
|
|
* // no-JS users.
|
|
* .vector-animations-ready .foo {
|
|
* .transition( transform 100ms ease-out; );
|
|
* }
|
|
* ```
|
|
*
|
|
* @param {Document} document
|
|
* @return {void}
|
|
*/
|
|
function enableCssAnimations( document ) {
|
|
document.documentElement.classList.add( 'vector-animations-ready' );
|
|
}
|
|
|
|
/**
|
|
* @param {Window} window
|
|
* @return {void}
|
|
*/
|
|
function main( window ) {
|
|
enableCssAnimations( window.document );
|
|
collapsibleTabs.init();
|
|
sidebar.init( window );
|
|
$( vector.init );
|
|
pageReady.loadSearchModule(
|
|
// Decide between new Vue implementation or old.
|
|
config.wgVectorUseCoreSearch ?
|
|
'mediawiki.searchSuggest' : 'skins.vector.search'
|
|
);
|
|
}
|
|
|
|
main( window );
|