diff --git a/Resources.php b/Resources.php index 1557eb45..80400c34 100644 --- a/Resources.php +++ b/Resources.php @@ -147,11 +147,16 @@ $wgResourceModules['ext.uls.preferences'] = array( $wgResourceModules['ext.uls.webfonts'] = array( 'scripts' => 'resources/js/ext.uls.webfonts.js', 'dependencies' => array( - 'jquery.webfonts', 'ext.uls.init', + 'ext.uls.preferences', + ), +) + $resourcePaths; + +$wgResourceModules['ext.uls.webfonts.fonts'] = array( + 'dependencies' => array( + 'jquery.webfonts', 'jquery.uls.data', 'ext.uls.webfonts.repository', - 'ext.uls.preferences', ), ) + $resourcePaths; diff --git a/UniversalLanguageSelector.hooks.php b/UniversalLanguageSelector.hooks.php index cdf4c6a5..9315718a 100644 --- a/UniversalLanguageSelector.hooks.php +++ b/UniversalLanguageSelector.hooks.php @@ -35,7 +35,7 @@ class UniversalLanguageSelectorHooks { return false; } - return $user->getBoolOption( 'uls-enable' ); + return true; } /** @@ -47,11 +47,6 @@ class UniversalLanguageSelectorHooks { public static function addModules( $out, $skin ) { global $wgULSPosition, $wgULSGeoService, $wgULSEventLogging; - $user = $out->getUser(); - if ( !$user->getBoolOption( 'uls-enable') ) { - return true; - } - // Load the style for users without JS, to hide the useless links $out->addModuleStyles( 'ext.uls.nojs' ); @@ -71,7 +66,7 @@ class UniversalLanguageSelectorHooks { $out->addModules( 'ext.uls.geoclient' ); } - if ( self::isToolbarEnabled( $user ) ) { + if ( self::isToolbarEnabled( $out->getUser() ) ) { // Enable UI language selection for the user. $out->addModules( 'ext.uls.interface' ); } @@ -267,7 +262,9 @@ class UniversalLanguageSelectorHooks { * @return bool */ public static function addConfig( &$vars ) { - global $wgULSGeoService, $wgULSIMEEnabled, $wgULSPosition, $wgULSNoWebfontsSelectors, + global $wgULSGeoService, + $wgULSIMEEnabled, $wgULSWebfontsEnabled, + $wgULSPosition, $wgULSNoWebfontsSelectors, $wgULSAnonCanChangeLanguage, $wgULSEventLogging, $wgULSImeSelectors, $wgULSNoImeSelectors, $wgULSFontRepositoryBasePath, $wgExtensionAssetsPath; @@ -275,7 +272,9 @@ class UniversalLanguageSelectorHooks { if ( is_string( $wgULSGeoService ) ) { $vars['wgULSGeoService'] = $wgULSGeoService; } + $vars['wgULSIMEEnabled'] = $wgULSIMEEnabled; + $vars['wgULSWebfontsEnabled'] = $wgULSWebfontsEnabled; $vars['wgULSPosition'] = $wgULSPosition; $vars['wgULSAnonCanChangeLanguage'] = $wgULSAnonCanChangeLanguage; $vars['wgULSEventLogging'] = $wgULSEventLogging; @@ -311,12 +310,6 @@ class UniversalLanguageSelectorHooks { } public static function onGetPreferences( $user, &$preferences ) { - $preferences['uls-enable'] = array( - 'type' => 'toggle', - 'label-message' => 'uls-preference', - 'section' => 'personal/i18n', - ); - $preferences['uls-preferences'] = array( 'type' => 'api', ); diff --git a/UniversalLanguageSelector.i18n.php b/UniversalLanguageSelector.i18n.php index b5e86925..358d4b02 100644 --- a/UniversalLanguageSelector.i18n.php +++ b/UniversalLanguageSelector.i18n.php @@ -33,7 +33,6 @@ $messages['en'] = array( 'uls-plang-title-languages' => 'Languages', 'uls-ime-helppage' => 'https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Extension:UniversalLanguageSelector/Input_methods/$1', - 'uls-preference' => 'Enable the [https://www.mediawiki.org/wiki/Special:MyLanguage/Universal_Language_Selector Universal Language Selector]', 'ext-uls-select-language-settings-icon-tooltip' => 'Language settings', 'ext-uls-undo-language-tooltip-text' => 'Language changed from $1', 'ext-uls-language-settings-preferences-link' => 'More language settings', diff --git a/UniversalLanguageSelector.php b/UniversalLanguageSelector.php index 0596abe1..eac7b6b5 100644 --- a/UniversalLanguageSelector.php +++ b/UniversalLanguageSelector.php @@ -100,10 +100,17 @@ $GLOBALS['wgULSLanguageDetection'] = true; /** * Enable the input methods feature for all users by default. - * Can be disabled manually by the user. + * Can be controlled by the user. */ $GLOBALS['wgULSIMEEnabled'] = true; +/** + * Enable the webfonts feature for all users by default. + * Can be controlled by the user. + * @since 2013.01 + */ +$GLOBALS['wgULSWebfontsEnabled'] = true; + /** * Set whether webfont support is loaded within the mobile interface (via the * MobileFrontend extension). @@ -195,7 +202,6 @@ $GLOBALS['wgHooks']['SkinTemplateOutputPageBeforeExec'][] = $GLOBALS['wgHooks']['EnterMobileMode'][] = 'UniversalLanguageSelectorHooks::onEnterMobileMode'; $GLOBALS['wgDefaultUserOptions']['uls-preferences'] = ''; -$GLOBALS['wgDefaultUserOptions']['uls-enable'] = ''; $GLOBALS['wgHooks']['GetPreferences'][] = 'UniversalLanguageSelectorHooks::onGetPreferences'; $GLOBALS['wgExtensionFunctions'][] = function () { @@ -219,7 +225,7 @@ $GLOBALS['wgExtensionFunctions'][] = function () { $wgResourceModules['schema.UniversalLanguageSelector'] = array( 'class' => 'ResourceLoaderSchemaModule', 'schema' => 'UniversalLanguageSelector', - 'revision' => 5729800, + 'revision' => 7327441, ); } else { wfWarn( 'UniversalLanguageSelector is configured to use EventLogging, but ' diff --git a/i18n/en.json b/i18n/en.json index 0366fc87..640a868d 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -20,6 +20,9 @@ "ext-uls-display-settings-anon-label": "Display language:", "ext-uls-display-settings-anon-same-as-content": "$1 (same as content)", "ext-uls-display-settings-anon-log-in-cta": "[[Special:UserLogin|Log in]] to select a different language for menus.", +"ext-uls-webfonts-settings-title": "Download fonts when needed", +"ext-uls-webfonts-settings-info": "Download missing fonts automatically and allow selection of preferred fonts.", +"ext-uls-webfonts-settings-info-link": "More information", "ext-uls-webfonts-select-for": "Select font for $1", "ext-uls-webfonts-select-for-ui-info": "Font used for user interface", "ext-uls-webfonts-select-for-content-info": "Font used for content", diff --git a/i18n/qqq.json b/i18n/qqq.json index 8d69481e..59bf5949 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -24,6 +24,9 @@ "ext-uls-display-settings-anon-label": "A label that appears to anonymous users before the message {{msg-mw|Jquery-uls-ext-uls-display-settings-anon-same-as-content}}.\n\n{{Identical|Display language}}", "ext-uls-display-settings-anon-same-as-content": "Text that appears to anonymous users after the label {{msg-mw|Jquery-uls-ext-uls-display-settings-anon-label}}.\n\nParameters:\n* $1 - ...", "ext-uls-display-settings-anon-log-in-cta": "A call to action for an anonymous user to log in.", + "ext-uls-webfonts-settings-title": "Short title for enabling webfonts", + "ext-uls-webfonts-settings-info": "Webfonts will be downloaded for displaying text in special scripts.", + "ext-uls-webfonts-settings-info-link": "More information link text for webfonts\n{{Identical|More information}}", "ext-uls-webfonts-select-for": "Label for font selector dropdown. $1 is a language name", "ext-uls-webfonts-select-for-ui-info": "Information displayed under font selector", "ext-uls-webfonts-select-for-content-info": "Information displayed under font selector", @@ -50,4 +53,4 @@ "ext-uls-input-disable-notification-info-interlanguage": "Notification bubble text when input methods are disabled, appears if the ULS is at interlanguage toolbar", "ext-uls-language-settings-applying": "Label for apply settings button in language settings screen, while settings being saved. Please keep it short.", "ext-uls-language-settings-preferences-link": "Text for the link showin in user preference screen" -} \ No newline at end of file +} diff --git a/resources/js/ext.uls.displaysettings.js b/resources/js/ext.uls.displaysettings.js index ed2ecea6..bf243155 100644 --- a/resources/js/ext.uls.displaysettings.js +++ b/resources/js/ext.uls.displaysettings.js @@ -77,6 +77,18 @@ + '' // End font selectors + // Webfonts enabling checkbox with label + + '
' + + '
' + + '' + + '
' + + '
' + + ''; // End font settings section function DisplaySettings( $parent ) { @@ -104,6 +116,7 @@ this.prepareLanguages(); this.prepareUIFonts(); this.prepareContentFonts(); + this.prepareWebfontsCheckbox(); // Usually this is already loaded, but when changing language it // might not be. @@ -112,6 +125,20 @@ this.dirty = false; }, + prepareWebfontsCheckbox: function () { + var webFontsEnabled = this.isWebFontsEnabled(); + + if ( !webFontsEnabled ) { + $( '#uls-display-settings-font-selectors' ).addClass( 'hide' ); + } + + $( '#webfonts-enable-checkbox' ).prop( 'checked', webFontsEnabled ); + }, + + isWebFontsEnabled: function () { + return mw.webfonts.preferences.isEnabled(); + }, + /** * Prepare the UI language selector */ @@ -343,7 +370,9 @@ $.i18n().locale = language; mw.uls.loadLocalization( language ).done( function () { displaySettings.i18n(); - displaySettings.$webfonts.refresh(); + if ( displaySettings.$webfonts ) { + displaySettings.$webfonts.refresh(); + } } ); }, @@ -383,7 +412,11 @@ // Get the language code from the right property - // uiLanguage or contentLanguage language = this[ target + 'Language' ]; - fonts = this.$webfonts.list( language ); + if ( this.isWebFontsEnabled() ) { + fonts = this.$webfonts.list( language ); + } else { + fonts = []; + } // Possible classes: // uls-ui-fonts @@ -418,6 +451,8 @@ } } ); + $fontSelector.prop( 'disabled', !this.isWebFontsEnabled() ); + // Using attr() instead of data() because jquery.i18n doesn't // currently see latter. $systemFont = $( '