Simplify code using .one
Change-Id: I84fb5e0ade474738ff6a05c2304de351a2476186
This commit is contained in:
committed by
Santhosh Thottingal
parent
791cefeec6
commit
0784540c40
@@ -87,28 +87,31 @@
|
|||||||
var $displaySettings = displaySettings();
|
var $displaySettings = displaySettings();
|
||||||
|
|
||||||
uls.$menu.find( '#uls-settings-block' ).append( $displaySettings );
|
uls.$menu.find( '#uls-settings-block' ).append( $displaySettings );
|
||||||
$displaySettings.on( 'click', function () {
|
|
||||||
var languagesettings = $displaySettings.data( 'languagesettings' ),
|
// Initialize the trigger
|
||||||
displaySettingsOptions = {
|
$displaySettings.one( 'click', function () {
|
||||||
|
var displaySettingsOptions = {
|
||||||
defaultModule: 'display'
|
defaultModule: 'display'
|
||||||
},
|
},
|
||||||
ulsPosition = mw.config.get( 'wgULSPosition' ),
|
ulsPosition = mw.config.get( 'wgULSPosition' ),
|
||||||
anonMode = ( mw.user.isAnon() &&
|
anonMode = ( mw.user.isAnon() &&
|
||||||
!mw.config.get( 'wgULSAnonCanChangeLanguage' ) );
|
!mw.config.get( 'wgULSAnonCanChangeLanguage' ) );
|
||||||
|
|
||||||
if ( !languagesettings ) {
|
// If the ULS trigger is shown in the top personal menu,
|
||||||
// If the ULS trigger is shown in the top personal menu,
|
// closing the display settings must show the main ULS
|
||||||
// closing the display settings must show the main ULS
|
// languages list, unless we are in anon mode and thus
|
||||||
// languages list, unless we are in anon mode and thus
|
// cannot show the language list
|
||||||
// cannot show the language list
|
if ( ulsPosition === 'personal' && !anonMode ) {
|
||||||
if ( ulsPosition === 'personal' && !anonMode ) {
|
displaySettingsOptions.onClose = function () {
|
||||||
displaySettingsOptions.onClose = function () {
|
uls.show();
|
||||||
uls.show();
|
};
|
||||||
};
|
|
||||||
}
|
|
||||||
$.extend( displaySettingsOptions, uls.position() );
|
|
||||||
$displaySettings.languagesettings( displaySettingsOptions ).click();
|
|
||||||
}
|
}
|
||||||
|
$.extend( displaySettingsOptions, uls.position() );
|
||||||
|
$displaySettings.languagesettings( displaySettingsOptions ).click();
|
||||||
|
} );
|
||||||
|
|
||||||
|
// On every click
|
||||||
|
$displaySettings.on( 'click', function () {
|
||||||
mw.hook( 'mw.uls.settings.open' ).fire( 'uls' );
|
mw.hook( 'mw.uls.settings.open' ).fire( 'uls' );
|
||||||
uls.hide();
|
uls.hide();
|
||||||
} );
|
} );
|
||||||
@@ -123,21 +126,23 @@
|
|||||||
var $inputSettings = inputSettings();
|
var $inputSettings = inputSettings();
|
||||||
|
|
||||||
uls.$menu.find( '#uls-settings-block' ).append( $inputSettings );
|
uls.$menu.find( '#uls-settings-block' ).append( $inputSettings );
|
||||||
|
|
||||||
|
// Initialize the trigger
|
||||||
|
$inputSettings.one( 'click', function () {
|
||||||
|
var position = uls.position();
|
||||||
|
|
||||||
|
$inputSettings.languagesettings( {
|
||||||
|
defaultModule: 'input',
|
||||||
|
onClose: function () {
|
||||||
|
uls.show();
|
||||||
|
},
|
||||||
|
top: position.top,
|
||||||
|
left: position.left
|
||||||
|
} ).click();
|
||||||
|
} );
|
||||||
|
|
||||||
|
// On every click
|
||||||
$inputSettings.on( 'click', function () {
|
$inputSettings.on( 'click', function () {
|
||||||
var position = uls.position(),
|
|
||||||
languagesettings = $inputSettings.data( 'languagesettings' );
|
|
||||||
|
|
||||||
if ( !languagesettings ) {
|
|
||||||
$inputSettings.languagesettings( {
|
|
||||||
defaultModule: 'input',
|
|
||||||
onClose: function () {
|
|
||||||
uls.show();
|
|
||||||
},
|
|
||||||
top: position.top,
|
|
||||||
left: position.left
|
|
||||||
} ).click();
|
|
||||||
}
|
|
||||||
|
|
||||||
mw.hook( 'mw.uls.settings.open' ).fire( 'uls' );
|
mw.hook( 'mw.uls.settings.open' ).fire( 'uls' );
|
||||||
uls.hide();
|
uls.hide();
|
||||||
} );
|
} );
|
||||||
|
|||||||
Reference in New Issue
Block a user