Remove browser checks and use MediaWiki browser policy

We had a browser check to blacklist all browsers older than IE 8
IE <= 7

But that is no longer required since JS support is not there for such
browsers as per https://www.mediawiki.org/wiki/Compatibility#Modern
We can support all modern browsers listed there and we don't need
additional blacklisting now. From 1.27 onwards, there is no JS loaded
for IE 8 too. So we can just use MW browser support policy.

In this commit, the code to do brower checks removed and simplified
the initialization code. Still I am not happy with the interface module,
that need further refactoring.

Change-Id: I655826c55fb2c7c5c88f16368110142d64a96eec
This commit is contained in:
Santhosh Thottingal
2016-04-12 10:39:28 +05:30
parent d964a10c83
commit 64eab95b94
4 changed files with 170 additions and 203 deletions

View File

@@ -160,7 +160,6 @@
"mediawiki.api", "mediawiki.api",
"mediawiki.api.options", "mediawiki.api.options",
"mediawiki.cookie", "mediawiki.cookie",
"jquery.client",
"jquery.cookie" "jquery.cookie"
], ],
"position": "top", "position": "top",
@@ -251,7 +250,8 @@
"scripts": "js/ext.uls.webfonts.js", "scripts": "js/ext.uls.webfonts.js",
"dependencies": [ "dependencies": [
"ext.uls.init", "ext.uls.init",
"ext.uls.preferences" "ext.uls.preferences",
"jquery.client"
], ],
"localBasePath": "resources", "localBasePath": "resources",
"remoteExtPath": "UniversalLanguageSelector/resources" "remoteExtPath": "UniversalLanguageSelector/resources"

View File

@@ -183,40 +183,4 @@
return unique; return unique;
}; };
/**
* Checks whether the browser is supported.
* Browser support policy: http://www.mediawiki.org/wiki/Browser_support#Grade_A
*
* @return {boolean}
*/
function isBrowserSupported() {
var blacklist = {
msie: [
[ '<=', 7 ]
]
};
return !$.client.test( blacklist, null, true );
}
/**
* Initialize ULS front-end if browser is supported.
*
* @param {Function} callback callback function to be called after initialization.
*/
mw.uls.init = function ( callback ) {
if ( !isBrowserSupported() ) {
$( '#pt-uls' ).hide();
return;
}
if ( callback ) {
callback.call( this );
}
};
$( document ).ready( function () {
mw.uls.init();
} );
}( jQuery, mediaWiki ) ); }( jQuery, mediaWiki ) );

View File

@@ -317,13 +317,13 @@
// TODO: Refactor this, because it doesn't directly belong // TODO: Refactor this, because it doesn't directly belong
// to the tooltip. // to the tooltip.
$.cookie( mw.uls.previousLanguageAutonymCookie, $.cookie( mw.uls.previousLanguageAutonymCookie,
mw.config.get( 'wgULSCurrentAutonym' ), mw.config.get( 'wgULSCurrentAutonym' ), {
{ path: '/' } path: '/'
}
); );
} }
$( document ).ready( function () { function initInterface() {
mw.uls.init( function () {
var $triggers, var $triggers,
$pLang, $pLang,
$ulsTrigger = $( '.uls-trigger' ), $ulsTrigger = $( '.uls-trigger' ),
@@ -489,6 +489,9 @@
mw.ime.handleFocus( $input ); mw.ime.handleFocus( $input );
} ); } );
} ); } );
} ); }
$( document ).ready( function () {
initInterface();
} ); } );
}( jQuery, mediaWiki ) ); }( jQuery, mediaWiki ) );

View File

@@ -87,7 +87,9 @@
length = Math.min( 4, text.length ), length = Math.min( 4, text.length ),
detected = false; detected = false;
if ( $.client.test( { msie: false } ) ) { if ( $.client.test( {
msie: false
} ) ) {
// IE shows a different tofu for unassigned code points! // IE shows a different tofu for unassigned code points!
text = tofuSalt + text; text = tofuSalt + text;
} }
@@ -222,12 +224,10 @@
}; };
$( document ).ready( function () { $( document ).ready( function () {
mw.uls.init( function () {
mw.webfonts.preferences.load(); mw.webfonts.preferences.load();
if ( mw.webfonts.preferences.isEnabled() ) { if ( mw.webfonts.preferences.isEnabled() ) {
mw.loader.using( 'ext.uls.webfonts.fonts', mw.webfonts.setup ); mw.loader.using( 'ext.uls.webfonts.fonts', mw.webfonts.setup );
} }
} ); } );
} );
}( jQuery, mediaWiki ) ); }( jQuery, mediaWiki ) );