Update test files
- Updated versions and order of checkers. - Some consistency updates in Gruntfile.js. - Updates to make jscs pass. Change-Id: I7ed93596ff383dc713bd17af2da0472be934d59d
This commit is contained in:
committed by
Nikerabbit
parent
faa5c06bda
commit
6a2b2e0bba
3
.jscsrc
3
.jscsrc
@@ -1,3 +1,4 @@
|
||||
{
|
||||
"preset": "wikimedia"
|
||||
"preset": "wikimedia",
|
||||
"requireCamelCaseOrUpperCaseIdentifiers": null
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
|
||||
"camelcase": true,
|
||||
"camelcase": false,
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"immed": true,
|
||||
|
||||
16
Gruntfile.js
16
Gruntfile.js
@@ -1,10 +1,11 @@
|
||||
/*jshint node:true */
|
||||
module.exports = function ( grunt ) {
|
||||
'use strict';
|
||||
|
||||
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
|
||||
grunt.loadNpmTasks( 'grunt-banana-checker' );
|
||||
grunt.loadNpmTasks( 'grunt-jsonlint' );
|
||||
grunt.loadNpmTasks( 'grunt-jscs' );
|
||||
grunt.loadNpmTasks( 'grunt-jsonlint' );
|
||||
grunt.loadNpmTasks( 'grunt-banana-checker' );
|
||||
|
||||
grunt.initConfig( {
|
||||
jshint: {
|
||||
@@ -12,20 +13,23 @@ module.exports = function ( grunt ) {
|
||||
jshintrc: true
|
||||
},
|
||||
all: [
|
||||
'*.js'
|
||||
'**/*.js',
|
||||
'!lib/**',
|
||||
'!node_modules/**',
|
||||
'!resources/js/ext.uls.webfonts.repository.js'
|
||||
]
|
||||
},
|
||||
jscs: {
|
||||
src: '<%= jshint.all %>'
|
||||
},
|
||||
banana: {
|
||||
all: 'i18n/'
|
||||
},
|
||||
jsonlint: {
|
||||
all: [
|
||||
'**/*.json',
|
||||
'!node_modules/**'
|
||||
]
|
||||
},
|
||||
banana: {
|
||||
all: 'i18n'
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
"grunt": "0.4.5",
|
||||
"grunt-cli": "0.1.13",
|
||||
"grunt-contrib-jshint": "0.11.3",
|
||||
"grunt-jscs": "2.1.0",
|
||||
"grunt-banana-checker": "0.4.0",
|
||||
"grunt-jsonlint": "1.0.7"
|
||||
"grunt-jscs": "2.5.0",
|
||||
"grunt-jsonlint": "1.0.7",
|
||||
"grunt-banana-checker": "0.4.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* Compact the interlanguage links in the sidebar
|
||||
*
|
||||
* Copyright (C) 2012-2014 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris,
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
/**
|
||||
* For the given array, remove duplicates
|
||||
*
|
||||
* @param {Array} originalArray
|
||||
* @return {Array} de-duplicated array
|
||||
*/
|
||||
@@ -114,6 +115,7 @@
|
||||
},
|
||||
/**
|
||||
* Language selection handler
|
||||
*
|
||||
* @param {string} language language code
|
||||
*/
|
||||
onSelect: function ( language ) {
|
||||
@@ -152,6 +154,7 @@
|
||||
|
||||
/**
|
||||
* Get the compacted interlanguage list as associative array
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
getCompactList: function () {
|
||||
@@ -174,6 +177,7 @@
|
||||
|
||||
/**
|
||||
* Compact a given array of languages
|
||||
*
|
||||
* @param {Array} languages
|
||||
* @return {Array} Compacted array
|
||||
*/
|
||||
@@ -210,6 +214,7 @@
|
||||
* Filter the language list by previous languages.
|
||||
* Not all previous languages will be present in interlanguage links,
|
||||
* so we are filtering them.
|
||||
*
|
||||
* @return {Array} List of language codes supported by the article
|
||||
*/
|
||||
filterByPreviousLanguages: function ( languages ) {
|
||||
@@ -223,6 +228,7 @@
|
||||
/**
|
||||
* Filter the language list by common languages.
|
||||
* Common languages are the most probable languages predicted by ULS.
|
||||
*
|
||||
* @return {Array} List of language codes supported by the article
|
||||
*/
|
||||
filterByCommonLanguages: function ( languages ) {
|
||||
@@ -236,6 +242,7 @@
|
||||
/**
|
||||
* Filter the language list by Translate's assistant languages.
|
||||
* Where available, they're languages deemed useful by the user.
|
||||
*
|
||||
* @return {Array} List of those language codes which are supported by article
|
||||
*/
|
||||
filterByAssistantLanguages: function ( languages ) {
|
||||
@@ -253,6 +260,7 @@
|
||||
/**
|
||||
* Find out the existing languages supported
|
||||
* by the article and fetch their href.
|
||||
*
|
||||
* @return {Object} List of existing language codes and their hrefs
|
||||
*/
|
||||
getInterlanguageList: function () {
|
||||
@@ -303,6 +311,7 @@
|
||||
|
||||
/**
|
||||
* Show a language from the interlanguage list
|
||||
*
|
||||
* @param {string} language
|
||||
*/
|
||||
showLanguage: function ( language ) {
|
||||
@@ -312,6 +321,7 @@
|
||||
|
||||
/**
|
||||
* CompactInterlanguageList Plugin
|
||||
*
|
||||
* @param {Object} [option]
|
||||
*/
|
||||
$.fn.compactInterlanguageList = function ( option ) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* ULS-based display settings panel
|
||||
*
|
||||
* Copyright (C) 2012 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris,
|
||||
@@ -16,6 +16,7 @@
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
* @licence MIT License
|
||||
*/
|
||||
|
||||
( function ( $, mw ) {
|
||||
'use strict';
|
||||
|
||||
@@ -359,7 +360,8 @@
|
||||
|
||||
/**
|
||||
* Preview the settings panel in the given language
|
||||
* @param {String} language Language code
|
||||
*
|
||||
* @param {string} language Language code
|
||||
*/
|
||||
preview: function ( language ) {
|
||||
var displaySettings = this;
|
||||
@@ -378,7 +380,8 @@
|
||||
|
||||
/**
|
||||
* Get previous languages
|
||||
* @returns {Array}
|
||||
*
|
||||
* @return {Array}
|
||||
*/
|
||||
frequentLanguageList: function () {
|
||||
return mw.uls.getFrequentLanguageList();
|
||||
@@ -386,7 +389,8 @@
|
||||
|
||||
/**
|
||||
* Get the current user interface language.
|
||||
* @returns String Current UI language
|
||||
*
|
||||
* @return {string} Current UI language
|
||||
*/
|
||||
getUILanguage: function () {
|
||||
return mw.config.get( 'wgUserLanguage' );
|
||||
@@ -394,7 +398,8 @@
|
||||
|
||||
/**
|
||||
* Get the current content language.
|
||||
* @returns String Current content language
|
||||
*
|
||||
* @return {string} Current content language
|
||||
*/
|
||||
getContentLanguage: function () {
|
||||
return mw.config.get( 'wgContentLanguage' );
|
||||
@@ -403,7 +408,7 @@
|
||||
/**
|
||||
* Prepare a font selector section with a label and a selector element.
|
||||
*
|
||||
* @param target String 'ui' or 'content'
|
||||
* @param {string} target 'ui' or 'content'
|
||||
*/
|
||||
prepareFontSelector: function ( target ) {
|
||||
var language, fonts, $fontSelector, savedFont,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* ULS Event logger
|
||||
*
|
||||
* Copyright (C) 2012-2013 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris,
|
||||
@@ -16,14 +16,15 @@
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
* @licence MIT License
|
||||
*/
|
||||
|
||||
( function ( $, mw ) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* ULS Event logger
|
||||
* See https://meta.wikimedia.org/wiki/Schema:UniversalLanguageSelector
|
||||
*
|
||||
* @since 2013.08
|
||||
* @see https://meta.wikimedia.org/wiki/Schema:UniversalLanguageSelector
|
||||
*/
|
||||
function ULSEventLogger() {
|
||||
this.logEventQueue = $.Callbacks( 'memory once' );
|
||||
@@ -49,7 +50,7 @@
|
||||
* Local wrapper for 'mw.eventLog.logEvent'
|
||||
*
|
||||
* @param {Object} event Event action and optional fields
|
||||
* @param {String} schema The schema; 'UniversalLanguageSelector' is the default
|
||||
* @param {string} schema The schema; 'UniversalLanguageSelector' is the default
|
||||
* @return {jQuery.Promise} jQuery Promise object for the logging call
|
||||
*/
|
||||
log: function ( event, schema ) {
|
||||
@@ -95,6 +96,7 @@
|
||||
|
||||
/**
|
||||
* Log language settings open
|
||||
*
|
||||
* @param {string} context Where it was opened from
|
||||
*/
|
||||
ulsSettingsOpen: function ( context ) {
|
||||
@@ -106,6 +108,7 @@
|
||||
|
||||
/**
|
||||
* Log language revert
|
||||
*
|
||||
* @param {jQuery.Deferred} deferred
|
||||
*/
|
||||
ulsLanguageRevert: function ( deferred ) {
|
||||
@@ -114,6 +117,7 @@
|
||||
|
||||
/**
|
||||
* Log IME disabling
|
||||
*
|
||||
* @param {string} context Where the setting was changed.
|
||||
*/
|
||||
disableIME: function ( context ) {
|
||||
@@ -122,6 +126,7 @@
|
||||
|
||||
/**
|
||||
* Log IME enabling
|
||||
*
|
||||
* @param {string} context Where the setting was changed.
|
||||
*/
|
||||
enableIME: function ( context ) {
|
||||
@@ -130,6 +135,7 @@
|
||||
|
||||
/**
|
||||
* Log IME change
|
||||
*
|
||||
* @param {string} inputMethod
|
||||
*/
|
||||
changeIME: function ( inputMethod ) {
|
||||
@@ -141,6 +147,7 @@
|
||||
|
||||
/**
|
||||
* Log login link click in display settings.
|
||||
*
|
||||
* @param {jQuery.Deferred} deferred
|
||||
*/
|
||||
loginClick: function ( deferred ) {
|
||||
@@ -215,6 +222,7 @@
|
||||
|
||||
/**
|
||||
* Log webfonts disabling
|
||||
*
|
||||
* @param {string} context Where the setting was changed.
|
||||
*/
|
||||
disableWebfonts: function ( context ) {
|
||||
@@ -223,6 +231,7 @@
|
||||
|
||||
/**
|
||||
* Log webfonts enabling
|
||||
*
|
||||
* @param {string} context Where the setting was changed.
|
||||
*/
|
||||
enableWebfonts: function ( context ) {
|
||||
@@ -231,6 +240,7 @@
|
||||
|
||||
/**
|
||||
* Log search strings which produce no search results.
|
||||
*
|
||||
* @param {jQuery.event} event The orignal event
|
||||
* @param {string} context The query string
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* ULS GeoIP client
|
||||
*
|
||||
* Copyright (C) 2012 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris,
|
||||
@@ -16,17 +16,18 @@
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
* @licence MIT License
|
||||
*/
|
||||
|
||||
( function ( $, mw ) {
|
||||
'use strict';
|
||||
|
||||
var currentProto, httpOnly, settings,
|
||||
service = mw.config.get( 'wgULSGeoService' );
|
||||
|
||||
mw.uls = mw.uls || {};
|
||||
mw.uls.setGeo = function ( data ) {
|
||||
window.Geo = data;
|
||||
};
|
||||
|
||||
var currentProto, httpOnly, settings,
|
||||
service = mw.config.get( 'wgULSGeoService' );
|
||||
|
||||
// Call the service only if defined, and if the current
|
||||
// protocol is https, only if the service is not configured
|
||||
// with http:// as the protocol
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* ULS i18n preparation using jquery.i18n library
|
||||
*
|
||||
* Copyright (C) 2012-2013 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris,
|
||||
@@ -16,6 +16,7 @@
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
* @licence MIT License
|
||||
*/
|
||||
|
||||
( function ( $, mw ) {
|
||||
'use strict';
|
||||
|
||||
@@ -37,6 +38,7 @@
|
||||
* Load localization messags for a locale to the jquery.i18n
|
||||
* messagestore.
|
||||
* Also called by RL module ResourceLoaderULSJsonMessageModule
|
||||
*
|
||||
* @param {string} locale the language code
|
||||
* @param {Object} [messages]
|
||||
* @return {jQuery.Promise}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* ULS - jQuery IME integration
|
||||
*
|
||||
* Copyright (C) 2012 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris,
|
||||
@@ -16,6 +16,7 @@
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
* @licence MIT License
|
||||
*/
|
||||
|
||||
( function ( $, mw ) {
|
||||
'use strict';
|
||||
|
||||
@@ -208,6 +209,7 @@
|
||||
/**
|
||||
* Loads necessary dependencies, checks input for validity and
|
||||
* adds the ime menu for elements that should have it.
|
||||
*
|
||||
* @param {jquery.Element} $input
|
||||
* @since 2013.11
|
||||
*/
|
||||
@@ -244,6 +246,7 @@
|
||||
|
||||
/**
|
||||
* Just adds ime menu to any input element.
|
||||
*
|
||||
* @param {jquery.Element} $input
|
||||
* @since 2013.11
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* ULS startup script - MediaWiki specific customization for jquery.uls
|
||||
*
|
||||
* Copyright (C) 2012-2013 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris,
|
||||
@@ -16,6 +16,7 @@
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
* @licence MIT License
|
||||
*/
|
||||
|
||||
( function ( $, mw ) {
|
||||
'use strict';
|
||||
|
||||
@@ -61,6 +62,7 @@
|
||||
|
||||
/**
|
||||
* Change the language of wiki using API or set cookie and reload the page
|
||||
*
|
||||
* @param {string} language Language code.
|
||||
*/
|
||||
mw.uls.changeLanguage = function ( language ) {
|
||||
@@ -147,7 +149,6 @@
|
||||
return ( window.navigator.language || window.navigator.userLanguage || '' ).split( '-' )[ 0 ];
|
||||
};
|
||||
|
||||
/*jshint camelcase:false*/
|
||||
mw.uls.getCountryCode = function () {
|
||||
return window.Geo && ( window.Geo.country || window.Geo.country_code );
|
||||
};
|
||||
@@ -165,7 +166,7 @@
|
||||
* and finally, the languages of countryCode taken from the CLDR,
|
||||
* taken by default from the user's geolocation.
|
||||
*
|
||||
* @param {String} [countryCode] Uppercase country code.
|
||||
* @param {string} [countryCode] Uppercase country code.
|
||||
* @return {Array} List of language codes without duplicates.
|
||||
*/
|
||||
mw.uls.getFrequentLanguageList = function ( countryCode ) {
|
||||
@@ -218,11 +219,12 @@
|
||||
/**
|
||||
* Checks whether the browser is supported.
|
||||
* Browser support policy: http://www.mediawiki.org/wiki/Browser_support#Grade_A
|
||||
* @return boolean
|
||||
*
|
||||
* @return {boolean}
|
||||
*/
|
||||
function isBrowserSupported() {
|
||||
var blacklist = {
|
||||
'msie': [
|
||||
msie: [
|
||||
[ '<=', 7 ]
|
||||
]
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* ULS-based ime settings panel
|
||||
*
|
||||
* Copyright (C) 2012 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris,
|
||||
@@ -16,6 +16,7 @@
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
* @licence MIT License
|
||||
*/
|
||||
|
||||
( function ( $, mw ) {
|
||||
'use strict';
|
||||
|
||||
@@ -346,12 +347,16 @@
|
||||
);
|
||||
},
|
||||
onVisible: function () {
|
||||
var $parent;
|
||||
|
||||
if ( !inputSettings.$parent.$window.hasClass( 'callout' ) ) {
|
||||
// callout menus will have position rules. others use
|
||||
// default position
|
||||
return;
|
||||
}
|
||||
var $parent = $( '#language-settings-dialog' );
|
||||
|
||||
$parent = $( '#language-settings-dialog' );
|
||||
|
||||
// Re-position the element according to the window that called it
|
||||
if ( parseInt( $parent.css( 'left' ), 10 ) ) {
|
||||
this.$menu.css( 'left', $parent.css( 'left' ) );
|
||||
@@ -402,7 +407,8 @@
|
||||
|
||||
/**
|
||||
* Get previous languages
|
||||
* @returns {Array}
|
||||
*
|
||||
* @return {Array}
|
||||
*/
|
||||
frequentLanguageList: function () {
|
||||
return mw.uls.getFrequentLanguageList();
|
||||
@@ -410,7 +416,8 @@
|
||||
|
||||
/**
|
||||
* Get the current user interface language.
|
||||
* @returns String Current UI language
|
||||
*
|
||||
* @return {string} Current UI language
|
||||
*/
|
||||
getInterfaceLanguage: function () {
|
||||
return mw.config.get( 'wgUserLanguage' );
|
||||
@@ -418,7 +425,8 @@
|
||||
|
||||
/**
|
||||
* Get the current content language.
|
||||
* @returns String Current content language
|
||||
*
|
||||
* @return {string} Current content language
|
||||
*/
|
||||
getContentLanguage: function () {
|
||||
return mw.config.get( 'wgContentLanguage' );
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* ULS interface integration logic
|
||||
*
|
||||
* Copyright (C) 2012-2013 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris,
|
||||
@@ -16,11 +16,13 @@
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
* @licence MIT License
|
||||
*/
|
||||
|
||||
( function ( $, mw ) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Construct the display settings link
|
||||
*
|
||||
* @return {jQuery}
|
||||
*/
|
||||
function displaySettings() {
|
||||
@@ -40,7 +42,8 @@
|
||||
|
||||
/**
|
||||
* Construct the input settings link
|
||||
* @returns {jQuery}
|
||||
*
|
||||
* @return {jQuery}
|
||||
*/
|
||||
function inputSettings() {
|
||||
var $inputSettingsTitle, inputSettingsText, $inputSettings;
|
||||
@@ -59,6 +62,7 @@
|
||||
|
||||
/**
|
||||
* Add display settings link to the settings bar in ULS
|
||||
*
|
||||
* @param {Object} uls The ULS object
|
||||
*/
|
||||
function addDisplaySettings( uls ) {
|
||||
@@ -97,6 +101,7 @@
|
||||
|
||||
/**
|
||||
* Add input settings link to the settings bar in ULS
|
||||
*
|
||||
* @param {Object} uls The ULS object
|
||||
*/
|
||||
function addInputSettings( uls ) {
|
||||
@@ -127,6 +132,7 @@
|
||||
|
||||
/**
|
||||
* Helper function to make the uls triggers accessible with the keyboard.
|
||||
*
|
||||
* @param {jQuery} $target One or more jQuery elements.
|
||||
* @since 2013.07
|
||||
*/
|
||||
@@ -165,6 +171,7 @@
|
||||
|
||||
/**
|
||||
* Gets the name of the previously active language
|
||||
*
|
||||
* @param {string} code Language code of previously selected language.
|
||||
* @return {jQuery.Promise}
|
||||
*/
|
||||
@@ -187,7 +194,7 @@
|
||||
}
|
||||
|
||||
function userCanChangeLanguage() {
|
||||
return mw.config.get( 'wgULSAnonCanChangeLanguage') || !mw.user.isAnon();
|
||||
return mw.config.get( 'wgULSAnonCanChangeLanguage' ) || !mw.user.isAnon();
|
||||
}
|
||||
|
||||
function userHasChangedLanguage() {
|
||||
@@ -260,7 +267,7 @@
|
||||
previousLanguages.push( currentLang );
|
||||
mw.uls.setPreviousLanguages( previousLanguages );
|
||||
|
||||
getUndoAutonym( previousLang ).done( function( autonym ) {
|
||||
getUndoAutonym( previousLang ).done( function ( autonym ) {
|
||||
// Attach a tipsy tooltip to the trigger
|
||||
$ulsTrigger.tipsy( {
|
||||
gravity: tipsyGravity[ ulsPosition ],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* ULS-based language settings dialog for MediaWiki.
|
||||
*
|
||||
* Copyright (C) 2012 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris,
|
||||
@@ -16,6 +16,7 @@
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
* @licence MIT License
|
||||
*/
|
||||
|
||||
( function ( $, mw ) {
|
||||
'use strict';
|
||||
|
||||
@@ -113,6 +114,7 @@
|
||||
/**
|
||||
* Initialize the module.
|
||||
* Render the link and settings area for a language setting module.
|
||||
*
|
||||
* @param {string} moduleName Name of the setting module
|
||||
* @param {boolean} active boolean Make this module active and show by default
|
||||
*/
|
||||
@@ -237,6 +239,7 @@
|
||||
* Busy mode means displaying a progress cursor,
|
||||
* and showing the 'apply' button as disabled and with
|
||||
* a different label.
|
||||
*
|
||||
* @param {boolean} busy set true to put the panel in busy mode,
|
||||
* false to unset the busy mode.
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* jquery.uls defaults for MediaWiki.
|
||||
*
|
||||
* Copyright (C) 2013 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris,
|
||||
@@ -16,6 +16,7 @@
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
* @licence MIT License
|
||||
*/
|
||||
|
||||
( function ( $, mw ) {
|
||||
'use strict';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* ULS preferences system for MediaWiki.
|
||||
* Local storage for anonymous users, preferences for logged in users.
|
||||
*
|
||||
@@ -17,6 +17,7 @@
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
* @licence MIT License
|
||||
*/
|
||||
|
||||
( function ( $, mw ) {
|
||||
'use strict';
|
||||
|
||||
@@ -50,7 +51,7 @@
|
||||
/*
|
||||
* Returns the value of the given key
|
||||
* @param {string} key
|
||||
* @retun {Object} value of the key
|
||||
* @return {Object} value of the key
|
||||
*/
|
||||
get: function ( key ) {
|
||||
var data;
|
||||
@@ -97,10 +98,12 @@
|
||||
* Initialize
|
||||
*/
|
||||
init: function () {
|
||||
var options;
|
||||
|
||||
if ( this.isAnon ) {
|
||||
this.preferences = preferenceStore().get( this.preferenceName );
|
||||
} else {
|
||||
var options = mw.user.options.get( this.preferenceName );
|
||||
options = mw.user.options.get( this.preferenceName );
|
||||
if ( !options ) {
|
||||
options = '{}';
|
||||
}
|
||||
@@ -118,8 +121,8 @@
|
||||
/**
|
||||
* Set the preference
|
||||
*
|
||||
* @param {String} key
|
||||
* @param value
|
||||
* @param {string} key
|
||||
* @param {mixed} value
|
||||
*/
|
||||
set: function ( key, value ) {
|
||||
this.preferences[ key ] = value;
|
||||
@@ -128,7 +131,7 @@
|
||||
/**
|
||||
* Get a preference value for the given preference name
|
||||
*
|
||||
* @param key
|
||||
* @param {string} key
|
||||
*/
|
||||
get: function ( key ) {
|
||||
return this.preferences[ key ];
|
||||
@@ -137,7 +140,7 @@
|
||||
/**
|
||||
* Save the preferences
|
||||
*
|
||||
* @param callback
|
||||
* @param {Function} callback
|
||||
*/
|
||||
save: function ( callback ) {
|
||||
var ulsPreferences = this;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* ULS-Webfonts integration
|
||||
*
|
||||
* Copyright (C) 2012 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris,
|
||||
@@ -16,8 +16,10 @@
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
* @licence MIT License
|
||||
*/
|
||||
|
||||
( function ( $, mw ) {
|
||||
'use strict';
|
||||
|
||||
var ulsPreferences,
|
||||
// Text to prepend the sample text. 0D00 is an unassigned unicode point.
|
||||
tofuSalt = '\u0D00',
|
||||
@@ -45,11 +47,11 @@
|
||||
},
|
||||
|
||||
setFont: function ( language, font ) {
|
||||
this.registry.fonts[language] = font;
|
||||
this.registry.fonts[ language ] = font;
|
||||
},
|
||||
|
||||
getFont: function ( language ) {
|
||||
return this.registry.fonts[language];
|
||||
return this.registry.fonts[ language ];
|
||||
},
|
||||
|
||||
save: function ( callback ) {
|
||||
@@ -97,13 +99,13 @@
|
||||
.appendTo( 'body' );
|
||||
|
||||
for ( index = 0; index < length; index++ ) {
|
||||
$fixture.text( text[index] );
|
||||
width[index] = $fixture.width() || width[index - 1];
|
||||
height[index] = $fixture.height();
|
||||
$fixture.text( text[ index ] );
|
||||
width[ index ] = $fixture.width() || width[ index - 1 ];
|
||||
height[ index ] = $fixture.height();
|
||||
|
||||
if ( index > 0 &&
|
||||
( width[index] !== width[index - 1] ||
|
||||
height[index] !== height[index - 1] )
|
||||
( width[ index ] !== width[ index - 1 ] ||
|
||||
height[ index ] !== height[ index - 1 ] )
|
||||
) {
|
||||
detected = false;
|
||||
break;
|
||||
@@ -135,7 +137,7 @@
|
||||
*
|
||||
* @param {Object} repository
|
||||
* @param {string} language
|
||||
* @param {array} classes
|
||||
* @param {Array} classes
|
||||
*/
|
||||
fontSelector: function ( repository, language, classes ) {
|
||||
var font, autonym, defaultFont;
|
||||
@@ -160,17 +162,17 @@
|
||||
|
||||
// There is a default font for this language,
|
||||
// but check whether the user sees tofu for it.
|
||||
if ( tofuLanguages[language] === undefined ) {
|
||||
tofuLanguages[language] = detectTofu( $.uls.data.getAutonym( language ) );
|
||||
if ( tofuLanguages[ language ] === undefined ) {
|
||||
tofuLanguages[ language ] = detectTofu( $.uls.data.getAutonym( language ) );
|
||||
|
||||
// Log the tofu detection only once per page per language
|
||||
if ( tofuLanguages[language] ) {
|
||||
if ( tofuLanguages[ language ] ) {
|
||||
mw.log( 'tofu detected for ' + language );
|
||||
mw.hook( 'mw.uls.webfonts.tofudetected' ).fire( language );
|
||||
}
|
||||
}
|
||||
|
||||
if ( tofuLanguages[language] ) {
|
||||
if ( tofuLanguages[ language ] ) {
|
||||
font = autonym ? 'Autonym' : defaultFont;
|
||||
} else {
|
||||
// No tofu and no font preference. Use system font.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* MobileFrontend compatible ULS-Webfonts integration
|
||||
*
|
||||
* Copyright (C) 2013 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris,
|
||||
@@ -16,6 +16,7 @@
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
* @licence MIT License
|
||||
*/
|
||||
|
||||
( function ( $, mw ) {
|
||||
'use strict';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* QUnit tests for ULS.
|
||||
*
|
||||
* Copyright (C) 2012 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris,
|
||||
@@ -38,17 +38,18 @@
|
||||
} );
|
||||
|
||||
QUnit.test( 'User preferences', function ( assert ) {
|
||||
var prefName, prefs, prefsToSave, readPrefs;
|
||||
|
||||
QUnit.expect( 2 );
|
||||
|
||||
// 'gofanim' means "fonts" in Hebrew.
|
||||
// Here it's used as a meaningless word, to test
|
||||
// the preferences without changing anything useful.
|
||||
var prefName = 'gofanim',
|
||||
prefs = mw.uls.preferences(),
|
||||
prefsToSave = {},
|
||||
readPrefs;
|
||||
prefName = 'gofanim';
|
||||
prefs = mw.uls.preferences();
|
||||
prefsToSave = {};
|
||||
|
||||
prefsToSave[prefName] = {
|
||||
prefsToSave[ prefName ] = {
|
||||
fonts: {
|
||||
qqy: 'Megafont'
|
||||
}
|
||||
@@ -58,7 +59,7 @@
|
||||
|
||||
readPrefs = prefs.get( prefName );
|
||||
assert.strictEqual(
|
||||
readPrefs[prefName].fonts.qqy,
|
||||
readPrefs[ prefName ].fonts.qqy,
|
||||
'Megafont',
|
||||
'Correct value for the font name'
|
||||
);
|
||||
@@ -87,8 +88,8 @@
|
||||
languagesInPH = mw.uls.getFrequentLanguageList( 'PH' );
|
||||
|
||||
for ( i = 0; i < languagesInPH.length; i++ ) {
|
||||
if ( $.uls.data.isRedirect( languagesInPH[i] ) === 'tl' ||
|
||||
languagesInPH[i] === 'tl'
|
||||
if ( $.uls.data.isRedirect( languagesInPH[ i ] ) === 'tl' ||
|
||||
languagesInPH[ i ] === 'tl'
|
||||
) {
|
||||
foundTagalog = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user