After training the PHPStorm code formatter.

See https://github.com/siebrand/MediaWiki-PHPStorm

Issue remains with anonymous functions in JavaScript.

Change-Id: I2b520f8df127452acf02deb659277a6465e6ca59
This commit is contained in:
Siebrand Mazeland
2012-09-17 17:10:59 -07:00
parent 569b09712c
commit e1a4f7f0cb
17 changed files with 336 additions and 298 deletions

View File

@@ -32,6 +32,7 @@ class UniversalLanguageSelectorHooks {
if ( $wgULSGeoService ) { if ( $wgULSGeoService ) {
$out->addModules( 'ext.uls.geoclient' ); $out->addModules( 'ext.uls.geoclient' );
} }
return true; return true;
} }
@@ -48,6 +49,7 @@ class UniversalLanguageSelectorHooks {
'localBasePath' => __DIR__, 'localBasePath' => __DIR__,
'remoteExtPath' => 'UniversalLanguageSelector', 'remoteExtPath' => 'UniversalLanguageSelector',
); );
return true; return true;
} }
@@ -57,17 +59,21 @@ class UniversalLanguageSelectorHooks {
*/ */
static function addTrigger( array &$personal_urls, &$title ) { static function addTrigger( array &$personal_urls, &$title ) {
global $wgLang; global $wgLang;
$personal_urls = array( 'uls' => array( $personal_urls = array(
'uls' => array(
'text' => $wgLang->getLanguageName( $wgLang->getCode() ), 'text' => $wgLang->getLanguageName( $wgLang->getCode() ),
'href' => '#', 'href' => '#',
'class' => 'uls-trigger', 'class' => 'uls-trigger',
'active' => true 'active' => true
) ) + $personal_urls; )
) + $personal_urls;
return true; return true;
} }
protected static function isSupportedLanguage( $language ) { protected static function isSupportedLanguage( $language ) {
$supported = Language::fetchLanguageNames( null, 'mwfile' ); $supported = Language::fetchLanguageNames( null, 'mwfile' );
return isset( $supported[$language] ); return isset( $supported[$language] );
} }
@@ -93,6 +99,7 @@ class UniversalLanguageSelectorHooks {
return $code; return $code;
} }
} }
return ""; return "";
} }
@@ -151,6 +158,7 @@ class UniversalLanguageSelectorHooks {
public static function addConfig( &$vars ) { public static function addConfig( &$vars ) {
global $wgULSGeoService; global $wgULSGeoService;
$vars['wgULSGeoService'] = $wgULSGeoService; $vars['wgULSGeoService'] = $wgULSGeoService;
return true; return true;
} }
@@ -160,8 +168,11 @@ class UniversalLanguageSelectorHooks {
* @return bool * @return bool
*/ */
public static function addVariables( &$vars, OutputPage $out ) { public static function addVariables( &$vars, OutputPage $out ) {
$vars['wgULSLanguages'] = Language::fetchLanguageNames( $out->getLanguage()->getCode(), 'mwfile' ); $vars['wgULSLanguages'] = Language::fetchLanguageNames(
$out->getLanguage()->getCode(), 'mwfile'
);
$vars['wgULSAcceptLanguageList'] = array_keys( $out->getRequest()->getAcceptLang() ); $vars['wgULSAcceptLanguageList'] = array_keys( $out->getRequest()->getAcceptLang() );
return true; return true;
} }
} }

View File

@@ -67,8 +67,8 @@ class ApiLanguageSearch extends ApiBase {
'api.php?action=languagesearch&search=ഫി&typos=1', 'api.php?action=languagesearch&search=ഫി&typos=1',
); );
} }
public function getVersion() { public function getVersion() {
return __CLASS__ . ': ' . ULS_VERSION; return __CLASS__ . ': ' . ULS_VERSION;
} }
} }

View File

@@ -44,6 +44,7 @@ class LanguageNameSearch {
$results[$code] = $name; $results[$code] = $name;
} }
} }
return $results; return $results;
} }
@@ -57,6 +58,7 @@ class LanguageNameSearch {
if ( !isset( $buckets[$bucket] ) ) { if ( !isset( $buckets[$bucket] ) ) {
$buckets[$bucket] = array(); $buckets[$bucket] = array();
} }
return $bucket; return $bucket;
} }
@@ -82,6 +84,7 @@ class LanguageNameSearch {
if ( count( $values ) === $lookingFor ) { if ( count( $values ) === $lookingFor ) {
// Refer http://en.wikipedia.org/wiki/UTF-8#Description // Refer http://en.wikipedia.org/wiki/UTF-8#Description
$number = ( $lookingFor === 3 ) ? ( ( $values[0] % 16 ) * 4096 ) + ( ( $values[1] % 64 ) * 64 ) + ( $values[2] % 64 ) : ( ( $values[0] % 32 ) * 64 ) + ( $values[1] % 64 ); $number = ( $lookingFor === 3 ) ? ( ( $values[0] % 16 ) * 4096 ) + ( ( $values[1] % 64 ) * 64 ) + ( $values[2] % 64 ) : ( ( $values[0] % 32 ) * 64 ) + ( $values[1] % 64 );
return $number; return $number;
} }
} }
@@ -120,7 +123,7 @@ class LanguageNameSearch {
} }
$prevRow = $currentRow; $prevRow = $currentRow;
} }
return $prevRow[$length2]; return $prevRow[$length2];
} }
} }

View File

@@ -82,8 +82,7 @@ button.button.down {
button.button:disabled, button.button:disabled,
button.button.hover:disabled, button.button.hover:disabled,
button.button.disabled, button.button.disabled,
button.button.disabled:hover button.button.disabled:hover {
{
background-color: #F0F0F0; background-color: #F0F0F0;
background-image: -webkit-linear-gradient(top, #f0f0f0, #f0f0f0); background-image: -webkit-linear-gradient(top, #f0f0f0, #f0f0f0);
background-image: -moz-linear-gradient(center top, #F0F0F0, #F0F0F0); background-image: -moz-linear-gradient(center top, #F0F0F0, #F0F0F0);

View File

@@ -1,6 +1,5 @@
#uls-current-language-nav { /* @embed */ #uls-current-language-nav { /* @embed */
background: url('../images/cog-16x16-ltr.png') no-repeat scroll right background: url('../images/cog-16x16-ltr.png') no-repeat scroll right top transparent;
top transparent;
cursor: pointer; cursor: pointer;
} }
@@ -93,7 +92,6 @@
border-left-color: #3366BB; border-left-color: #3366BB;
} }
#languagesettings-panels div#settings-block { #languagesettings-panels div#settings-block {
border-left: 1px solid #C9C9C9; border-left: 1px solid #C9C9C9;
padding-left: 10px; padding-left: 10px;

View File

@@ -26,7 +26,6 @@
searchAPI: mw.util.wikiScript( 'api' ) + "?action=languagesearch" searchAPI: mw.util.wikiScript( 'api' ) + "?action=languagesearch"
} ); } );
var currentLang = mw.config.get( 'wgUserLanguage' ); var currentLang = mw.config.get( 'wgUserLanguage' );
mw.uls = mw.uls || {}; mw.uls = mw.uls || {};
mw.uls.previousLanguagesCookie = 'uls-previous-languages'; mw.uls.previousLanguagesCookie = 'uls-previous-languages';
@@ -65,9 +64,11 @@
mw.uls.getFrequentLanguageList = function () { mw.uls.getFrequentLanguageList = function () {
var unique = [], var unique = [],
list = [ mw.config.get( 'wgUserLanguage' ), list = [
mw.config.get( 'wgUserLanguage' ),
mw.config.get( 'wgContentLanguage' ), mw.config.get( 'wgContentLanguage' ),
mw.uls.getBrowserLanguage() ] mw.uls.getBrowserLanguage()
]
.concat( mw.uls.getPreviousLanguages() ) .concat( mw.uls.getPreviousLanguages() )
.concat( mw.uls.getAcceptLanguageList() ); .concat( mw.uls.getAcceptLanguageList() );
if ( window.GEO ) { if ( window.GEO ) {
@@ -136,7 +137,6 @@
} }
} ); } );
if ( !previousLang ) { if ( !previousLang ) {
previousLanguages.push( currentLang ); previousLanguages.push( currentLang );
mw.uls.setPreviousLanguages( previousLanguages ); mw.uls.setPreviousLanguages( previousLanguages );

View File

@@ -34,10 +34,10 @@
settingsMenu + settingsMenu +
settingsPanel + settingsPanel +
'</div>'; '</div>';
var windowTemplate = '<div style="display: block;" id="language-settings-dialog" class="uls-menu">' + var windowTemplate = '<div style="display: block;" id="language-settings-dialog" class="uls-menu">'
closeRow + + closeRow
panelsRow + + panelsRow
'</div>'; + '</div>';
var LanguageSettings = function ( element, options ) { var LanguageSettings = function ( element, options ) {
this.$element = $( element ); this.$element = $( element );

View File

@@ -82,59 +82,84 @@ test( "-- $.uls.data testing", function() {
); );
strictEqual( $.uls.data.script( 'ii' ), 'Yiii', 'Correct script of the Yi language was selected' ); strictEqual( $.uls.data.script( 'ii' ), 'Yiii', 'Correct script of the Yi language was selected' );
deepEqual( $.uls.data.regions( 'lzz' ), [ 'EU', 'ME' ], 'Correct regions of the Laz language were selected' ); deepEqual( $.uls.data.regions( 'lzz' ), [
'EU', 'ME'
], 'Correct regions of the Laz language were selected' );
strictEqual( $.uls.data.regions( 'no-such-language' ), 'UNKNOWN', "The region of an invalid language is 'UNKNOWN'" ); strictEqual( $.uls.data.regions( 'no-such-language' ), 'UNKNOWN', "The region of an invalid language is 'UNKNOWN'" );
var allLanguagesByRegionAndScript = $.uls.data.allLanguagesByRegionAndScript(); var allLanguagesByRegionAndScript = $.uls.data.allLanguagesByRegionAndScript();
deepEqual( allLanguagesByRegionAndScript['4']['AS']['SouthEastAsian']['Bugi'], ['bug'], 'All languages in the Buginese script in Asia were selected' ); deepEqual( allLanguagesByRegionAndScript['4']['AS']['SouthEastAsian']['Bugi'], [
'bug'
], 'All languages in the Buginese script in Asia were selected' );
deepEqual( $.uls.data.languagesInRegion( "PA" ), deepEqual( $.uls.data.languagesInRegion( "PA" ),
["ace", "bi", "ch", "en-gb", "en", "fj", "haw", "hif-latn", "hif", "ho", "jv", [
"ace", "bi", "ch", "en-gb", "en", "fj", "haw", "hif-latn", "hif", "ho", "jv",
"mh", "mi", "na", "niu", "pih", "pis", "pt", "rtm", "sm", "tet", "mh", "mi", "na", "niu", "pih", "pis", "pt", "rtm", "sm", "tet",
"to", "tpi", "ty", "wls"], "to", "tpi", "ty", "wls"
],
"languages of region PA are selected correctly" ); "languages of region PA are selected correctly" );
deepEqual( $.uls.data.languagesInRegions( ["AM", "WW"] ), deepEqual( $.uls.data.languagesInRegions( ["AM", "WW"] ),
[ [
"akz", "arn", "aro", "ase", "avk", "ay", "cho", "chr", "chy", "cr-cans", "cr-latn", "cr", "akz", "arn", "aro", "ase", "avk", "ay", "cho", "chr", "chy", "cr-cans", "cr-latn",
"en-ca", "en", "eo", "es-419", "es-formal", "es", "esu", "fr", "cr", "en-ca", "en", "eo", "es-419", "es-formal", "es", "esu", "fr", "gcf", "gn",
"gcf", "gn", "guc", "haw", "ht", "ia", "ie", "ik", "ike-cans", "ike-latn", "io", "iu", "guc", "haw", "ht", "ia", "ie", "ik", "ike-cans", "ike-latn", "io", "iu", "jam",
"jam", "jbo", "kgp", "kl", "lad", "lfn", "mfe", "mic", "mus", "nah", "nl-informal", "nl", "nov", "nv", "jbo", "kgp", "kl", "lad", "lfn", "mfe", "mic", "mus", "nah", "nl-informal", "nl",
"pap", "pdc", "pdt", "ppl", "pt-br", "pt", "qu", "qug", "rap", "sei", "simple", "srn", "tokipona", "nov", "nv", "pap", "pdc", "pdt", "ppl", "pt-br", "pt", "qu", "qug", "rap", "sei",
"vo", "yi", "yrl", "yua" "simple", "srn", "tokipona", "vo", "yi", "yrl", "yua"
], ],
"languages of regions AM and WW are selected correctly" "languages of regions AM and WW are selected correctly"
); );
deepEqual( $.uls.data.languagesInScript( 'Knda' ), ["kn", "tcy"], "languages in script Knda are selected correctly" ); deepEqual( $.uls.data.languagesInScript( 'Knda' ), [
"kn", "tcy"
], "languages in script Knda are selected correctly" );
deepEqual( $.uls.data.languagesInScripts( ['Geor', 'Armn'] ), deepEqual( $.uls.data.languagesInScripts( ['Geor', 'Armn'] ),
["hy", "ka", "xmf"], ["hy", "ka", "xmf"],
"languages in scripts Geor and Armn are selected correctly" "languages in scripts Geor and Armn are selected correctly"
); );
deepEqual( $.uls.data.regionsInGroup( 3 ), ["EU", "ME", "AF"], "regions in group 2 are selected correctly" ); deepEqual( $.uls.data.regionsInGroup( 3 ), [
deepEqual( $.uls.data.regionsInGroup( 2 ), ["AM"], "regions in group 2 are selected correctly" ); "EU", "ME", "AF"
deepEqual( $.uls.data.regionsInGroup( 1 ), ["WW"], "regions in group 1 are selected correctly" ); ], "regions in group 2 are selected correctly" );
deepEqual( $.uls.data.regionsInGroup( 2 ), [
"AM"
], "regions in group 2 are selected correctly" );
deepEqual( $.uls.data.regionsInGroup( 1 ), [
"WW"
], "regions in group 1 are selected correctly" );
var languagesByScriptInAM = $.uls.data.languagesByScriptInRegion( "AM" ); var languagesByScriptInAM = $.uls.data.languagesByScriptInRegion( "AM" );
deepEqual( languagesByScriptInAM['Cans'], ["cr-cans", "cr", "ike-cans", "iu"], "correct languages in Cans in AM selected" ); deepEqual( languagesByScriptInAM['Cans'], [
"cr-cans", "cr", "ike-cans", "iu"
], "correct languages in Cans in AM selected" );
strictEqual( $.uls.data.autonym( 'pa' ), 'ਪੰਜਾਬੀ', 'Correct autonym of the Punjabi language was selected' ); strictEqual( $.uls.data.autonym( 'pa' ), 'ਪੰਜਾਬੀ', 'Correct autonym of the Punjabi language was selected' );
var languagesByScriptGroupInEMEA = $.uls.data.languagesByScriptGroupInRegions( $.uls.data.regionsInGroup( 3 ) ); var languagesByScriptGroupInEMEA = $.uls.data.languagesByScriptGroupInRegions( $.uls.data.regionsInGroup( 3 ) );
deepEqual( languagesByScriptGroupInEMEA['WestCaucasian'], ['hy', 'ka', 'xmf'], 'Correct languages in WestCaucasian script group in EMEA selected' ); deepEqual( languagesByScriptGroupInEMEA['WestCaucasian'], [
'hy', 'ka', 'xmf'
], 'Correct languages in WestCaucasian script group in EMEA selected' );
var allLanguagesByScriptGroup = $.uls.data.allLanguagesByScriptGroup(); var allLanguagesByScriptGroup = $.uls.data.allLanguagesByScriptGroup();
deepEqual( allLanguagesByScriptGroup['Greek'], ['el', 'grc', 'pnt', 'ruq-grek', 'tsd'], 'All languages in the Greek script found' ); deepEqual( allLanguagesByScriptGroup['Greek'], [
'el', 'grc', 'pnt', 'ruq-grek', 'tsd'
], 'All languages in the Greek script found' );
deepEqual( $.uls.data.allRegions(), ["WW", "AM", "EU", "ME", "AF", "AS", "PA"], "All regions found" ); deepEqual( $.uls.data.allRegions(), [
"WW", "AM", "EU", "ME", "AF", "AS", "PA"
], "All regions found" );
// autonyms: gn: avañe'ẽ, de: deutsch, hu: magyar, fi: suomi // autonyms: gn: avañe'ẽ, de: deutsch, hu: magyar, fi: suomi
deepEqual( ['de', 'fi', 'gn', 'hu'].sort( $.uls.data.sortByAutonym ), ['gn', 'de', 'hu', 'fi'], 'Languages are correctly sorted by autonym' ); deepEqual( ['de', 'fi', 'gn', 'hu'].sort( $.uls.data.sortByAutonym ), [
'gn', 'de', 'hu', 'fi'
], 'Languages are correctly sorted by autonym' );
strictEqual( $.uls.data.isRtl( "te" ), false, "Telugu language is not RTL" ); strictEqual( $.uls.data.isRtl( "te" ), false, "Telugu language is not RTL" );
strictEqual( $.uls.data.isRtl( "dv" ), true, "Divehi language is RTL" ); strictEqual( $.uls.data.isRtl( "dv" ), true, "Divehi language is RTL" );
ok( $.inArray( "sah", $.uls.data.languagesInTerritory( "RU" ) ) > -1, "Sakha language is spoken in Russia" ); ok( $.inArray( "sah", $.uls.data.languagesInTerritory( "RU" ) )
> -1, "Sakha language is spoken in Russia" );
} ); } );
}() ); }() );

View File

@@ -43,6 +43,7 @@
} ); } );
$fontSelector.trigger( 'change' ); $fontSelector.trigger( 'change' );
} }
listFonts( fonts ); listFonts( fonts );
$.each( languages, function ( lang, language ) { $.each( languages, function ( lang, language ) {
$langselector.append( $( "<option></option>" ).attr( $langselector.append( $( "<option></option>" ).attr(
@@ -110,7 +111,8 @@ select {
</div> </div>
</div> </div>
<div contenteditable="true" id="webfonts-preview-area">The quick brown fox jumps over the <div contenteditable="true" id="webfonts-preview-area">The quick brown fox jumps over the
lazy dog</div> lazy dog
</div>
</div> </div>
</div> </div>
</body> </body>