Index: trunk/phase3/tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.js |
— | — | @@ -1,12 +1,12 @@ |
2 | | -module( 'mediawiki.special.preferences.js' ); |
| 2 | +module( 'mw.special.recentchanges.js' ); |
3 | 3 | |
4 | 4 | test( '-- Initial check', function() { |
5 | 5 | expect( 2 ); |
6 | | - ok( mediaWiki.special.recentchanges.init, |
7 | | - 'mediaWiki.special.recentchanges.init defined' |
| 6 | + ok( mw.special.recentchanges.init, |
| 7 | + 'mw.special.recentchanges.init defined' |
8 | 8 | ); |
9 | | - ok( mediaWiki.special.recentchanges.updateCheckboxes, |
10 | | - 'mediaWiki.special.recentchanges.updateCheckboxes defined' |
| 9 | + ok( mw.special.recentchanges.updateCheckboxes, |
| 10 | + 'mw.special.recentchanges.updateCheckboxes defined' |
11 | 11 | ); |
12 | 12 | // TODO: verify checkboxes == [ 'nsassociated', 'nsinvert' ] |
13 | 13 | }); |
— | — | @@ -38,29 +38,29 @@ |
39 | 39 | // TODO abstract the double strictEquals |
40 | 40 | |
41 | 41 | // At first checkboxes are enabled |
42 | | - strictEqual( $('input#nsinvert').attr('disabled'), enabled); |
43 | | - strictEqual( $('input#nsassociated').attr('disabled'), enabled); |
| 42 | + strictEqual( $( '#nsinvert' ).attr( 'disabled' ), enabled ); |
| 43 | + strictEqual( $( '#nsassociated' ).attr( 'disabled' ), enabled ); |
44 | 44 | |
45 | 45 | // load our magic code to disable them |
46 | | - mediaWiki.special.recentchanges.init(); |
47 | | - strictEqual( $('#nsinvert').attr('disabled'), 'disabled'); |
48 | | - strictEqual( $('#nsassociated').attr('disabled'), 'disabled' ); |
| 46 | + mw.special.recentchanges.init(); |
| 47 | + strictEqual( $( '#nsinvert' ).attr( 'disabled' ), 'disabled' ); |
| 48 | + strictEqual( $( '#nsassociated' ).attr( 'disabled' ), 'disabled' ); |
49 | 49 | |
50 | 50 | // select second option... |
51 | | - $('select#namespace option:nth-child(1)').removeAttr( 'selected' ); |
52 | | - $('select#namespace option:nth-child(2)').attr( 'selected', 'selected' ); |
53 | | - $('select#namespace').change(); |
| 51 | + $( '#namespace option:nth-child(1)' ).removeAttr( 'selected' ); |
| 52 | + $( '#namespace option:nth-child(2)' ).attr( 'selected', 'selected' ); |
| 53 | + $( '#namespace' ).change(); |
54 | 54 | // ... and checkboxes should be enabled again |
55 | | - strictEqual( $('input#nsinvert').attr('disabled'), enabled); |
56 | | - strictEqual( $('input#nsassociated').attr('disabled'), enabled); |
| 55 | + strictEqual( $( '#nsinvert' ).attr( 'disabled' ), enabled ); |
| 56 | + strictEqual( $( '#nsassociated' ).attr( 'disabled' ), enabled ); |
57 | 57 | |
58 | | - // select first option ('all' namespace)... |
59 | | - $('select#namespace option:nth-child(1)').attr( 'selected', 'selected' ); |
60 | | - $('select#namespace option:nth-child(2)').removeAttr( 'selected' ); |
61 | | - $('select#namespace').change(); |
| 58 | + // select first option ( 'all' namespace)... |
| 59 | + $( '#namespace option:nth-child(1)' ).attr( 'selected', 'selected' ); |
| 60 | + $( '#namespace option:nth-child(2)' ).removeAttr( 'selected' ); |
| 61 | + $( '#namespace' ).change(); |
62 | 62 | // ... and checkboxes should now be disabled |
63 | | - strictEqual( $('#nsinvert').attr('disabled'), 'disabled'); |
64 | | - strictEqual( $('#nsassociated').attr('disabled'), 'disabled' ); |
| 63 | + strictEqual( $( '#nsinvert' ).attr( 'disabled' ), 'disabled' ); |
| 64 | + strictEqual( $( '#nsassociated' ).attr( 'disabled' ), 'disabled' ); |
65 | 65 | |
66 | 66 | // DOM cleanup |
67 | 67 | $env.remove(); |
Index: trunk/phase3/resources/mediawiki.special/mediawiki.special.recentchanges.js |
— | — | @@ -1,38 +1,40 @@ |
2 | 2 | /* JavaScript for Special:RecentChanges */ |
3 | | -( function( $, mw ) { |
| 3 | +( function( $ ) { |
4 | 4 | |
5 | | -mw.special.recentchanges = { |
6 | | - // -- Variables |
7 | | - 'select' : false, |
8 | | - 'checkboxes' : [ 'nsassociated', 'nsinvert' ], |
| 5 | + var checkboxes = [ 'nsassociated', 'nsinvert' ]; |
9 | 6 | |
10 | | - // -- Methods |
11 | | - 'init' : function() { |
12 | | - this.select = $( 'select#namespace' ); |
| 7 | + mw.special.recentchanges = { |
13 | 8 | |
14 | | - // Register an onChange trigger for the <select> element |
15 | | - this.select.change( function() { |
16 | | - mw.special.recentchanges.updateCheckboxes(); |
17 | | - }); |
18 | | - // on load, trigger the event to eventually update checkboxes statuses |
19 | | - this.select.change(); |
20 | | - }, |
| 9 | + /** |
| 10 | + * @var select {jQuery} |
| 11 | + */ |
| 12 | + $select: null, |
| 13 | + |
| 14 | + init: function() { |
| 15 | + var rc = this; |
| 16 | + |
| 17 | + rc.$select = |
| 18 | + $( 'select#namespace' ) |
| 19 | + .change( rc.updateCheckboxes ) |
| 20 | + // Trigger once set the initial statuses of the checkboxes. |
| 21 | + .change(); |
| 22 | + }, |
21 | 23 | |
22 | | - /** |
23 | | - * handler to disable/enable the namespace selector checkboxes when the |
24 | | - * special 'all' namespace is selected/unselected respectively. |
25 | | - */ |
26 | | - 'updateCheckboxes' : function() { |
27 | | - // The 'all' namespace is the FIRST in the list. |
28 | | - var isAllNS = this.select.find( 'option' ).first().is( ':selected' ); |
| 24 | + /** |
| 25 | + * Handler to disable/enable the namespace selector checkboxes when the |
| 26 | + * special 'all' namespace is selected/unselected respectively. |
| 27 | + */ |
| 28 | + updateCheckboxes: function() { |
| 29 | + // The 'all' namespace is the FIRST in the list. |
| 30 | + var isAllNS = mw.special.recentchanges.$select.find( 'option' ).first().is( ':selected' ); |
29 | 31 | |
30 | | - // Iterates over checkboxes and propagate the selected option |
31 | | - $.map( this.checkboxes, function(id) { |
32 | | - $( 'input#'+id ).attr( 'disabled', isAllNS ); |
33 | | - }); |
34 | | - }, |
35 | | -}; |
| 32 | + // Iterates over checkboxes and propagate the selected option |
| 33 | + $.map( checkboxes, function( id ) { |
| 34 | + $( '#'+id ).attr( 'disabled', isAllNS ); |
| 35 | + }); |
| 36 | + }, |
| 37 | + }; |
36 | 38 | |
37 | | -mw.special.recentchanges.init(); |
| 39 | + mw.special.recentchanges.init(); |
38 | 40 | |
39 | | -}(jQuery, mediaWiki ) ); |
| 41 | +})( jQuery ); |
Index: trunk/phase3/resources/mediawiki.special/mediawiki.special.js |
— | — | @@ -1,5 +1 @@ |
2 | | -( function( $, mw ) { |
3 | | - |
4 | | - mw.special = {}; |
5 | | - |
6 | | -} )( jQuery, mediaWiki ); |
| 2 | +mw.special = {}; |