Index: trunk/phase3/resources/Resources.php |
— | — | @@ -534,6 +534,13 @@ |
535 | 535 | 'scripts' => 'resources/mediawiki.special/mediawiki.special.movePage.js', |
536 | 536 | 'dependencies' => 'jquery.byteLimit', |
537 | 537 | ), |
| 538 | + 'mediawiki.special' => array( |
| 539 | + 'scripts' => 'resources/mediawiki/mediawiki.special.js', |
| 540 | + ), |
| 541 | + 'mediawiki.special.recentchanges' => array( |
| 542 | + 'scripts' => 'resources/mediawiki.special/mediawiki.special.recentchanges.js', |
| 543 | + 'dependencies' => array( 'mediawiki.special' ), |
| 544 | + ), |
538 | 545 | 'mediawiki.special.upload' => array( |
539 | 546 | // @TODO: merge in remainder of mediawiki.legacy.upload |
540 | 547 | 'scripts' => 'resources/mediawiki.special/mediawiki.special.upload.js', |
Index: trunk/phase3/resources/mediawiki.special/mediawiki.special.recentchanges.js |
— | — | @@ -0,0 +1,38 @@ |
| 2 | +/* JavaScript for Special:RecentChanges */ |
| 3 | +( function( $, mw ) { |
| 4 | + |
| 5 | +mw.special.recentchanges = { |
| 6 | + // -- Variables |
| 7 | + 'select' : false, |
| 8 | + 'checkboxes' : [ 'nsassociated', 'nsinvert' ], |
| 9 | + |
| 10 | + // -- Methods |
| 11 | + 'init' : function() { |
| 12 | + this.select = $( 'select#namespace' ); |
| 13 | + |
| 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 | + }, |
| 21 | + |
| 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' ); |
| 29 | + |
| 30 | + // Iterates over checkboxes and propagate the selected option |
| 31 | + $.map( this.checkboxes, function(id) { |
| 32 | + $( 'input#'+id ).attr( 'disabled', isAllNS ); |
| 33 | + }); |
| 34 | + }, |
| 35 | +}; |
| 36 | + |
| 37 | +mw.special.recentchanges.init(); |
| 38 | + |
| 39 | +}(jQuery, mediaWiki ) ); |
Property changes on: trunk/phase3/resources/mediawiki.special/mediawiki.special.recentchanges.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 40 | + native |
Index: trunk/phase3/tests/qunit/index.html |
— | — | @@ -44,6 +44,8 @@ |
45 | 45 | <script src="../../resources/jquery/jquery.tabIndex.js"></script> |
46 | 46 | <script src="../../resources/jquery/jquery.tablesorter.js"></script> |
47 | 47 | <script src="../../resources/mediawiki/mediawiki.Title.js"></script> |
| 48 | + <script src="../../resources/mediawiki/mediawiki.special.js"></script> |
| 49 | + <script src="../../resources/mediawiki.special/mediawiki.special.recentchanges.js"></script> |
48 | 50 | |
49 | 51 | <!-- QUnit: Load framework --> |
50 | 52 | <link rel="stylesheet" href="../../resources/jquery/jquery.qunit.css" /> |
— | — | @@ -62,6 +64,7 @@ |
63 | 65 | <script src="suites/resources/jquery/jquery.tabIndex.js"></script> |
64 | 66 | <script src="suites/resources/jquery/jquery.tablesorter.test.js" charset="UTF-8"></script> |
65 | 67 | <script src="suites/resources/mediawiki/mediawiki.Title.js"></script> |
| 68 | + <script src="suites/resources/mediawiki.special/mediawiki.special.recentchanges.js"></script> |
66 | 69 | |
67 | 70 | <!-- TestSwarm: If a test swarm is running this, |
68 | 71 | the following script will allow it to extract the results. |
Index: trunk/phase3/tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.js |
— | — | @@ -0,0 +1,67 @@ |
| 2 | +module( 'mediawiki.special.preferences.js' ); |
| 3 | + |
| 4 | +test( '-- Initial check', function() { |
| 5 | + expect( 2 ); |
| 6 | + ok( mediaWiki.special.recentchanges.init, |
| 7 | + 'mediaWiki.special.recentchanges.init defined' |
| 8 | + ); |
| 9 | + ok( mediaWiki.special.recentchanges.updateCheckboxes, |
| 10 | + 'mediaWiki.special.recentchanges.updateCheckboxes defined' |
| 11 | + ); |
| 12 | + // TODO: verify checkboxes == [ 'nsassociated', 'nsinvert' ] |
| 13 | +}); |
| 14 | + |
| 15 | +test( 'foobar', function() { |
| 16 | + |
| 17 | + // from Special:Recentchanges |
| 18 | + var select = |
| 19 | + '<select id="namespace" name="namespace" class="namespaceselector">' |
| 20 | + + '<option value="" selected="selected">all</option>' |
| 21 | + + '<option value="0">(Main)</option>' |
| 22 | + + '<option value="1">Talk</option>' |
| 23 | + + '<option value="2">User</option>' |
| 24 | + + '<option value="3">User talk</option>' |
| 25 | + + '<option value="4">ProjectName</option>' |
| 26 | + + '<option value="5">ProjectName talk</option>' |
| 27 | + + '</select>' |
| 28 | + + '<input name="invert" type="checkbox" value="1" id="nsinvert" title="no title" />' |
| 29 | + + '<label for="nsinvert" title="no title">Invert selection</label>' |
| 30 | + + '<input name="associated" type="checkbox" value="1" id="nsassociated" title="no title" />' |
| 31 | + + '<label for="nsassociated" title="no title">Associated namespace</label>' |
| 32 | + + '<input type="submit" value="Go" />' |
| 33 | + + '<input type="hidden" value="Special:RecentChanges" name="title" />' |
| 34 | + ; |
| 35 | + |
| 36 | + var $env = $( '<div>' ).html( select ).appendTo( 'body' ); |
| 37 | + var enabled = undefined; |
| 38 | + |
| 39 | + // TODO abstract the double strictEquals |
| 40 | + |
| 41 | + // At first checkboxes are enabled |
| 42 | + strictEqual( $('input#nsinvert').attr('disabled'), enabled); |
| 43 | + strictEqual( $('input#nsassociated').attr('disabled'), enabled); |
| 44 | + |
| 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' ); |
| 49 | + |
| 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(); |
| 54 | + // ... and checkboxes should be enabled again |
| 55 | + strictEqual( $('input#nsinvert').attr('disabled'), enabled); |
| 56 | + strictEqual( $('input#nsassociated').attr('disabled'), enabled); |
| 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(); |
| 62 | + // ... and checkboxes should now be disabled |
| 63 | + strictEqual( $('#nsinvert').attr('disabled'), 'disabled'); |
| 64 | + strictEqual( $('#nsassociated').attr('disabled'), 'disabled' ); |
| 65 | + |
| 66 | + // DOM cleanup |
| 67 | + $env.remove(); |
| 68 | +}); |
Property changes on: trunk/phase3/tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 69 | + native |
Index: trunk/phase3/includes/Xml.php |
— | — | @@ -132,6 +132,8 @@ |
133 | 133 | } |
134 | 134 | |
135 | 135 | if( !is_null( $all ) ) |
| 136 | + # Please make sure the 'namespacesall' is the first or you will break |
| 137 | + # such an assumption (ex js: mw.special.recentchanges.updateCheckboxes) |
136 | 138 | $namespaces = array( $all => wfMsg( 'namespacesall' ) ) + $namespaces; |
137 | 139 | foreach( $namespaces as $index => $name ) { |
138 | 140 | if( $index < NS_MAIN ) { |
Index: trunk/phase3/includes/specials/SpecialRecentchanges.php |
— | — | @@ -140,6 +140,7 @@ |
141 | 141 | $opts = $this->getOptions(); |
142 | 142 | $this->setHeaders(); |
143 | 143 | $this->outputHeader(); |
| 144 | + $this->addRecentChangesJS(); |
144 | 145 | |
145 | 146 | // Fetch results, prepare a batch link existence check query |
146 | 147 | $conds = $this->buildMainQueryConds( $opts ); |
— | — | @@ -839,4 +840,14 @@ |
840 | 841 | $rclistfrom = wfMsgExt( 'rclistfrom', array( 'parseinline', 'replaceafter' ), $tl ); |
841 | 842 | return "{$note}$rclinks<br />$rclistfrom"; |
842 | 843 | } |
| 844 | + |
| 845 | + /** |
| 846 | + * add javascript specific to the [[Special:RecentChanges]] page |
| 847 | + */ |
| 848 | + function addRecentChangesJS() { |
| 849 | + global $wgOut; |
| 850 | + $wgOut->addModules( array( |
| 851 | + 'mediawiki.special.recentchanges', |
| 852 | + ) ); |
| 853 | + } |
843 | 854 | } |