http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90984
Revision: 90984
Author: krinkle
Date: 2011-06-28 17:56:56 +0000 (Tue, 28 Jun 2011)
Log Message:
-----------
mw.special.recentchanges fixes:
- Partial self-revert of r90982 (binding and triggering must not be chained, as
the calling function refers to the variable we're setting)
- The Qunit tests pass now :)
Follows up: r90943 r90960 r90968 r90980 r90982
Modified Paths:
--------------
trunk/phase3/resources/Resources.php
trunk/phase3/resources/mediawiki.special/mediawiki.special.recentchanges.js
trunk/phase3/tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.js
Modified: trunk/phase3/resources/Resources.php
===================================================================
--- trunk/phase3/resources/Resources.php 2011-06-28 17:47:29 UTC (rev
90983)
+++ trunk/phase3/resources/Resources.php 2011-06-28 17:56:56 UTC (rev
90984)
@@ -538,6 +538,7 @@
'mediawiki.special.recentchanges' => array(
'scripts' =>
'resources/mediawiki.special/mediawiki.special.recentchanges.js',
'dependencies' => array( 'mediawiki.special' ),
+ 'position' => 'top',
),
'mediawiki.special.upload' => array(
// @TODO: merge in remainder of mediawiki.legacy.upload
Modified:
trunk/phase3/resources/mediawiki.special/mediawiki.special.recentchanges.js
===================================================================
--- trunk/phase3/resources/mediawiki.special/mediawiki.special.recentchanges.js
2011-06-28 17:47:29 UTC (rev 90983)
+++ trunk/phase3/resources/mediawiki.special/mediawiki.special.recentchanges.js
2011-06-28 17:56:56 UTC (rev 90984)
@@ -3,22 +3,12 @@
var checkboxes = [ 'nsassociated', 'nsinvert' ];
- mw.special.recentchanges = {
+ /**
+ * @var select {jQuery}
+ */
+ var $select = null;
- /**
- * @var select {jQuery}
- */
- $select: null,
-
- init: function() {
- var rc = this;
-
- rc.$select =
- $( 'select#namespace' )
- .change( rc.updateCheckboxes )
- // Trigger once set the initial
statuses of the checkboxes.
- .change();
- },
+ var rc = mw.special.recentchanges = {
/**
* Handler to disable/enable the namespace selector checkboxes
when the
@@ -26,15 +16,24 @@
*/
updateCheckboxes: function() {
// The 'all' namespace is the FIRST in the list.
- var isAllNS = mw.special.recentchanges.$select.find(
'option' ).first().is( ':selected' );
+ var isAllNS = $select.find( 'option' ).first().is(
':selected' );
// Iterates over checkboxes and propagate the selected
option
- $.map( checkboxes, function( id ) {
- $( '#'+id ).attr( 'disabled', isAllNS );
+ $.each( checkboxes, function( i, id ) {
+ $( '#' + id ).attr( 'disabled', isAllNS );
});
},
+
+ init: function() {
+ // Populate & bind
+ $select = $( '#namespace' ).change( rc.updateCheckboxes
);
+
+ // Trigger once set the initial statuses of the
checkboxes.
+ $select.change();
+ }
};
- mw.special.recentchanges.init();
+ // Run when document is ready
+ $( rc.init );
})( jQuery );
Modified:
trunk/phase3/tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.js
===================================================================
---
trunk/phase3/tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.js
2011-06-28 17:47:29 UTC (rev 90983)
+++
trunk/phase3/tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.js
2011-06-28 17:56:56 UTC (rev 90984)
@@ -33,31 +33,35 @@
;
var $env = $( '<div>' ).html( select ).appendTo( 'body' );
- var enabled = undefined;
// TODO abstract the double strictEquals
// At first checkboxes are enabled
- strictEqual( $( '#nsinvert' ).attr( 'disabled' ), enabled );
- strictEqual( $( '#nsassociated' ).attr( 'disabled' ), enabled );
+ strictEqual( $( '#nsinvert' ).attr( 'disabled' ), undefined );
+ strictEqual( $( '#nsassociated' ).attr( 'disabled' ), undefined );
- // load our magic code to disable them
+ // Initiate the recentchanges module
mw.special.recentchanges.init();
+
+ // By default
strictEqual( $( '#nsinvert' ).attr( 'disabled' ), 'disabled' );
strictEqual( $( '#nsassociated' ).attr( 'disabled' ), 'disabled' );
// select second option...
- $( '#namespace option:nth-child(1)' ).removeAttr( 'selected' );
- $( '#namespace option:nth-child(2)' ).attr( 'selected', 'selected' );
+ var $options = $( '#namespace' ).find( 'option' );
+ $options.eq(0).removeAttr( 'selected' );
+ $options.eq(1).attr( 'selected', 'selected' );
$( '#namespace' ).change();
+
// ... and checkboxes should be enabled again
- strictEqual( $( '#nsinvert' ).attr( 'disabled' ), enabled );
- strictEqual( $( '#nsassociated' ).attr( 'disabled' ), enabled );
+ strictEqual( $( '#nsinvert' ).attr( 'disabled' ), undefined );
+ strictEqual( $( '#nsassociated' ).attr( 'disabled' ), undefined );
// select first option ( 'all' namespace)...
- $( '#namespace option:nth-child(1)' ).attr( 'selected', 'selected' );
- $( '#namespace option:nth-child(2)' ).removeAttr( 'selected' );
+ $options.eq(1).removeAttr( 'selected' );
+ $options.eq(0).attr( 'selected', 'selected' );;
$( '#namespace' ).change();
+
// ... and checkboxes should now be disabled
strictEqual( $( '#nsinvert' ).attr( 'disabled' ), 'disabled' );
strictEqual( $( '#nsassociated' ).attr( 'disabled' ), 'disabled' );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs