Optionally exclude elements from applying webfonts
* Updates jquery.webfonts from upstream * Introduces wgULSNoWebfontsSelectors configuration variable. It takes an array of jquery selector to which webfonts will not be applied if defined. Change-Id: I0dc263f84620af4077f52e18eeb0f986ff0f13b9
This commit is contained in:
@@ -248,7 +248,7 @@ class UniversalLanguageSelectorHooks {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function addConfig( &$vars ) {
|
public static function addConfig( &$vars ) {
|
||||||
global $wgULSGeoService, $wgULSIMEEnabled, $wgULSPosition,
|
global $wgULSGeoService, $wgULSIMEEnabled, $wgULSPosition, $wgULSNoWebfontsSelectors,
|
||||||
$wgULSAnonCanChangeLanguage, $wgULSEventLogging, $wgULSNoImeSelectors;
|
$wgULSAnonCanChangeLanguage, $wgULSEventLogging, $wgULSNoImeSelectors;
|
||||||
|
|
||||||
// Place constant stuff here (not depending on request context)
|
// Place constant stuff here (not depending on request context)
|
||||||
@@ -260,6 +260,7 @@ class UniversalLanguageSelectorHooks {
|
|||||||
$vars['wgULSAnonCanChangeLanguage'] = $wgULSAnonCanChangeLanguage;
|
$vars['wgULSAnonCanChangeLanguage'] = $wgULSAnonCanChangeLanguage;
|
||||||
$vars['wgULSEventLogging'] = $wgULSEventLogging;
|
$vars['wgULSEventLogging'] = $wgULSEventLogging;
|
||||||
$vars['wgULSNoImeSelectors'] = $wgULSNoImeSelectors;
|
$vars['wgULSNoImeSelectors'] = $wgULSNoImeSelectors;
|
||||||
|
$vars['wgULSNoWebfontsSelectors'] = $wgULSNoWebfontsSelectors;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,6 +130,14 @@ $wgULSEventLogging = false;
|
|||||||
*/
|
*/
|
||||||
$wgULSNoImeSelectors = array( '#wpCaptchaWord' );
|
$wgULSNoImeSelectors = array( '#wpCaptchaWord' );
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of jQuery selectors of elements on which webfonts must not be applied.
|
||||||
|
* By default exclude the interwiki language links.
|
||||||
|
* @since 2013.09
|
||||||
|
*/
|
||||||
|
$wgULSNoWebfontsSelectors = array( '#p-lang li > a' );
|
||||||
|
|
||||||
$dir = __DIR__;
|
$dir = __DIR__;
|
||||||
|
|
||||||
// Internationalization
|
// Internationalization
|
||||||
|
|||||||
@@ -190,6 +190,10 @@
|
|||||||
var fontFamilyStyle, fontFamily,
|
var fontFamilyStyle, fontFamily,
|
||||||
$element = $( element );
|
$element = $( element );
|
||||||
|
|
||||||
|
if ( $element.is( webfonts.options.exclude ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Note: it depends on the browser whether this returns font names
|
// Note: it depends on the browser whether this returns font names
|
||||||
// which don't exist. In Chrome it does, while in Opera it doesn't.
|
// which don't exist. In Chrome it does, while in Opera it doesn't.
|
||||||
fontFamilyStyle = $element.css( 'fontFamily' );
|
fontFamilyStyle = $element.css( 'fontFamily' );
|
||||||
|
|||||||
@@ -70,12 +70,17 @@
|
|||||||
return font;
|
return font;
|
||||||
},
|
},
|
||||||
exclude: ( function () {
|
exclude: ( function () {
|
||||||
|
var excludes = $.fn.webfonts.defaults.exclude;
|
||||||
|
|
||||||
if ( mw.user.options.get( 'editfont' ) !== 'default' ) {
|
if ( mw.user.options.get( 'editfont' ) !== 'default' ) {
|
||||||
// Exclude textboxes from webfonts if user has edit area font option
|
// Exclude textboxes from webfonts if user has edit area font option
|
||||||
// set using 'Preferences' page
|
// set using 'Preferences' page
|
||||||
return 'textarea';
|
excludes = ( excludes )
|
||||||
|
? excludes + ',textarea'
|
||||||
|
: 'textarea';
|
||||||
}
|
}
|
||||||
return $.fn.webfonts.defaults.exclude;
|
|
||||||
|
return excludes;
|
||||||
}() )
|
}() )
|
||||||
} );
|
} );
|
||||||
$( 'body' ).webfonts();
|
$( 'body' ).webfonts();
|
||||||
@@ -87,7 +92,8 @@
|
|||||||
// MediaWiki specific overrides for jquery.webfonts
|
// MediaWiki specific overrides for jquery.webfonts
|
||||||
$.extend( $.fn.webfonts.defaults, {
|
$.extend( $.fn.webfonts.defaults, {
|
||||||
repository: mediawikiFontRepository,
|
repository: mediawikiFontRepository,
|
||||||
fontStack: $( 'body' ).css( 'font-family' ).split( /, /g )
|
fontStack: $( 'body' ).css( 'font-family' ).split( /, /g ),
|
||||||
|
exclude: mw.config.get( 'wgULSNoWebfontsSelectors' ).join( ', ' )
|
||||||
} );
|
} );
|
||||||
|
|
||||||
mw.webfonts.preferences.load();
|
mw.webfonts.preferences.load();
|
||||||
|
|||||||
Reference in New Issue
Block a user