Restore enableWebfonts pref and remove uls-enable
This patch restores the enableWebfonts preference, stored inside the uls-preferences blob. It existed as 'enable-webfonts' in the past and was removed in If735a733717596fae03042c5e277bd538bd8501f Each wiki can be configured to load the fonts by default using the new global variable $wgULSWebfontsEnabled. Its default value is true (to load fonts). This also removes the preference 'uls-enable', recently added in I71b70d8ee7c3cad7f49b32e5dc494ef4fc1bdb2f The initialization of ext.uls.webfonts.js is changed as well, so that minimal webfonts JS library code is loaded, and the rest is loaded only if a user requests it. Bug: 60304 Change-Id: I49e812eae32266f165591c75fd67b86ca06b13f0
This commit is contained in:
@@ -18,8 +18,7 @@
|
||||
*/
|
||||
( function ( $, mw ) {
|
||||
'use strict';
|
||||
|
||||
var mediawikiFontRepository, ulsPreferences,
|
||||
var ulsPreferences,
|
||||
// Text to prepend the sample text. 0D00 is an unassigned unicode point.
|
||||
tofuSalt = '\u0D00',
|
||||
// cache languages with tofu.
|
||||
@@ -29,7 +28,20 @@
|
||||
ulsPreferences = mw.uls.preferences();
|
||||
mw.webfonts.preferences = {
|
||||
registry: {
|
||||
fonts: {}
|
||||
fonts: {},
|
||||
webfontsEnabled: mw.config.get( 'wgULSWebfontsEnabled' )
|
||||
},
|
||||
|
||||
isEnabled: function () {
|
||||
return this.registry.webfontsEnabled;
|
||||
},
|
||||
|
||||
enable: function () {
|
||||
this.registry.webfontsEnabled = true;
|
||||
},
|
||||
|
||||
disable: function () {
|
||||
this.registry.webfontsEnabled = false;
|
||||
},
|
||||
|
||||
setFont: function ( language, font ) {
|
||||
@@ -53,7 +65,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Detect tofu
|
||||
*
|
||||
@@ -108,11 +119,19 @@
|
||||
return detected;
|
||||
}
|
||||
|
||||
mediawikiFontRepository = $.webfonts.repository;
|
||||
mediawikiFontRepository.base = mw.config.get( 'wgULSFontRepositoryBasePath' );
|
||||
|
||||
mw.webfonts.setup = function () {
|
||||
// Initialize webfonts
|
||||
var mediawikiFontRepository = $.webfonts.repository;
|
||||
|
||||
mediawikiFontRepository.base = mw.config.get( 'wgULSFontRepositoryBasePath' );
|
||||
|
||||
// MediaWiki specific overrides for jquery.webfonts
|
||||
$.extend( $.fn.webfonts.defaults, {
|
||||
repository: mediawikiFontRepository,
|
||||
fontStack: $( 'body' ).css( 'font-family' ).split( /, /g ),
|
||||
exclude: mw.config.get( 'wgULSNoWebfontsSelectors' ).join( ', ' )
|
||||
} );
|
||||
|
||||
$.fn.webfonts.defaults = $.extend( $.fn.webfonts.defaults, {
|
||||
/**
|
||||
* Font selector - depending the language and optionally
|
||||
@@ -200,16 +219,11 @@
|
||||
|
||||
$( document ).ready( function () {
|
||||
mw.uls.init( function () {
|
||||
|
||||
// MediaWiki specific overrides for jquery.webfonts
|
||||
$.extend( $.fn.webfonts.defaults, {
|
||||
repository: mediawikiFontRepository,
|
||||
fontStack: $( 'body' ).css( 'font-family' ).split( /, /g ),
|
||||
exclude: mw.config.get( 'wgULSNoWebfontsSelectors' ).join( ', ' )
|
||||
} );
|
||||
|
||||
mw.webfonts.preferences.load();
|
||||
mw.webfonts.setup();
|
||||
|
||||
if ( mw.webfonts.preferences.isEnabled() ) {
|
||||
mw.loader.using( 'ext.uls.webfonts.fonts', mw.webfonts.setup );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}( jQuery, mediaWiki ) );
|
||||
|
||||
Reference in New Issue
Block a user