Follow-up r72340: Special page and its user rights have gone
[lhc/web/wiklou.git] / resources / mw / mw.legacy.block.js
1 /*
2 * Legacy emulation for the now depricated block.js
3 *
4 * Ported by: Trevor Parscal
5 */
6
7 ( function( $ ) {
8
9 $.extend( mw.legacy, {
10 'considerChangingExpiryFocus': function() {
11 var $expiry = $( '#wpBlockExpiry' );
12 var $other = $( '#wpBlockOther' );
13 if ( $expiry.length && $other.length ) {
14 if ( $expiry.val() == 'other' ) {
15 $other.css( 'display', '' );
16 } else {
17 $other.css( 'display', 'none' );
18 }
19 }
20 },
21 'updateBlockOptions': function() {
22 var $target = $( '#mw-bi-target' );
23 if ( $target.length ) {
24 var address = $target.val();
25 var isEmpty = address.match( /^\s*$/ );
26 var isIp = address.match( /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|:(:[0-9A-Fa-f]{1,4}){1,7}|[0-9A-Fa-f]{1,4}(:{1,2}[0-9A-Fa-f]{1,4}|::$){1,7})(\/\d+)?$/ );
27 var isIpRange = isIp && address.match( /\/\d+$/ );
28
29 $( '#wpAnonOnlyRow' ).css( 'display', !isIp && !isEmpty ? 'none' : '' );
30 $( '#wpEnableAutoblockRow,#wpEnableHideUser' ).css( 'display', isIp && !isEmpty ? 'none' : '' );
31 $( '#wpEnableWatchUser' ).css( 'display', isIpRange && !isEmpty ? 'none' : '' );
32 }
33 }
34 } );
35
36 /* Initialization */
37
38 $( document ).ready( function() {
39 mw.legacy.considerChangingExpiryFocus();
40 } );
41
42 } )( jQuery );