Refactor ime lazy loading
* Do not load anything unless input field is focused * Split the setup function to smaller functions * Introduce $wgULSImeSelectors to allow configuration and avoid duplication of selectors in two places. Change-Id: If5a476e66681dde9f0b72f619d35ddf6255246ac
This commit is contained in:
committed by
Santhosh Thottingal
parent
39faf1a72e
commit
193f69b017
@@ -297,6 +297,7 @@
|
||||
rtlPage = $( 'body' ).hasClass( 'rtl' ),
|
||||
anonMode = ( mw.user.isAnon() &&
|
||||
!mw.config.get( 'wgULSAnonCanChangeLanguage' ) ),
|
||||
imeSelector = mw.config.get( 'wgULSImeSelectors' ).join( ', ' ),
|
||||
ulsPosition = mw.config.get( 'wgULSPosition' );
|
||||
|
||||
if ( ulsPosition === 'interlanguage' ) {
|
||||
@@ -445,6 +446,15 @@
|
||||
} );
|
||||
|
||||
showULSTooltip();
|
||||
|
||||
$( 'body' ).on( 'focus.imeinit', imeSelector, function () {
|
||||
var $input = $( this );
|
||||
$( 'body' ).off( '.imeinit' );
|
||||
mw.loader.using( 'ext.uls.ime', function () {
|
||||
mw.ime.setup();
|
||||
mw.ime.handleFocus( $input );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
}( jQuery, mediaWiki ) );
|
||||
|
||||
Reference in New Issue
Block a user