mediawiki-extensions-Revisi.../modules/ext.RevisionSlider.lazy.js
thiemowmde fe8f8fa05d Don't add keypress handler when not needed
I'm not sure why it was done this way. Probably because it doesn't
make an actual difference from the user's perspective. My motivation
is: When we already called the code that auto-expands the
RevisionSlider UI then it doesn't make much sense to give the user
a keyypress handler that does the same a second time.

Possibly even related to T342556?

This patch also contains a few small, unrelated code cleanups.

Change-Id: I123e89d9d7dc3b1e33cf43831c679330d9dd1cdd
2023-08-28 06:10:06 +00:00

19 lines
492 B
JavaScript

const Settings = require( 'ext.RevisionSlider.Settings' ),
autoExpand = new Settings().shouldAutoExpand();
if ( autoExpand ) {
mw.loader.load( 'ext.RevisionSlider.init' );
} else {
$( '.mw-revslider-toggle-button' ).on( {
click: function () {
mw.loader.load( 'ext.RevisionSlider.init' );
},
keypress: function ( event ) {
if ( event.which === 13 || event.which === 32 ) {
event.preventDefault();
$( '.mw-revslider-toggle-button' ).trigger( 'click' );
}
}
} );
}