Avoid loading of jquery.i18n and messages until trigger clicked

Use RL for trigger tooltip messages to avoid using jquery.i18n just
to display the triggers. Reordered dependencies so that messages
are loaded for the setting panels and ime menu.

Change-Id: Ic9518f7b63699542deb02a413e03c28344c99fa4
This commit is contained in:
Niklas Laxström
2014-01-23 23:01:09 +00:00
committed by Nikerabbit
parent 9df061c692
commit 15b3c31029
5 changed files with 22 additions and 41 deletions

View File

@@ -40,11 +40,6 @@
}() );
}
var jsonLoader = null,
initialized = false,
currentLang = mw.config.get( 'wgUserLanguage' );
mw.uls = mw.uls || {};
mw.uls.previousLanguagesCookie = 'uls-previous-languages';
mw.uls.previousLanguageAutonymCookie = 'uls-previous-language-autonym';
@@ -230,33 +225,19 @@
}
/**
* Initialize ULS front-end and its i18n.
* Initialize ULS front-end if browser is supported.
*
* @param {Function} callback callback function to be called after initialization.
*/
mw.uls.init = function ( callback ) {
callback = callback || $.noop;
if ( initialized ) {
callback.call( this );
return;
}
if ( !isBrowserSupported() ) {
$( '#pt-uls' ).hide();
return;
}
if ( !jsonLoader ) {
jsonLoader = mw.uls.loadLocalization( currentLang );
} else {
jsonLoader.done( function () {
initialized = true;
} );
jsonLoader.done( callback );
if ( callback ) {
callback.call( this );
}
};

View File

@@ -231,7 +231,7 @@
// Get the html of the link by wrapping it in div first
link = $( '<div>' ).html( link ).html();
return $.i18n( 'ext-uls-undo-language-tooltip-text', link );
return mw.msg( 'ext-uls-undo-language-tooltip-text', link );
}
} );
@@ -321,9 +321,7 @@
// The interlanguage links section
$pLang = $( '#p-lang' );
// Add an element near the interlanguage links header
$ulsTrigger = $( '<span>' )
.addClass( 'uls-settings-trigger' )
.attr( 'title', $.i18n( 'ext-uls-language-settings-title' ) );
$ulsTrigger = $( '<span>' ).addClass( 'uls-settings-trigger' );
// Append ULS cog to languages section, but make sure it is visible.
$pLang.show().prepend( $ulsTrigger );
// Take care of any other elements with this class.
@@ -344,7 +342,7 @@
}
$ulsTrigger.attr( {
title: $.i18n( 'ext-uls-select-language-settings-icon-tooltip' )
title: mw.msg( 'ext-uls-select-language-settings-icon-tooltip' )
} );
$ulsTrigger.on( 'click', function ( e, eventParams ) {
@@ -461,7 +459,7 @@
// Bind language settings to preferences page link
$( '#uls-preferences-link' )
.text( $.i18n( 'ext-uls-language-settings-preferences-link' ) )
.text( mw.msg( 'ext-uls-language-settings-preferences-link' ) )
.click( function () {
$ulsTrigger.trigger( 'click', {
source: 'preferences'