jenkins-bot has submitted this change and it was merged.

Change subject: Initial support for webfonts in MobileFrontend
......................................................................


Initial support for webfonts in MobileFrontend

Written in pair-programming with Ryan Kaldari.

This adds a version of webfonts initialization that is stripped
of any smart features. It only loads the basic jquery.webfonts
library and the fonts repository in a way that is usable
with the MobileFronted extension.

It is completely disabled by default.

It can be enabled by setting
$wgULSMobileWebfontsEnabled = true;
and even then it will only be enabled for users
who opted in for the mobile beta mode.

Change-Id: I488e411232a1192bbf46ae5675c701366bda9a3e
---
M Resources.php
M UniversalLanguageSelector.hooks.php
M UniversalLanguageSelector.php
A resources/js/ext.uls.webfonts.mobile.js
4 files changed, 84 insertions(+), 0 deletions(-)

Approvals:
  Amire80: Looks good to me, but someone else must approve
  Kaldari: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Resources.php b/Resources.php
index 5c9ef2c..723a3c8 100644
--- a/Resources.php
+++ b/Resources.php
@@ -153,6 +153,16 @@
 
 $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.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.
diff --git a/UniversalLanguageSelector.hooks.php 
b/UniversalLanguageSelector.hooks.php
index 8de93f2..6e2f563 100644
--- a/UniversalLanguageSelector.hooks.php
+++ b/UniversalLanguageSelector.hooks.php
@@ -344,4 +344,21 @@
 
                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;
+       }
 }
diff --git a/UniversalLanguageSelector.php b/UniversalLanguageSelector.php
index c15a330..d7ebe2f 100644
--- a/UniversalLanguageSelector.php
+++ b/UniversalLanguageSelector.php
@@ -105,6 +105,12 @@
 $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:
  * 'personal': as a link near the username or the log in link in
@@ -184,6 +190,7 @@
 $wgHooks['UserGetLanguageObject'][] = 
'UniversalLanguageSelectorHooks::getLanguage';
 $wgHooks['SkinTemplateOutputPageBeforeExec'][] =
        'UniversalLanguageSelectorHooks::onSkinTemplateOutputPageBeforeExec';
+$wgHooks['EnterMobileMode'][] = 
'UniversalLanguageSelectorHooks::onEnterMobileMode';
 
 $wgDefaultUserOptions['uls-preferences'] = '';
 $wgHooks['GetPreferences'][] = 
'UniversalLanguageSelectorHooks::onGetPreferences';
diff --git a/resources/js/ext.uls.webfonts.mobile.js 
b/resources/js/ext.uls.webfonts.mobile.js
new file mode 100644
index 0000000..43a6b53
--- /dev/null
+++ b/resources/js/ext.uls.webfonts.mobile.js
@@ -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 ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/86337
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I488e411232a1192bbf46ae5675c701366bda9a3e
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector
Gerrit-Branch: master
Gerrit-Owner: Amire80 <amir.ahar...@mail.huji.ac.il>
Gerrit-Reviewer: Amire80 <amir.ahar...@mail.huji.ac.il>
Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org>
Gerrit-Reviewer: JGonera <jgon...@wikimedia.org>
Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Kaldari <rkald...@wikimedia.org>
Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com>
Gerrit-Reviewer: Santhosh <santhosh.thottin...@gmail.com>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to