From: Antoine Musso Date: Tue, 28 Jun 2011 06:40:49 +0000 (+0000) Subject: Disable ns selector checkboxes when 'all' namespace is selected X-Git-Tag: 1.31.0-rc.0~29228 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=d4abcb52680621dbc773e82e2d2e0ee5fa5a4c60;p=lhc%2Fweb%2Fwiklou.git Disable ns selector checkboxes when 'all' namespace is selected * based on an idea by Aaron on r90866 * comes with QUnit test * expect the special 'all' namespace to be the first in the list * function build on mediawiki.special form r90941 --- diff --git a/includes/Xml.php b/includes/Xml.php index a100a8bf28..1e8696be1e 100644 --- a/includes/Xml.php +++ b/includes/Xml.php @@ -132,6 +132,8 @@ class Xml { } if( !is_null( $all ) ) + # Please make sure the 'namespacesall' is the first or you will break + # such an assumption (ex js: mw.special.recentchanges.updateCheckboxes) $namespaces = array( $all => wfMsg( 'namespacesall' ) ) + $namespaces; foreach( $namespaces as $index => $name ) { if( $index < NS_MAIN ) { diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index da5d5f0072..da7babe67a 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -140,6 +140,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { $opts = $this->getOptions(); $this->setHeaders(); $this->outputHeader(); + $this->addRecentChangesJS(); // Fetch results, prepare a batch link existence check query $conds = $this->buildMainQueryConds( $opts ); @@ -839,4 +840,14 @@ class SpecialRecentChanges extends IncludableSpecialPage { $rclistfrom = wfMsgExt( 'rclistfrom', array( 'parseinline', 'replaceafter' ), $tl ); return "{$note}$rclinks
$rclistfrom"; } + + /** + * add javascript specific to the [[Special:RecentChanges]] page + */ + function addRecentChangesJS() { + global $wgOut; + $wgOut->addModules( array( + 'mediawiki.special.recentchanges', + ) ); + } } diff --git a/resources/Resources.php b/resources/Resources.php index 38965c5e40..c942e28d74 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -534,6 +534,13 @@ return array( 'scripts' => 'resources/mediawiki.special/mediawiki.special.movePage.js', 'dependencies' => 'jquery.byteLimit', ), + 'mediawiki.special' => array( + 'scripts' => 'resources/mediawiki/mediawiki.special.js', + ), + 'mediawiki.special.recentchanges' => array( + 'scripts' => 'resources/mediawiki.special/mediawiki.special.recentchanges.js', + 'dependencies' => array( 'mediawiki.special' ), + ), 'mediawiki.special.upload' => array( // @TODO: merge in remainder of mediawiki.legacy.upload 'scripts' => 'resources/mediawiki.special/mediawiki.special.upload.js', diff --git a/resources/mediawiki.special/mediawiki.special.recentchanges.js b/resources/mediawiki.special/mediawiki.special.recentchanges.js new file mode 100644 index 0000000000..1006a9d204 --- /dev/null +++ b/resources/mediawiki.special/mediawiki.special.recentchanges.js @@ -0,0 +1,38 @@ +/* JavaScript for Special:RecentChanges */ +( function( $, mw ) { + +mw.special.recentchanges = { + // -- Variables + 'select' : false, + 'checkboxes' : [ 'nsassociated', 'nsinvert' ], + + // -- Methods + 'init' : function() { + this.select = $( 'select#namespace' ); + + // Register an onChange trigger for the