MediaWiki r46468 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r46467‎ | r46468 (on ViewVC)‎ | r46469 >
Date:19:40, 28 January 2009
Author:werdna
Status:deferred
Tags:
Comment:
Hide action parameters if an action isn't selected.
Modified paths:

Diff [purge]

Index: trunk/extensions/AbuseFilter/AbuseFilter.php
===================================================================
--- trunk/extensions/AbuseFilter/AbuseFilter.php	(revision 46467)
+++ trunk/extensions/AbuseFilter/AbuseFilter.php	(revision 46468)
@@ -83,7 +83,7 @@
 $wgAjaxExportList[] = 'AbuseFilter::ajaxReAutoconfirm';
 
 // Bump the version number every time you change any of the .css/.js files
-$wgAbuseFilterStyleVersion = 2;
+$wgAbuseFilterStyleVersion = 3;
 
 $wgAbuseFilterRestrictedActions = array( 'block', 'degroup' );
 
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewEdit.php
===================================================================
--- trunk/extensions/AbuseFilter/Views/AbuseFilterViewEdit.php	(revision 46467)
+++ trunk/extensions/AbuseFilter/Views/AbuseFilterViewEdit.php	(revision 46468)
@@ -294,7 +294,7 @@
 		
 		switch( $action ) {
 			case 'throttle':
-				$throttleSettings = Xml::checkLabel( wfMsg( 'abusefilter-edit-action-throttle' ), 'wpFilterActionThrottle', 'wpFilterActionThrottle', $set );
+				$throttleSettings = Xml::checkLabel( wfMsg( 'abusefilter-edit-action-throttle' ), 'wpFilterActionThrottle', "mw-abusefilter-action-checkbox-$action", $set, array(  'class' => 'mw-abusefilter-action-checkbox' ) );
 				$throttleFields = array();
 
 				if ($set) {
@@ -314,19 +314,19 @@
 				$throttleFields['abusefilter-edit-throttle-count'] = Xml::input( 'wpFilterThrottleCount', 20, $throttleCount );
 				$throttleFields['abusefilter-edit-throttle-period'] = wfMsgExt( 'abusefilter-edit-throttle-seconds', array( 'parseinline', 'replaceafter' ), array(Xml::input( 'wpFilterThrottlePeriod', 20, $throttlePeriod )  ) );
 				$throttleFields['abusefilter-edit-throttle-groups'] = Xml::textarea( 'wpFilterThrottleGroups', $throttleGroups."\n" );
-				$throttleSettings .= Xml::buildForm( $throttleFields );
-				return Xml::tags( 'p', null, $throttleSettings );
+				$throttleSettings .= Xml::tags( 'div', array( 'id' => 'mw-abusefilter-throttle-parameters' ), Xml::buildForm( $throttleFields ) );
+				return $throttleSettings;
 			case 'flag':
-				$checkbox = Xml::checkLabel( wfMsg( 'abusefilter-edit-action-flag' ), 'wpFilterActionFlag', 'wpFilterActionFlag', true, array( 'disabled' => '1' ) );
+				$checkbox = Xml::checkLabel( wfMsg( 'abusefilter-edit-action-flag' ), 'wpFilterActionFlag', "mw-abusefilter-action-checkbox-$action", true, array( 'disabled' => '1', 'class' => 'mw-abusefilter-action-checkbox' ) );
 				return Xml::tags( 'p', null, $checkbox );
 			case 'warn':
 				$output = '';
-				$checkbox = Xml::checkLabel( wfMsg( 'abusefilter-edit-action-warn' ), 'wpFilterActionWarn', 'wpFilterActionWarn', $set );
+				$checkbox = Xml::checkLabel( wfMsg( 'abusefilter-edit-action-warn' ), 'wpFilterActionWarn', "mw-abusefilter-action-checkbox-$action", $set, array( 'class' => 'mw-abusefilter-action-checkbox' ) );
 				$output .= Xml::tags( 'p', null, $checkbox );
 
 				$warnMsg = empty($set) ? 'abusefilter-warning' : $parameters[0];
 				$warnFields['abusefilter-edit-warn-message'] = Xml::input( 'wpFilterWarnMessage', 45, $warnMsg );
-				$output .= Xml::tags( 'p', null, Xml::buildForm( $warnFields ) );
+				$output .= Xml::tags( 'div', array( 'id' => 'mw-abusefilter-warn-parameters' ), Xml::buildForm( $warnFields ) );
 				return $output;
 			case 'tag':
 				if ($set) {
@@ -336,18 +336,18 @@
 				}
 				$output = '';
 
-				$checkbox = Xml::checkLabel( wfMsg('abusefilter-edit-action-tag'), 'wpFilterActionTag', 'wpFilterActionTag', $set );
+				$checkbox = Xml::checkLabel( wfMsg('abusefilter-edit-action-tag'), 'wpFilterActionTag', "mw-abusefilter-action-checkbox-$action", $set, array( 'class' => 'mw-abusefilter-action-checkbox' ) );
 				$output .= Xml::tags( 'p', null, $checkbox );
 
 				$tagFields['abusefilter-edit-tag-tag'] = Xml::textarea( 'wpFilterTags', implode( "\n", $tags ) );
-				$output .= Xml::tags( 'p', null, Xml::buildForm( $tagFields ) );
+				$output .= Xml::tags( 'div', array( 'id' => 'mw-abusefilter-tag-parameters' ), Xml::buildForm( $tagFields ) );
 				return $output;
 			default:
 				$message = 'abusefilter-edit-action-'.$action;
 				$form_field = 'wpFilterAction' . ucfirst($action);
 				$status = $set;
 
-				$thisAction = Xml::checkLabel( wfMsg( $message ), $form_field, $form_field, $status );
+				$thisAction = Xml::checkLabel( wfMsg( $message ), $form_field, "mw-abusefilter-action-checkbox-$action", $status, array( 'class' => 'mw-abusefilter-action-checkbox' ) );
 				$thisAction = Xml::tags( 'p', null, $thisAction );
 				return $thisAction;
 		}
Index: trunk/extensions/AbuseFilter/edit.js
===================================================================
--- trunk/extensions/AbuseFilter/edit.js	(revision 46467)
+++ trunk/extensions/AbuseFilter/edit.js	(revision 46468)
@@ -69,6 +69,36 @@
 	}
 }
 
+function setupActions() {
+	var checkboxen = getElementsByClassName( document, 'input', 'mw-abusefilter-action-checkbox' );
+
+	for( var i=0; i<checkboxen.length; i++ ) {
+		var checkbox = checkboxen[i];
+
+		addHandler( checkbox, 'click', hideDeselectedActions );
+	}
+	// A second loop, so sue me.
+	hideDeselectedActions();
+}
+
+function hideDeselectedActions() {
+	var checkboxen = getElementsByClassName( document, 'input', 'mw-abusefilter-action-checkbox' );
+
+	for( var i=0; i<checkboxen.length; i++ ) {
+		// ID format is mw-abusefilter-action-checkbox-$action
+		// We want substr(31)
+		var checkbox = checkboxen[i];
+		var action = checkbox.id.substr(31);
+		var params = document.getElementById( "mw-abusefilter-"+action+"-parameters" );
+
+		if (params && checkbox.checked) {
+			params.style.display = 'block';
+		} else if (params) {
+			params.style.display = 'none';
+		}
+	}
+}
+
 addOnloadHook( function() {
 	addHandler( document.getElementById( wgFilterBoxName ), 'keyup', function() {
 		el = document.getElementById( 'mw-abusefilter-syntaxresult' );
@@ -76,4 +106,6 @@
 			el.style.display = 'none';
 		}
 	} );
+
+	setupActions();
 } );
\ No newline at end of file

Status & tagging log

  • 23:05, 5 February 2009 Werdna (Talk | contribs) changed the status of r46468 [removed: new added: deferred]
Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox