Customise linktrail for Gujarati (gu)
[mediawiki.git] / resources / mediawiki.special / mediawiki.special.block.js
blobb8bcf177da85366e201a2baa9c939ab6cb3d17b3
1 /**
2  * JavaScript for Special:Block
3  */
4 ( function ( mw, $ ) {
5         $( function () {
6                 var $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                 function updateBlockOptions( instant ) {
13                         var blocktarget = $.trim( $blockTarget.val() ),
14                                 isEmpty = blocktarget === '',
15                                 isIp = mw.util.isIPv4Address( blocktarget, true ) || mw.util.isIPv6Address( blocktarget, true ),
16                                 isIpRange = isIp && blocktarget.match( /\/\d+$/ );
18                         if ( isIp && !isEmpty ) {
19                                 $enableAutoblockRow.goOut( instant );
20                                 $hideUser.goOut( instant );
21                         } else {
22                                 $enableAutoblockRow.goIn( instant );
23                                 $hideUser.goIn( instant );
24                         }
25                         if ( !isIp && !isEmpty ) {
26                                 $anonOnlyRow.goOut( instant );
27                         } else {
28                                 $anonOnlyRow.goIn( instant );
29                         }
30                         if ( isIpRange && !isEmpty ) {
31                                 $watchUser.goOut( instant );
32                         } else {
33                                 $watchUser.goIn( instant );
34                         }
35                 }
37                 if ( $blockTarget.length ) {
38                         // Bind functions so they're checked whenever stuff changes
39                         $blockTarget.keyup( updateBlockOptions );
41                         // Call them now to set initial state (ie. Special:Block/Foobar?wpBlockExpiry=2+hours)
42                         updateBlockOptions( /* instant= */ true );
43                 }
44         } );
45 }( mediaWiki, jQuery ) );