mediawiki.page.ready: Fire hook 'wikipage.indicators' with children
The parameter of the hook 'wikipage.indicators' in mediawiki.page.ready
and in mediawiki.action.edit.preview was inconsistent:
* mediawiki.page.ready fired the hook with the root element.
* mediawiki.action.edit.preview fired the hook with the children
elements.
This should be consistent.
mediawiki.action.edit.preview fires the hook before adding the elements
to the DOM. Therefor it can't fired with the root element before adding
to DOM. To be consistent the behavior in mediawiki.page.ready must
changed to the behavior in mediawiki.action.edit.preview.
Also remove the text nodes with the newline from the value in
mediawiki.action.edit.preview to be consistent with the value in
mediawiki.page.ready.
This change is a follow-up to bea70565d9.
Bug: T293564
Change-Id: Ie8890e6396db071975794655c4e4ec3616891f96
This commit is contained in:
parent
42d554c930
commit
8bec93a573
3 changed files with 24 additions and 19 deletions
|
|
@ -451,7 +451,10 @@ abstract class BaseTemplate extends QuickTemplate {
|
|||
'class' => 'mw-indicator',
|
||||
],
|
||||
$content
|
||||
) . "\n";
|
||||
) .
|
||||
// Add whitespace between the <div>s because
|
||||
// they get displayed with display: inline-block
|
||||
"\n";
|
||||
}
|
||||
$out .= "</div>\n";
|
||||
return $out;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
* @param {Object} response Response data
|
||||
*/
|
||||
function parsePreviewRequest( response ) {
|
||||
var newList, $displaytitle, $content, $parent, $list, arrow, $previewHeader, $wikiPreview, $editform;
|
||||
var indicators, newList, $displaytitle, $content, $parent, $list, arrow, $previewHeader, $wikiPreview, $editform;
|
||||
|
||||
$editform = $( '#editform' );
|
||||
$wikiPreview = $( '#wikiPreview' );
|
||||
|
|
@ -26,23 +26,25 @@
|
|||
) );
|
||||
}
|
||||
|
||||
newList = [];
|
||||
// eslint-disable-next-line no-jquery/no-each-util
|
||||
$.each( response.parse.indicators, function ( name, indicator ) {
|
||||
newList.push(
|
||||
$( '<div>' )
|
||||
.addClass( 'mw-indicator' )
|
||||
.attr( 'id', mw.util.escapeIdForAttribute( 'mw-indicator-' + name ) )
|
||||
.html( indicator )
|
||||
.get( 0 ),
|
||||
// Add a whitespace between the <div>s because
|
||||
// they get displayed with display: inline-block
|
||||
document.createTextNode( '\n' )
|
||||
);
|
||||
// eslint-disable-next-line no-jquery/no-map-util
|
||||
indicators = $.map( response.parse.indicators, function ( indicator, name ) {
|
||||
return $( '<div>' )
|
||||
.addClass( 'mw-indicator' )
|
||||
.attr( 'id', mw.util.escapeIdForAttribute( 'mw-indicator-' + name ) )
|
||||
.html( indicator )
|
||||
.get( 0 );
|
||||
} );
|
||||
if ( newList.length ) {
|
||||
mw.hook( 'wikipage.indicators' ).fire( $( newList ) );
|
||||
if ( indicators.length ) {
|
||||
mw.hook( 'wikipage.indicators' ).fire( $( indicators ) );
|
||||
}
|
||||
|
||||
// Add whitespace between the <div>s because
|
||||
// they get displayed with display: inline-block
|
||||
newList = [];
|
||||
indicators.forEach( function ( indicator ) {
|
||||
newList.push( indicator, document.createTextNode( '\n' ) );
|
||||
} );
|
||||
|
||||
$( '.mw-indicators' ).empty().append( newList );
|
||||
|
||||
if ( response.parse.displaytitle ) {
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@ $( function () {
|
|||
*
|
||||
* @event wikipage_indicators
|
||||
* @member mw.hook
|
||||
* @param {jQuery} $content The root element of the indicators
|
||||
* @param {jQuery} $content jQuery object with the elements of the indicators
|
||||
*/
|
||||
mw.hook( 'wikipage.indicators' ).fire( $( node ) );
|
||||
mw.hook( 'wikipage.indicators' ).fire( $( node.children ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue