Keep IEFixes separate, load conditionally in JS
[mediawiki.git] / skins / common / block.js
blobad04f8103be748c791616a63fde04b53ce062371
1 addOnloadHook( considerChangingExpiryFocus );
3 function considerChangingExpiryFocus() {
4         if ( !document.getElementById ) {
5                 return;
6         }
7         var drop = document.getElementById( 'wpBlockExpiry' );
8         if ( !drop ) {
9                 return;
10         }
11         var field = document.getElementById( 'wpBlockOther' );
12         if ( !field ) {
13                 return;
14         }
15         var opt = drop.value;
16         if ( opt == 'other' ) {
17                 field.style.display = '';
18         } else {
19                 field.style.display = 'none';
20         }
23 function updateBlockOptions() {
24         if ( !document.getElementById ) {
25                 return;
26         }
28         var target = document.getElementById( 'mw-bi-target' );
29         if ( !target ) {
30                 return;
31         }
33         var addy = target.value;
34         var isEmpty = addy.match(/^\s*$/);
35         var isIp = addy.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+)?$/);
36         var isIpRange = isIp && addy.match(/\/\d+$/);
38         var anonymousRow = document.getElementById( 'wpAnonOnlyRow' );
39         if( anonymousRow ) {
40                 anonymousRow.style.display = ( !isIp && !isEmpty ) ? 'none' : '';
41         }
43         var autoblockRow = document.getElementById( 'wpEnableAutoblockRow' );
44         if( autoblockRow ) {
45                 autoblockRow.style.display = isIp && !isEmpty ? 'none' : '';
46         }
47         
48         var hideuserRow = document.getElementById( 'wpEnableHideUser' );
49         if( hideuserRow ) {
50                 hideuserRow.style.display = isIp && !isEmpty ? 'none' : '';
51         }
53         var watchuserRow = document.getElementById( 'wpEnableWatchUser' );
54         if( watchuserRow ) {
55                 watchuserRow.style.display = isIpRange && !isEmpty ? 'none' : '';
56         }