Index: trunk/phase3/skins/common/block.js |
— | — | @@ -1,89 +0,0 @@ |
2 | | -// @TODO: find some better JS file for this |
3 | | -// Note: borrows from IP.php |
4 | | -window.isIPv4Address = function( address, allowBlock ) { |
5 | | - var block = allowBlock ? '(?:\\/(?:3[0-2]|[12]?\\d))?' : ''; |
6 | | - var RE_IP_BYTE = '(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|0?[0-9]?[0-9])'; |
7 | | - var RE_IP_ADD = '(?:' + RE_IP_BYTE + '\\.){3}' + RE_IP_BYTE; |
8 | | - return address.search( new RegExp( '^' + RE_IP_ADD + block + '$' ) ) != -1; |
9 | | -}; |
10 | | - |
11 | | -// @TODO: find some better JS file for this |
12 | | -// Note: borrows from IP.php |
13 | | -window.isIPv6Address = function( address, allowBlock ) { |
14 | | - var block = allowBlock ? '(?:\\/(?:12[0-8]|1[01][0-9]|[1-9]?\\d))?' : ''; |
15 | | - var RE_IPV6_ADD = |
16 | | - '(?:' + // starts with "::" (including "::") |
17 | | - ':(?::|(?::' + '[0-9A-Fa-f]{1,4}' + '){1,7})' + |
18 | | - '|' + // ends with "::" (except "::") |
19 | | - '[0-9A-Fa-f]{1,4}' + '(?::' + '[0-9A-Fa-f]{1,4}' + '){0,6}::' + |
20 | | - '|' + // contains no "::" |
21 | | - '[0-9A-Fa-f]{1,4}' + '(?::' + '[0-9A-Fa-f]{1,4}' + '){7}' + |
22 | | - ')'; |
23 | | - if ( address.search( new RegExp( '^' + RE_IPV6_ADD + block + '$' ) ) != -1 ) { |
24 | | - return true; |
25 | | - } |
26 | | - var RE_IPV6_ADD = // contains one "::" in the middle (single '::' check below) |
27 | | - '[0-9A-Fa-f]{1,4}' + '(?:::?' + '[0-9A-Fa-f]{1,4}' + '){1,6}'; |
28 | | - return address.search( new RegExp( '^' + RE_IPV6_ADD + block + '$' ) ) != -1 |
29 | | - && address.search( /::/ ) != -1 && address.search( /::.*::/ ) == -1; |
30 | | -}; |
31 | | - |
32 | | -window.considerChangingExpiryFocus = function() { |
33 | | - if ( !document.getElementById ) { |
34 | | - return; |
35 | | - } |
36 | | - var drop = document.getElementById( 'wpBlockExpiry' ); |
37 | | - if ( !drop ) { |
38 | | - return; |
39 | | - } |
40 | | - var field = document.getElementById( 'wpBlockOther' ); |
41 | | - if ( !field ) { |
42 | | - return; |
43 | | - } |
44 | | - var opt = drop.value; |
45 | | - if ( opt == 'other' ) { |
46 | | - field.style.display = ''; |
47 | | - } else { |
48 | | - field.style.display = 'none'; |
49 | | - } |
50 | | -}; |
51 | | - |
52 | | -window.updateBlockOptions = function() { |
53 | | - if ( !document.getElementById ) { |
54 | | - return; |
55 | | - } |
56 | | - |
57 | | - var target = document.getElementById( 'mw-bi-target' ); |
58 | | - if ( !target ) { |
59 | | - return; |
60 | | - } |
61 | | - |
62 | | - var addy = target.value.replace( /(^\s*|\s*$)/, '' ); // trim |
63 | | - var isEmpty = (addy == ""); |
64 | | - |
65 | | - var isIp = isIPv4Address( addy, true ) || isIPv6Address( addy, true ); |
66 | | - var isIpRange = isIp && addy.match(/\/\d+$/); |
67 | | - |
68 | | - var anonymousRow = document.getElementById( 'wpAnonOnlyRow' ); |
69 | | - if( anonymousRow ) { |
70 | | - anonymousRow.style.display = ( !isIp && !isEmpty ) ? 'none' : ''; |
71 | | - } |
72 | | - |
73 | | - var autoblockRow = document.getElementById( 'wpEnableAutoblockRow' ); |
74 | | - if( autoblockRow ) { |
75 | | - autoblockRow.style.display = isIp && !isEmpty ? 'none' : ''; |
76 | | - } |
77 | | - |
78 | | - var hideuserRow = document.getElementById( 'wpEnableHideUser' ); |
79 | | - if( hideuserRow ) { |
80 | | - hideuserRow.style.display = isIp && !isEmpty ? 'none' : ''; |
81 | | - } |
82 | | - |
83 | | - var watchuserRow = document.getElementById( 'wpEnableWatchUser' ); |
84 | | - if( watchuserRow ) { |
85 | | - watchuserRow.style.display = isIpRange && !isEmpty ? 'none' : ''; |
86 | | - } |
87 | | -}; |
88 | | - |
89 | | -addOnloadHook( updateBlockOptions ); |
90 | | -addOnloadHook( considerChangingExpiryFocus ); |
Index: trunk/phase3/includes/specials/SpecialBlockip.php |
— | — | @@ -199,7 +199,7 @@ |
200 | 200 | wfMsgForContent( 'ipbreason-dropdown' ), |
201 | 201 | wfMsgForContent( 'ipbreasonotherlist' ), $this->BlockReasonList, 'wpBlockDropDown', 4 ); |
202 | 202 | |
203 | | - $wgOut->addModules( 'mediawiki.legacy.block' ); |
| 203 | + $wgOut->addModules( 'mediawiki.special.block' ); |
204 | 204 | $wgOut->addHTML( |
205 | 205 | Xml::openElement( 'form', array( 'method' => 'post', 'action' => $titleObj->getLocalURL( 'action=submit' ), 'id' => 'blockip' ) ) . |
206 | 206 | Xml::openElement( 'fieldset' ) . |
— | — | @@ -269,14 +269,6 @@ |
270 | 270 | ) + ( $this->BlockAddress ? array( 'autofocus' ) : array() ) ) . " |
271 | 271 | </td> |
272 | 272 | </tr> |
273 | | - <tr id='wpAnonOnlyRow'> |
274 | | - <td> </td> |
275 | | - <td class='mw-input'>" . |
276 | | - Xml::checkLabel( wfMsg( 'ipbanononly' ), |
277 | | - 'wpAnonOnly', 'wpAnonOnly', $this->BlockAnonOnly, |
278 | | - array( 'tabindex' => '6' ) ) . " |
279 | | - </td> |
280 | | - </tr> |
281 | 273 | <tr id='wpCreateAccountRow'> |
282 | 274 | <td> </td> |
283 | 275 | <td class='mw-input'>" . |
— | — | @@ -284,14 +276,6 @@ |
285 | 277 | 'wpCreateAccount', 'wpCreateAccount', $this->BlockCreateAccount, |
286 | 278 | array( 'tabindex' => '7' ) ) . " |
287 | 279 | </td> |
288 | | - </tr> |
289 | | - <tr id='wpEnableAutoblockRow'> |
290 | | - <td> </td> |
291 | | - <td class='mw-input'>" . |
292 | | - Xml::checkLabel( wfMsg( 'ipbenableautoblock' ), |
293 | | - 'wpEnableAutoblock', 'wpEnableAutoblock', $this->BlockEnableAutoblock, |
294 | | - array( 'tabindex' => '8' ) ) . " |
295 | | - </td> |
296 | 280 | </tr>" |
297 | 281 | ); |
298 | 282 | |
— | — | @@ -308,6 +292,32 @@ |
309 | 293 | ); |
310 | 294 | } |
311 | 295 | |
| 296 | + # Can we explicitly disallow the use of user_talk? |
| 297 | + global $wgBlockAllowsUTEdit; |
| 298 | + if( $wgBlockAllowsUTEdit ){ |
| 299 | + $wgOut->addHTML(" |
| 300 | + <tr id='wpAllowUsertalkRow'> |
| 301 | + <td> </td> |
| 302 | + <td class='mw-input'>" . |
| 303 | + Xml::checkLabel( wfMsg( 'ipballowusertalk' ), |
| 304 | + 'wpAllowUsertalk', 'wpAllowUsertalk', $this->BlockAllowUsertalk, |
| 305 | + array( 'tabindex' => '12' ) ) . " |
| 306 | + </td> |
| 307 | + </tr>" |
| 308 | + ); |
| 309 | + } |
| 310 | + |
| 311 | + $wgOut->addHTML( " |
| 312 | + <tr id='wpEnableAutoblockRow'> |
| 313 | + <td> </td> |
| 314 | + <td class='mw-input'>" . |
| 315 | + Xml::checkLabel( wfMsg( 'ipbenableautoblock' ), |
| 316 | + 'wpEnableAutoblock', 'wpEnableAutoblock', $this->BlockEnableAutoblock, |
| 317 | + array( 'tabindex' => '8' ) ) . " |
| 318 | + </td> |
| 319 | + </tr>" |
| 320 | + ); |
| 321 | + |
312 | 322 | // Allow some users to hide name from block log, blocklist and listusers |
313 | 323 | if( $wgUser->isAllowed( 'hideuser' ) ) { |
314 | 324 | $wgOut->addHTML(" |
— | — | @@ -337,22 +347,15 @@ |
338 | 348 | ); |
339 | 349 | } |
340 | 350 | |
341 | | - # Can we explicitly disallow the use of user_talk? |
342 | | - global $wgBlockAllowsUTEdit; |
343 | | - if( $wgBlockAllowsUTEdit ){ |
344 | | - $wgOut->addHTML(" |
345 | | - <tr id='wpAllowUsertalkRow'> |
346 | | - <td> </td> |
347 | | - <td class='mw-input'>" . |
348 | | - Xml::checkLabel( wfMsg( 'ipballowusertalk' ), |
349 | | - 'wpAllowUsertalk', 'wpAllowUsertalk', $this->BlockAllowUsertalk, |
350 | | - array( 'tabindex' => '12' ) ) . " |
351 | | - </td> |
352 | | - </tr>" |
353 | | - ); |
354 | | - } |
355 | | - |
356 | 351 | $wgOut->addHTML(" |
| 352 | + <tr id='wpAnonOnlyRow'> |
| 353 | + <td> </td> |
| 354 | + <td class='mw-input'>" . |
| 355 | + Xml::checkLabel( wfMsg( 'ipbanononly' ), |
| 356 | + 'wpAnonOnly', 'wpAnonOnly', $this->BlockAnonOnly, |
| 357 | + array( 'tabindex' => '6' ) ) . " |
| 358 | + </td> |
| 359 | + </tr> |
357 | 360 | <tr> |
358 | 361 | <td style='padding-top: 1em'> </td> |
359 | 362 | <td class='mw-submit' style='padding-top: 1em'>" . |
Index: trunk/phase3/resources/Resources.php |
— | — | @@ -424,6 +424,10 @@ |
425 | 425 | 'mediawiki.special.search' => array( |
426 | 426 | 'scripts' => 'resources/mediawiki.special/mediawiki.special.search.js', |
427 | 427 | ), |
| 428 | + 'mediawiki.special.block' => array( |
| 429 | + 'scripts' => 'resources/mediawiki.special/mediawiki.special.block.js', |
| 430 | + 'dependencies' => array( 'jquery.effects.blind' ), |
| 431 | + ), |
428 | 432 | 'mediawiki.special.upload' => array( |
429 | 433 | // @TODO: merge in remainder of mediawiki.legacy.upload |
430 | 434 | 'scripts' => 'resources/mediawiki.special/mediawiki.special.upload.js', |
Index: trunk/phase3/resources/mediawiki.special/mediawiki.special.block.js |
— | — | @@ -0,0 +1,57 @@ |
| 2 | +/* JavaScript for Special:Block */ |
| 3 | +jQuery( function( $ ) { |
| 4 | + |
| 5 | + $('#mw-bi-target').keyup(function(){ |
| 6 | + var isIPv4Address = function( address ) { |
| 7 | + var RE_IP_BYTE = '(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|0?[0-9]?[0-9])'; |
| 8 | + var RE_IP_ADD = '(?:' + RE_IP_BYTE + '\\.){3}' + RE_IP_BYTE; |
| 9 | + return address.search( new RegExp( '^' + RE_IP_ADD + '(?:\\/(?:3[0-2]|[12]?\\d))?$' ) ) != -1; |
| 10 | + }; |
| 11 | + var isIPv6Address = function( address ) { |
| 12 | + var RE_IPV6_ADD = |
| 13 | + '(?:' + // starts with "::" (including "::") |
| 14 | + ':(?::|(?::' + '[0-9A-Fa-f]{1,4}' + '){1,7})' + |
| 15 | + '|' + // ends with "::" (except "::") |
| 16 | + '[0-9A-Fa-f]{1,4}' + '(?::' + '[0-9A-Fa-f]{1,4}' + '){0,6}::' + |
| 17 | + '|' + // contains no "::" |
| 18 | + '[0-9A-Fa-f]{1,4}' + '(?::' + '[0-9A-Fa-f]{1,4}' + '){7}' + |
| 19 | + ')'; |
| 20 | + if ( address.search( new RegExp( '^' + RE_IPV6_ADD + '(?:\\/(?:12[0-8]|1[01][0-9]|[1-9]?\\d))?$' ) ) != -1 ) { |
| 21 | + return true; |
| 22 | + } |
| 23 | + var RE_IPV6_ADD_SHORT = // contains one "::" in the middle (single '::' check below) |
| 24 | + '[0-9A-Fa-f]{1,4}' + '(?:::?' + '[0-9A-Fa-f]{1,4}' + '){1,6}'; |
| 25 | + return address.search( new RegExp( '^' + RE_IPV6_ADD_SHORT + '(?:\\/(?:12[0-8]|1[01][0-9]|[1-9]?\\d))?$' ) ) != -1 |
| 26 | + && address.search( /::/ ) != -1 && address.search( /::.*::/ ) == -1; |
| 27 | + }; |
| 28 | + |
| 29 | + var input = $('#mw-bi-target').val(); |
| 30 | + |
| 31 | + var isEmpty = ( input == "" ); |
| 32 | + var isIp = isIPv4Address( input ) || isIPv6Address( input ); |
| 33 | + var isIpRange = isIp && input.match(/\/\d+$/); |
| 34 | + |
| 35 | + if( !isEmpty ){ |
| 36 | + if( isIp ){ |
| 37 | + $( '#wpAnonOnlyRow' ).stop( true, true ).delay(1000).fadeIn(); |
| 38 | + $( '#wpEnableAutoblockRow, #wpEnableHideUser' ).stop( true, true ).delay(1000).fadeOut(); |
| 39 | + } else { |
| 40 | + $( '#wpAnonOnlyRow' ).stop( true, true ).delay(1000).fadeOut(); |
| 41 | + $( '#wpEnableAutoblockRow, #wpEnableHideUser' ).stop( true, true ).delay(1000).fadeIn(); |
| 42 | + } |
| 43 | + if( isIpRange ){ |
| 44 | + $( '#wpEnableWatchUser' ).stop( true, true ).delay(1000).fadeOut(); |
| 45 | + } else { |
| 46 | + $( '#wpEnableWatchUser' ).stop( true, true ).delay(1000).fadeIn(); |
| 47 | + } |
| 48 | + } |
| 49 | + }).keyup(); |
| 50 | + |
| 51 | + $('#wpBlockExpiry').change( function(){ |
| 52 | + if( $(this).val() == 'other' ){ |
| 53 | + $('#wpBlockOther').stop( true, true ).fadeIn(); |
| 54 | + } else { |
| 55 | + $('#wpBlockOther').stop( true, true ).fadeOut(); |
| 56 | + } |
| 57 | + }).change(); |
| 58 | +} ); |
\ No newline at end of file |
Property changes on: trunk/phase3/resources/mediawiki.special/mediawiki.special.block.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 59 | + native |