Localisation updates from http://translatewiki.net.
[mediawiki.git] / resources / mediawiki.special / mediawiki.special.block.js
blob2a158dfbd03f6f61669b7dc752e492cbcccce366
1 /**
2 * JavaScript for Special:Block
3 */
4 ( function ( mw, $ ) {
5 $( document ).ready( 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 );
25 if ( !isIp && !isEmpty ) {
26 $anonOnlyRow.goOut( instant );
27 } else {
28 $anonOnlyRow.goIn( instant );
30 if ( isIpRange && !isEmpty ) {
31 $watchUser.goOut( instant );
32 } else {
33 $watchUser.goIn( instant );
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 );
44 } );
45 }( mediaWiki, jQuery ) );