Index: trunk/extensions/EducationProgram/resources/ep.js |
— | — | @@ -6,54 +6,58 @@ |
7 | 7 | * @author Jeroen De Dauw <jeroendedauw at gmail dot com> |
8 | 8 | */ |
9 | 9 | |
10 | | -window.educationProgram = new( function() { |
11 | | - |
12 | | - this.compatMode = null; |
13 | | - |
14 | | - this.msg = function () { |
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 | | - }; |
| 10 | +( function ( $, mw ) { |
| 11 | + |
| 12 | + var compatMode = undefined; |
| 13 | + |
| 14 | + var ep = { |
| 15 | + msg: function () { |
| 16 | + // Yeah, doing it here, since "mw.loader.using( 'mediawiki.language'," |
| 17 | + // does not have mediaWiki.language loaded. |
| 18 | + if ( compatMode === undefined ) { |
| 19 | + compatMode = window.mediaWiki.language.gender === undefined; |
| 20 | + |
| 21 | + if ( compatMode ) { |
| 22 | + mw.language.gender = function( gender, forms ) { |
| 23 | + if ( !forms || forms.length === 0 ) { |
| 24 | + return ''; |
| 25 | + } |
| 26 | + forms = mw.language.preConvertPlural( forms, 2 ); |
| 27 | + if ( gender === 'male' ) { |
| 28 | + return forms[0]; |
| 29 | + } |
| 30 | + if ( gender === 'female' ) { |
| 31 | + return forms[1]; |
| 32 | + } |
| 33 | + return ( forms.length === 3 ) ? forms[2] : forms[0]; |
| 34 | + }; |
| 35 | + |
| 36 | + mw.jqueryMsg.htmlEmitter.prototype.gender = function( nodes ) { |
| 37 | + var gender; |
| 38 | + if ( nodes[0] && nodes[0].options instanceof mw.Map ){ |
| 39 | + gender = nodes[0].options.get( 'gender' ); |
| 40 | + } else { |
| 41 | + gender = nodes[0]; |
| 42 | + } |
| 43 | + var forms = nodes.slice(1); |
| 44 | + return this.language.gender( gender, forms ); |
| 45 | + }; |
| 46 | + } |
45 | 47 | } |
| 48 | + |
| 49 | + if ( compatMode ) { |
| 50 | + return gM.apply( this, arguments ); |
| 51 | + } |
| 52 | + else { |
| 53 | + return mw.msg.apply( this, arguments ); |
| 54 | + } |
| 55 | + }, |
| 56 | + |
| 57 | + msge: function () { |
| 58 | + return mw.html.escape( this.msg.apply( this, arguments ) ); |
46 | 59 | } |
47 | | - |
48 | | - if ( this.compatMode ) { |
49 | | - return gM.apply( this, arguments ); |
50 | | - } |
51 | | - else { |
52 | | - return mw.msg.apply( this, arguments ); |
53 | | - } |
54 | | - }; |
55 | | - |
56 | | - this.msge = function () { |
57 | | - return mw.html.escape( this.msg.apply( this, arguments ) ); |
58 | | - }; |
59 | | - |
60 | | -} ); |
| 60 | + } |
| 61 | + |
| 62 | + mw.educationProgram = ep; |
| 63 | + |
| 64 | +}( jQuery, mediaWiki ) ); |
Index: trunk/extensions/EducationProgram/resources/ep.api.js |
— | — | @@ -6,9 +6,9 @@ |
7 | 7 | * @author Jeroen De Dauw <jeroendedauw at gmail dot com> |
8 | 8 | */ |
9 | 9 | |
10 | | -window.educationProgram.api = new( function() { |
| 10 | +( function ( $, mw ) { |
11 | 11 | |
12 | | - this.remove = function( data, callback ) { |
| 12 | + mw.educationProgram.remove = function( data, callback ) { |
13 | 13 | var requestArgs = { |
14 | 14 | 'action': 'deleteeducation', |
15 | 15 | 'format': 'json', |
— | — | @@ -29,40 +29,6 @@ |
30 | 30 | } |
31 | 31 | ); |
32 | 32 | }; |
33 | | - |
34 | | - this.instructor = function( args ) { |
35 | | - var requestArgs = $.extend( { |
36 | | - 'action': 'instructor', |
37 | | - 'format': 'json', |
38 | | - 'token': window.mw.user.tokens.get( 'editToken' ) |
39 | | - }, args ); |
40 | | - |
41 | | - var deferred = $.Deferred(); |
42 | | - |
43 | | - $.post( |
44 | | - wgScriptPath + '/api.php', |
45 | | - requestArgs, |
46 | | - function( data ) { |
47 | | - if ( data.hasOwnProperty( 'success' ) && data.success ) { |
48 | | - deferred.resolve(); |
49 | | - } |
50 | | - else { |
51 | | - deferred.reject(); |
52 | | - } |
53 | | - } |
54 | | - ); |
55 | | - |
56 | | - return deferred.promise(); |
57 | | - }; |
58 | | - |
59 | | - this.addInstructor = function( args ) { |
60 | | - args.subaction = 'add'; |
61 | | - return this.instructor( args ); |
62 | | - }; |
63 | | - |
64 | | - this.removeInstructor = function( args ) { |
65 | | - args.subaction = 'remove'; |
66 | | - return this.instructor( args ); |
67 | | - }; |
68 | 33 | |
69 | | -} ); |
| 34 | +}( jQuery, mediaWiki ) ); |
| 35 | + |
Index: trunk/extensions/EducationProgram/resources/ep.instructor.js |
— | — | @@ -6,8 +6,10 @@ |
7 | 7 | * @author Jeroen De Dauw <jeroendedauw at gmail dot com> |
8 | 8 | */ |
9 | 9 | |
10 | | -(function( $, mw, ep ) { |
11 | | - |
| 10 | +(function( $, mw ) { |
| 11 | + |
| 12 | + var ep = mw.educationProgram; |
| 13 | + |
12 | 14 | $( document ).ready( function() { |
13 | 15 | |
14 | 16 | $( '.ep-instructor-remove' ).click( function( event ) { |
— | — | @@ -148,7 +150,7 @@ |
149 | 151 | 'text': ep.msg( 'ep-instructor-add-cancel-button' ), |
150 | 152 | 'id': 'ep-instructor-add-cancel-button', |
151 | 153 | 'click': function() { |
152 | | - $dialog.dialog( 'close' ); |
| 154 | + _this.$dialog.dialog( 'close' ); |
153 | 155 | } |
154 | 156 | } |
155 | 157 | ] |
— | — | @@ -195,4 +197,4 @@ |
196 | 198 | |
197 | 199 | } ); |
198 | 200 | |
199 | | -})( window.jQuery, window.mediaWiki, window.educationProgram ); |
\ No newline at end of file |
| 201 | +})( window.jQuery, window.mediaWiki ); |
\ No newline at end of file |
Index: trunk/extensions/EducationProgram/resources/ep.pager.js |
— | — | @@ -6,8 +6,10 @@ |
7 | 7 | * @author Jeroen De Dauw <jeroendedauw at gmail dot com> |
8 | 8 | */ |
9 | 9 | |
10 | | -(function ( $, mw, ep ) { |
| 10 | +(function ( $, mw ) { |
11 | 11 | |
| 12 | + var ep = mw.educationProgram; |
| 13 | + |
12 | 14 | $( document ).ready( function () { |
13 | 15 | |
14 | 16 | $( '.ep-pager-clear' ).click( function () { |
— | — | @@ -101,4 +103,4 @@ |
102 | 104 | |
103 | 105 | } ); |
104 | 106 | |
105 | | -})( window.jQuery, window.mediaWiki, window.educationProgram ); |
\ No newline at end of file |
| 107 | +})( window.jQuery, window.mediaWiki ); |
\ No newline at end of file |