Index: trunk/phase3/tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.js |
— | — | @@ -33,31 +33,35 @@ |
34 | 34 | ; |
35 | 35 | |
36 | 36 | var $env = $( '<div>' ).html( select ).appendTo( 'body' ); |
37 | | - var enabled = undefined; |
38 | 37 | |
39 | 38 | // TODO abstract the double strictEquals |
40 | 39 | |
41 | 40 | // At first checkboxes are enabled |
42 | | - strictEqual( $( '#nsinvert' ).attr( 'disabled' ), enabled ); |
43 | | - strictEqual( $( '#nsassociated' ).attr( 'disabled' ), enabled ); |
| 41 | + strictEqual( $( '#nsinvert' ).attr( 'disabled' ), undefined ); |
| 42 | + strictEqual( $( '#nsassociated' ).attr( 'disabled' ), undefined ); |
44 | 43 | |
45 | | - // load our magic code to disable them |
| 44 | + // Initiate the recentchanges module |
46 | 45 | mw.special.recentchanges.init(); |
| 46 | + |
| 47 | + // By default |
47 | 48 | strictEqual( $( '#nsinvert' ).attr( 'disabled' ), 'disabled' ); |
48 | 49 | strictEqual( $( '#nsassociated' ).attr( 'disabled' ), 'disabled' ); |
49 | 50 | |
50 | 51 | // select second option... |
51 | | - $( '#namespace option:nth-child(1)' ).removeAttr( 'selected' ); |
52 | | - $( '#namespace option:nth-child(2)' ).attr( 'selected', 'selected' ); |
| 52 | + var $options = $( '#namespace' ).find( 'option' ); |
| 53 | + $options.eq(0).removeAttr( 'selected' ); |
| 54 | + $options.eq(1).attr( 'selected', 'selected' ); |
53 | 55 | $( '#namespace' ).change(); |
| 56 | + |
54 | 57 | // ... and checkboxes should be enabled again |
55 | | - strictEqual( $( '#nsinvert' ).attr( 'disabled' ), enabled ); |
56 | | - strictEqual( $( '#nsassociated' ).attr( 'disabled' ), enabled ); |
| 58 | + strictEqual( $( '#nsinvert' ).attr( 'disabled' ), undefined ); |
| 59 | + strictEqual( $( '#nsassociated' ).attr( 'disabled' ), undefined ); |
57 | 60 | |
58 | 61 | // select first option ( 'all' namespace)... |
59 | | - $( '#namespace option:nth-child(1)' ).attr( 'selected', 'selected' ); |
60 | | - $( '#namespace option:nth-child(2)' ).removeAttr( 'selected' ); |
| 62 | + $options.eq(1).removeAttr( 'selected' ); |
| 63 | + $options.eq(0).attr( 'selected', 'selected' );; |
61 | 64 | $( '#namespace' ).change(); |
| 65 | + |
62 | 66 | // ... and checkboxes should now be disabled |
63 | 67 | strictEqual( $( '#nsinvert' ).attr( 'disabled' ), 'disabled' ); |
64 | 68 | strictEqual( $( '#nsassociated' ).attr( 'disabled' ), 'disabled' ); |
Index: trunk/phase3/resources/Resources.php |
— | — | @@ -538,6 +538,7 @@ |
539 | 539 | 'mediawiki.special.recentchanges' => array( |
540 | 540 | 'scripts' => 'resources/mediawiki.special/mediawiki.special.recentchanges.js', |
541 | 541 | 'dependencies' => array( 'mediawiki.special' ), |
| 542 | + 'position' => 'top', |
542 | 543 | ), |
543 | 544 | 'mediawiki.special.upload' => array( |
544 | 545 | // @TODO: merge in remainder of mediawiki.legacy.upload |
Index: trunk/phase3/resources/mediawiki.special/mediawiki.special.recentchanges.js |
— | — | @@ -3,22 +3,12 @@ |
4 | 4 | |
5 | 5 | var checkboxes = [ 'nsassociated', 'nsinvert' ]; |
6 | 6 | |
7 | | - mw.special.recentchanges = { |
| 7 | + /** |
| 8 | + * @var select {jQuery} |
| 9 | + */ |
| 10 | + var $select = null; |
8 | 11 | |
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 | | - }, |
| 12 | + var rc = mw.special.recentchanges = { |
23 | 13 | |
24 | 14 | /** |
25 | 15 | * Handler to disable/enable the namespace selector checkboxes when the |
— | — | @@ -26,15 +16,24 @@ |
27 | 17 | */ |
28 | 18 | updateCheckboxes: function() { |
29 | 19 | // The 'all' namespace is the FIRST in the list. |
30 | | - var isAllNS = mw.special.recentchanges.$select.find( 'option' ).first().is( ':selected' ); |
| 20 | + var isAllNS = $select.find( 'option' ).first().is( ':selected' ); |
31 | 21 | |
32 | 22 | // Iterates over checkboxes and propagate the selected option |
33 | | - $.map( checkboxes, function( id ) { |
34 | | - $( '#'+id ).attr( 'disabled', isAllNS ); |
| 23 | + $.each( checkboxes, function( i, id ) { |
| 24 | + $( '#' + id ).attr( 'disabled', isAllNS ); |
35 | 25 | }); |
36 | 26 | }, |
| 27 | + |
| 28 | + init: function() { |
| 29 | + // Populate & bind |
| 30 | + $select = $( '#namespace' ).change( rc.updateCheckboxes ); |
| 31 | + |
| 32 | + // Trigger once set the initial statuses of the checkboxes. |
| 33 | + $select.change(); |
| 34 | + } |
37 | 35 | }; |
38 | 36 | |
39 | | - mw.special.recentchanges.init(); |
| 37 | + // Run when document is ready |
| 38 | + $( rc.init ); |
40 | 39 | |
41 | 40 | })( jQuery ); |