Use single entry point mw.uls.init for all ULS ui initialization

Change-Id: I485ea27deebb530eb89e4b0935eda01a5276f884
This commit is contained in:
Santhosh Thottingal
2013-07-04 18:27:32 +05:30
committed by Amire80
parent ea50b8216c
commit 8ddff0b2fc
4 changed files with 37 additions and 30 deletions

View File

@@ -203,17 +203,14 @@
};
$( document ).ready( function () {
if ( !mw.uls.isBrowserSupported() ) {
return;
}
mw.uls.init( function () {
// Load the ime preferences
$.ime.preferences.load();
if ( $.ime.preferences.isEnabled() ) {
mw.ime.setup();
}
} );
} );
function imeNotification () {

View File

@@ -31,7 +31,8 @@
this.$languageFilter.addClass( 'noime' );
};
var currentLang = mw.config.get( 'wgUserLanguage' );
var initialized = false,
currentLang = mw.config.get( 'wgUserLanguage' );
mw.uls = mw.uls || {};
mw.uls.previousLanguagesCookie = 'uls-previous-languages';
/**
@@ -139,10 +140,10 @@
* Browse support policy: http://www.mediawiki.org/wiki/Browser_support#Grade_A
* @return boolean
*/
mw.uls.isBrowserSupported = function () {
function isBrowserSupported() {
// Blacklist Grade B browsers IE 6, 7 and IE60-IE79
return !/MSIE [67]/i.test( navigator.userAgent );
};
}
/**
* Local wrapper for 'mw.eventLog.logEvent' which handles default params
@@ -187,8 +188,14 @@
.load( jsonLoader + currentLang, currentLang );
}
$( document ).ready( function () {
if ( !mw.uls.isBrowserSupported() ) {
mw.uls.init = function( callback ) {
callback = callback || $.noop;
if ( initialized ) {
callback.call( this, false );
return;
}
if ( !isBrowserSupported() ) {
$( '#pt-uls' ).hide();
return;
}
@@ -205,5 +212,11 @@
// JavaScript side i18n initialization
i18nInit();
initialized = true;
callback.call( this, true );
};
$( document ).ready( function () {
mw.uls.init();
} );
}( jQuery, mediaWiki ) );

View File

@@ -223,6 +223,7 @@
}
$( document ).ready( function () {
mw.uls.init( function () {
var $ulsTrigger = $( '.uls-trigger' ),
$ulsSettingsTrigger,
$pLang,
@@ -232,10 +233,6 @@
!mw.config.get( 'wgULSAnonCanChangeLanguage' ) ),
ulsPosition = mw.config.get( 'wgULSPosition' );
if ( !mw.uls.isBrowserSupported() ) {
return;
}
if ( ulsPosition === 'interlanguage' ) {
// The interlanguage links section
$pLang = $( '#p-lang' );
@@ -330,4 +327,5 @@
showULSTooltip();
} );
} );
}( jQuery, mediaWiki ) );

View File

@@ -81,9 +81,8 @@
};
$( document ).ready( function () {
if ( !mw.uls.isBrowserSupported() ) {
return;
}
mw.uls.init( function () {
// MediaWiki specific overrides for jquery.webfonts
$.extend( $.fn.webfonts.defaults, {
repository: mediawikiFontRepository,
@@ -93,5 +92,5 @@
mw.webfonts.preferences.load();
mw.webfonts.setup();
} );
} );
}( jQuery, mediaWiki ) );