r109098 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109097‎ | r109098 | r109099 >
Date:01:12, 17 January 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
attempt to get around weird 1.18 issue
Modified paths:
  • /trunk/extensions/EducationProgram/resources/ep.js (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/resources/ep.js
@@ -8,10 +8,43 @@
99
1010 window.educationProgram = new( function() {
1111
12 - this.compatMode = true;
 12+ this.compatMode = null;
1313
1414 this.msg = function () {
15 - if ( window.educationProgram.compatMode ) {
 15+ // Yeah, doing it here, since "mw.loader.using( 'mediawiki.language',"
 16+ // does not have mediaWiki.language loaded.
 17+ if ( this.compatMode === null ) {
 18+ this.compatMode = typeof window.mediaWiki.language.gender === 'undefined';
 19+
 20+ if ( window.educationProgram.compatMode ) {
 21+ mw.language.gender = function( gender, forms ) {
 22+ if ( !forms || forms.length === 0 ) {
 23+ return '';
 24+ }
 25+ forms = mw.language.preConvertPlural( forms, 2 );
 26+ if ( gender === 'male' ) {
 27+ return forms[0];
 28+ }
 29+ if ( gender === 'female' ) {
 30+ return forms[1];
 31+ }
 32+ return ( forms.length === 3 ) ? forms[2] : forms[0];
 33+ };
 34+
 35+ mw.jqueryMsg.htmlEmitter.prototype.gender = function( nodes ) {
 36+ var gender;
 37+ if ( nodes[0] && nodes[0].options instanceof mw.Map ){
 38+ gender = nodes[0].options.get( 'gender' );
 39+ } else {
 40+ gender = nodes[0];
 41+ }
 42+ var forms = nodes.slice(1);
 43+ return this.language.gender( gender, forms );
 44+ };
 45+ }
 46+ }
 47+
 48+ if ( this.compatMode ) {
1649 return gM.apply( this, arguments );
1750 }
1851 else {
@@ -24,35 +57,3 @@
2558 };
2659
2760 } );
28 -
29 -mw.loader.using( 'mediawiki.language', function() {
30 - window.educationProgram.compatMode = typeof window.mediaWiki.language === 'undefined';
31 -
32 - if ( window.educationProgram.compatMode ) {
33 - mw.language.gender = function( gender, forms ) {
34 - if ( !forms || forms.length === 0 ) {
35 - return '';
36 - }
37 - forms = mw.language.preConvertPlural( forms, 2 );
38 - if ( gender === 'male' ) {
39 - return forms[0];
40 - }
41 - if ( gender === 'female' ) {
42 - return forms[1];
43 - }
44 - return ( forms.length === 3 ) ? forms[2] : forms[0];
45 - };
46 -
47 - mw.jqueryMsg.htmlEmitter.prototype.gender = function( nodes ) {
48 - var gender;
49 - if ( nodes[0] && nodes[0].options instanceof mw.Map ){
50 - gender = nodes[0].options.get( 'gender' );
51 - } else {
52 - gender = nodes[0];
53 - }
54 - var forms = nodes.slice(1);
55 - return this.language.gender( gender, forms );
56 - };
57 - }
58 -
59 -} );
\ No newline at end of file

Status & tagging log