Use require to clarify ext.uls.preferences

ext.uls.preferences only depended on ext.uls.common because of its
use of the uls global. This is unnecessary, and made clearer by using
require and module.exports to access it.

Change-Id: Ied2a1b560d19a18529fd766ced778c912199fa2f
This commit is contained in:
jdlrobson
2020-10-19 13:09:31 -07:00
committed by Jdlrobson
parent 5cd10ce862
commit f8fde38197
4 changed files with 8 additions and 8 deletions

View File

@@ -21,13 +21,14 @@
'use strict'; 'use strict';
var mwImeRulesPath, inputSelector, inputPreferences, ulsIMEPreferences, customHelpLink, var mwImeRulesPath, inputSelector, inputPreferences, ulsIMEPreferences, customHelpLink,
getULSPreferences = require( 'ext.uls.preferences' ),
languageSettingsModules = [ 'ext.uls.displaysettings' ]; languageSettingsModules = [ 'ext.uls.displaysettings' ];
mwImeRulesPath = mw.config.get( 'wgExtensionAssetsPath' ) + mwImeRulesPath = mw.config.get( 'wgExtensionAssetsPath' ) +
'/UniversalLanguageSelector/lib/jquery.ime/'; '/UniversalLanguageSelector/lib/jquery.ime/';
inputSelector = 'input:not([type]), input[type=text], input[type=search], textarea, [contenteditable]'; inputSelector = 'input:not([type]), input[type=text], input[type=search], textarea, [contenteditable]';
inputPreferences = mw.uls.preferences(); inputPreferences = getULSPreferences();
mw.ime = mw.ime || {}; mw.ime = mw.ime || {};
@@ -74,7 +75,7 @@
// we don't want to save isDirty field. // we don't want to save isDirty field.
this.registry.isDirty = undefined; this.registry.isDirty = undefined;
// get updated copy of preferences // get updated copy of preferences
inputPreferences = mw.uls.preferences(); inputPreferences = getULSPreferences();
inputPreferences.set( 'ime', this.registry ); inputPreferences.set( 'ime', this.registry );
inputPreferences.save( callback ); inputPreferences.save( callback );
// reset the dirty bit // reset the dirty bit

View File

@@ -145,8 +145,7 @@
} }
}; };
mw.uls = mw.uls || {}; module.exports = function () {
mw.uls.preferences = function () {
var data = $( document.body ).data( 'preferences' ); var data = $( document.body ).data( 'preferences' );
if ( !data ) { if ( !data ) {

View File

@@ -20,10 +20,10 @@
( function () { ( function () {
'use strict'; 'use strict';
var ulsPreferences; var getULSPreferences = require( 'ext.uls.preferences' ),
ulsPreferences = getULSPreferences();
mw.webfonts = mw.webfonts || {}; mw.webfonts = mw.webfonts || {};
ulsPreferences = mw.uls.preferences();
mw.webfonts.preferences = { mw.webfonts.preferences = {
registry: { registry: {
fonts: {}, fonts: {},
@@ -52,7 +52,7 @@
save: function ( callback ) { save: function ( callback ) {
// get updated copy of preferences // get updated copy of preferences
ulsPreferences = mw.uls.preferences(); ulsPreferences = getULSPreferences();
ulsPreferences.set( 'webfonts', this.registry ); ulsPreferences.set( 'webfonts', this.registry );
ulsPreferences.save( callback ); ulsPreferences.save( callback );
}, },

View File

@@ -40,7 +40,7 @@
// Here it's used as a meaningless word, to test // Here it's used as a meaningless word, to test
// the preferences without changing anything useful. // the preferences without changing anything useful.
prefName = 'gofanim'; prefName = 'gofanim';
prefs = mw.uls.preferences(); prefs = require( 'ext.uls.preferences' )();
prefsToSave = {}; prefsToSave = {};
prefsToSave[ prefName ] = { prefsToSave[ prefName ] = {