Merge "Initial support for webfonts in MobileFrontend"
This commit is contained in:
@@ -153,6 +153,16 @@ $wgResourceModules['ext.uls.webfonts'] = array(
|
||||
|
||||
$wgResourceModules['ext.uls.webfonts.repository'] = array(
|
||||
'scripts' => 'resources/js/ext.uls.webfonts.repository.js',
|
||||
'targets' => array( 'desktop', 'mobile' ),
|
||||
) + $resourcePaths;
|
||||
|
||||
$wgResourceModules['ext.uls.webfonts.mobile'] = array(
|
||||
'scripts' => 'resources/js/ext.uls.webfonts.mobile.js',
|
||||
'targets' => array( 'mobile' ),
|
||||
'dependencies' => array(
|
||||
'jquery.webfonts',
|
||||
'ext.uls.webfonts.repository',
|
||||
),
|
||||
) + $resourcePaths;
|
||||
|
||||
$wgResourceModules['jquery.i18n'] = array(
|
||||
@@ -234,6 +244,7 @@ $wgResourceModules['jquery.uls.grid'] = array(
|
||||
|
||||
$wgResourceModules['jquery.webfonts'] = array(
|
||||
'scripts' => 'lib/jquery.webfonts.js',
|
||||
'targets' => array( 'desktop', 'mobile' ),
|
||||
) + $resourcePaths;
|
||||
|
||||
// A module named rangy is defined in VisualExtension with more features of rangy.
|
||||
|
||||
@@ -344,4 +344,21 @@ class UniversalLanguageSelectorHooks {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add basic webfonts support to the mobile interface (via MobileFrontend extension)
|
||||
* Hook: EnterMobileMode
|
||||
* @param MobileContext $context
|
||||
* @return bool
|
||||
*/
|
||||
public static function onEnterMobileMode( $context ) {
|
||||
global $wgULSEnable, $wgULSMobileWebfontsEnabled;
|
||||
|
||||
// Currently only supported in mobile Beta mode
|
||||
if ( $wgULSEnable && $wgULSMobileWebfontsEnabled && $context->isBetaGroupMember() ) {
|
||||
$context->getOutput()->addModules( 'ext.uls.webfonts.mobile' );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +104,12 @@ $wgULSLanguageDetection = true;
|
||||
*/
|
||||
$wgULSIMEEnabled = true;
|
||||
|
||||
/**
|
||||
* Set whether webfont support is loaded within the mobile interface (via the
|
||||
* MobileFrontend extension).
|
||||
*/
|
||||
$wgULSMobileWebfontsEnabled = false;
|
||||
|
||||
/**
|
||||
* The location and the form of the language selection trigger.
|
||||
* The possible values are:
|
||||
@@ -184,6 +190,7 @@ $wgAPIModules['ulslocalization'] = 'ApiULSLocalization';
|
||||
$wgHooks['UserGetLanguageObject'][] = 'UniversalLanguageSelectorHooks::getLanguage';
|
||||
$wgHooks['SkinTemplateOutputPageBeforeExec'][] =
|
||||
'UniversalLanguageSelectorHooks::onSkinTemplateOutputPageBeforeExec';
|
||||
$wgHooks['EnterMobileMode'][] = 'UniversalLanguageSelectorHooks::onEnterMobileMode';
|
||||
|
||||
$wgDefaultUserOptions['uls-preferences'] = '';
|
||||
$wgHooks['GetPreferences'][] = 'UniversalLanguageSelectorHooks::onGetPreferences';
|
||||
|
||||
49
resources/js/ext.uls.webfonts.mobile.js
Normal file
49
resources/js/ext.uls.webfonts.mobile.js
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* MobileFrontend compatible ULS-Webfonts integration
|
||||
*
|
||||
* Copyright (C) 2013 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris,
|
||||
* Niklas Laxström, Pau Giner, Ryan Kaldari, Santhosh Thottingal, Siebrand Mazeland
|
||||
* and other contributors. See CREDITS for a list.
|
||||
*
|
||||
* UniversalLanguageSelector is dual licensed GPLv2 or later and MIT. You don't
|
||||
* have to do anything special to choose one license or the other and you don't
|
||||
* have to notify anyone which license you are using. You are free to use
|
||||
* UniversalLanguageSelector in commercial projects as long as the copyright
|
||||
* header is left intact. See files GPL-LICENSE and MIT-LICENSE for details.
|
||||
*
|
||||
* @file
|
||||
* @ingroup Extensions
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
* @licence MIT License
|
||||
*/
|
||||
( function ( $, mw ) {
|
||||
'use strict';
|
||||
|
||||
var mediawikiFontRepository;
|
||||
|
||||
mw.webfonts = mw.webfonts || {};
|
||||
|
||||
mediawikiFontRepository = $.webfonts.repository;
|
||||
mediawikiFontRepository.base = mw.config.get( 'wgExtensionAssetsPath' ) +
|
||||
'/UniversalLanguageSelector/data/fontrepo/fonts/';
|
||||
|
||||
$( document ).ready( function () {
|
||||
// MediaWiki specific overrides for jquery.webfonts
|
||||
$.extend( $.fn.webfonts.defaults, {
|
||||
repository: mediawikiFontRepository,
|
||||
fontStack: $( 'body' ).css( 'font-family' ).split( /, /g ),
|
||||
fontSelector: function ( repository, language ) {
|
||||
var font = repository.defaultFont( language );
|
||||
|
||||
if ( font === 'system' ) {
|
||||
// Avoid setting 'system' as a font in css
|
||||
font = null;
|
||||
}
|
||||
|
||||
return font;
|
||||
}
|
||||
} );
|
||||
|
||||
$( 'body' ).webfonts();
|
||||
} );
|
||||
}( jQuery, mediaWiki ) );
|
||||
Reference in New Issue
Block a user