* Hide irrelevant block options in Special:Blockip based on whether an
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 20 Feb 2007 00:55:54 +0000 (00:55 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 20 Feb 2007 00:55:54 +0000 (00:55 +0000)
  IP address/range or username is listed. (Dynamic using JS.)

RELEASE-NOTES
includes/DefaultSettings.php
includes/SpecialBlockip.php
skins/common/block.js [new file with mode: 0644]
skins/common/wikibits.js

index b4a3ed7..634a4aa 100644 (file)
@@ -202,6 +202,8 @@ lighter making things easier to read.
   LocalSettings.php files.
 * Give Content-Length header for HTTP/1.0 clients.
 * Partial support for Flash cross-domain-policy filtering. 
+* Hide irrelevant block options in Special:Blockip based on whether an
+  IP address/range or username is listed. (Dynamic using JS.)
 
 
 == Languages updated ==
index 30a7f37..6db13e9 100644 (file)
@@ -1117,7 +1117,7 @@ $wgCacheEpoch = '20030516000000';
  * to ensure that client-side caches don't keep obsolete copies of global
  * styles.
  */
-$wgStyleVersion = '58';
+$wgStyleVersion = '59';
 
 
 # Server-side caching:
index b7518eb..af36689 100644 (file)
@@ -104,14 +104,20 @@ class IPBlockForm {
 
                $token = htmlspecialchars( $wgUser->editToken() );
 
+               global $wgStylePath, $wgStyleVersion;
                $wgOut->addHTML( "
+<script type=\"text/javascript\" src=\"$wgStylePath/common/block.js?$wgStyleVersion\">
+</script>
 <form id=\"blockip\" method=\"post\" action=\"{$action}\">
        <table border='0'>
                <tr>
                        <td align=\"right\">{$mIpaddress}:</td>
                        <td align=\"left\">
                                " . Xml::input( 'wpBlockAddress', 40, $this->BlockAddress,
-                                       array( 'tabindex' => '1', 'id' => 'mw-bi-target' ) ) . "
+                                       array(
+                                               'tabindex' => '1',
+                                               'id' => 'mw-bi-target',
+                                               'onchange' => 'updateBlockOptions()' ) ) . "
                        </td>
                </tr>
                <tr>");
@@ -141,7 +147,7 @@ class IPBlockForm {
                                        array( 'tabindex' => '3', 'id' => 'mw-bi-reason' ) ) . "
                        </td>
                </tr>
-               <tr>
+               <tr id='wpAnonOnlyRow'>
                        <td>&nbsp;</td>
                        <td align=\"left\">
                                " . wfCheckLabel( wfMsg( 'ipbanononly' ),
@@ -149,7 +155,7 @@ class IPBlockForm {
                                        array( 'tabindex' => 4 ) ) . "
                        </td>
                </tr>
-               <tr>
+               <tr id='wpCreateAccountRow'>
                        <td>&nbsp;</td>
                        <td align=\"left\">
                                " . wfCheckLabel( wfMsg( 'ipbcreateaccount' ),
@@ -157,7 +163,7 @@ class IPBlockForm {
                                        array( 'tabindex' => 5 ) ) . "
                        </td>
                </tr>
-               <tr>
+               <tr id='wpEnableAutoblockRow'>
                        <td>&nbsp;</td>
                        <td align=\"left\">
                                " . wfCheckLabel( wfMsg( 'ipbenableautoblock' ),
@@ -174,7 +180,9 @@ class IPBlockForm {
                </tr>
        </table>" .
        Xml::hidden( 'wpEditToken', $token ) .
-"</form>\n" );
+"</form>
+<script type=\"text/javascript\">updateBlockOptions()</script>
+\n" );
 
                $wgOut->addHtml( $this->getConvenienceLinks() );
 
diff --git a/skins/common/block.js b/skins/common/block.js
new file mode 100644 (file)
index 0000000..958faa3
--- /dev/null
@@ -0,0 +1,47 @@
+
+function considerChangingExpiryFocus() {
+       if (!document.getElementById) {
+               return;
+       }
+       var drop = document.getElementById('wpBlockExpiry');
+       if (!drop) {
+               return;
+       }
+       var field = document.getElementById('wpBlockOther');
+       if (!field) {
+               return;
+       }
+       var opt = drop.value;
+       if (opt == 'other') {
+               field.style.display = '';
+       } else {
+               field.style.display = 'none';
+       }
+}
+
+function updateBlockOptions() {
+       if (!document.getElementById)
+               return;
+       
+       var target = document.getElementById('mw-bi-target');
+       if (!target)
+               return;
+       
+       var addy = target.value;
+       var isEmpty = addy.match(/^\s*$/);
+       var isIp = addy.match(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(\/\d+)?$/);
+       
+       /*
+       var anonymousCheck = document.getElementById('wpAnonOnly');
+       anonymousCheck.disabled = !isIp && !isEmpty;
+       
+       var autoblockCheck = document.getElementById('wpEnableAutoblock');
+       autoblockCheck.disabled = isIp && !isEmpty;
+       */
+
+       var anonymousRow = document.getElementById('wpAnonOnlyRow');
+       anonymousRow.style.display = (!isIp && !isEmpty) ? 'none' : '';
+       
+       var autoblockRow = document.getElementById('wpEnableAutoblockRow');
+       autoblockRow.style.display = isIp && !isEmpty ? 'none' : '';
+}
index bb2280b..6299e5f 100644 (file)
@@ -794,27 +794,6 @@ function fillDestFilename(id) {
        }
 }
 
-
-function considerChangingExpiryFocus() {
-       if (!document.getElementById) {
-               return;
-       }
-       var drop = document.getElementById('wpBlockExpiry');
-       if (!drop) {
-               return;
-       }
-       var field = document.getElementById('wpBlockOther');
-       if (!field) {
-               return;
-       }
-       var opt = drop.value;
-       if (opt == 'other') {
-               field.style.display = '';
-       } else {
-               field.style.display = 'none';
-       }
-}
-
 function scrollEditBox() {
        var editBoxEl = document.getElementById("wpTextbox1");
        var scrollTopEl = document.getElementById("wpScrolltop");