mediawiki.page.ready: Introduce wikipage.indicators hook
This new hook allows extensions and gadgets to enhance indicators on page load and on live preview. This is useful for the Kartographer extension. The hook gets fired only if there is at least one indicator present. The new hook gets fired before `wikipage.content` fires, to have the same order like in the DOM. Bug: T280363 Change-Id: I154ebbf049fbce1e872548651953adb1419b6cba
This commit is contained in:
parent
71d9aa661b
commit
bea70565d9
2 changed files with 15 additions and 0 deletions
|
|
@ -40,6 +40,9 @@
|
|||
document.createTextNode( '\n' )
|
||||
);
|
||||
} );
|
||||
if ( newList.length ) {
|
||||
mw.hook( 'wikipage.indicators' ).fire( $( newList ) );
|
||||
}
|
||||
$( '.mw-indicators' ).empty().append( newList );
|
||||
|
||||
if ( response.parse.displaytitle ) {
|
||||
|
|
|
|||
|
|
@ -52,6 +52,18 @@ $( function () {
|
|||
// Add accesskey hints to the tooltips
|
||||
$( '[accesskey]' ).updateTooltipAccessKeys();
|
||||
|
||||
var node = document.querySelector( '.mw-indicators' );
|
||||
if ( node && node.children.length ) {
|
||||
/**
|
||||
* Fired when indicators are being added to the DOM
|
||||
*
|
||||
* @event wikipage_indicators
|
||||
* @member mw.hook
|
||||
* @param {jQuery} $content The root element of the indicators
|
||||
*/
|
||||
mw.hook( 'wikipage.indicators' ).fire( $( node ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when wiki content is being added to the DOM
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue