ext.uls.interface: clarify code
Changes to comments, naming and code to increase clarity of the code and explain better what it does and why. No change in behavior. Change-Id: I998fcfd620c2ee737618c3ab8f41fb6dfdd2c99a
This commit is contained in:
committed by
jenkins-bot
parent
099f1f37c8
commit
95b1137a57
@@ -321,7 +321,9 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the trigger at the bottom of the language list
|
* Add the trigger at the bottom of the language list.
|
||||||
|
*
|
||||||
|
* Click handler is setup in ext.uls.interface module.
|
||||||
*/
|
*/
|
||||||
CompactInterlanguageList.prototype.addTrigger = function () {
|
CompactInterlanguageList.prototype.addTrigger = function () {
|
||||||
var trigger = document.createElement( 'button' );
|
var trigger = document.createElement( 'button' );
|
||||||
|
|||||||
@@ -466,40 +466,48 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event handler for the language button
|
* Load and open ULS for content language selection.
|
||||||
|
*
|
||||||
|
* This dialog is primarily for selecting the language of the content, but may also provide
|
||||||
|
* access to display and input settings if isUsingStandaloneLanguageButton() returns true.
|
||||||
|
*
|
||||||
* @param {jQuery.Event} ev
|
* @param {jQuery.Event} ev
|
||||||
*/
|
*/
|
||||||
function clickLanguageButton( ev ) {
|
function loadContentLanguageSelector( ev ) {
|
||||||
var uls,
|
|
||||||
$target = $( ev.currentTarget );
|
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
// Load the ULS now.
|
|
||||||
mw.loader.using( 'ext.uls.mediawiki' ).then( function () {
|
mw.loader.using( 'ext.uls.mediawiki' ).then( function () {
|
||||||
var parent = document.querySelectorAll( '.mw-portlet-lang, #p-lang' )[ 0 ];
|
var $target, parent, languageNodes, uls;
|
||||||
launchULS(
|
|
||||||
$target,
|
$target = $( ev.currentTarget );
|
||||||
mw.uls.getInterlanguageListFromNodes(
|
parent = document.querySelectorAll( '.mw-portlet-lang, #p-lang' )[ 0 ];
|
||||||
parent ? parent.querySelectorAll( '.interlanguage-link-target' ) : []
|
languageNodes = parent ? parent.querySelectorAll( '.interlanguage-link-target' ) : [];
|
||||||
)
|
|
||||||
);
|
// Setup click handler for ULS
|
||||||
uls = $target.data( 'uls' );
|
launchULS( $target, mw.uls.getInterlanguageListFromNodes( languageNodes ) );
|
||||||
|
// Trigger the click handler to open ULS
|
||||||
$target.trigger( 'click' );
|
$target.trigger( 'click' );
|
||||||
// In New Vector the settings cog is currently not shown. To provide access these are added to
|
// Provide access to display and input settings if this entry point is the single point
|
||||||
// the footer of the ULS dialog (T274396)
|
// of access to all language settings.
|
||||||
|
uls = $target.data( 'uls' );
|
||||||
if ( isUsingStandaloneLanguageButton() ) {
|
if ( isUsingStandaloneLanguageButton() ) {
|
||||||
loadDisplayAndInputSettings( uls );
|
loadDisplayAndInputSettings( uls );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Sets up the interlanguage selector button if present
|
/** Setup lazy-loading for content language selector */
|
||||||
*/
|
function initContentLanguageSelectorClickHandler() {
|
||||||
function initInterlanguageSelector() {
|
// FIXME: In Timeless ULS is embedded in a menu which stops event propagation
|
||||||
// Special handling for Timeless which stops propagation on links in this menu
|
|
||||||
if ( $( '.sidebar-inner' ).length ) {
|
if ( $( '.sidebar-inner' ).length ) {
|
||||||
$( '.sidebar-inner #p-lang' ).one( 'click', '.mw-interlanguage-selector', clickLanguageButton );
|
$( '.sidebar-inner #p-lang' )
|
||||||
|
.one( 'click', '.mw-interlanguage-selector', loadContentLanguageSelector );
|
||||||
} else {
|
} else {
|
||||||
$( document ).one( 'click', '.mw-interlanguage-selector', clickLanguageButton );
|
// This button may be created by the new Vector skin, or ext.uls.compactlinks module
|
||||||
|
// if there are many languages. Warning: Both this module and ext.uls.compactlinks
|
||||||
|
// module may run simultaneously. Using event delegation to avoid race conditions where
|
||||||
|
// the trigger may be created after this code.
|
||||||
|
$( document ).one( 'click', '.mw-interlanguage-selector', loadContentLanguageSelector );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,7 +515,7 @@
|
|||||||
initInterface();
|
initInterface();
|
||||||
initTooltip();
|
initTooltip();
|
||||||
initIme();
|
initIme();
|
||||||
initInterlanguageSelector();
|
initContentLanguageSelectorClickHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Early execute of init
|
// Early execute of init
|
||||||
|
|||||||
Reference in New Issue
Block a user