Implement language-selection-method event
Change-Id: If2d207f8a221c8f2a560b1399ad69a3032b2064b
This commit is contained in:
committed by
Nikerabbit
parent
e5891b83b5
commit
a3bca89a42
@@ -39,6 +39,39 @@
|
||||
mw.uls.previousLanguagesCookie = 'uls-previous-languages';
|
||||
mw.uls.languageSettingsModules = ['ext.uls.inputsettings', 'ext.uls.displaysettings'];
|
||||
|
||||
// What was the last thing that the user did to select the language:
|
||||
// * 'map' - clicked the map
|
||||
// * 'search' - typed in the search box
|
||||
// * 'common' - clicked a link in the "Common languages" section
|
||||
// If the user just clicked in some other section, it remains undefined.
|
||||
// This is useful for logging.
|
||||
mw.uls.languageSelectionMethod = undefined;
|
||||
|
||||
/**
|
||||
* Add event logging triggers, which are common to different
|
||||
* ULS instances
|
||||
*/
|
||||
mw.uls.addEventLoggingTriggers = function () {
|
||||
// Remove previous values when reinitializing
|
||||
mw.uls.languageSelectionMethod = undefined;
|
||||
|
||||
$( '#map-block' ).on( 'click', function () {
|
||||
mw.uls.languageSelectionMethod = 'map';
|
||||
} );
|
||||
|
||||
$( '#languagefilter' ).on( 'keydown', function () {
|
||||
// If it's the first letter,
|
||||
// log the usage of the search box
|
||||
if ( $( this ).val() === '' ) {
|
||||
mw.uls.languageSelectionMethod = 'search';
|
||||
}
|
||||
} );
|
||||
|
||||
$( '#uls-lcd-quicklist a' ).on( 'click', function () {
|
||||
mw.uls.languageSelectionMethod = 'common';
|
||||
} );
|
||||
};
|
||||
|
||||
/**
|
||||
* Change the language of wiki using setlang URL parameter
|
||||
* @param {string} language Language code.
|
||||
|
||||
Reference in New Issue
Block a user