mediawiki.page.startup: Merge with mediawiki.page.ready module
The distinction between the two was lost several years years ago when the "position top" queue ceased to be a thing. Since then, the two have been loaded and executed together in the same batch, and are doing similar things. mediawiki.page.ready is publicly used in several places as dependendency, but mediawiki.page.startup is entirely internal to core, which makes it the easier one of the two to dissolve. Keep an alias for two weeks for cache compat to avoid console warnings about unknown modules. Although even some cache still refers to it, this is harmless since the errors are recoverable and the correct module was also loaded by the cached pages already. Bug: T260210 Change-Id: Ic418c23a7400abba22fd07b17f173d3c5f1d1d10
This commit is contained in:
parent
9af266fd44
commit
274c4232b9
7 changed files with 50 additions and 66 deletions
|
|
@ -3292,7 +3292,7 @@ class OutputPage extends ContextSource {
|
|||
|
||||
// Internal variables for MediaWiki core
|
||||
$vars = [
|
||||
// @internal For mediawiki.page.startup
|
||||
// @internal For mediawiki.page.ready
|
||||
'wgBreakFrames' => $this->getFrameOptions() == 'DENY',
|
||||
|
||||
// @internal For jquery.tablesorter
|
||||
|
|
|
|||
|
|
@ -230,12 +230,10 @@ abstract class Skin extends ContextSource {
|
|||
],
|
||||
'core' => [
|
||||
'site',
|
||||
'mediawiki.page.startup',
|
||||
],
|
||||
// modules that enhance the content in some way
|
||||
'content' => [
|
||||
'mediawiki.page.ready',
|
||||
],
|
||||
// modules that enhance the content in some way
|
||||
'content' => [],
|
||||
// modules relating to search functionality
|
||||
'search' => [],
|
||||
// Skins can register their own scripts
|
||||
|
|
|
|||
|
|
@ -54,8 +54,8 @@ class SpecialJavaScriptTest extends SpecialPage {
|
|||
$out = $this->getOutput();
|
||||
$rl = $out->getResourceLoader();
|
||||
|
||||
// Allow framing (disabling wgBreakFrames). Otherwise, mediawiki.page.startup.js
|
||||
// will close this tab when run from CLI using karma-qunit.
|
||||
// Allow framing (disabling wgBreakFrames). Otherwise, mediawiki.page.ready
|
||||
// will close this tab when running from CLI using karma-qunit.
|
||||
$out->allowClickjacking();
|
||||
|
||||
$query = [
|
||||
|
|
|
|||
|
|
@ -1495,7 +1495,8 @@ return [
|
|||
]
|
||||
],
|
||||
'mediawiki.page.startup' => [
|
||||
'scripts' => 'resources/src/mediawiki.page.startup.js',
|
||||
// TODO: Keep for HTML cache compat until 2020-08-21.
|
||||
'dependencies' => [ 'mediawiki.page.ready' ],
|
||||
'targets' => [ 'desktop', 'mobile' ],
|
||||
],
|
||||
'mediawiki.page.watch.ajax' => [
|
||||
|
|
|
|||
|
|
@ -1,6 +1,16 @@
|
|||
var checkboxShift = require( './checkboxShift.js' );
|
||||
var config = require( './config.json' );
|
||||
|
||||
// Break out of framesets
|
||||
if ( mw.config.get( 'wgBreakFrames' ) ) {
|
||||
// Note: In IE < 9 strict comparison to window is non-standard (the standard didn't exist yet)
|
||||
// it works only comparing to window.self or window.window (https://stackoverflow.com/q/4850978/319266)
|
||||
if ( window.top !== window.self ) {
|
||||
// Un-trap us from framesets
|
||||
window.top.location.href = location.href;
|
||||
}
|
||||
}
|
||||
|
||||
mw.hook( 'wikipage.content' ).add( function ( $content ) {
|
||||
var $sortable, $collapsible, $sortableAndCollapsible,
|
||||
dependencies = [];
|
||||
|
|
@ -47,6 +57,24 @@ $( function () {
|
|||
// Add accesskey hints to the tooltips
|
||||
$( '[accesskey]' ).updateTooltipAccessKeys();
|
||||
|
||||
/**
|
||||
* Fired when wiki content is being added to the DOM
|
||||
*
|
||||
* It is encouraged to fire it before the main DOM is changed (when $content
|
||||
* is still detached). However, this order is not defined either way, so you
|
||||
* should only rely on $content itself.
|
||||
*
|
||||
* This includes the ready event on a page load (including post-edit loads)
|
||||
* and when content has been previewed with LivePreview.
|
||||
*
|
||||
* @event wikipage_content
|
||||
* @member mw.hook
|
||||
* @param {jQuery} $content The most appropriate element containing the content,
|
||||
* such as #mw-content-text (regular content root) or #wikiPreview (live preview
|
||||
* root)
|
||||
*/
|
||||
mw.hook( 'wikipage.content' ).fire( $( '#mw-content-text' ) );
|
||||
|
||||
$nodes = $( '.catlinks[data-mw="interface"]' );
|
||||
if ( $nodes.length ) {
|
||||
/**
|
||||
|
|
@ -67,6 +95,21 @@ $( function () {
|
|||
mw.hook( 'wikipage.categories' ).fire( $nodes );
|
||||
}
|
||||
|
||||
$nodes = $( 'table.diff[data-mw="interface"]' );
|
||||
if ( $nodes.length ) {
|
||||
/**
|
||||
* Fired when the diff is added to a page containing a diff
|
||||
*
|
||||
* Similar to the {@link mw.hook#event-wikipage_content wikipage.content hook}
|
||||
* $diff may still be detached when the hook is fired.
|
||||
*
|
||||
* @event wikipage_diff
|
||||
* @member mw.hook
|
||||
* @param {jQuery} $diff The root element of the MediaWiki diff (`table.diff`).
|
||||
*/
|
||||
mw.hook( 'wikipage.diff' ).fire( $nodes.eq( 0 ) );
|
||||
}
|
||||
|
||||
$( '#t-print a' ).on( 'click', function ( e ) {
|
||||
window.print();
|
||||
e.preventDefault();
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
( function () {
|
||||
// Break out of framesets
|
||||
if ( mw.config.get( 'wgBreakFrames' ) ) {
|
||||
// Note: In IE < 9 strict comparison to window is non-standard (the standard didn't exist yet)
|
||||
// it works only comparing to window.self or window.window (http://stackoverflow.com/q/4850978/319266)
|
||||
if ( window.top !== window.self ) {
|
||||
// Un-trap us from framesets
|
||||
window.top.location.href = location.href;
|
||||
}
|
||||
}
|
||||
|
||||
$( function () {
|
||||
var $diff;
|
||||
|
||||
/**
|
||||
* Fired for wiki content that is or will be rendered somewhere on the page.
|
||||
*
|
||||
* Use this hook if you need to enhance or modify parts of a wiki page.
|
||||
*
|
||||
* This hook should be used instead of `$.ready` as otherwise you will
|
||||
* miss content that is rendered without a browser reload. For example,
|
||||
* during a JavaScript-based live preview, or after saving an edit with
|
||||
* VisualEditor.
|
||||
*
|
||||
* Keep in mind:
|
||||
* - The `$content` might represent content that is not yet publicly saved,
|
||||
* such as during a (personal) preview.
|
||||
* - The `$content` might represent only a small portion of the page,
|
||||
* for example when editing a section, or after an extension inserts
|
||||
* or lazy-loads additional content.
|
||||
* - The `$content` element might be detached (invisible) when the hook runs.
|
||||
* This has the benefit of allowing you to modify the content beforehand,
|
||||
* which avoids "flash" or other visual disruption afterwards.
|
||||
*
|
||||
* @event wikipage_content
|
||||
* @member mw.hook
|
||||
* @param {jQuery} $content An element containing wiki content.
|
||||
*/
|
||||
mw.hook( 'wikipage.content' ).fire( $( '#mw-content-text' ) );
|
||||
|
||||
$diff = $( 'table.diff[data-mw="interface"]' );
|
||||
if ( $diff.length ) {
|
||||
/**
|
||||
* Fired when the diff is added to a page containing a diff
|
||||
*
|
||||
* Similar to the {@link mw.hook#event-wikipage_content wikipage.content hook}
|
||||
* $diff may still be detached when the hook is fired.
|
||||
*
|
||||
* @event wikipage_diff
|
||||
* @member mw.hook
|
||||
* @param {jQuery} $diff The root element of the MediaWiki diff (`table.diff`).
|
||||
*/
|
||||
mw.hook( 'wikipage.diff' ).fire( $diff.eq( 0 ) );
|
||||
}
|
||||
} );
|
||||
|
||||
}() );
|
||||
|
|
@ -18,7 +18,6 @@ return [
|
|||
],
|
||||
'dependencies' => [
|
||||
'mediawiki.page.ready',
|
||||
'mediawiki.page.startup',
|
||||
'sinonjs',
|
||||
],
|
||||
'targets' => [ 'desktop', 'mobile' ],
|
||||
|
|
|
|||
Loading…
Reference in a new issue