Alright, IE7 is fixed by r89613. IE6 stays problematic, for some reason it contains...
[mediawiki.git] / resources / mediawiki.special / mediawiki.special.block.js
blob08768a772c12a55b48613e8510da9dc58fc4cd8e
1 /* JavaScript for Special:Block */
3 jQuery( function( $ ) {
5         var     DO_INSTANT = true,
6                 $blockTarget = $( '#mw-bi-target' ),
7                 $anonOnlyRow = $( '#mw-input-wpHardblock' ).closest( 'tr' ),
8                 $enableAutoblockRow = $( '#mw-input-wpAutoBlock' ).closest( 'tr' ),
9                 $hideUser = $( '#mw-input-wpHideUser' ).closest( 'tr' ),
10                 $watchUser = $( '#mw-input-wpWatch' ).closest( 'tr' );
12         var updateBlockOptions = function( instant ) {
13                 if ( !$blockTarget.length ) {
14                         return;
15                 }
17                 var blocktarget = $.trim( $blockTarget.val() );
18                 var isEmpty = ( blocktarget === '' );
19                 var isIp = mw.util.isIPv4Address( blocktarget, true ) || mw.util.isIPv6Address( blocktarget, true );
20                 var isIpRange = isIp && blocktarget.match( /\/\d+$/ );
22                 if ( isIp && !isEmpty ) {
23                         $enableAutoblockRow.goOut( instant );
24                         $hideUser.goOut( instant );
25                 } else {
26                         $enableAutoblockRow.goIn( instant );
27                         $hideUser.goIn( instant );
28                 }
29                 if ( !isIp && !isEmpty ) {
30                         $anonOnlyRow.goOut( instant );
31                 } else {
32                         $anonOnlyRow.goIn( instant );
33                 }
34                 if ( isIpRange && !isEmpty ) {
35                         $watchUser.goOut( instant );
36                 } else {
37                         $watchUser.goIn( instant );
38                 }
39         };
41         // Bind functions so they're checked whenever stuff changes
42         $blockTarget.keyup( updateBlockOptions );
44         // Call them now to set initial state (ie. Special:Block/Foobar?wpBlockExpiry=2+hours)
45         updateBlockOptions( DO_INSTANT );
46 });