mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RevisionSlider
synced 2024-11-13 18:27:03 +00:00
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
This commit is contained in:
parent
a998e73f25
commit
fe8f8fa05d
|
@ -62,10 +62,8 @@ $.extend( Settings.prototype, {
|
|||
if ( mw.user.isNamed() ) {
|
||||
setting = mw.user.options.get( 'userjs-revslider-' + name );
|
||||
} else {
|
||||
setting = mw.storage.get( 'mw-revslider-' + name );
|
||||
if ( !setting ) {
|
||||
setting = mw.cookie.get( '-revslider-' + name );
|
||||
}
|
||||
setting = mw.storage.get( 'mw-revslider-' + name ) ||
|
||||
mw.cookie.get( '-revslider-' + name );
|
||||
}
|
||||
|
||||
return setting !== null && setting !== false ? setting : defaultValue;
|
||||
|
|
|
@ -769,16 +769,11 @@ $.extend( SliderView.prototype, {
|
|||
},
|
||||
|
||||
setSliderLineCSS: function ( $lineContainer, widthToSet, marginToSet ) {
|
||||
$lineContainer.css( 'width', widthToSet );
|
||||
if ( this.dir === 'ltr' ) {
|
||||
$lineContainer.css( {
|
||||
width: widthToSet,
|
||||
'margin-left': marginToSet
|
||||
} );
|
||||
$lineContainer.css( 'margin-left', marginToSet );
|
||||
} else {
|
||||
$lineContainer.css( {
|
||||
width: widthToSet,
|
||||
'margin-right': marginToSet + this.revisionWidth
|
||||
} );
|
||||
$lineContainer.css( 'margin-right', marginToSet + this.revisionWidth );
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
const Settings = require( 'ext.RevisionSlider.Settings' ),
|
||||
settings = new Settings(),
|
||||
autoExpand = settings.shouldAutoExpand();
|
||||
autoExpand = new Settings().shouldAutoExpand();
|
||||
|
||||
if ( autoExpand ) {
|
||||
mw.loader.load( 'ext.RevisionSlider.init' );
|
||||
} else {
|
||||
$( '.mw-revslider-toggle-button' ).on( 'click',
|
||||
function () {
|
||||
$( '.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' );
|
||||
}
|
||||
}
|
||||
);
|
||||
} );
|
||||
}
|
||||
$( '.mw-revslider-toggle-button' ).on( 'keypress', function ( event ) {
|
||||
if ( event.which === 13 || event.which === 32 ) {
|
||||
event.preventDefault();
|
||||
$( '.mw-revslider-toggle-button' ).trigger( 'click' );
|
||||
}
|
||||
} );
|
||||
|
|
Loading…
Reference in a new issue